Completed
Push — master ( 259354...a4a45b )
by Yannick
05:33
created
require/class.Satellite.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		try {
20 20
 			$sth = $this->db->prepare($query);
21 21
 			$sth->execute(array(':name' => $name));
22
-		} catch(PDOException $e) {
22
+		} catch (PDOException $e) {
23 23
 			echo $e->getMessage();
24 24
 		}
25 25
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		try {
32 32
 			$sth = $this->db->prepare($query);
33 33
 			$sth->execute();
34
-		} catch(PDOException $e) {
34
+		} catch (PDOException $e) {
35 35
 			echo $e->getMessage();
36 36
 		}
37 37
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		try {
44 44
 			$sth = $this->db->prepare($query);
45 45
 			$sth->execute();
46
-		} catch(PDOException $e) {
46
+		} catch (PDOException $e) {
47 47
 			echo $e->getMessage();
48 48
 		}
49 49
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		try {
56 56
 			$sth = $this->db->prepare($query);
57 57
 			$sth->execute(array(':type' => $type));
58
-		} catch(PDOException $e) {
58
+		} catch (PDOException $e) {
59 59
 			echo $e->getMessage();
60 60
 		}
61 61
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -63,27 +63,27 @@  discard block
 block discarded – undo
63 63
 		else return array();
64 64
 	}
65 65
 	
66
-	public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) {
66
+	public function position_all($timestamp_begin = '', $timestamp_end = '', $second = 10) {
67 67
 		$all_sat = $this->get_tle_names();
68 68
 		$result = array();
69 69
 		foreach ($all_sat as $sat) {
70
-			$position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second);
71
-			$result = array_merge($position,$result);
70
+			$position = $this->position($sat['tle_name'], $timestamp_begin, $timestamp_end, $second);
71
+			$result = array_merge($position, $result);
72 72
 		}
73 73
 		return $result;
74 74
 	}
75 75
 
76
-	public function position_all_type($type,$timestamp_begin = '',$timestamp_end = '',$second = 10) {
76
+	public function position_all_type($type, $timestamp_begin = '', $timestamp_end = '', $second = 10) {
77 77
 		$all_sat = $this->get_tle_names_type($type);
78 78
 		$result = array();
79 79
 		foreach ($all_sat as $sat) {
80
-			$position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second);
81
-			$result = array_merge($position,$result);
80
+			$position = $this->position($sat['tle_name'], $timestamp_begin, $timestamp_end, $second);
81
+			$result = array_merge($position, $result);
82 82
 		}
83 83
 		return $result;
84 84
 	}
85 85
 	
86
-	public function position($name,$timestamp_begin = '',$timestamp_end = '',$second = 10) {
86
+	public function position($name, $timestamp_begin = '', $timestamp_end = '', $second = 10) {
87 87
 		$qth = new Predict_QTH();
88 88
 		$qth->lat = 37.790252;
89 89
 		$qth->lon = -122.419968;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		$tle_file = $this->get_tle($name);
92 92
 		//print_r($tle_file);
93 93
 		$type = $tle_file['tle_type'];
94
-		$tle = new Predict_TLE($tle_file['tle_name'],$tle_file['tle_tle1'],$tle_file['tle_tle2']);
94
+		$tle = new Predict_TLE($tle_file['tle_name'], $tle_file['tle_tle1'], $tle_file['tle_tle2']);
95 95
 		$sat = new Predict_Sat($tle);
96 96
 		$predict = new Predict();
97 97
 		//if ($timestamp == '') $now = Predict_Time::get_current_daynum();
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 		if ($timestamp_end == '') {
100 100
 			$now = Predict_Time::unix2daynum($timestamp_begin);
101 101
 			//echo $now;
102
-			$predict->predict_calc($sat,$qth,$now);
103
-			return array('name' => $name, 'latitude' => $sat->ssplat,'longitude' => $sat->ssplon, 'altitude' => $sat->alt,'speed' => $sat->velo*60*60,'timestamp' => $timestamp_begin,'type' => $type);
102
+			$predict->predict_calc($sat, $qth, $now);
103
+			return array('name' => $name, 'latitude' => $sat->ssplat, 'longitude' => $sat->ssplon, 'altitude' => $sat->alt, 'speed' => $sat->velo*60*60, 'timestamp' => $timestamp_begin, 'type' => $type);
104 104
 		} else {
105
-			for ($timestamp = $timestamp_begin; $timestamp <= $timestamp_end; $timestamp=$timestamp+$second) {
105
+			for ($timestamp = $timestamp_begin; $timestamp <= $timestamp_end; $timestamp = $timestamp + $second) {
106 106
 				//echo $timestamp."\n";
107 107
 				$now = Predict_Time::unix2daynum($timestamp);
108 108
 				//echo $now;
109
-				$predict->predict_calc($sat,$qth,$now);
110
-				$result[] = array('name' => $name,'latitude' => $sat->ssplat,'longitude' => $sat->ssplon, 'altitude' => $sat->alt,'speed' => $sat->velo*60*60,'timestamp' => $timestamp,'type' => $type);
109
+				$predict->predict_calc($sat, $qth, $now);
110
+				$result[] = array('name' => $name, 'latitude' => $sat->ssplat, 'longitude' => $sat->ssplon, 'altitude' => $sat->alt, 'speed' => $sat->velo*60*60, 'timestamp' => $timestamp, 'type' => $type);
111 111
 			}
112 112
 			return $result;
113 113
 		}
Please login to merge, or discard this patch.
Braces   +23 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,8 +23,11 @@  discard block
 block discarded – undo
23 23
 			echo $e->getMessage();
24 24
 		}
25 25
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
26
-		if (isset($result[0])) return $result[0];
27
-		else return array();
26
+		if (isset($result[0])) {
27
+			return $result[0];
28
+		} else {
29
+			return array();
30
+		}
28 31
 	}
29 32
 	public function get_tle_types() {
30 33
 		$query = 'SELECT DISTINCT tle_type FROM tle ORDER BY tle_type';
@@ -35,8 +38,11 @@  discard block
 block discarded – undo
35 38
 			echo $e->getMessage();
36 39
 		}
37 40
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
38
-		if (isset($result[0])) return $result;
39
-		else return array();
41
+		if (isset($result[0])) {
42
+			return $result;
43
+		} else {
44
+			return array();
45
+		}
40 46
 	}
41 47
 	public function get_tle_names() {
42 48
 		$query = 'SELECT DISTINCT tle_name, tle_type FROM tle';
@@ -47,8 +53,11 @@  discard block
 block discarded – undo
47 53
 			echo $e->getMessage();
48 54
 		}
49 55
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
50
-		if (isset($result[0])) return $result;
51
-		else return array();
56
+		if (isset($result[0])) {
57
+			return $result;
58
+		} else {
59
+			return array();
60
+		}
52 61
 	}
53 62
 	public function get_tle_names_type($type) {
54 63
 		$query = 'SELECT tle_name, tle_type FROM tle WHERE tle_type = :type ORDER BY tle_name';
@@ -59,8 +68,11 @@  discard block
 block discarded – undo
59 68
 			echo $e->getMessage();
60 69
 		}
61 70
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
62
-		if (isset($result[0])) return $result;
63
-		else return array();
71
+		if (isset($result[0])) {
72
+			return $result;
73
+		} else {
74
+			return array();
75
+		}
64 76
 	}
65 77
 	
66 78
 	public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) {
@@ -95,7 +107,9 @@  discard block
 block discarded – undo
95 107
 		$sat = new Predict_Sat($tle);
96 108
 		$predict = new Predict();
97 109
 		//if ($timestamp == '') $now = Predict_Time::get_current_daynum();
98
-		if ($timestamp_begin == '') $timestamp_begin = time();
110
+		if ($timestamp_begin == '') {
111
+			$timestamp_begin = time();
112
+		}
99 113
 		if ($timestamp_end == '') {
100 114
 			$now = Predict_Time::unix2daynum($timestamp_begin);
101 115
 			//echo $now;
Please login to merge, or discard this patch.
space-data.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 <button type="button" class="close">&times;</button>
8 8
 <?php
9 9
 
10
-$sat = filter_input(INPUT_GET,'sat',FILTER_SANITIZE_STRING);
10
+$sat = filter_input(INPUT_GET, 'sat', FILTER_SANITIZE_STRING);
11 11
 $sat = urldecode($sat);
12 12
 
13 13
 if ($sat == 'ISS (ZARYA)') {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	$aircraft_name = 'INTEGRAL';
43 43
 //	$ground_speed = 14970;
44 44
 	$launch_date = '17 October 2002';
45
-} elseif (strpos($sat,'IRIDIUM') !== false) {
45
+} elseif (strpos($sat, 'IRIDIUM') !== false) {
46 46
 	$image = 'https://upload.wikimedia.org/wikipedia/commons/b/b6/Iridium_Satellite.jpg';
47 47
 	$image_copyright = 'Cliff';
48 48
 	$ident = 'Iridium satellite constellation';
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
 	$aircraft_name = $sat;
51 51
 //	$ground_speed = 14970;
52 52
 //	$launch_date = '29 september 2011';
53
-} elseif (strpos($sat,'ORBCOMM') !== false) {
53
+} elseif (strpos($sat, 'ORBCOMM') !== false) {
54 54
 	$ident = 'Orbcomm';
55 55
 	$aircraft_wiki = 'https://en.wikipedia.org/wiki/Orbcomm_(satellite)';
56 56
 	$aircraft_name = $sat;
57
-} elseif (strpos($sat,'GLOBALSTAR') !== false) {
57
+} elseif (strpos($sat, 'GLOBALSTAR') !== false) {
58 58
 	$ident = 'Globalstar';
59 59
 	$aircraft_wiki = 'https://en.wikipedia.org/wiki/Globalstar';
60 60
 	$aircraft_name = $sat;
61
-} elseif (strpos($sat,'OSCAR 7') !== false) {
61
+} elseif (strpos($sat, 'OSCAR 7') !== false) {
62 62
 	$image = 'https://upload.wikimedia.org/wikipedia/en/a/ad/AMSAT-OSCAR_7.jpg';
63 63
 	$image_copyright = 'Amsat.org';
64 64
 	$ident = 'AMSAT-OSCAR 7';
Please login to merge, or discard this patch.
install/populate_all.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,48 +1,48 @@
 block discarded – undo
1 1
 #!/usr/bin/php
2 2
 <?php
3
-    require_once('../require/settings.php');
4
-    if ($globalInstalled) {
5
-        echo '$globalInstalled must be set to FALSE in require/settings.php';
6
-        exit;
7
-    }
8
-    require('class.update_db.php');
9
-    echo "Populate all tables...\n";
10
-    update_db::update_all();
11
-    echo "\nInstall waypoints...(VERY slow!)";
12
-    update_db::update_waypoints();
13
-    echo "Done !\n";
14
-    echo "Install airspace...";
15
-    update_db::update_airspace();
16
-    echo "Done !\n";
17
-    echo "Install countries...";
18
-    update_db::update_countries();
19
-    echo "Done !\n";
20
-    if (isset($globalOwner) && $globalOwner) {
3
+	require_once('../require/settings.php');
4
+	if ($globalInstalled) {
5
+		echo '$globalInstalled must be set to FALSE in require/settings.php';
6
+		exit;
7
+	}
8
+	require('class.update_db.php');
9
+	echo "Populate all tables...\n";
10
+	update_db::update_all();
11
+	echo "\nInstall waypoints...(VERY slow!)";
12
+	update_db::update_waypoints();
13
+	echo "Done !\n";
14
+	echo "Install airspace...";
15
+	update_db::update_airspace();
16
+	echo "Done !\n";
17
+	echo "Install countries...";
18
+	update_db::update_countries();
19
+	echo "Done !\n";
20
+	if (isset($globalOwner) && $globalOwner) {
21 21
 	echo "Install private owners...";
22 22
 	update_db::update_owner();
23
-        echo "Done !\n";
24
-    }
25
-    /*
23
+		echo "Done !\n";
24
+	}
25
+	/*
26 26
     if (isset($globalIVAO) && $globalIVAO) {
27 27
         echo "Install IVAO airlines and logos...";
28 28
         update_db::update_IVAO();
29 29
 	echo "Done !\n";
30 30
     }
31 31
     */
32
-    if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
32
+	if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
33 33
 	echo "Install NOTAM from notaminfo.com...";
34
-        update_db:update_notam();
35
-        echo "Done !\n";
36
-    }
37
-    if (isset($globalMap3D) && $globalMap3D) {
34
+		update_db:update_notam();
35
+		echo "Done !\n";
36
+	}
37
+	if (isset($globalMap3D) && $globalMap3D) {
38 38
 	echo "Install 3D models...";
39 39
 	update_db::update_models();
40 40
 	echo "Done !\n";
41 41
 	if (isset($globalMapSatellites) && $globalMapSatellites) {
42
-	    echo "Install Space 3D models...";
43
-	    update_db::update_space_models();
44
-	    echo "Done !\n";
45
-        }
46
-    }
42
+		echo "Install Space 3D models...";
43
+		update_db::update_space_models();
44
+		echo "Done !\n";
45
+		}
46
+	}
47 47
 
48 48
 ?>
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
header.php 3 patches
Braces   +32 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
6 6
 $current_page = $file_path['filename'];
7 7
 date_default_timezone_set($globalTimezone);
8
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9
-else $MapType = $globalMapProvider;
8
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
9
+	$MapType = $_COOKIE['MapType'];
10
+} else {
11
+	$MapType = $globalMapProvider;
12
+}
10 13
 ?>
11 14
 <!DOCTYPE html>
12 15
 <html>
@@ -181,7 +184,13 @@  discard block
 block discarded – undo
181 184
 <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script>
182 185
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
183 186
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
184
-<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
187
+<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
188
+	print '&latitude='.$latitude;
189
+}
190
+?><?php if(isset($longitude)) {
191
+	print '&longitude='.$longitude;
192
+}
193
+?>&<?php print time(); ?>"></script>
185 194
 <?php
186 195
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
187 196
 ?>
@@ -235,7 +244,13 @@  discard block
 block discarded – undo
235 244
 <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script>
236 245
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
237 246
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
238
-<script src="<?php print $globalURL; ?>/js/map.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
247
+<script src="<?php print $globalURL; ?>/js/map.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
248
+	print '&latitude='.$latitude;
249
+}
250
+?><?php if(isset($longitude)) {
251
+	print '&longitude='.$longitude;
252
+}
253
+?>&<?php print time(); ?>"></script>
239 254
 <?php
240 255
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
241 256
 ?>
@@ -308,7 +323,12 @@  discard block
 block discarded – undo
308 323
         <span class="icon-bar"></span>
309 324
       </button>
310 325
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a>
311
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
326
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
327
+	print '/';
328
+} else {
329
+	print $globalURL;
330
+}
331
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
312 332
     </div>
313 333
     <div class="collapse navbar-collapse">
314 334
       <ul class="nav navbar-nav">
@@ -386,7 +406,9 @@  discard block
 block discarded – undo
386 406
   		        $alllang = $Language->getLanguages();
387 407
   		        foreach ($alllang as $key => $lang) {
388 408
   		            print '<option value="'.$key.'"';
389
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
409
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
410
+  		            	print ' selected ';
411
+  		            }
390 412
   		            print '>'.$lang[0].'</option>';
391 413
   		        }
392 414
   		    ?>
@@ -533,4 +555,7 @@  discard block
 block discarded – undo
533 555
 
534 556
 ?>
535 557
 
536
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
558
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
559
+	print 'index ';
560
+}
561
+?>clear">
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 ?>
169 169
 <?php 
170
-    if (isset($_POST['archive'])) {
170
+	if (isset($_POST['archive'])) {
171 171
 ?>
172 172
 <?php 
173
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
173
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
174 174
 ?>
175 175
 
176 176
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
177 177
 <?php    
178
-	    }
179
-    } else {
178
+		}
179
+	} else {
180 180
 ?>
181 181
 <?php
182 182
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
 */
189 189
 ?>
190 190
 <?php 
191
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
191
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
192 192
 ?>
193 193
 <script src="<?php print $globalURL; ?>/js/leaflet-playback.js"></script>
194 194
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>"></script>
195 195
 <?php
196
-	    }
196
+		}
197 197
 ?>
198 198
 <?php
199 199
 //	}
200 200
 ?>
201 201
 <?php
202
-    }
202
+	}
203 203
 }
204 204
 ?>
205 205
 <?php
@@ -359,23 +359,23 @@  discard block
 block discarded – undo
359 359
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
360 360
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
361 361
             <?php
362
-        	if ($globalACARS) {
363
-        	    if (isset($globalDemo) && $globalDemo) {
364
-    	    ?>
362
+			if ($globalACARS) {
363
+				if (isset($globalDemo) && $globalDemo) {
364
+			?>
365 365
             <li><hr /></li>
366 366
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
367 367
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
368 368
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
369 369
             <?php
370
-        	    } else {
371
-    	    ?>
370
+				} else {
371
+			?>
372 372
             <li><hr /></li>
373 373
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
374 374
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
375 375
             <?php
376
-        	    }
377
-        	}
378
-    	    ?>
376
+				}
377
+			}
378
+			?>
379 379
             <li><hr /></li>
380 380
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
381 381
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -417,14 +417,14 @@  discard block
 block discarded – undo
417 417
   	    <form>
418 418
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
419 419
   		    <?php
420
-  		        $Language = new Language();
421
-  		        $alllang = $Language->getLanguages();
422
-  		        foreach ($alllang as $key => $lang) {
423
-  		            print '<option value="'.$key.'"';
424
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
425
-  		            print '>'.$lang[0].'</option>';
426
-  		        }
427
-  		    ?>
420
+  				$Language = new Language();
421
+  				$alllang = $Language->getLanguages();
422
+  				foreach ($alllang as $key => $lang) {
423
+  					print '<option value="'.$key.'"';
424
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
425
+  					print '>'.$lang[0].'</option>';
426
+  				}
427
+  			?>
428 428
   		</select>
429 429
   	    </form>
430 430
   	</div>
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 }
461 461
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
462 462
 {
463
-    ?>
463
+	?>
464 464
     <div class="top-header clear" role="main">
465 465
         <div id="map"></div>
466 466
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
         var zoom = 13;
472 472
 //create the map
473 473
 <?php
474
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
474
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
475 475
 ?>
476 476
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
477 477
 <?php
478
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
478
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
479 479
 ?>
480 480
   map = L.map('map', { zoomControl:true });
481 481
 <?php
482
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
482
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
483 483
 ?>
484 484
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
485 485
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -487,22 +487,22 @@  discard block
 block discarded – undo
487 487
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
488 488
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
489 489
 <?php
490
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
490
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
491 491
 ?>
492 492
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
493 493
 <?php
494
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
494
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
495 495
 ?>
496 496
   map = L.map('map', { zoomControl:true });
497 497
 <?php
498
-    }
498
+	}
499 499
 ?>
500 500
   //initialize the layer group for the aircrft markers
501 501
   var layer_data = L.layerGroup();
502 502
 
503 503
   //a few title layers
504 504
 <?php
505
-    if ($globalMapProvider == 'Mapbox') {
505
+	if ($globalMapProvider == 'Mapbox') {
506 506
 ?>
507 507
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
508 508
     maxZoom: 18,
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
     token : '<?php print $globalMapboxToken; ?>'
514 514
   }).addTo(map);
515 515
 <?php
516
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
516
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
517 517
 ?>
518 518
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
519 519
     maxZoom: 18,
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
522 522
   }).addTo(map);
523 523
 <?php
524
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
524
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
525 525
 ?>
526 526
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
527 527
     maxZoom: 18,
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
531 531
   }).addTo(map);
532 532
 <?php
533
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
533
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
534 534
 ?>
535 535
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
536 536
     maxZoom: 18,
@@ -539,27 +539,27 @@  discard block
 block discarded – undo
539 539
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
540 540
   }).addTo(map);
541 541
 <?php
542
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
542
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
543 543
 ?>
544 544
     var googleLayer = new L.Google('ROADMAP');
545 545
     map.addLayer(googleLayer);
546 546
 <?php
547
-    } elseif ($globalMapProvider == 'Google-Satellite') {
547
+	} elseif ($globalMapProvider == 'Google-Satellite') {
548 548
 ?>
549 549
     var googleLayer = new L.Google('SATELLITE');
550 550
     map.addLayer(googleLayer);
551 551
 <?php
552
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
552
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
553 553
 ?>
554 554
     var googleLayer = new L.Google('HYBRID');
555 555
     map.addLayer(googleLayer);
556 556
 <?php
557
-    } elseif ($globalMapProvider == 'Google-Terrain') {
557
+	} elseif ($globalMapProvider == 'Google-Terrain') {
558 558
 ?>
559 559
     var googleLayer = new L.Google('Terrain');
560 560
     map.addLayer(googleLayer);
561 561
 <?php
562
-    }
562
+	}
563 563
 ?>
564 564
         </script>
565 565
     </div>
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,31 +8,31 @@  discard block
 block discarded – undo
8 8
 if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9 9
 else $MapType = $globalMapProvider;
10 10
 if (isset($_GET['3d'])) {
11
-	setcookie('MapFormat','3d');
11
+	setcookie('MapFormat', '3d');
12 12
 } else if (isset($_GET['2d'])) {
13
-	setcookie('MapFormat','2d');
13
+	setcookie('MapFormat', '2d');
14 14
 }
15 15
 
16 16
 if (isset($_POST['archive'])) {
17
-	setcookie('archive','true');
18
-	setcookie('archive_begin',strtotime($_POST['start_date']));
19
-	setcookie('archive_end',strtotime($_POST['end_date']));
20
-	setcookie('archive_speed',$_POST['archivespeed']);
17
+	setcookie('archive', 'true');
18
+	setcookie('archive_begin', strtotime($_POST['start_date']));
19
+	setcookie('archive_end', strtotime($_POST['end_date']));
20
+	setcookie('archive_speed', $_POST['archivespeed']);
21 21
 }
22 22
 if (isset($_POST['noarchive'])) {
23
-	setcookie('archive','false',-1);
24
-	setcookie('archive_begin','',-1);
25
-	setcookie('archive_end','',-1);
26
-	setcookie('archive_speed','',-1);
23
+	setcookie('archive', 'false', -1);
24
+	setcookie('archive_begin', '', -1);
25
+	setcookie('archive_end', '', -1);
26
+	setcookie('archive_speed', '', -1);
27 27
 }
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
30
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
31
+	    return strpos($key, 'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
35
-		setcookie($filt,null,-1);
35
+		setcookie($filt, null, -1);
36 36
 	}
37 37
 }
38 38
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script>
217 217
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
218 218
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
219
-<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
219
+<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
220 220
 <?php
221 221
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
222 222
 ?>
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script>
271 271
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
272 272
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
273
-<script src="<?php print $globalURL; ?>/js/map.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
273
+<script src="<?php print $globalURL; ?>/js/map.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
274 274
 <?php
275 275
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
276 276
 ?>
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 ?>
434 434
       <div class="search">
435 435
       <form action="<?php print $globalURL; ?>/search" method="get">
436
-		<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
436
+		<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
437 437
 	</form>
438 438
 	</div>
439 439
   	<div class="social">
@@ -451,14 +451,14 @@  discard block
 block discarded – undo
451 451
 	print '</div>';
452 452
 }
453 453
 
454
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
454
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
455 455
 ?>
456 456
     <div class="top-header clear" role="main">
457 457
     <div id="archive-map"></div>
458 458
     </div>
459 459
 <?php
460 460
 }
461
-if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
461
+if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false))
462 462
 {
463 463
     ?>
464 464
     <div class="top-header clear" role="main">
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
         var zoom = 13;
472 472
 //create the map
473 473
 <?php
474
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
474
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
475 475
 ?>
476 476
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
477 477
 <?php
478
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
478
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
479 479
 ?>
480 480
   map = L.map('map', { zoomControl:true });
481 481
 <?php
482
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
482
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
483 483
 ?>
484 484
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
485 485
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
488 488
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
489 489
 <?php
490
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
490
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
491 491
 ?>
492 492
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
493 493
 <?php
Please login to merge, or discard this patch.
live-sat-czml.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
 
21 21
 $spotter_array = array();
22 22
 if (isset($_COOKIE['sattypes']) && $_COOKIE['sattypes'] != '') {
23
-	$sattypes = explode(',',$_COOKIE['sattypes']);
23
+	$sattypes = explode(',', $_COOKIE['sattypes']);
24 24
 	foreach ($sattypes as $sattype) {
25
-		$spotter_array = array_merge($Satellite->position_all_type($sattype,$timeb-$globalLiveInterval,$timeb),$spotter_array);
25
+		$spotter_array = array_merge($Satellite->position_all_type($sattype, $timeb - $globalLiveInterval, $timeb), $spotter_array);
26 26
 	}
27 27
 }
28 28
 if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss']) {
29
-	$spotter_array = array_merge($Satellite->position('ISS (ZARYA)',time()-$globalLiveInterval,time()),$spotter_array);
30
-	$spotter_array = array_merge($Satellite->position('TIANGONG 1',time()-$globalLiveInterval,time()),$spotter_array);
31
-	$spotter_array = array_merge($Satellite->position('TIANGONG-2',time()-$globalLiveInterval,time()),$spotter_array);
29
+	$spotter_array = array_merge($Satellite->position('ISS (ZARYA)', time() - $globalLiveInterval, time()), $spotter_array);
30
+	$spotter_array = array_merge($Satellite->position('TIANGONG 1', time() - $globalLiveInterval, time()), $spotter_array);
31
+	$spotter_array = array_merge($Satellite->position('TIANGONG-2', time() - $globalLiveInterval, time()), $spotter_array);
32 32
 }
33
-$spotter_array = array_unique($spotter_array,SORT_REGULAR);
33
+$spotter_array = array_unique($spotter_array, SORT_REGULAR);
34 34
 /*
35 35
 $modelsdb = array();
36 36
 if (file_exists('models/space/space_modelsdb')) {
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}';
55 55
 
56 56
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
57
-$output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
57
+$output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
58 58
 //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
59 59
 
60 60
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"step": "SYSTEM_CLOCK_MULTIPLIER"}';
61 61
 $output .= '},';
62 62
 if (!empty($spotter_array) && is_array($spotter_array))
63 63
 {
64
-	foreach($spotter_array as $spotter_item)
64
+	foreach ($spotter_array as $spotter_item)
65 65
 	{
66 66
 		$j++;
67 67
 		date_default_timezone_set('UTC');
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			$orientation = '';
77 77
 			$prev_satname = $spotter_item['name'];
78 78
 			$output .= '{';
79
-			$output .= '"id": "'.trim(str_replace(array('[+]','[-]'),'',$spotter_item['name'])).'",';
79
+			$output .= '"id": "'.trim(str_replace(array('[+]', '[-]'), '', $spotter_item['name'])).'",';
80 80
 			$output .= '"properties": {';
81 81
 			// Not yet supported in CZML with Cesium
82 82
 			$output .= '},';
@@ -114,23 +114,23 @@  discard block
 block discarded – undo
114 114
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubiesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
115 115
 				} elseif ($spotter_item['name'] == 'TERRA') {
116 116
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/terra.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
117
-				} elseif (strpos($spotter_item['name'],'O3B') !== false) {
117
+				} elseif (strpos($spotter_item['name'], 'O3B') !== false) {
118 118
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/o3b.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
119
-				} elseif (strpos($spotter_item['name'],'GLOBALSTAR') !== false) {
119
+				} elseif (strpos($spotter_item['name'], 'GLOBALSTAR') !== false) {
120 120
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/globalstar.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
121
-				} elseif (strpos($spotter_item['name'],'GPS') !== false) {
121
+				} elseif (strpos($spotter_item['name'], 'GPS') !== false) {
122 122
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/gps.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
123
-				} elseif (strpos($spotter_item['name'],'GENESIS') !== false) {
123
+				} elseif (strpos($spotter_item['name'], 'GENESIS') !== false) {
124 124
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/genesis.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
125
-				} elseif (strpos($spotter_item['name'],'OSCAR 7') !== false) {
125
+				} elseif (strpos($spotter_item['name'], 'OSCAR 7') !== false) {
126 126
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/oscar7.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
127
-				} elseif (strpos($spotter_item['name'],'FLOCK') !== false) {
127
+				} elseif (strpos($spotter_item['name'], 'FLOCK') !== false) {
128 128
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
129
-				} elseif (strpos($spotter_item['name'],'PLEIADES') !== false) {
129
+				} elseif (strpos($spotter_item['name'], 'PLEIADES') !== false) {
130 130
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/pleiades.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
131
-				} elseif (strpos($spotter_item['name'],'DUCHIFAT') !== false) {
131
+				} elseif (strpos($spotter_item['name'], 'DUCHIFAT') !== false) {
132 132
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/duchifat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
133
-				} elseif (strpos($spotter_item['name'],'FORMOSAT-2') !== false) {
133
+				} elseif (strpos($spotter_item['name'], 'FORMOSAT-2') !== false) {
134 134
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/formosat2.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
135 135
 				} elseif ($spotter_item['type'] == 'iridium') {
136 136
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/iridium.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
 	//		$output .= '"interpolationDegree" : 5,';
152 152
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
153 153
 			$output .= '"cartographicDegrees": [';
154
-			$output .= '"'.date("c",$spotter_item['timestamp']).'", ';
154
+			$output .= '"'.date("c", $spotter_item['timestamp']).'", ';
155 155
 			$output .= $spotter_item['longitude'].', ';
156 156
 			$output .= $spotter_item['latitude'].', ';
157 157
 			$output .= $spotter_item['altitude']*1000;
158 158
 			$orientation = '"orientation" : { ';
159 159
 			$orientation .= '"unitQuaternion": [';
160 160
 		} else {
161
-			$output .= ',"'.date("c",$spotter_item['timestamp']).'", ';
161
+			$output .= ',"'.date("c", $spotter_item['timestamp']).'", ';
162 162
 			$output .= $spotter_item['longitude'].', ';
163 163
 			$output .= $spotter_item['latitude'].', ';
164 164
 			$output .= $spotter_item['altitude']*1000;
Please login to merge, or discard this patch.
require/class.Stats.php 4 patches
Doc Comments   +32 added lines patch added patch discarded remove patch
@@ -13,6 +13,10 @@  discard block
 block discarded – undo
13 13
 		$this->db = $Connection->db();
14 14
         }
15 15
               
16
+	/**
17
+	 * @param string $type
18
+	 * @param string $stats_date
19
+	 */
16 20
 	public function addLastStatsUpdate($type,$stats_date) {
17 21
                 $query = "DELETE FROM config WHERE name = :type;
18 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -578,6 +582,11 @@  discard block
 block discarded – undo
578 582
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
579 583
                 return $all;
580 584
         }
585
+
586
+	/**
587
+	 * @param string $type
588
+	 * @param string $year
589
+	 */
581 590
 	public function getSumStats($type,$year,$stats_airline = '') {
582 591
     		global $globalArchiveMonths, $globalDBdriver;
583 592
     		if ($globalDBdriver == 'mysql') {
@@ -677,6 +686,10 @@  discard block
 block discarded – undo
677 686
                 return $all[0]['total'];
678 687
         }
679 688
 
689
+	/**
690
+	 * @param string $type
691
+	 * @param string $stats_date
692
+	 */
680 693
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '') {
681 694
 		global $globalDBdriver;
682 695
 		if ($globalDBdriver == 'mysql') {
@@ -708,6 +721,10 @@  discard block
 block discarded – undo
708 721
                         return "error : ".$e->getMessage();
709 722
                 }
710 723
         }
724
+
725
+	/**
726
+	 * @param string $date
727
+	 */
711 728
 	public function getStatsSource($date,$stats_type = '') {
712 729
 		if ($stats_type == '') {
713 730
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -726,6 +743,9 @@  discard block
 block discarded – undo
726 743
                 return $all;
727 744
         }
728 745
 
746
+	/**
747
+	 * @param string $stats_type
748
+	 */
729 749
 	public function addStatSource($data,$source_name,$stats_type,$date) {
730 750
 		global $globalDBdriver;
731 751
 		if ($globalDBdriver == 'mysql') {
@@ -741,6 +761,10 @@  discard block
 block discarded – undo
741 761
                         return "error : ".$e->getMessage();
742 762
                 }
743 763
         }
764
+
765
+	/**
766
+	 * @param string $type
767
+	 */
744 768
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '') {
745 769
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline) VALUES (:type,:flight_date,:cnt,:stats_airline)";
746 770
                 $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline);
@@ -927,6 +951,10 @@  discard block
 block discarded – undo
927 951
                         return "error : ".$e->getMessage();
928 952
                 }
929 953
         }
954
+
955
+	/**
956
+	 * @param string $type
957
+	 */
930 958
 	public function deleteStatFlight($type) {
931 959
                 $query = "DELETE FROM stats_flight WHERE stats_type = :type";
932 960
                 $query_values = array(':type' => $type);
@@ -937,6 +965,10 @@  discard block
 block discarded – undo
937 965
                         return "error : ".$e->getMessage();
938 966
                 }
939 967
         }
968
+
969
+	/**
970
+	 * @param string $type
971
+	 */
940 972
 	public function deleteStatAirport($type) {
941 973
                 $query = "DELETE FROM stats_airport WHERE stats_type = :type";
942 974
                 $query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Indentation   +811 added lines, -811 removed lines patch added patch discarded remove patch
@@ -15,67 +15,67 @@  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
-        }
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 43
 	public function getAllAirlineNames($filter_name = '') {
44 44
 		if ($filter_name == '') $filter_name = $this->filter_name;
45
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
46
-                 try {
47
-                        $sth = $this->db->prepare($query);
48
-                        $sth->execute(array(':filter_name' => $filter_name));
49
-                } catch(PDOException $e) {
50
-                        echo "error : ".$e->getMessage();
51
-                }
52
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
53
-                return $all;
54
-        }
45
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
46
+				 try {
47
+						$sth = $this->db->prepare($query);
48
+						$sth->execute(array(':filter_name' => $filter_name));
49
+				} catch(PDOException $e) {
50
+						echo "error : ".$e->getMessage();
51
+				}
52
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
53
+				return $all;
54
+		}
55 55
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
56 56
 		if ($filter_name == '') $filter_name = $this->filter_name;
57
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
58
-                 try {
59
-                        $sth = $this->db->prepare($query);
60
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
61
-                } catch(PDOException $e) {
62
-                        echo "error : ".$e->getMessage();
63
-                }
64
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
65
-                return $all;
66
-        }
57
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
58
+				 try {
59
+						$sth = $this->db->prepare($query);
60
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
61
+				} catch(PDOException $e) {
62
+						echo "error : ".$e->getMessage();
63
+				}
64
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
65
+				return $all;
66
+		}
67 67
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
68 68
 		if ($filter_name == '') $filter_name = $this->filter_name;
69
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
70
-                 try {
71
-                        $sth = $this->db->prepare($query);
72
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
73
-                } catch(PDOException $e) {
74
-                        echo "error : ".$e->getMessage();
75
-                }
76
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
77
-                return $all;
78
-        }
69
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
70
+				 try {
71
+						$sth = $this->db->prepare($query);
72
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
73
+				} catch(PDOException $e) {
74
+						echo "error : ".$e->getMessage();
75
+				}
76
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
77
+				return $all;
78
+		}
79 79
 
80 80
 
81 81
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
@@ -83,66 +83,66 @@  discard block
 block discarded – undo
83 83
 		if ($filter_name == '') $filter_name = $this->filter_name;
84 84
 		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
85 85
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
86
-                 try {
87
-                        $sth = $this->db->prepare($query);
88
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
89
-                } catch(PDOException $e) {
90
-                        echo "error : ".$e->getMessage();
91
-                }
92
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
93
-                if (empty($all)) {
94
-            	    $filters = array('airlines' => array($stats_airline));
95
-            	    if ($filter_name != '') {
96
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
97
-            	    }
98
-            	    $Spotter = new Spotter($this->db);
99
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
100
-                }
101
-                return $all;
86
+				 try {
87
+						$sth = $this->db->prepare($query);
88
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
89
+				} catch(PDOException $e) {
90
+						echo "error : ".$e->getMessage();
91
+				}
92
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
93
+				if (empty($all)) {
94
+					$filters = array('airlines' => array($stats_airline));
95
+					if ($filter_name != '') {
96
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
97
+					}
98
+					$Spotter = new Spotter($this->db);
99
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
100
+				}
101
+				return $all;
102 102
 	}
103 103
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
104 104
 		global $globalStatsFilters;
105 105
 		if ($filter_name == '') $filter_name = $this->filter_name;
106 106
 		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";
107 107
 		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";
108
-                 try {
109
-                        $sth = $this->db->prepare($query);
110
-                        $sth->execute(array(':filter_name' => $filter_name));
111
-                } catch(PDOException $e) {
112
-                        echo "error : ".$e->getMessage();
113
-                }
114
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
115
-                if (empty($all)) {
116
-            		$Spotter = new Spotter($this->db);
117
-            		$filters = array();
118
-            		if ($filter_name != '') {
119
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
120
-			}
121
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
122
-                }
123
-                return $all;
108
+				 try {
109
+						$sth = $this->db->prepare($query);
110
+						$sth->execute(array(':filter_name' => $filter_name));
111
+				} catch(PDOException $e) {
112
+						echo "error : ".$e->getMessage();
113
+				}
114
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
115
+				if (empty($all)) {
116
+					$Spotter = new Spotter($this->db);
117
+					$filters = array();
118
+					if ($filter_name != '') {
119
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
120
+			}
121
+					$all = $Spotter->countAllAirlineCountries($limit,$filters);
122
+				}
123
+				return $all;
124 124
 	}
125 125
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
126 126
 		global $globalStatsFilters;
127 127
 		if ($filter_name == '') $filter_name = $this->filter_name;
128 128
 		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";
129 129
 		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";
130
-                 try {
131
-                        $sth = $this->db->prepare($query);
132
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
133
-                } catch(PDOException $e) {
134
-                        echo "error : ".$e->getMessage();
135
-                }
136
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
137
-                if (empty($all)) {
138
-            		$filters = array('airlines' => array($stats_airline));
139
-            		if ($filter_name != '') {
140
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
130
+				 try {
131
+						$sth = $this->db->prepare($query);
132
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
133
+				} catch(PDOException $e) {
134
+						echo "error : ".$e->getMessage();
135
+				}
136
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
137
+				if (empty($all)) {
138
+					$filters = array('airlines' => array($stats_airline));
139
+					if ($filter_name != '') {
140
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
141 141
 			}
142
-            		$Spotter = new Spotter($this->db);
142
+					$Spotter = new Spotter($this->db);
143 143
 			$all = $Spotter->countAllAircraftManufacturers($filters);
144
-                }
145
-                return $all;
144
+				}
145
+				return $all;
146 146
 	}
147 147
 
148 148
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
@@ -150,44 +150,44 @@  discard block
 block discarded – undo
150 150
 		if ($filter_name == '') $filter_name = $this->filter_name;
151 151
 		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";
152 152
 		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";
153
-                 try {
154
-                        $sth = $this->db->prepare($query);
155
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
156
-                } catch(PDOException $e) {
157
-                        echo "error : ".$e->getMessage();
158
-                }
159
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
160
-                if (empty($all)) {
153
+				 try {
154
+						$sth = $this->db->prepare($query);
155
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
156
+				} catch(PDOException $e) {
157
+						echo "error : ".$e->getMessage();
158
+				}
159
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
160
+				if (empty($all)) {
161 161
 			$filters = array('airlines' => array($stats_airline));
162 162
 			if ($filter_name != '') {
163
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
163
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
164 164
 			}
165 165
 			$Spotter = new Spotter($this->db);
166 166
 			$all = $Spotter->countAllArrivalCountries($limit,$filters);
167
-                }
168
-                return $all;
167
+				}
168
+				return $all;
169 169
 	}
170 170
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
171 171
 		global $globalStatsFilters;
172 172
 		if ($filter_name == '') $filter_name = $this->filter_name;
173 173
 		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";
174 174
 		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";
175
-                 try {
176
-                        $sth = $this->db->prepare($query);
177
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
178
-                } catch(PDOException $e) {
179
-                        echo "error : ".$e->getMessage();
180
-                }
181
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
182
-                if (empty($all)) {
175
+				 try {
176
+						$sth = $this->db->prepare($query);
177
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
178
+				} catch(PDOException $e) {
179
+						echo "error : ".$e->getMessage();
180
+				}
181
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
182
+				if (empty($all)) {
183 183
 			$filters = array('airlines' => array($stats_airline));
184 184
 			if ($filter_name != '') {
185
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
185
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
186 186
 			}
187 187
 			$Spotter = new Spotter($this->db);
188 188
 			$all = $Spotter->countAllDepartureCountries($filters);
189
-                }
190
-                return $all;
189
+				}
190
+				return $all;
191 191
 	}
192 192
 
193 193
 	public function countAllAirlines($limit = true,$filter_name = '') {
@@ -195,45 +195,45 @@  discard block
 block discarded – undo
195 195
 		if ($filter_name == '') $filter_name = $this->filter_name;
196 196
 		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
197 197
 		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 ORDER BY airline_count DESC";
198
-                 try {
199
-                        $sth = $this->db->prepare($query);
200
-                        $sth->execute(array(':filter_name' => $filter_name));
201
-                } catch(PDOException $e) {
202
-                        echo "error : ".$e->getMessage();
203
-                }
204
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
205
-                if (empty($all)) {
206
-	                $Spotter = new Spotter($this->db);
207
-            		$filters = array();
208
-            		if ($filter_name != '') {
209
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
198
+				 try {
199
+						$sth = $this->db->prepare($query);
200
+						$sth->execute(array(':filter_name' => $filter_name));
201
+				} catch(PDOException $e) {
202
+						echo "error : ".$e->getMessage();
203
+				}
204
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
205
+				if (empty($all)) {
206
+					$Spotter = new Spotter($this->db);
207
+					$filters = array();
208
+					if ($filter_name != '') {
209
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
210 210
 			}
211 211
 
212
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
213
-                }
214
-                return $all;
212
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
213
+				}
214
+				return $all;
215 215
 	}
216 216
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
217 217
 		global $globalStatsFilters;
218 218
 		if ($filter_name == '') $filter_name = $this->filter_name;
219 219
 		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";
220 220
 		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";
221
-                 try {
222
-                        $sth = $this->db->prepare($query);
223
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
224
-                } catch(PDOException $e) {
225
-                        echo "error : ".$e->getMessage();
226
-                }
227
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
228
-                if (empty($all)) {
221
+				 try {
222
+						$sth = $this->db->prepare($query);
223
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
224
+				} catch(PDOException $e) {
225
+						echo "error : ".$e->getMessage();
226
+				}
227
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
228
+				if (empty($all)) {
229 229
 			$filters = array('airlines' => array($stats_airline));
230 230
 			if ($filter_name != '') {
231 231
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
232 232
 			}
233
-	                $Spotter = new Spotter($this->db);
234
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
235
-                }
236
-                return $all;
233
+					$Spotter = new Spotter($this->db);
234
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
235
+				}
236
+				return $all;
237 237
 	}
238 238
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
239 239
 		global $globalStatsFilters;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 				echo "error : ".$e->getMessage();
271 271
 			}
272 272
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
273
-                /*
273
+				/*
274 274
                 if (empty($all)) {
275 275
 	                $Spotter = new Spotter($this->db);
276 276
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -286,84 +286,84 @@  discard block
 block discarded – undo
286 286
 		if ($filter_name == '') $filter_name = $this->filter_name;
287 287
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
288 288
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
289
-                 try {
290
-                        $sth = $this->db->prepare($query);
291
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
292
-                } catch(PDOException $e) {
293
-                        echo "error : ".$e->getMessage();
294
-                }
295
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
296
-                if (empty($all)) {
289
+				 try {
290
+						$sth = $this->db->prepare($query);
291
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
292
+				} catch(PDOException $e) {
293
+						echo "error : ".$e->getMessage();
294
+				}
295
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
296
+				if (empty($all)) {
297 297
 			$filters = array('airlines' => array($stats_airline));
298 298
 			if ($filter_name != '') {
299 299
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
300 300
 			}
301
-            		$Spotter = new Spotter($this->db);
302
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
303
-                }
304
-                return $all;
301
+					$Spotter = new Spotter($this->db);
302
+					$all = $Spotter->countAllPilots($limit,0,'',$filters);
303
+				}
304
+				return $all;
305 305
 	}
306 306
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
307 307
 		global $globalStatsFilters;
308 308
 		if ($filter_name == '') $filter_name = $this->filter_name;
309 309
 		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";
310 310
 		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";
311
-                 try {
312
-                        $sth = $this->db->prepare($query);
313
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
314
-                } catch(PDOException $e) {
315
-                        echo "error : ".$e->getMessage();
316
-                }
317
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
318
-                if (empty($all)) {
311
+				 try {
312
+						$sth = $this->db->prepare($query);
313
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
314
+				} catch(PDOException $e) {
315
+						echo "error : ".$e->getMessage();
316
+				}
317
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
318
+				if (empty($all)) {
319 319
 			$filters = array('airlines' => array($stats_airline));
320 320
 			if ($filter_name != '') {
321 321
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
322 322
 			}
323
-            		$Spotter = new Spotter($this->db);
324
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
325
-                }
326
-                return $all;
323
+					$Spotter = new Spotter($this->db);
324
+					$all = $Spotter->countAllOwners($limit,0,'',$filters);
325
+				}
326
+				return $all;
327 327
 	}
328 328
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
329 329
 		global $globalStatsFilters;
330 330
 		if ($filter_name == '') $filter_name = $this->filter_name;
331 331
 		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
332 332
 		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
333
-                 try {
334
-                        $sth = $this->db->prepare($query);
335
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
336
-                } catch(PDOException $e) {
337
-                        echo "error : ".$e->getMessage();
338
-                }
339
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
340
-                if (empty($all)) {
333
+				 try {
334
+						$sth = $this->db->prepare($query);
335
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
336
+				} catch(PDOException $e) {
337
+						echo "error : ".$e->getMessage();
338
+				}
339
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
340
+				if (empty($all)) {
341 341
 			$filters = array('airlines' => array($stats_airline));
342
-            		if ($filter_name != '') {
343
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
344
-			}
345
-            		$Spotter = new Spotter($this->db);
346
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
347
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
348
-        		$all = array();
349
-        		foreach ($pall as $value) {
350
-        			$icao = $value['airport_departure_icao'];
351
-        			$all[$icao] = $value;
352
-        		}
342
+					if ($filter_name != '') {
343
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
344
+			}
345
+					$Spotter = new Spotter($this->db);
346
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
347
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
348
+				$all = array();
349
+				foreach ($pall as $value) {
350
+					$icao = $value['airport_departure_icao'];
351
+					$all[$icao] = $value;
352
+				}
353 353
         		
354
-        		foreach ($dall as $value) {
355
-        			$icao = $value['airport_departure_icao'];
356
-        			if (isset($all[$icao])) {
357
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
358
-        			} else $all[$icao] = $value;
359
-        		}
360
-        		$count = array();
361
-        		foreach ($all as $key => $row) {
362
-        			$count[$key] = $row['airport_departure_icao_count'];
363
-        		}
364
-        		array_multisort($count,SORT_DESC,$all);
365
-                }
366
-                return $all;
354
+				foreach ($dall as $value) {
355
+					$icao = $value['airport_departure_icao'];
356
+					if (isset($all[$icao])) {
357
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
358
+					} else $all[$icao] = $value;
359
+				}
360
+				$count = array();
361
+				foreach ($all as $key => $row) {
362
+					$count[$key] = $row['airport_departure_icao_count'];
363
+				}
364
+				array_multisort($count,SORT_DESC,$all);
365
+				}
366
+				return $all;
367 367
 	}
368 368
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
369 369
 		global $globalStatsFilters;
@@ -385,26 +385,26 @@  discard block
 block discarded – undo
385 385
 			$Spotter = new Spotter($this->db);
386 386
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
387 387
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
388
-        		$all = array();
389
-        		foreach ($pall as $value) {
390
-        			$icao = $value['airport_arrival_icao'];
391
-        			$all[$icao] = $value;
392
-        		}
388
+				$all = array();
389
+				foreach ($pall as $value) {
390
+					$icao = $value['airport_arrival_icao'];
391
+					$all[$icao] = $value;
392
+				}
393 393
         		
394
-        		foreach ($dall as $value) {
395
-        			$icao = $value['airport_arrival_icao'];
396
-        			if (isset($all[$icao])) {
397
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
398
-        			} else $all[$icao] = $value;
399
-        		}
400
-        		$count = array();
401
-        		foreach ($all as $key => $row) {
402
-        			$count[$key] = $row['airport_arrival_icao_count'];
403
-        		}
404
-        		array_multisort($count,SORT_DESC,$all);
405
-                }
394
+				foreach ($dall as $value) {
395
+					$icao = $value['airport_arrival_icao'];
396
+					if (isset($all[$icao])) {
397
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
398
+					} else $all[$icao] = $value;
399
+				}
400
+				$count = array();
401
+				foreach ($all as $key => $row) {
402
+					$count[$key] = $row['airport_arrival_icao_count'];
403
+				}
404
+				array_multisort($count,SORT_DESC,$all);
405
+				}
406 406
  
407
-                return $all;
407
+				return $all;
408 408
 	}
409 409
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
410 410
 		global $globalDBdriver, $globalStatsFilters;
@@ -417,23 +417,23 @@  discard block
 block discarded – undo
417 417
 			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";
418 418
 		}
419 419
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
420
-                 try {
421
-                        $sth = $this->db->prepare($query);
422
-                        $sth->execute($query_data);
423
-                } catch(PDOException $e) {
424
-                        echo "error : ".$e->getMessage();
425
-                }
426
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
427
-                if (empty($all)) {
420
+				 try {
421
+						$sth = $this->db->prepare($query);
422
+						$sth->execute($query_data);
423
+				} catch(PDOException $e) {
424
+						echo "error : ".$e->getMessage();
425
+				}
426
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
427
+				if (empty($all)) {
428 428
 			$filters = array('airlines' => array($stats_airline));
429 429
 			if ($filter_name != '') {
430 430
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
431 431
 			}
432
-            		$Spotter = new Spotter($this->db);
433
-            		$all = $Spotter->countAllMonthsLastYear($filters);
434
-                }
432
+					$Spotter = new Spotter($this->db);
433
+					$all = $Spotter->countAllMonthsLastYear($filters);
434
+				}
435 435
                 
436
-                return $all;
436
+				return $all;
437 437
 	}
438 438
 	
439 439
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -441,22 +441,22 @@  discard block
 block discarded – undo
441 441
 		if ($filter_name == '') $filter_name = $this->filter_name;
442 442
 		$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";
443 443
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
444
-                 try {
445
-                        $sth = $this->db->prepare($query);
446
-                        $sth->execute($query_data);
447
-                } catch(PDOException $e) {
448
-                        echo "error : ".$e->getMessage();
449
-                }
450
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
451
-                if (empty($all)) {
444
+				 try {
445
+						$sth = $this->db->prepare($query);
446
+						$sth->execute($query_data);
447
+				} catch(PDOException $e) {
448
+						echo "error : ".$e->getMessage();
449
+				}
450
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
451
+				if (empty($all)) {
452 452
 			$filters = array('airlines' => array($stats_airline));
453 453
 			if ($filter_name != '') {
454 454
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
455 455
 			}
456
-            		$Spotter = new Spotter($this->db);
457
-            		$all = $Spotter->countAllDatesLastMonth($filters);
458
-                }
459
-                return $all;
456
+					$Spotter = new Spotter($this->db);
457
+					$all = $Spotter->countAllDatesLastMonth($filters);
458
+				}
459
+				return $all;
460 460
 	}
461 461
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
462 462
 		global $globalDBdriver, $globalStatsFilters;
@@ -467,108 +467,108 @@  discard block
 block discarded – undo
467 467
 			$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";
468 468
 		}
469 469
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
470
-                 try {
471
-                        $sth = $this->db->prepare($query);
472
-                        $sth->execute($query_data);
473
-                } catch(PDOException $e) {
474
-                        echo "error : ".$e->getMessage();
475
-                }
476
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
477
-                if (empty($all)) {
470
+				 try {
471
+						$sth = $this->db->prepare($query);
472
+						$sth->execute($query_data);
473
+				} catch(PDOException $e) {
474
+						echo "error : ".$e->getMessage();
475
+				}
476
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
477
+				if (empty($all)) {
478 478
 			$filters = array('airlines' => array($stats_airline));
479 479
 			if ($filter_name != '') {
480 480
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
481 481
 			}
482
-            		$Spotter = new Spotter($this->db);
483
-            		$all = $Spotter->countAllDatesLast7Days($filters);
484
-                }
485
-                return $all;
482
+					$Spotter = new Spotter($this->db);
483
+					$all = $Spotter->countAllDatesLast7Days($filters);
484
+				}
485
+				return $all;
486 486
 	}
487 487
 	public function countAllDates($stats_airline = '',$filter_name = '') {
488 488
 		global $globalStatsFilters;
489 489
 		if ($filter_name == '') $filter_name = $this->filter_name;
490 490
 		$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";
491 491
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492
-                 try {
493
-                        $sth = $this->db->prepare($query);
494
-                        $sth->execute($query_data);
495
-                } catch(PDOException $e) {
496
-                        echo "error : ".$e->getMessage();
497
-                }
498
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
499
-                if (empty($all)) {
492
+				 try {
493
+						$sth = $this->db->prepare($query);
494
+						$sth->execute($query_data);
495
+				} catch(PDOException $e) {
496
+						echo "error : ".$e->getMessage();
497
+				}
498
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
499
+				if (empty($all)) {
500 500
 			$filters = array('airlines' => array($stats_airline));
501 501
 			if ($filter_name != '') {
502
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
502
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
503 503
 			}
504
-            		$Spotter = new Spotter($this->db);
505
-            		$all = $Spotter->countAllDates($filters);
506
-                }
507
-                return $all;
504
+					$Spotter = new Spotter($this->db);
505
+					$all = $Spotter->countAllDates($filters);
506
+				}
507
+				return $all;
508 508
 	}
509 509
 	public function countAllDatesByAirlines($filter_name = '') {
510 510
 		global $globalStatsFilters;
511 511
 		if ($filter_name == '') $filter_name = $this->filter_name;
512 512
 		$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";
513 513
 		$query_data = array('filter_name' => $filter_name);
514
-                 try {
515
-                        $sth = $this->db->prepare($query);
516
-                        $sth->execute($query_data);
517
-                } catch(PDOException $e) {
518
-                        echo "error : ".$e->getMessage();
519
-                }
520
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
521
-                if (empty($all)) {
522
-            		$filters = array();
523
-            		if ($filter_name != '') {
524
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
525
-			}
526
-            		$Spotter = new Spotter($this->db);
527
-            		$all = $Spotter->countAllDatesByAirlines($filters);
528
-                }
529
-                return $all;
514
+				 try {
515
+						$sth = $this->db->prepare($query);
516
+						$sth->execute($query_data);
517
+				} catch(PDOException $e) {
518
+						echo "error : ".$e->getMessage();
519
+				}
520
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
521
+				if (empty($all)) {
522
+					$filters = array();
523
+					if ($filter_name != '') {
524
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
525
+			}
526
+					$Spotter = new Spotter($this->db);
527
+					$all = $Spotter->countAllDatesByAirlines($filters);
528
+				}
529
+				return $all;
530 530
 	}
531 531
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
532 532
 		global $globalStatsFilters;
533 533
 		if ($filter_name == '') $filter_name = $this->filter_name;
534
-	    	$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";
535
-                 try {
536
-                        $sth = $this->db->prepare($query);
537
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
538
-                } catch(PDOException $e) {
539
-                        echo "error : ".$e->getMessage();
540
-                }
541
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
542
-                if (empty($all)) {
534
+			$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";
535
+				 try {
536
+						$sth = $this->db->prepare($query);
537
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
538
+				} catch(PDOException $e) {
539
+						echo "error : ".$e->getMessage();
540
+				}
541
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
542
+				if (empty($all)) {
543 543
 			$filters = array('airlines' => array($stats_airline));
544 544
 			if ($filter_name != '') {
545 545
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
546 546
 			}
547
-            		$Spotter = new Spotter($this->db);
548
-            		$all = $Spotter->countAllMonths($filters);
549
-                }
550
-                return $all;
547
+					$Spotter = new Spotter($this->db);
548
+					$all = $Spotter->countAllMonths($filters);
549
+				}
550
+				return $all;
551 551
 	}
552 552
 	public function countAllMilitaryMonths($filter_name = '') {
553 553
 		global $globalStatsFilters;
554 554
 		if ($filter_name == '') $filter_name = $this->filter_name;
555
-	    	$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";
556
-                 try {
557
-                        $sth = $this->db->prepare($query);
558
-                        $sth->execute(array(':filter_name' => $filter_name));
559
-                } catch(PDOException $e) {
560
-                        echo "error : ".$e->getMessage();
561
-                }
562
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
563
-                if (empty($all)) {
564
-            		$filters = array();
565
-            		if ($filter_name != '') {
566
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
567
-			}
568
-            		$Spotter = new Spotter($this->db);
569
-            		$all = $Spotter->countAllMilitaryMonths($filters);
570
-                }
571
-                return $all;
555
+			$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";
556
+				 try {
557
+						$sth = $this->db->prepare($query);
558
+						$sth->execute(array(':filter_name' => $filter_name));
559
+				} catch(PDOException $e) {
560
+						echo "error : ".$e->getMessage();
561
+				}
562
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
563
+				if (empty($all)) {
564
+					$filters = array();
565
+					if ($filter_name != '') {
566
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
567
+			}
568
+					$Spotter = new Spotter($this->db);
569
+					$all = $Spotter->countAllMilitaryMonths($filters);
570
+				}
571
+				return $all;
572 572
 	}
573 573
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
574 574
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -584,22 +584,22 @@  discard block
 block discarded – undo
584 584
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
585 585
 		}
586 586
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
587
-                 try {
588
-                        $sth = $this->db->prepare($query);
589
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
590
-                } catch(PDOException $e) {
591
-                        echo "error : ".$e->getMessage();
592
-                }
593
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
594
-                if (empty($all)) {
587
+				 try {
588
+						$sth = $this->db->prepare($query);
589
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
590
+				} catch(PDOException $e) {
591
+						echo "error : ".$e->getMessage();
592
+				}
593
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
594
+				if (empty($all)) {
595 595
 			$filters = array('airlines' => array($stats_airline));
596 596
 			if ($filter_name != '') {
597
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
597
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
598 598
 			}
599
-            		$Spotter = new Spotter($this->db);
600
-            		$all = $Spotter->countAllHours($orderby,$filters);
601
-                }
602
-                return $all;
599
+					$Spotter = new Spotter($this->db);
600
+					$all = $Spotter->countAllHours($orderby,$filters);
601
+				}
602
+				return $all;
603 603
 	}
604 604
 	
605 605
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 		if ($filter_name == '') $filter_name = $this->filter_name;
622 622
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
623 623
 		if (empty($all)) {
624
-		        $filters = array();
625
-            		if ($filter_name != '') {
626
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
624
+				$filters = array();
625
+					if ($filter_name != '') {
626
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
627 627
 			}
628 628
 			$Spotter = new Spotter($this->db);
629 629
 			$all = $Spotter->countOverallMilitaryFlights($filters);
@@ -662,19 +662,19 @@  discard block
 block discarded – undo
662 662
 		global $globalStatsFilters;
663 663
 		if ($filter_name == '') $filter_name = $this->filter_name;
664 664
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
665
-                 try {
666
-                        $sth = $this->db->prepare($query);
667
-                        $sth->execute(array(':filter_name' => $filter_name));
668
-                } catch(PDOException $e) {
669
-                        echo "error : ".$e->getMessage();
670
-                }
671
-                $result = $sth->fetchAll(PDO::FETCH_ASSOC);
672
-                $all = $result[0]['nb_airline'];
665
+				 try {
666
+						$sth = $this->db->prepare($query);
667
+						$sth->execute(array(':filter_name' => $filter_name));
668
+				} catch(PDOException $e) {
669
+						echo "error : ".$e->getMessage();
670
+				}
671
+				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
672
+				$all = $result[0]['nb_airline'];
673 673
 		//$all = $this->getSumStats('airlines_bymonth',date('Y'));
674 674
 		if (empty($all)) {
675
-            		$filters = array();
676
-            		if ($filter_name != '') {
677
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
675
+					$filters = array();
676
+					if ($filter_name != '') {
677
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
678 678
 			}
679 679
 			$Spotter = new Spotter($this->db);
680 680
 			$all = $Spotter->countOverallAirlines($filters);
@@ -725,166 +725,166 @@  discard block
 block discarded – undo
725 725
 		if ($filter_name == '') $filter_name = $this->filter_name;
726 726
 		$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";
727 727
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
728
-                 try {
729
-                        $sth = $this->db->prepare($query);
730
-                        $sth->execute($query_values);
731
-                } catch(PDOException $e) {
732
-                        echo "error : ".$e->getMessage();
733
-                }
734
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
735
-                return $all;
728
+				 try {
729
+						$sth = $this->db->prepare($query);
730
+						$sth->execute($query_values);
731
+				} catch(PDOException $e) {
732
+						echo "error : ".$e->getMessage();
733
+				}
734
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
735
+				return $all;
736 736
 	}
737 737
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
738 738
 		if ($filter_name == '') $filter_name = $this->filter_name;
739
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
740
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
741
-                 try {
742
-                        $sth = $this->db->prepare($query);
743
-                        $sth->execute($query_values);
744
-                } catch(PDOException $e) {
745
-                        echo "error : ".$e->getMessage();
746
-                }
747
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
748
-                return $all;
749
-        }
739
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
740
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
741
+				 try {
742
+						$sth = $this->db->prepare($query);
743
+						$sth->execute($query_values);
744
+				} catch(PDOException $e) {
745
+						echo "error : ".$e->getMessage();
746
+				}
747
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
748
+				return $all;
749
+		}
750 750
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
751 751
 		if ($filter_name == '') $filter_name = $this->filter_name;
752
-    		global $globalArchiveMonths, $globalDBdriver;
753
-    		if ($globalDBdriver == 'mysql') {
754
-	                $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";
755
-	        } else {
756
-            		$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";
757
-                }
758
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
759
-                 try {
760
-                        $sth = $this->db->prepare($query);
761
-                        $sth->execute($query_values);
762
-                } catch(PDOException $e) {
763
-                        echo "error : ".$e->getMessage();
764
-                }
765
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
766
-                return $all[0]['total'];
767
-        }
752
+			global $globalArchiveMonths, $globalDBdriver;
753
+			if ($globalDBdriver == 'mysql') {
754
+					$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";
755
+			} else {
756
+					$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";
757
+				}
758
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
759
+				 try {
760
+						$sth = $this->db->prepare($query);
761
+						$sth->execute($query_values);
762
+				} catch(PDOException $e) {
763
+						echo "error : ".$e->getMessage();
764
+				}
765
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
766
+				return $all[0]['total'];
767
+		}
768 768
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
769
-    		global $globalArchiveMonths, $globalDBdriver;
769
+			global $globalArchiveMonths, $globalDBdriver;
770 770
 		if ($filter_name == '') $filter_name = $this->filter_name;
771
-    		if ($globalDBdriver == 'mysql') {
771
+			if ($globalDBdriver == 'mysql') {
772 772
 			$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";
773 773
 		} else {
774 774
 			$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";
775
-                }
776
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
777
-                 try {
778
-                        $sth = $this->db->prepare($query);
779
-                        $sth->execute($query_values);
780
-                } catch(PDOException $e) {
781
-                        echo "error : ".$e->getMessage();
782
-                }
783
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
784
-                return $all[0]['total'];
785
-        }
775
+				}
776
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
777
+				 try {
778
+						$sth = $this->db->prepare($query);
779
+						$sth->execute($query_values);
780
+				} catch(PDOException $e) {
781
+						echo "error : ".$e->getMessage();
782
+				}
783
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
784
+				return $all[0]['total'];
785
+		}
786 786
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
787
-    		global $globalArchiveMonths, $globalDBdriver;
787
+			global $globalArchiveMonths, $globalDBdriver;
788 788
 		if ($filter_name == '') $filter_name = $this->filter_name;
789
-    		if ($globalDBdriver == 'mysql') {
789
+			if ($globalDBdriver == 'mysql') {
790 790
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
791
-                } else {
791
+				} else {
792 792
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
793
-                }
794
-                 try {
795
-                        $sth = $this->db->prepare($query);
796
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
797
-                } catch(PDOException $e) {
798
-                        echo "error : ".$e->getMessage();
799
-                }
800
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
801
-                return $all[0]['total'];
802
-        }
793
+				}
794
+				 try {
795
+						$sth = $this->db->prepare($query);
796
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
797
+				} catch(PDOException $e) {
798
+						echo "error : ".$e->getMessage();
799
+				}
800
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
801
+				return $all[0]['total'];
802
+		}
803 803
 	public function getStatsAirlineTotal($filter_name = '') {
804
-    		global $globalArchiveMonths, $globalDBdriver;
804
+			global $globalArchiveMonths, $globalDBdriver;
805 805
 		if ($filter_name == '') $filter_name = $this->filter_name;
806
-    		if ($globalDBdriver == 'mysql') {
806
+			if ($globalDBdriver == 'mysql') {
807 807
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
808
-                } else {
808
+				} else {
809 809
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
810
-                }
811
-                 try {
812
-                        $sth = $this->db->prepare($query);
813
-                        $sth->execute(array(':filter_name' => $filter_name));
814
-                } catch(PDOException $e) {
815
-                        echo "error : ".$e->getMessage();
816
-                }
817
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
818
-                return $all[0]['total'];
819
-        }
810
+				}
811
+				 try {
812
+						$sth = $this->db->prepare($query);
813
+						$sth->execute(array(':filter_name' => $filter_name));
814
+				} catch(PDOException $e) {
815
+						echo "error : ".$e->getMessage();
816
+				}
817
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
818
+				return $all[0]['total'];
819
+		}
820 820
 	public function getStatsOwnerTotal($filter_name = '') {
821
-    		global $globalArchiveMonths, $globalDBdriver;
821
+			global $globalArchiveMonths, $globalDBdriver;
822 822
 		if ($filter_name == '') $filter_name = $this->filter_name;
823
-    		if ($globalDBdriver == 'mysql') {
823
+			if ($globalDBdriver == 'mysql') {
824 824
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
825 825
 		} else {
826 826
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
827
-                }
828
-                 try {
829
-                        $sth = $this->db->prepare($query);
830
-                        $sth->execute(array(':filter_name' => $filter_name));
831
-                } catch(PDOException $e) {
832
-                        echo "error : ".$e->getMessage();
833
-                }
834
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
835
-                return $all[0]['total'];
836
-        }
827
+				}
828
+				 try {
829
+						$sth = $this->db->prepare($query);
830
+						$sth->execute(array(':filter_name' => $filter_name));
831
+				} catch(PDOException $e) {
832
+						echo "error : ".$e->getMessage();
833
+				}
834
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
835
+				return $all[0]['total'];
836
+		}
837 837
 	public function getStatsPilotTotal($filter_name = '') {
838
-    		global $globalArchiveMonths, $globalDBdriver;
838
+			global $globalArchiveMonths, $globalDBdriver;
839 839
 		if ($filter_name == '') $filter_name = $this->filter_name;
840
-    		if ($globalDBdriver == 'mysql') {
841
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
842
-            	} else {
843
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
844
-            	}
845
-                 try {
846
-                        $sth = $this->db->prepare($query);
847
-                        $sth->execute(array(':filter_name' => $filter_name));
848
-                } catch(PDOException $e) {
849
-                        echo "error : ".$e->getMessage();
850
-                }
851
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
852
-                return $all[0]['total'];
853
-        }
840
+			if ($globalDBdriver == 'mysql') {
841
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
842
+				} else {
843
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
844
+				}
845
+				 try {
846
+						$sth = $this->db->prepare($query);
847
+						$sth->execute(array(':filter_name' => $filter_name));
848
+				} catch(PDOException $e) {
849
+						echo "error : ".$e->getMessage();
850
+				}
851
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
852
+				return $all[0]['total'];
853
+		}
854 854
 
855 855
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
856 856
 		global $globalDBdriver;
857 857
 		if ($filter_name == '') $filter_name = $this->filter_name;
858 858
 		if ($globalDBdriver == 'mysql') {
859 859
 			$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";
860
-                } else {
860
+				} else {
861 861
 			$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);"; 
862 862
 		}
863
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
864
-                 try {
865
-                        $sth = $this->db->prepare($query);
866
-                        $sth->execute($query_values);
867
-                } catch(PDOException $e) {
868
-                        return "error : ".$e->getMessage();
869
-                }
870
-        }
863
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
864
+				 try {
865
+						$sth = $this->db->prepare($query);
866
+						$sth->execute($query_values);
867
+				} catch(PDOException $e) {
868
+						return "error : ".$e->getMessage();
869
+				}
870
+		}
871 871
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
872 872
 		global $globalDBdriver;
873 873
 		if ($filter_name == '') $filter_name = $this->filter_name;
874 874
 		if ($globalDBdriver == 'mysql') {
875 875
 			$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";
876 876
 		} else {
877
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
877
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
878 878
 			$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);"; 
879
-                }
880
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
881
-                 try {
882
-                        $sth = $this->db->prepare($query);
883
-                        $sth->execute($query_values);
884
-                } catch(PDOException $e) {
885
-                        return "error : ".$e->getMessage();
886
-                }
887
-        }
879
+				}
880
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
881
+				 try {
882
+						$sth = $this->db->prepare($query);
883
+						$sth->execute($query_values);
884
+				} catch(PDOException $e) {
885
+						return "error : ".$e->getMessage();
886
+				}
887
+		}
888 888
 	public function getStatsSource($date,$stats_type = '') {
889 889
 		if ($stats_type == '') {
890 890
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -893,15 +893,15 @@  discard block
 block discarded – undo
893 893
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
894 894
 			$query_values = array(':date' => $date,':stats_type' => $stats_type);
895 895
 		}
896
-                 try {
897
-                        $sth = $this->db->prepare($query);
898
-                        $sth->execute($query_values);
899
-                } catch(PDOException $e) {
900
-                        echo "error : ".$e->getMessage();
901
-                }
902
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
903
-                return $all;
904
-        }
896
+				 try {
897
+						$sth = $this->db->prepare($query);
898
+						$sth->execute($query_values);
899
+				} catch(PDOException $e) {
900
+						echo "error : ".$e->getMessage();
901
+				}
902
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
903
+				return $all;
904
+		}
905 905
 
906 906
 	public function addStatSource($data,$source_name,$stats_type,$date) {
907 907
 		global $globalDBdriver;
@@ -909,25 +909,25 @@  discard block
 block discarded – undo
909 909
 			$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";
910 910
 		} else {
911 911
 			$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);"; 
912
-                }
913
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
914
-                 try {
915
-                        $sth = $this->db->prepare($query);
916
-                        $sth->execute($query_values);
917
-                } catch(PDOException $e) {
918
-                        return "error : ".$e->getMessage();
919
-                }
920
-        }
912
+				}
913
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
914
+				 try {
915
+						$sth = $this->db->prepare($query);
916
+						$sth->execute($query_values);
917
+				} catch(PDOException $e) {
918
+						return "error : ".$e->getMessage();
919
+				}
920
+		}
921 921
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
922
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
923
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
924
-                 try {
925
-                        $sth = $this->db->prepare($query);
926
-                        $sth->execute($query_values);
927
-                } catch(PDOException $e) {
928
-                        return "error : ".$e->getMessage();
929
-                }
930
-        }
922
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
923
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
924
+				 try {
925
+						$sth = $this->db->prepare($query);
926
+						$sth->execute($query_values);
927
+				} catch(PDOException $e) {
928
+						return "error : ".$e->getMessage();
929
+				}
930
+		}
931 931
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') {
932 932
 		global $globalDBdriver;
933 933
 		if ($globalDBdriver == 'mysql') {
@@ -935,14 +935,14 @@  discard block
 block discarded – undo
935 935
 		} else {
936 936
 			$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);"; 
937 937
 		}
938
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
939
-                 try {
940
-                        $sth = $this->db->prepare($query);
941
-                        $sth->execute($query_values);
942
-                } catch(PDOException $e) {
943
-                        return "error : ".$e->getMessage();
944
-                }
945
-        }
938
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
939
+				 try {
940
+						$sth = $this->db->prepare($query);
941
+						$sth->execute($query_values);
942
+				} catch(PDOException $e) {
943
+						return "error : ".$e->getMessage();
944
+				}
945
+		}
946 946
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') {
947 947
 		global $globalDBdriver;
948 948
 		if ($globalDBdriver == 'mysql') {
@@ -950,14 +950,14 @@  discard block
 block discarded – undo
950 950
 		} else {
951 951
 			$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);"; 
952 952
 		}
953
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
954
-                 try {
955
-                        $sth = $this->db->prepare($query);
956
-                        $sth->execute($query_values);
957
-                } catch(PDOException $e) {
958
-                        return "error : ".$e->getMessage();
959
-                }
960
-        }
953
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
954
+				 try {
955
+						$sth = $this->db->prepare($query);
956
+						$sth->execute($query_values);
957
+				} catch(PDOException $e) {
958
+						return "error : ".$e->getMessage();
959
+				}
960
+		}
961 961
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') {
962 962
 		global $globalDBdriver;
963 963
 		if ($globalDBdriver == 'mysql') {
@@ -965,14 +965,14 @@  discard block
 block discarded – undo
965 965
 		} else {
966 966
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
967 967
 		}
968
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
969
-                 try {
970
-                        $sth = $this->db->prepare($query);
971
-                        $sth->execute($query_values);
972
-                } catch(PDOException $e) {
973
-                        return "error : ".$e->getMessage();
974
-                }
975
-        }
968
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
969
+				 try {
970
+						$sth = $this->db->prepare($query);
971
+						$sth->execute($query_values);
972
+				} catch(PDOException $e) {
973
+						return "error : ".$e->getMessage();
974
+				}
975
+		}
976 976
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
977 977
 		global $globalDBdriver;
978 978
 		if ($globalDBdriver == 'mysql') {
@@ -980,14 +980,14 @@  discard block
 block discarded – undo
980 980
 		} else {
981 981
 			$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);"; 
982 982
 		}
983
-                $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);
984
-                 try {
985
-                        $sth = $this->db->prepare($query);
986
-                        $sth->execute($query_values);
987
-                } catch(PDOException $e) {
988
-                        return "error : ".$e->getMessage();
989
-                }
990
-        }
983
+				$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);
984
+				 try {
985
+						$sth = $this->db->prepare($query);
986
+						$sth->execute($query_values);
987
+				} catch(PDOException $e) {
988
+						return "error : ".$e->getMessage();
989
+				}
990
+		}
991 991
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') {
992 992
 		global $globalDBdriver;
993 993
 		if ($globalDBdriver == 'mysql') {
@@ -995,14 +995,14 @@  discard block
 block discarded – undo
995 995
 		} else {
996 996
 			$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);"; 
997 997
 		}
998
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
999
-                 try {
1000
-                        $sth = $this->db->prepare($query);
1001
-                        $sth->execute($query_values);
1002
-                } catch(PDOException $e) {
1003
-                        return "error : ".$e->getMessage();
1004
-                }
1005
-        }
998
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
999
+				 try {
1000
+						$sth = $this->db->prepare($query);
1001
+						$sth->execute($query_values);
1002
+				} catch(PDOException $e) {
1003
+						return "error : ".$e->getMessage();
1004
+				}
1005
+		}
1006 1006
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') {
1007 1007
 		global $globalDBdriver;
1008 1008
 		if ($globalDBdriver == 'mysql') {
@@ -1010,14 +1010,14 @@  discard block
 block discarded – undo
1010 1010
 		} else {
1011 1011
 			$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);"; 
1012 1012
 		}
1013
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1014
-                 try {
1015
-                        $sth = $this->db->prepare($query);
1016
-                        $sth->execute($query_values);
1017
-                } catch(PDOException $e) {
1018
-                        return "error : ".$e->getMessage();
1019
-                }
1020
-        }
1013
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1014
+				 try {
1015
+						$sth = $this->db->prepare($query);
1016
+						$sth->execute($query_values);
1017
+				} catch(PDOException $e) {
1018
+						return "error : ".$e->getMessage();
1019
+				}
1020
+		}
1021 1021
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') {
1022 1022
 		global $globalDBdriver;
1023 1023
 		if ($globalDBdriver == 'mysql') {
@@ -1025,14 +1025,14 @@  discard block
 block discarded – undo
1025 1025
 		} else {
1026 1026
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1027 1027
 		}
1028
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1029
-                 try {
1030
-                        $sth = $this->db->prepare($query);
1031
-                        $sth->execute($query_values);
1032
-                } catch(PDOException $e) {
1033
-                        return "error : ".$e->getMessage();
1034
-                }
1035
-        }
1028
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1029
+				 try {
1030
+						$sth = $this->db->prepare($query);
1031
+						$sth->execute($query_values);
1032
+				} catch(PDOException $e) {
1033
+						return "error : ".$e->getMessage();
1034
+				}
1035
+		}
1036 1036
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1037 1037
 		global $globalDBdriver;
1038 1038
 		if ($globalDBdriver == 'mysql') {
@@ -1040,14 +1040,14 @@  discard block
 block discarded – undo
1040 1040
 		} else {
1041 1041
 			$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);"; 
1042 1042
 		}
1043
-                $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);
1044
-                 try {
1045
-                        $sth = $this->db->prepare($query);
1046
-                        $sth->execute($query_values);
1047
-                } catch(PDOException $e) {
1048
-                        return "error : ".$e->getMessage();
1049
-                }
1050
-        }
1043
+				$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);
1044
+				 try {
1045
+						$sth = $this->db->prepare($query);
1046
+						$sth->execute($query_values);
1047
+				} catch(PDOException $e) {
1048
+						return "error : ".$e->getMessage();
1049
+				}
1050
+		}
1051 1051
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1052 1052
 		global $globalDBdriver;
1053 1053
 		if ($globalDBdriver == 'mysql') {
@@ -1055,14 +1055,14 @@  discard block
 block discarded – undo
1055 1055
 		} else {
1056 1056
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1057 1057
 		}
1058
-                $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);
1059
-                 try {
1060
-                        $sth = $this->db->prepare($query);
1061
-                        $sth->execute($query_values);
1062
-                } catch(PDOException $e) {
1063
-                        return "error : ".$e->getMessage();
1064
-                }
1065
-        }
1058
+				$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);
1059
+				 try {
1060
+						$sth = $this->db->prepare($query);
1061
+						$sth->execute($query_values);
1062
+				} catch(PDOException $e) {
1063
+						return "error : ".$e->getMessage();
1064
+				}
1065
+		}
1066 1066
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1067 1067
 		global $globalDBdriver;
1068 1068
 		if ($globalDBdriver == 'mysql') {
@@ -1070,14 +1070,14 @@  discard block
 block discarded – undo
1070 1070
 		} else {
1071 1071
 			$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);"; 
1072 1072
 		}
1073
-                $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);
1074
-                 try {
1075
-                        $sth = $this->db->prepare($query);
1076
-                        $sth->execute($query_values);
1077
-                } catch(PDOException $e) {
1078
-                        return "error : ".$e->getMessage();
1079
-                }
1080
-        }
1073
+				$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);
1074
+				 try {
1075
+						$sth = $this->db->prepare($query);
1076
+						$sth->execute($query_values);
1077
+				} catch(PDOException $e) {
1078
+						return "error : ".$e->getMessage();
1079
+				}
1080
+		}
1081 1081
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1082 1082
 		global $globalDBdriver;
1083 1083
 		if ($globalDBdriver == 'mysql') {
@@ -1085,52 +1085,52 @@  discard block
 block discarded – undo
1085 1085
 		} else {
1086 1086
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1087 1087
 		}
1088
-                $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);
1089
-                 try {
1090
-                        $sth = $this->db->prepare($query);
1091
-                        $sth->execute($query_values);
1092
-                } catch(PDOException $e) {
1093
-                        return "error : ".$e->getMessage();
1094
-                }
1095
-        }
1088
+				$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);
1089
+				 try {
1090
+						$sth = $this->db->prepare($query);
1091
+						$sth->execute($query_values);
1092
+				} catch(PDOException $e) {
1093
+						return "error : ".$e->getMessage();
1094
+				}
1095
+		}
1096 1096
 
1097 1097
 	public function deleteStat($id) {
1098
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1099
-                $query_values = array(':id' => $id);
1100
-                 try {
1101
-                        $sth = $this->db->prepare($query);
1102
-                        $sth->execute($query_values);
1103
-                } catch(PDOException $e) {
1104
-                        return "error : ".$e->getMessage();
1105
-                }
1106
-        }
1098
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1099
+				$query_values = array(':id' => $id);
1100
+				 try {
1101
+						$sth = $this->db->prepare($query);
1102
+						$sth->execute($query_values);
1103
+				} catch(PDOException $e) {
1104
+						return "error : ".$e->getMessage();
1105
+				}
1106
+		}
1107 1107
 	public function deleteStatFlight($type) {
1108
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1109
-                $query_values = array(':type' => $type);
1110
-                 try {
1111
-                        $sth = $this->db->prepare($query);
1112
-                        $sth->execute($query_values);
1113
-                } catch(PDOException $e) {
1114
-                        return "error : ".$e->getMessage();
1115
-                }
1116
-        }
1108
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1109
+				$query_values = array(':type' => $type);
1110
+				 try {
1111
+						$sth = $this->db->prepare($query);
1112
+						$sth->execute($query_values);
1113
+				} catch(PDOException $e) {
1114
+						return "error : ".$e->getMessage();
1115
+				}
1116
+		}
1117 1117
 	public function deleteStatAirport($type) {
1118
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1119
-                $query_values = array(':type' => $type);
1120
-                 try {
1121
-                        $sth = $this->db->prepare($query);
1122
-                        $sth->execute($query_values);
1123
-                } catch(PDOException $e) {
1124
-                        return "error : ".$e->getMessage();
1125
-                }
1126
-        }
1118
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1119
+				$query_values = array(':type' => $type);
1120
+				 try {
1121
+						$sth = $this->db->prepare($query);
1122
+						$sth->execute($query_values);
1123
+				} catch(PDOException $e) {
1124
+						return "error : ".$e->getMessage();
1125
+				}
1126
+		}
1127 1127
         
1128
-        public function addOldStats() {
1129
-    		global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters;
1130
-    		$Common = new Common();
1131
-    		$Connection = new Connection();
1132
-    		date_default_timezone_set('UTC');
1133
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1128
+		public function addOldStats() {
1129
+			global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters;
1130
+			$Common = new Common();
1131
+			$Connection = new Connection();
1132
+			date_default_timezone_set('UTC');
1133
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1134 1134
 		//print_r($last_update);
1135 1135
 		/*
1136 1136
 		$flightsbymonth = $this->getStats('flights_by_month');
@@ -1384,46 +1384,46 @@  discard block
 block discarded – undo
1384 1384
 			}
1385 1385
 			
1386 1386
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1387
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1388
-	        	$alldata = array();
1387
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1388
+				$alldata = array();
1389 1389
 	        	
1390
-    			foreach ($pall as $value) {
1391
-	        		$icao = $value['airport_departure_icao'];
1392
-    				$alldata[$icao] = $value;
1393
-	        	}
1394
-	        	foreach ($dall as $value) {
1395
-    				$icao = $value['airport_departure_icao'];
1396
-        			if (isset($alldata[$icao])) {
1397
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1398
-        			} else $alldata[$icao] = $value;
1399
-			}
1400
-    			$count = array();
1401
-    			foreach ($alldata as $key => $row) {
1402
-    				$count[$key] = $row['airport_departure_icao_count'];
1403
-        		}
1390
+				foreach ($pall as $value) {
1391
+					$icao = $value['airport_departure_icao'];
1392
+					$alldata[$icao] = $value;
1393
+				}
1394
+				foreach ($dall as $value) {
1395
+					$icao = $value['airport_departure_icao'];
1396
+					if (isset($alldata[$icao])) {
1397
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1398
+					} else $alldata[$icao] = $value;
1399
+			}
1400
+				$count = array();
1401
+				foreach ($alldata as $key => $row) {
1402
+					$count[$key] = $row['airport_departure_icao_count'];
1403
+				}
1404 1404
 			array_multisort($count,SORT_DESC,$alldata);
1405 1405
 			foreach ($alldata as $number) {
1406 1406
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1407 1407
 			}
1408 1408
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1409
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1410
-	        	$alldata = array();
1411
-    			foreach ($pall as $value) {
1412
-	        		$icao = $value['airport_arrival_icao'];
1413
-    				$alldata[$icao] = $value;
1414
-	        	}
1415
-	        	foreach ($dall as $value) {
1416
-    				$icao = $value['airport_arrival_icao'];
1417
-        			if (isset($alldata[$icao])) {
1418
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1419
-	        		} else $alldata[$icao] = $value;
1420
-    			}
1421
-        		$count = array();
1422
-        		foreach ($alldata as $key => $row) {
1423
-        			$count[$key] = $row['airport_arrival_icao_count'];
1424
-	        	}
1425
-    			array_multisort($count,SORT_DESC,$alldata);
1426
-                        foreach ($alldata as $number) {
1409
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1410
+				$alldata = array();
1411
+				foreach ($pall as $value) {
1412
+					$icao = $value['airport_arrival_icao'];
1413
+					$alldata[$icao] = $value;
1414
+				}
1415
+				foreach ($dall as $value) {
1416
+					$icao = $value['airport_arrival_icao'];
1417
+					if (isset($alldata[$icao])) {
1418
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1419
+					} else $alldata[$icao] = $value;
1420
+				}
1421
+				$count = array();
1422
+				foreach ($alldata as $key => $row) {
1423
+					$count[$key] = $row['airport_arrival_icao_count'];
1424
+				}
1425
+				array_multisort($count,SORT_DESC,$alldata);
1426
+						foreach ($alldata as $number) {
1427 1427
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1428 1428
 			}
1429 1429
 			if ($Connection->tableExists('countries')) {
@@ -1475,8 +1475,8 @@  discard block
 block discarded – undo
1475 1475
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1476 1476
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1477 1477
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1478
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1479
-        		/*
1478
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1479
+				/*
1480 1480
 	        	$alldata = array();
1481 1481
     			foreach ($pall as $value) {
1482 1482
 	        		$icao = $value['departure_airport_icao'];
@@ -1495,29 +1495,29 @@  discard block
 block discarded – undo
1495 1495
 	        	}
1496 1496
     			array_multisort($count,SORT_DESC,$alldata);
1497 1497
     			*/
1498
-    			foreach ($dall as $value) {
1499
-    				$icao = $value['departure_airport_icao'];
1500
-    				$ddate = $value['date'];
1501
-    				$find = false;
1502
-    				foreach ($pall as $pvalue) {
1503
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1504
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1505
-    						$find = true;
1506
-    						break;
1507
-    					}
1508
-    				}
1509
-    				if ($find === false) {
1510
-    					$pall[] = $value;
1511
-    				}
1512
-    			}
1513
-    			$alldata = $pall;
1498
+				foreach ($dall as $value) {
1499
+					$icao = $value['departure_airport_icao'];
1500
+					$ddate = $value['date'];
1501
+					$find = false;
1502
+					foreach ($pall as $pvalue) {
1503
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1504
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1505
+							$find = true;
1506
+							break;
1507
+						}
1508
+					}
1509
+					if ($find === false) {
1510
+						$pall[] = $value;
1511
+					}
1512
+				}
1513
+				$alldata = $pall;
1514 1514
 			foreach ($alldata as $number) {
1515 1515
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1516 1516
 			}
1517 1517
 			echo '...Arrival'."\n";
1518 1518
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1519
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1520
-        		/*
1519
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1520
+				/*
1521 1521
 	        	$alldata = array();
1522 1522
     			foreach ($pall as $value) {
1523 1523
 	        		$icao = $value['arrival_airport_icao'];
@@ -1537,22 +1537,22 @@  discard block
 block discarded – undo
1537 1537
     			*/
1538 1538
 
1539 1539
 
1540
-    			foreach ($dall as $value) {
1541
-    				$icao = $value['arrival_airport_icao'];
1542
-    				$ddate = $value['date'];
1543
-    				$find = false;
1544
-    				foreach ($pall as $pvalue) {
1545
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1546
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1547
-    						$find = true;
1548
-    						break;
1549
-    					}
1550
-    				}
1551
-    				if ($find === false) {
1552
-    					$pall[] = $value;
1553
-    				}
1554
-    			}
1555
-    			$alldata = $pall;
1540
+				foreach ($dall as $value) {
1541
+					$icao = $value['arrival_airport_icao'];
1542
+					$ddate = $value['date'];
1543
+					$find = false;
1544
+					foreach ($pall as $pvalue) {
1545
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1546
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1547
+							$find = true;
1548
+							break;
1549
+						}
1550
+					}
1551
+					if ($find === false) {
1552
+						$pall[] = $value;
1553
+					}
1554
+				}
1555
+				$alldata = $pall;
1556 1556
 			foreach ($alldata as $number) {
1557 1557
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1558 1558
 			}
@@ -1612,47 +1612,47 @@  discard block
 block discarded – undo
1612 1612
 			}
1613 1613
 			
1614 1614
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1615
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1616
-	        	//$alldata = array();
1617
-    			foreach ($dall as $value) {
1618
-    				$icao = $value['airport_departure_icao'];
1619
-    				$dicao = $value['airline_icap'];
1620
-    				$find = false;
1621
-    				foreach ($pall as $pvalue) {
1622
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1623
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1624
-    						$find = true;
1625
-    						break;
1626
-    					}
1627
-    				}
1628
-    				if ($find === false) {
1629
-    					$pall[] = $value;
1630
-    				}
1631
-    			}
1632
-    			$alldata = $pall;
1615
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1616
+				//$alldata = array();
1617
+				foreach ($dall as $value) {
1618
+					$icao = $value['airport_departure_icao'];
1619
+					$dicao = $value['airline_icap'];
1620
+					$find = false;
1621
+					foreach ($pall as $pvalue) {
1622
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1623
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1624
+							$find = true;
1625
+							break;
1626
+						}
1627
+					}
1628
+					if ($find === false) {
1629
+						$pall[] = $value;
1630
+					}
1631
+				}
1632
+				$alldata = $pall;
1633 1633
 			foreach ($alldata as $number) {
1634 1634
 				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']);
1635 1635
 			}
1636 1636
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1637
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1638
-	        	//$alldata = array();
1639
-    			foreach ($dall as $value) {
1640
-    				$icao = $value['airport_arrival_icao'];
1641
-    				$dicao = $value['airline_icao'];
1642
-    				$find = false;
1643
-    				foreach ($pall as $pvalue) {
1644
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1645
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1646
-    						$find = true;
1647
-    						break;
1648
-    					}
1649
-    				}
1650
-    				if ($find === false) {
1651
-    					$pall[] = $value;
1652
-    				}
1653
-    			}
1654
-    			$alldata = $pall;
1655
-                        foreach ($alldata as $number) {
1637
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1638
+				//$alldata = array();
1639
+				foreach ($dall as $value) {
1640
+					$icao = $value['airport_arrival_icao'];
1641
+					$dicao = $value['airline_icao'];
1642
+					$find = false;
1643
+					foreach ($pall as $pvalue) {
1644
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1645
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1646
+							$find = true;
1647
+							break;
1648
+						}
1649
+					}
1650
+					if ($find === false) {
1651
+						$pall[] = $value;
1652
+					}
1653
+				}
1654
+				$alldata = $pall;
1655
+						foreach ($alldata as $number) {
1656 1656
 				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']);
1657 1657
 			}
1658 1658
 			$Spotter = new Spotter($this->db);
@@ -1680,47 +1680,47 @@  discard block
 block discarded – undo
1680 1680
 			}
1681 1681
 			echo '...Departure'."\n";
1682 1682
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1683
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1684
-    			foreach ($dall as $value) {
1685
-    				$icao = $value['departure_airport_icao'];
1686
-    				$airline = $value['airline_icao'];
1687
-    				$ddate = $value['date'];
1688
-    				$find = false;
1689
-    				foreach ($pall as $pvalue) {
1690
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1691
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1692
-    						$find = true;
1693
-    						break;
1694
-    					}
1695
-    				}
1696
-    				if ($find === false) {
1697
-    					$pall[] = $value;
1698
-    				}
1699
-    			}
1700
-    			$alldata = $pall;
1683
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1684
+				foreach ($dall as $value) {
1685
+					$icao = $value['departure_airport_icao'];
1686
+					$airline = $value['airline_icao'];
1687
+					$ddate = $value['date'];
1688
+					$find = false;
1689
+					foreach ($pall as $pvalue) {
1690
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1691
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1692
+							$find = true;
1693
+							break;
1694
+						}
1695
+					}
1696
+					if ($find === false) {
1697
+						$pall[] = $value;
1698
+					}
1699
+				}
1700
+				$alldata = $pall;
1701 1701
 			foreach ($alldata as $number) {
1702 1702
 				$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']);
1703 1703
 			}
1704 1704
 			echo '...Arrival'."\n";
1705 1705
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1706
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1707
-    			foreach ($dall as $value) {
1708
-    				$icao = $value['arrival_airport_icao'];
1709
-    				$airline = $value['airline_icao'];
1710
-    				$ddate = $value['date'];
1711
-    				$find = false;
1712
-    				foreach ($pall as $pvalue) {
1713
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1714
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1715
-    						$find = true;
1716
-    						break;
1717
-    					}
1718
-    				}
1719
-    				if ($find === false) {
1720
-    					$pall[] = $value;
1721
-    				}
1722
-    			}
1723
-    			$alldata = $pall;
1706
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1707
+				foreach ($dall as $value) {
1708
+					$icao = $value['arrival_airport_icao'];
1709
+					$airline = $value['airline_icao'];
1710
+					$ddate = $value['date'];
1711
+					$find = false;
1712
+					foreach ($pall as $pvalue) {
1713
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1714
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1715
+							$find = true;
1716
+							break;
1717
+						}
1718
+					}
1719
+					if ($find === false) {
1720
+						$pall[] = $value;
1721
+					}
1722
+				}
1723
+				$alldata = $pall;
1724 1724
 			foreach ($alldata as $number) {
1725 1725
 				$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']);
1726 1726
 			}
@@ -1780,45 +1780,45 @@  discard block
 block discarded – undo
1780 1780
 				}
1781 1781
     			
1782 1782
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1783
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1784
-		        	//$alldata = array();
1785
-	    			foreach ($dall as $value) {
1786
-	    				$icao = $value['airport_departure_icao'];
1787
-	    				$dicao = $value['airline_icap'];
1788
-	    				$find = false;
1789
-        				foreach ($pall as $pvalue) {
1790
-        					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1791
-        						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1792
-        						$find = true;
1793
-        						break;
1794
-        					}
1795
-        				}
1796
-        				if ($find === false) {
1797
-        					$pall[] = $value;
1798
-        				}
1799
-        			}
1800
-        			$alldata = $pall;
1783
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1784
+					//$alldata = array();
1785
+					foreach ($dall as $value) {
1786
+						$icao = $value['airport_departure_icao'];
1787
+						$dicao = $value['airline_icap'];
1788
+						$find = false;
1789
+						foreach ($pall as $pvalue) {
1790
+							if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1791
+								$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1792
+								$find = true;
1793
+								break;
1794
+							}
1795
+						}
1796
+						if ($find === false) {
1797
+							$pall[] = $value;
1798
+						}
1799
+					}
1800
+					$alldata = $pall;
1801 1801
 				foreach ($alldata as $number) {
1802
-    					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);
1802
+						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);
1803 1803
 				}
1804 1804
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);
1805
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1806
-	    			//$alldata = array();
1805
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1806
+					//$alldata = array();
1807 1807
 				foreach ($dall as $value) {
1808
-    					$icao = $value['airport_arrival_icao'];
1809
-	    				$dicao = $value['airline_icao'];
1810
-	    				$find = false;
1811
-    					foreach ($pall as $pvalue) {
1812
-    						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1808
+						$icao = $value['airport_arrival_icao'];
1809
+						$dicao = $value['airline_icao'];
1810
+						$find = false;
1811
+						foreach ($pall as $pvalue) {
1812
+							if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1813 1813
 							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1814 1814
 							$find = true;
1815 1815
 							break;
1816
-        					}
1816
+							}
1817 1817
 					}
1818 1818
 					if ($find === false) {
1819 1819
 						$pall[] = $value;
1820 1820
 					}
1821
-        			}
1821
+					}
1822 1822
 				$alldata = $pall;
1823 1823
 				foreach ($alldata as $number) {
1824 1824
 					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);
@@ -1848,47 +1848,47 @@  discard block
 block discarded – undo
1848 1848
 				}
1849 1849
 				echo '...Departure'."\n";
1850 1850
 				$pall = $Spotter->getLast7DaysAirportsDeparture($filter);
1851
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture($filter);
1852
-	    			foreach ($dall as $value) {
1853
-    					$icao = $value['departure_airport_icao'];
1854
-    					$airline = $value['airline_icao'];
1855
-	    				$ddate = $value['date'];
1856
-    					$find = false;
1857
-    					foreach ($pall as $pvalue) {
1858
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1859
-	    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1860
-    							$find = true;
1861
-    							break;
1862
-    						}
1863
-    					}
1851
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture($filter);
1852
+					foreach ($dall as $value) {
1853
+						$icao = $value['departure_airport_icao'];
1854
+						$airline = $value['airline_icao'];
1855
+						$ddate = $value['date'];
1856
+						$find = false;
1857
+						foreach ($pall as $pvalue) {
1858
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1859
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1860
+								$find = true;
1861
+								break;
1862
+							}
1863
+						}
1864 1864
 					if ($find === false) {
1865
-	    					$pall[] = $value;
1866
-    					}
1867
-    				}
1868
-	    			$alldata = $pall;
1865
+							$pall[] = $value;
1866
+						}
1867
+					}
1868
+					$alldata = $pall;
1869 1869
 				foreach ($alldata as $number) {
1870 1870
 					$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);
1871 1871
 				}
1872 1872
 				echo '...Arrival'."\n";
1873 1873
 				$pall = $Spotter->getLast7DaysAirportsArrival($filter);
1874
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival($filter);
1874
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival($filter);
1875 1875
 				foreach ($dall as $value) {
1876 1876
 					$icao = $value['arrival_airport_icao'];
1877 1877
 					$airline = $value['airline_icao'];
1878 1878
 					$ddate = $value['date'];
1879
-    					$find = false;
1879
+						$find = false;
1880 1880
 					foreach ($pall as $pvalue) {
1881
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1882
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1883
-    							$find = true;
1884
-    							break;
1885
-	    					}
1886
-    					}
1887
-    					if ($find === false) {
1888
-    						$pall[] = $value;
1889
-	    				}
1890
-    				}
1891
-    				$alldata = $pall;
1881
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1882
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1883
+								$find = true;
1884
+								break;
1885
+							}
1886
+						}
1887
+						if ($find === false) {
1888
+							$pall[] = $value;
1889
+						}
1890
+					}
1891
+					$alldata = $pall;
1892 1892
 				foreach ($alldata as $number) {
1893 1893
 					$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);
1894 1894
 				}
Please login to merge, or discard this patch.
Braces   +236 added lines, -84 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
         }
@@ -41,7 +43,9 @@  discard block
 block discarded – undo
41 43
                 return $all;
42 44
         }
43 45
 	public function getAllAirlineNames($filter_name = '') {
44
-		if ($filter_name == '') $filter_name = $this->filter_name;
46
+		if ($filter_name == '') {
47
+			$filter_name = $this->filter_name;
48
+		}
45 49
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
46 50
                  try {
47 51
                         $sth = $this->db->prepare($query);
@@ -53,7 +57,9 @@  discard block
 block discarded – undo
53 57
                 return $all;
54 58
         }
55 59
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
56
-		if ($filter_name == '') $filter_name = $this->filter_name;
60
+		if ($filter_name == '') {
61
+			$filter_name = $this->filter_name;
62
+		}
57 63
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
58 64
                  try {
59 65
                         $sth = $this->db->prepare($query);
@@ -65,7 +71,9 @@  discard block
 block discarded – undo
65 71
                 return $all;
66 72
         }
67 73
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
68
-		if ($filter_name == '') $filter_name = $this->filter_name;
74
+		if ($filter_name == '') {
75
+			$filter_name = $this->filter_name;
76
+		}
69 77
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
70 78
                  try {
71 79
                         $sth = $this->db->prepare($query);
@@ -80,9 +88,14 @@  discard block
 block discarded – undo
80 88
 
81 89
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
82 90
 		global $globalStatsFilters;
83
-		if ($filter_name == '') $filter_name = $this->filter_name;
84
-		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
85
-		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
91
+		if ($filter_name == '') {
92
+			$filter_name = $this->filter_name;
93
+		}
94
+		if ($limit) {
95
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
96
+		} else {
97
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
98
+		}
86 99
                  try {
87 100
                         $sth = $this->db->prepare($query);
88 101
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -102,9 +115,14 @@  discard block
 block discarded – undo
102 115
 	}
103 116
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
104 117
 		global $globalStatsFilters;
105
-		if ($filter_name == '') $filter_name = $this->filter_name;
106
-		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";
107
-		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";
118
+		if ($filter_name == '') {
119
+			$filter_name = $this->filter_name;
120
+		}
121
+		if ($limit) {
122
+			$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";
123
+		} else {
124
+			$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";
125
+		}
108 126
                  try {
109 127
                         $sth = $this->db->prepare($query);
110 128
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -124,9 +142,14 @@  discard block
 block discarded – undo
124 142
 	}
125 143
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
126 144
 		global $globalStatsFilters;
127
-		if ($filter_name == '') $filter_name = $this->filter_name;
128
-		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";
129
-		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";
145
+		if ($filter_name == '') {
146
+			$filter_name = $this->filter_name;
147
+		}
148
+		if ($limit) {
149
+			$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";
150
+		} else {
151
+			$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";
152
+		}
130 153
                  try {
131 154
                         $sth = $this->db->prepare($query);
132 155
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -147,9 +170,14 @@  discard block
 block discarded – undo
147 170
 
148 171
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
149 172
 		global $globalStatsFilters;
150
-		if ($filter_name == '') $filter_name = $this->filter_name;
151
-		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";
152
-		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";
173
+		if ($filter_name == '') {
174
+			$filter_name = $this->filter_name;
175
+		}
176
+		if ($limit) {
177
+			$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";
178
+		} else {
179
+			$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";
180
+		}
153 181
                  try {
154 182
                         $sth = $this->db->prepare($query);
155 183
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -169,9 +197,14 @@  discard block
 block discarded – undo
169 197
 	}
170 198
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
171 199
 		global $globalStatsFilters;
172
-		if ($filter_name == '') $filter_name = $this->filter_name;
173
-		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";
174
-		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";
200
+		if ($filter_name == '') {
201
+			$filter_name = $this->filter_name;
202
+		}
203
+		if ($limit) {
204
+			$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";
205
+		} else {
206
+			$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";
207
+		}
175 208
                  try {
176 209
                         $sth = $this->db->prepare($query);
177 210
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -192,9 +225,14 @@  discard block
 block discarded – undo
192 225
 
193 226
 	public function countAllAirlines($limit = true,$filter_name = '') {
194 227
 		global $globalStatsFilters;
195
-		if ($filter_name == '') $filter_name = $this->filter_name;
196
-		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
197
-		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 ORDER BY airline_count DESC";
228
+		if ($filter_name == '') {
229
+			$filter_name = $this->filter_name;
230
+		}
231
+		if ($limit) {
232
+			$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
233
+		} else {
234
+			$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
235
+		}
198 236
                  try {
199 237
                         $sth = $this->db->prepare($query);
200 238
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -215,9 +253,14 @@  discard block
 block discarded – undo
215 253
 	}
216 254
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
217 255
 		global $globalStatsFilters;
218
-		if ($filter_name == '') $filter_name = $this->filter_name;
219
-		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";
220
-		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";
256
+		if ($filter_name == '') {
257
+			$filter_name = $this->filter_name;
258
+		}
259
+		if ($limit) {
260
+			$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";
261
+		} else {
262
+			$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";
263
+		}
221 264
                  try {
222 265
                         $sth = $this->db->prepare($query);
223 266
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -237,9 +280,14 @@  discard block
 block discarded – undo
237 280
 	}
238 281
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
239 282
 		global $globalStatsFilters;
240
-		if ($filter_name == '') $filter_name = $this->filter_name;
241
-		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";
242
-		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";
283
+		if ($filter_name == '') {
284
+			$filter_name = $this->filter_name;
285
+		}
286
+		if ($limit) {
287
+			$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";
288
+		} else {
289
+			$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";
290
+		}
243 291
 		 try {
244 292
 			$sth = $this->db->prepare($query);
245 293
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -259,10 +307,15 @@  discard block
 block discarded – undo
259 307
 	}
260 308
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
261 309
 		$Connection = new Connection();
262
-		if ($filter_name == '') $filter_name = $this->filter_name;
310
+		if ($filter_name == '') {
311
+			$filter_name = $this->filter_name;
312
+		}
263 313
 		if ($Connection->tableExists('countries')) {
264
-			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";
265
-			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";
314
+			if ($limit) {
315
+				$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";
316
+			} else {
317
+				$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";
318
+			}
266 319
 			 try {
267 320
 				$sth = $this->db->prepare($query);
268 321
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -283,9 +336,14 @@  discard block
 block discarded – undo
283 336
 	}
284 337
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
285 338
 		global $globalStatsFilters;
286
-		if ($filter_name == '') $filter_name = $this->filter_name;
287
-		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
288
-		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
339
+		if ($filter_name == '') {
340
+			$filter_name = $this->filter_name;
341
+		}
342
+		if ($limit) {
343
+			$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
344
+		} else {
345
+			$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
346
+		}
289 347
                  try {
290 348
                         $sth = $this->db->prepare($query);
291 349
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -305,9 +363,14 @@  discard block
 block discarded – undo
305 363
 	}
306 364
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
307 365
 		global $globalStatsFilters;
308
-		if ($filter_name == '') $filter_name = $this->filter_name;
309
-		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";
310
-		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";
366
+		if ($filter_name == '') {
367
+			$filter_name = $this->filter_name;
368
+		}
369
+		if ($limit) {
370
+			$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";
371
+		} else {
372
+			$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";
373
+		}
311 374
                  try {
312 375
                         $sth = $this->db->prepare($query);
313 376
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -327,9 +390,14 @@  discard block
 block discarded – undo
327 390
 	}
328 391
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
329 392
 		global $globalStatsFilters;
330
-		if ($filter_name == '') $filter_name = $this->filter_name;
331
-		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
332
-		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
393
+		if ($filter_name == '') {
394
+			$filter_name = $this->filter_name;
395
+		}
396
+		if ($limit) {
397
+			$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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
398
+		} else {
399
+			$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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
400
+		}
333 401
                  try {
334 402
                         $sth = $this->db->prepare($query);
335 403
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -355,7 +423,9 @@  discard block
 block discarded – undo
355 423
         			$icao = $value['airport_departure_icao'];
356 424
         			if (isset($all[$icao])) {
357 425
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
358
-        			} else $all[$icao] = $value;
426
+        			} else {
427
+        				$all[$icao] = $value;
428
+        			}
359 429
         		}
360 430
         		$count = array();
361 431
         		foreach ($all as $key => $row) {
@@ -367,9 +437,14 @@  discard block
 block discarded – undo
367 437
 	}
368 438
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
369 439
 		global $globalStatsFilters;
370
-		if ($filter_name == '') $filter_name = $this->filter_name;
371
-		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
372
-		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
440
+		if ($filter_name == '') {
441
+			$filter_name = $this->filter_name;
442
+		}
443
+		if ($limit) {
444
+			$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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
445
+		} else {
446
+			$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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
447
+		}
373 448
 		try {
374 449
 			$sth = $this->db->prepare($query);
375 450
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -395,7 +470,9 @@  discard block
 block discarded – undo
395 470
         			$icao = $value['airport_arrival_icao'];
396 471
         			if (isset($all[$icao])) {
397 472
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
398
-        			} else $all[$icao] = $value;
473
+        			} else {
474
+        				$all[$icao] = $value;
475
+        			}
399 476
         		}
400 477
         		$count = array();
401 478
         		foreach ($all as $key => $row) {
@@ -408,13 +485,21 @@  discard block
 block discarded – undo
408 485
 	}
409 486
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
410 487
 		global $globalDBdriver, $globalStatsFilters;
411
-		if ($filter_name == '') $filter_name = $this->filter_name;
488
+		if ($filter_name == '') {
489
+			$filter_name = $this->filter_name;
490
+		}
412 491
 		if ($globalDBdriver == 'mysql') {
413
-			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";
414
-			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";
492
+			if ($limit) {
493
+				$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";
494
+			} else {
495
+				$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";
496
+			}
415 497
 		} else {
416
-			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";
417
-			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";
498
+			if ($limit) {
499
+				$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";
500
+			} else {
501
+				$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";
502
+			}
418 503
 		}
419 504
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
420 505
                  try {
@@ -438,7 +523,9 @@  discard block
 block discarded – undo
438 523
 	
439 524
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
440 525
 		global $globalStatsFilters;
441
-		if ($filter_name == '') $filter_name = $this->filter_name;
526
+		if ($filter_name == '') {
527
+			$filter_name = $this->filter_name;
528
+		}
442 529
 		$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";
443 530
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
444 531
                  try {
@@ -460,7 +547,9 @@  discard block
 block discarded – undo
460 547
 	}
461 548
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
462 549
 		global $globalDBdriver, $globalStatsFilters;
463
-		if ($filter_name == '') $filter_name = $this->filter_name;
550
+		if ($filter_name == '') {
551
+			$filter_name = $this->filter_name;
552
+		}
464 553
 		if ($globalDBdriver == 'mysql') {
465 554
 			$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";
466 555
 		} else {
@@ -486,7 +575,9 @@  discard block
 block discarded – undo
486 575
 	}
487 576
 	public function countAllDates($stats_airline = '',$filter_name = '') {
488 577
 		global $globalStatsFilters;
489
-		if ($filter_name == '') $filter_name = $this->filter_name;
578
+		if ($filter_name == '') {
579
+			$filter_name = $this->filter_name;
580
+		}
490 581
 		$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";
491 582
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492 583
                  try {
@@ -508,7 +599,9 @@  discard block
 block discarded – undo
508 599
 	}
509 600
 	public function countAllDatesByAirlines($filter_name = '') {
510 601
 		global $globalStatsFilters;
511
-		if ($filter_name == '') $filter_name = $this->filter_name;
602
+		if ($filter_name == '') {
603
+			$filter_name = $this->filter_name;
604
+		}
512 605
 		$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";
513 606
 		$query_data = array('filter_name' => $filter_name);
514 607
                  try {
@@ -530,7 +623,9 @@  discard block
 block discarded – undo
530 623
 	}
531 624
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
532 625
 		global $globalStatsFilters;
533
-		if ($filter_name == '') $filter_name = $this->filter_name;
626
+		if ($filter_name == '') {
627
+			$filter_name = $this->filter_name;
628
+		}
534 629
 	    	$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";
535 630
                  try {
536 631
                         $sth = $this->db->prepare($query);
@@ -551,7 +646,9 @@  discard block
 block discarded – undo
551 646
 	}
552 647
 	public function countAllMilitaryMonths($filter_name = '') {
553 648
 		global $globalStatsFilters;
554
-		if ($filter_name == '') $filter_name = $this->filter_name;
649
+		if ($filter_name == '') {
650
+			$filter_name = $this->filter_name;
651
+		}
555 652
 	    	$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";
556 653
                  try {
557 654
                         $sth = $this->db->prepare($query);
@@ -572,9 +669,14 @@  discard block
 block discarded – undo
572 669
 	}
573 670
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
574 671
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
575
-		if ($filter_name == '') $filter_name = $this->filter_name;
576
-		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";
577
-		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";
672
+		if ($filter_name == '') {
673
+			$filter_name = $this->filter_name;
674
+		}
675
+		if ($limit) {
676
+			$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";
677
+		} else {
678
+			$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";
679
+		}
578 680
 		if ($orderby == 'hour') {
579 681
 			/*
580 682
 			if ($globalDBdriver == 'mysql') {
@@ -583,7 +685,9 @@  discard block
 block discarded – undo
583 685
 			*/
584 686
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
585 687
 		}
586
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
688
+		if ($orderby == 'count') {
689
+			$query .= " ORDER BY hour_count DESC";
690
+		}
587 691
                  try {
588 692
                         $sth = $this->db->prepare($query);
589 693
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -604,7 +708,9 @@  discard block
 block discarded – undo
604 708
 	
605 709
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
606 710
 		global $globalStatsFilters;
607
-		if ($filter_name == '') $filter_name = $this->filter_name;
711
+		if ($filter_name == '') {
712
+			$filter_name = $this->filter_name;
713
+		}
608 714
 		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
609 715
 		if (empty($all)) {
610 716
 			$filters = array('airlines' => array($stats_airline));
@@ -618,7 +724,9 @@  discard block
 block discarded – undo
618 724
 	}
619 725
 	public function countOverallMilitaryFlights($filter_name = '') {
620 726
 		global $globalStatsFilters;
621
-		if ($filter_name == '') $filter_name = $this->filter_name;
727
+		if ($filter_name == '') {
728
+			$filter_name = $this->filter_name;
729
+		}
622 730
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
623 731
 		if (empty($all)) {
624 732
 		        $filters = array();
@@ -632,7 +740,9 @@  discard block
 block discarded – undo
632 740
 	}
633 741
 	public function countOverallArrival($stats_airline = '',$filter_name = '') {
634 742
 		global $globalStatsFilters;
635
-		if ($filter_name == '') $filter_name = $this->filter_name;
743
+		if ($filter_name == '') {
744
+			$filter_name = $this->filter_name;
745
+		}
636 746
 		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
637 747
 		if (empty($all)) {
638 748
 			$filters = array('airlines' => array($stats_airline));
@@ -646,7 +756,9 @@  discard block
 block discarded – undo
646 756
 	}
647 757
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
648 758
 		global $globalStatsFilters;
649
-		if ($filter_name == '') $filter_name = $this->filter_name;
759
+		if ($filter_name == '') {
760
+			$filter_name = $this->filter_name;
761
+		}
650 762
 		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
651 763
 		if (empty($all)) {
652 764
 			$filters = array('airlines' => array($stats_airline));
@@ -660,7 +772,9 @@  discard block
 block discarded – undo
660 772
 	}
661 773
 	public function countOverallAirlines($filter_name = '') {
662 774
 		global $globalStatsFilters;
663
-		if ($filter_name == '') $filter_name = $this->filter_name;
775
+		if ($filter_name == '') {
776
+			$filter_name = $this->filter_name;
777
+		}
664 778
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
665 779
                  try {
666 780
                         $sth = $this->db->prepare($query);
@@ -683,7 +797,9 @@  discard block
 block discarded – undo
683 797
 	}
684 798
 	public function countOverallOwners($stats_airline = '',$filter_name = '') {
685 799
 		global $globalStatsFilters;
686
-		if ($filter_name == '') $filter_name = $this->filter_name;
800
+		if ($filter_name == '') {
801
+			$filter_name = $this->filter_name;
802
+		}
687 803
 		/*
688 804
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
689 805
                  try {
@@ -708,7 +824,9 @@  discard block
 block discarded – undo
708 824
 	}
709 825
 	public function countOverallPilots($stats_airline = '',$filter_name = '') {
710 826
 		global $globalStatsFilters;
711
-		if ($filter_name == '') $filter_name = $this->filter_name;
827
+		if ($filter_name == '') {
828
+			$filter_name = $this->filter_name;
829
+		}
712 830
 		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
713 831
 		if (empty($all)) {
714 832
 			$filters = array('airlines' => array($stats_airline));
@@ -722,7 +840,9 @@  discard block
 block discarded – undo
722 840
 	}
723 841
 
724 842
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
725
-		if ($filter_name == '') $filter_name = $this->filter_name;
843
+		if ($filter_name == '') {
844
+			$filter_name = $this->filter_name;
845
+		}
726 846
 		$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";
727 847
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
728 848
                  try {
@@ -735,7 +855,9 @@  discard block
 block discarded – undo
735 855
                 return $all;
736 856
 	}
737 857
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
738
-		if ($filter_name == '') $filter_name = $this->filter_name;
858
+		if ($filter_name == '') {
859
+			$filter_name = $this->filter_name;
860
+		}
739 861
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
740 862
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
741 863
                  try {
@@ -748,7 +870,9 @@  discard block
 block discarded – undo
748 870
                 return $all;
749 871
         }
750 872
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
751
-		if ($filter_name == '') $filter_name = $this->filter_name;
873
+		if ($filter_name == '') {
874
+			$filter_name = $this->filter_name;
875
+		}
752 876
     		global $globalArchiveMonths, $globalDBdriver;
753 877
     		if ($globalDBdriver == 'mysql') {
754 878
 	                $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";
@@ -767,7 +891,9 @@  discard block
 block discarded – undo
767 891
         }
768 892
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
769 893
     		global $globalArchiveMonths, $globalDBdriver;
770
-		if ($filter_name == '') $filter_name = $this->filter_name;
894
+		if ($filter_name == '') {
895
+			$filter_name = $this->filter_name;
896
+		}
771 897
     		if ($globalDBdriver == 'mysql') {
772 898
 			$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";
773 899
 		} else {
@@ -785,7 +911,9 @@  discard block
 block discarded – undo
785 911
         }
786 912
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
787 913
     		global $globalArchiveMonths, $globalDBdriver;
788
-		if ($filter_name == '') $filter_name = $this->filter_name;
914
+		if ($filter_name == '') {
915
+			$filter_name = $this->filter_name;
916
+		}
789 917
     		if ($globalDBdriver == 'mysql') {
790 918
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
791 919
                 } else {
@@ -802,7 +930,9 @@  discard block
 block discarded – undo
802 930
         }
803 931
 	public function getStatsAirlineTotal($filter_name = '') {
804 932
     		global $globalArchiveMonths, $globalDBdriver;
805
-		if ($filter_name == '') $filter_name = $this->filter_name;
933
+		if ($filter_name == '') {
934
+			$filter_name = $this->filter_name;
935
+		}
806 936
     		if ($globalDBdriver == 'mysql') {
807 937
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
808 938
                 } else {
@@ -819,7 +949,9 @@  discard block
 block discarded – undo
819 949
         }
820 950
 	public function getStatsOwnerTotal($filter_name = '') {
821 951
     		global $globalArchiveMonths, $globalDBdriver;
822
-		if ($filter_name == '') $filter_name = $this->filter_name;
952
+		if ($filter_name == '') {
953
+			$filter_name = $this->filter_name;
954
+		}
823 955
     		if ($globalDBdriver == 'mysql') {
824 956
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
825 957
 		} else {
@@ -836,7 +968,9 @@  discard block
 block discarded – undo
836 968
         }
837 969
 	public function getStatsPilotTotal($filter_name = '') {
838 970
     		global $globalArchiveMonths, $globalDBdriver;
839
-		if ($filter_name == '') $filter_name = $this->filter_name;
971
+		if ($filter_name == '') {
972
+			$filter_name = $this->filter_name;
973
+		}
840 974
     		if ($globalDBdriver == 'mysql') {
841 975
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
842 976
             	} else {
@@ -854,7 +988,9 @@  discard block
 block discarded – undo
854 988
 
855 989
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
856 990
 		global $globalDBdriver;
857
-		if ($filter_name == '') $filter_name = $this->filter_name;
991
+		if ($filter_name == '') {
992
+			$filter_name = $this->filter_name;
993
+		}
858 994
 		if ($globalDBdriver == 'mysql') {
859 995
 			$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";
860 996
                 } else {
@@ -870,7 +1006,9 @@  discard block
 block discarded – undo
870 1006
         }
871 1007
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
872 1008
 		global $globalDBdriver;
873
-		if ($filter_name == '') $filter_name = $this->filter_name;
1009
+		if ($filter_name == '') {
1010
+			$filter_name = $this->filter_name;
1011
+		}
874 1012
 		if ($globalDBdriver == 'mysql') {
875 1013
 			$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";
876 1014
 		} else {
@@ -1356,7 +1494,9 @@  discard block
 block discarded – undo
1356 1494
 			echo 'Update stats !'."\n";
1357 1495
 			if (isset($last_update[0]['value'])) {
1358 1496
 				$last_update_day = $last_update[0]['value'];
1359
-			} else $last_update_day = '2012-12-12 12:12:12';
1497
+			} else {
1498
+				$last_update_day = '2012-12-12 12:12:12';
1499
+			}
1360 1500
 			$Spotter = new Spotter($this->db);
1361 1501
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1362 1502
 			foreach ($alldata as $number) {
@@ -1395,7 +1535,9 @@  discard block
 block discarded – undo
1395 1535
     				$icao = $value['airport_departure_icao'];
1396 1536
         			if (isset($alldata[$icao])) {
1397 1537
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1398
-        			} else $alldata[$icao] = $value;
1538
+        			} else {
1539
+        				$alldata[$icao] = $value;
1540
+        			}
1399 1541
 			}
1400 1542
     			$count = array();
1401 1543
     			foreach ($alldata as $key => $row) {
@@ -1416,7 +1558,9 @@  discard block
 block discarded – undo
1416 1558
     				$icao = $value['airport_arrival_icao'];
1417 1559
         			if (isset($alldata[$icao])) {
1418 1560
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1419
-	        		} else $alldata[$icao] = $value;
1561
+	        		} else {
1562
+	        			$alldata[$icao] = $value;
1563
+	        		}
1420 1564
     			}
1421 1565
         		$count = array();
1422 1566
         		foreach ($alldata as $key => $row) {
@@ -1442,7 +1586,9 @@  discard block
 block discarded – undo
1442 1586
 			$alldata = $Spotter->countAllMonths();
1443 1587
 			$lastyear = false;
1444 1588
 			foreach ($alldata as $number) {
1445
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1589
+				if ($number['year_name'] != date('Y')) {
1590
+					$lastyear = true;
1591
+				}
1446 1592
 				$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'])));
1447 1593
 			}
1448 1594
 			$alldata = $Spotter->countAllMilitaryMonths();
@@ -1659,7 +1805,9 @@  discard block
 block discarded – undo
1659 1805
 			$alldata = $Spotter->countAllMonthsByAirlines();
1660 1806
 			$lastyear = false;
1661 1807
 			foreach ($alldata as $number) {
1662
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1808
+				if ($number['year_name'] != date('Y')) {
1809
+					$lastyear = true;
1810
+				}
1663 1811
 				$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']);
1664 1812
 			}
1665 1813
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
@@ -1751,7 +1899,9 @@  discard block
 block discarded – undo
1751 1899
 			}
1752 1900
 			
1753 1901
 
1754
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
1902
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
1903
+				$globalStatsFilters = array();
1904
+			}
1755 1905
 			foreach ($globalStatsFilters as $name => $filter) {
1756 1906
 				//$filter_name = $filter['name'];
1757 1907
 				$filter_name = $name;
@@ -1827,7 +1977,9 @@  discard block
 block discarded – undo
1827 1977
 				$alldata = $Spotter->countAllMonths($filter);
1828 1978
 				$lastyear = false;
1829 1979
 				foreach ($alldata as $number) {
1830
-					if ($number['year_name'] != date('Y')) $lastyear = true;
1980
+					if ($number['year_name'] != date('Y')) {
1981
+						$lastyear = true;
1982
+					}
1831 1983
 					$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);
1832 1984
 				}
1833 1985
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
Spacing   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -46,31 +46,31 @@  discard block
 block discarded – undo
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
48 48
                         $sth->execute(array(':filter_name' => $filter_name));
49
-                } catch(PDOException $e) {
49
+                } catch (PDOException $e) {
50 50
                         echo "error : ".$e->getMessage();
51 51
                 }
52 52
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
53 53
                 return $all;
54 54
         }
55
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
55
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
56 56
 		if ($filter_name == '') $filter_name = $this->filter_name;
57 57
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
58 58
                  try {
59 59
                         $sth = $this->db->prepare($query);
60
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
61
-                } catch(PDOException $e) {
60
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
61
+                } catch (PDOException $e) {
62 62
                         echo "error : ".$e->getMessage();
63 63
                 }
64 64
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
65 65
                 return $all;
66 66
         }
67
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
67
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
68 68
 		if ($filter_name == '') $filter_name = $this->filter_name;
69 69
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
70 70
                  try {
71 71
                         $sth = $this->db->prepare($query);
72
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
73
-                } catch(PDOException $e) {
72
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
73
+                } catch (PDOException $e) {
74 74
                         echo "error : ".$e->getMessage();
75 75
                 }
76 76
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
86 86
                  try {
87 87
                         $sth = $this->db->prepare($query);
88
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
89
-                } catch(PDOException $e) {
88
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
89
+                } catch (PDOException $e) {
90 90
                         echo "error : ".$e->getMessage();
91 91
                 }
92 92
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
93 93
                 if (empty($all)) {
94 94
             	    $filters = array('airlines' => array($stats_airline));
95 95
             	    if ($filter_name != '') {
96
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
96
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
97 97
             	    }
98 98
             	    $Spotter = new Spotter($this->db);
99
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
99
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
100 100
                 }
101 101
                 return $all;
102 102
 	}
103
-	public function countAllAirlineCountries($limit = true,$filter_name = '') {
103
+	public function countAllAirlineCountries($limit = true, $filter_name = '') {
104 104
 		global $globalStatsFilters;
105 105
 		if ($filter_name == '') $filter_name = $this->filter_name;
106 106
 		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";
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                  try {
109 109
                         $sth = $this->db->prepare($query);
110 110
                         $sth->execute(array(':filter_name' => $filter_name));
111
-                } catch(PDOException $e) {
111
+                } catch (PDOException $e) {
112 112
                         echo "error : ".$e->getMessage();
113 113
                 }
114 114
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -116,28 +116,28 @@  discard block
 block discarded – undo
116 116
             		$Spotter = new Spotter($this->db);
117 117
             		$filters = array();
118 118
             		if ($filter_name != '') {
119
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
119
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
120 120
 			}
121
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
121
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
122 122
                 }
123 123
                 return $all;
124 124
 	}
125
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
125
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') {
126 126
 		global $globalStatsFilters;
127 127
 		if ($filter_name == '') $filter_name = $this->filter_name;
128 128
 		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";
129 129
 		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";
130 130
                  try {
131 131
                         $sth = $this->db->prepare($query);
132
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
133
-                } catch(PDOException $e) {
132
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
133
+                } catch (PDOException $e) {
134 134
                         echo "error : ".$e->getMessage();
135 135
                 }
136 136
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
137 137
                 if (empty($all)) {
138 138
             		$filters = array('airlines' => array($stats_airline));
139 139
             		if ($filter_name != '') {
140
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
140
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
141 141
 			}
142 142
             		$Spotter = new Spotter($this->db);
143 143
 			$all = $Spotter->countAllAircraftManufacturers($filters);
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 		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";
153 153
                  try {
154 154
                         $sth = $this->db->prepare($query);
155
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
156
-                } catch(PDOException $e) {
155
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
156
+                } catch (PDOException $e) {
157 157
                         echo "error : ".$e->getMessage();
158 158
                 }
159 159
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
160 160
                 if (empty($all)) {
161 161
 			$filters = array('airlines' => array($stats_airline));
162 162
 			if ($filter_name != '') {
163
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
163
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
164 164
 			}
165 165
 			$Spotter = new Spotter($this->db);
166
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
166
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
167 167
                 }
168 168
                 return $all;
169 169
 	}
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 		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";
175 175
                  try {
176 176
                         $sth = $this->db->prepare($query);
177
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
178
-                } catch(PDOException $e) {
177
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
178
+                } catch (PDOException $e) {
179 179
                         echo "error : ".$e->getMessage();
180 180
                 }
181 181
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
182 182
                 if (empty($all)) {
183 183
 			$filters = array('airlines' => array($stats_airline));
184 184
 			if ($filter_name != '') {
185
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
185
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
186 186
 			}
187 187
 			$Spotter = new Spotter($this->db);
188 188
 			$all = $Spotter->countAllDepartureCountries($filters);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                 return $all;
191 191
 	}
192 192
 
193
-	public function countAllAirlines($limit = true,$filter_name = '') {
193
+	public function countAllAirlines($limit = true, $filter_name = '') {
194 194
 		global $globalStatsFilters;
195 195
 		if ($filter_name == '') $filter_name = $this->filter_name;
196 196
 		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
                  try {
199 199
                         $sth = $this->db->prepare($query);
200 200
                         $sth->execute(array(':filter_name' => $filter_name));
201
-                } catch(PDOException $e) {
201
+                } catch (PDOException $e) {
202 202
                         echo "error : ".$e->getMessage();
203 203
                 }
204 204
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -206,58 +206,58 @@  discard block
 block discarded – undo
206 206
 	                $Spotter = new Spotter($this->db);
207 207
             		$filters = array();
208 208
             		if ($filter_name != '') {
209
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
209
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
210 210
 			}
211 211
 
212
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
212
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
213 213
                 }
214 214
                 return $all;
215 215
 	}
216
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
216
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') {
217 217
 		global $globalStatsFilters;
218 218
 		if ($filter_name == '') $filter_name = $this->filter_name;
219 219
 		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";
220 220
 		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";
221 221
                  try {
222 222
                         $sth = $this->db->prepare($query);
223
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
224
-                } catch(PDOException $e) {
223
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
224
+                } catch (PDOException $e) {
225 225
                         echo "error : ".$e->getMessage();
226 226
                 }
227 227
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
228 228
                 if (empty($all)) {
229 229
 			$filters = array('airlines' => array($stats_airline));
230 230
 			if ($filter_name != '') {
231
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
231
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
232 232
 			}
233 233
 	                $Spotter = new Spotter($this->db);
234
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
234
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
235 235
                 }
236 236
                 return $all;
237 237
 	}
238
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
238
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') {
239 239
 		global $globalStatsFilters;
240 240
 		if ($filter_name == '') $filter_name = $this->filter_name;
241 241
 		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";
242 242
 		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";
243 243
 		 try {
244 244
 			$sth = $this->db->prepare($query);
245
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
246
-		} catch(PDOException $e) {
245
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
246
+		} catch (PDOException $e) {
247 247
 			echo "error : ".$e->getMessage();
248 248
 		}
249 249
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
250 250
 		if (empty($all)) {
251 251
 			$filters = array('airlines' => array($stats_airline));
252 252
 			if ($filter_name != '') {
253
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
253
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
254 254
 			}
255 255
 			$Spotter = new Spotter($this->db);
256
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
256
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
257 257
 		}
258 258
 		return $all;
259 259
 	}
260
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
260
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') {
261 261
 		$Connection = new Connection();
262 262
 		if ($filter_name == '') $filter_name = $this->filter_name;
263 263
 		if ($Connection->tableExists('countries')) {
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 			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";
266 266
 			 try {
267 267
 				$sth = $this->db->prepare($query);
268
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
269
-			} catch(PDOException $e) {
268
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
269
+			} catch (PDOException $e) {
270 270
 				echo "error : ".$e->getMessage();
271 271
 			}
272 272
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -281,70 +281,70 @@  discard block
 block discarded – undo
281 281
 			return array();
282 282
 		}
283 283
 	}
284
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
284
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') {
285 285
 		global $globalStatsFilters;
286 286
 		if ($filter_name == '') $filter_name = $this->filter_name;
287 287
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
288 288
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
289 289
                  try {
290 290
                         $sth = $this->db->prepare($query);
291
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
292
-                } catch(PDOException $e) {
291
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
292
+                } catch (PDOException $e) {
293 293
                         echo "error : ".$e->getMessage();
294 294
                 }
295 295
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
296 296
                 if (empty($all)) {
297 297
 			$filters = array('airlines' => array($stats_airline));
298 298
 			if ($filter_name != '') {
299
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
299
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
300 300
 			}
301 301
             		$Spotter = new Spotter($this->db);
302
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
302
+            		$all = $Spotter->countAllPilots($limit, 0, '', $filters);
303 303
                 }
304 304
                 return $all;
305 305
 	}
306
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
306
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') {
307 307
 		global $globalStatsFilters;
308 308
 		if ($filter_name == '') $filter_name = $this->filter_name;
309 309
 		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";
310 310
 		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";
311 311
                  try {
312 312
                         $sth = $this->db->prepare($query);
313
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
314
-                } catch(PDOException $e) {
313
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
314
+                } catch (PDOException $e) {
315 315
                         echo "error : ".$e->getMessage();
316 316
                 }
317 317
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
318 318
                 if (empty($all)) {
319 319
 			$filters = array('airlines' => array($stats_airline));
320 320
 			if ($filter_name != '') {
321
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
321
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
322 322
 			}
323 323
             		$Spotter = new Spotter($this->db);
324
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
324
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
325 325
                 }
326 326
                 return $all;
327 327
 	}
328
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
328
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') {
329 329
 		global $globalStatsFilters;
330 330
 		if ($filter_name == '') $filter_name = $this->filter_name;
331 331
 		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
332 332
 		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
333 333
                  try {
334 334
                         $sth = $this->db->prepare($query);
335
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
336
-                } catch(PDOException $e) {
335
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
336
+                } catch (PDOException $e) {
337 337
                         echo "error : ".$e->getMessage();
338 338
                 }
339 339
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
340 340
                 if (empty($all)) {
341 341
 			$filters = array('airlines' => array($stats_airline));
342 342
             		if ($filter_name != '') {
343
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
343
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
344 344
 			}
345 345
             		$Spotter = new Spotter($this->db);
346
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
347
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
346
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
347
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
348 348
         		$all = array();
349 349
         		foreach ($pall as $value) {
350 350
         			$icao = $value['airport_departure_icao'];
@@ -361,30 +361,30 @@  discard block
 block discarded – undo
361 361
         		foreach ($all as $key => $row) {
362 362
         			$count[$key] = $row['airport_departure_icao_count'];
363 363
         		}
364
-        		array_multisort($count,SORT_DESC,$all);
364
+        		array_multisort($count, SORT_DESC, $all);
365 365
                 }
366 366
                 return $all;
367 367
 	}
368
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
368
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') {
369 369
 		global $globalStatsFilters;
370 370
 		if ($filter_name == '') $filter_name = $this->filter_name;
371 371
 		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
372 372
 		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 stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
373 373
 		try {
374 374
 			$sth = $this->db->prepare($query);
375
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
376
-		} catch(PDOException $e) {
375
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
376
+		} catch (PDOException $e) {
377 377
 			echo "error : ".$e->getMessage();
378 378
 		}
379 379
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
380 380
 		if (empty($all)) {
381 381
 			$filters = array('airlines' => array($stats_airline));
382 382
 			if ($filter_name != '') {
383
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
383
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
384 384
 			}
385 385
 			$Spotter = new Spotter($this->db);
386
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
387
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
386
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
387
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
388 388
         		$all = array();
389 389
         		foreach ($pall as $value) {
390 390
         			$icao = $value['airport_arrival_icao'];
@@ -401,12 +401,12 @@  discard block
 block discarded – undo
401 401
         		foreach ($all as $key => $row) {
402 402
         			$count[$key] = $row['airport_arrival_icao_count'];
403 403
         		}
404
-        		array_multisort($count,SORT_DESC,$all);
404
+        		array_multisort($count, SORT_DESC, $all);
405 405
                 }
406 406
  
407 407
                 return $all;
408 408
 	}
409
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
409
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
410 410
 		global $globalDBdriver, $globalStatsFilters;
411 411
 		if ($filter_name == '') $filter_name = $this->filter_name;
412 412
 		if ($globalDBdriver == 'mysql') {
@@ -416,18 +416,18 @@  discard block
 block discarded – undo
416 416
 			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";
417 417
 			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";
418 418
 		}
419
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
419
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
420 420
                  try {
421 421
                         $sth = $this->db->prepare($query);
422 422
                         $sth->execute($query_data);
423
-                } catch(PDOException $e) {
423
+                } catch (PDOException $e) {
424 424
                         echo "error : ".$e->getMessage();
425 425
                 }
426 426
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
427 427
                 if (empty($all)) {
428 428
 			$filters = array('airlines' => array($stats_airline));
429 429
 			if ($filter_name != '') {
430
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
430
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
431 431
 			}
432 432
             		$Spotter = new Spotter($this->db);
433 433
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -436,29 +436,29 @@  discard block
 block discarded – undo
436 436
                 return $all;
437 437
 	}
438 438
 	
439
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
439
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
440 440
 		global $globalStatsFilters;
441 441
 		if ($filter_name == '') $filter_name = $this->filter_name;
442 442
 		$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";
443
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
443
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
444 444
                  try {
445 445
                         $sth = $this->db->prepare($query);
446 446
                         $sth->execute($query_data);
447
-                } catch(PDOException $e) {
447
+                } catch (PDOException $e) {
448 448
                         echo "error : ".$e->getMessage();
449 449
                 }
450 450
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
451 451
                 if (empty($all)) {
452 452
 			$filters = array('airlines' => array($stats_airline));
453 453
 			if ($filter_name != '') {
454
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
454
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
455 455
 			}
456 456
             		$Spotter = new Spotter($this->db);
457 457
             		$all = $Spotter->countAllDatesLastMonth($filters);
458 458
                 }
459 459
                 return $all;
460 460
 	}
461
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
461
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
462 462
 		global $globalDBdriver, $globalStatsFilters;
463 463
 		if ($filter_name == '') $filter_name = $this->filter_name;
464 464
 		if ($globalDBdriver == 'mysql') {
@@ -466,40 +466,40 @@  discard block
 block discarded – undo
466 466
 		} else {
467 467
 			$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";
468 468
 		}
469
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
469
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
470 470
                  try {
471 471
                         $sth = $this->db->prepare($query);
472 472
                         $sth->execute($query_data);
473
-                } catch(PDOException $e) {
473
+                } catch (PDOException $e) {
474 474
                         echo "error : ".$e->getMessage();
475 475
                 }
476 476
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
477 477
                 if (empty($all)) {
478 478
 			$filters = array('airlines' => array($stats_airline));
479 479
 			if ($filter_name != '') {
480
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
480
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
481 481
 			}
482 482
             		$Spotter = new Spotter($this->db);
483 483
             		$all = $Spotter->countAllDatesLast7Days($filters);
484 484
                 }
485 485
                 return $all;
486 486
 	}
487
-	public function countAllDates($stats_airline = '',$filter_name = '') {
487
+	public function countAllDates($stats_airline = '', $filter_name = '') {
488 488
 		global $globalStatsFilters;
489 489
 		if ($filter_name == '') $filter_name = $this->filter_name;
490 490
 		$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";
491
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
491
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
492 492
                  try {
493 493
                         $sth = $this->db->prepare($query);
494 494
                         $sth->execute($query_data);
495
-                } catch(PDOException $e) {
495
+                } catch (PDOException $e) {
496 496
                         echo "error : ".$e->getMessage();
497 497
                 }
498 498
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
499 499
                 if (empty($all)) {
500 500
 			$filters = array('airlines' => array($stats_airline));
501 501
 			if ($filter_name != '') {
502
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
502
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
503 503
 			}
504 504
             		$Spotter = new Spotter($this->db);
505 505
             		$all = $Spotter->countAllDates($filters);
@@ -514,35 +514,35 @@  discard block
 block discarded – undo
514 514
                  try {
515 515
                         $sth = $this->db->prepare($query);
516 516
                         $sth->execute($query_data);
517
-                } catch(PDOException $e) {
517
+                } catch (PDOException $e) {
518 518
                         echo "error : ".$e->getMessage();
519 519
                 }
520 520
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
521 521
                 if (empty($all)) {
522 522
             		$filters = array();
523 523
             		if ($filter_name != '') {
524
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
524
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
525 525
 			}
526 526
             		$Spotter = new Spotter($this->db);
527 527
             		$all = $Spotter->countAllDatesByAirlines($filters);
528 528
                 }
529 529
                 return $all;
530 530
 	}
531
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
531
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
532 532
 		global $globalStatsFilters;
533 533
 		if ($filter_name == '') $filter_name = $this->filter_name;
534 534
 	    	$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";
535 535
                  try {
536 536
                         $sth = $this->db->prepare($query);
537 537
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
538
-                } catch(PDOException $e) {
538
+                } catch (PDOException $e) {
539 539
                         echo "error : ".$e->getMessage();
540 540
                 }
541 541
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
542 542
                 if (empty($all)) {
543 543
 			$filters = array('airlines' => array($stats_airline));
544 544
 			if ($filter_name != '') {
545
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
545
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
546 546
 			}
547 547
             		$Spotter = new Spotter($this->db);
548 548
             		$all = $Spotter->countAllMonths($filters);
@@ -556,21 +556,21 @@  discard block
 block discarded – undo
556 556
                  try {
557 557
                         $sth = $this->db->prepare($query);
558 558
                         $sth->execute(array(':filter_name' => $filter_name));
559
-                } catch(PDOException $e) {
559
+                } catch (PDOException $e) {
560 560
                         echo "error : ".$e->getMessage();
561 561
                 }
562 562
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
563 563
                 if (empty($all)) {
564 564
             		$filters = array();
565 565
             		if ($filter_name != '') {
566
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
566
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
567 567
 			}
568 568
             		$Spotter = new Spotter($this->db);
569 569
             		$all = $Spotter->countAllMilitaryMonths($filters);
570 570
                 }
571 571
                 return $all;
572 572
 	}
573
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
573
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
574 574
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
575 575
 		if ($filter_name == '') $filter_name = $this->filter_name;
576 576
 		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";
@@ -587,17 +587,17 @@  discard block
 block discarded – undo
587 587
                  try {
588 588
                         $sth = $this->db->prepare($query);
589 589
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
590
-                } catch(PDOException $e) {
590
+                } catch (PDOException $e) {
591 591
                         echo "error : ".$e->getMessage();
592 592
                 }
593 593
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
594 594
                 if (empty($all)) {
595 595
 			$filters = array('airlines' => array($stats_airline));
596 596
 			if ($filter_name != '') {
597
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
597
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
598 598
 			}
599 599
             		$Spotter = new Spotter($this->db);
600
-            		$all = $Spotter->countAllHours($orderby,$filters);
600
+            		$all = $Spotter->countAllHours($orderby, $filters);
601 601
                 }
602 602
                 return $all;
603 603
 	}
@@ -605,11 +605,11 @@  discard block
 block discarded – undo
605 605
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
606 606
 		global $globalStatsFilters;
607 607
 		if ($filter_name == '') $filter_name = $this->filter_name;
608
-		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
608
+		$all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name);
609 609
 		if (empty($all)) {
610 610
 			$filters = array('airlines' => array($stats_airline));
611 611
 			if ($filter_name != '') {
612
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
612
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
613 613
 			}
614 614
 			$Spotter = new Spotter($this->db);
615 615
 			$all = $Spotter->countOverallFlights($filters);
@@ -619,39 +619,39 @@  discard block
 block discarded – undo
619 619
 	public function countOverallMilitaryFlights($filter_name = '') {
620 620
 		global $globalStatsFilters;
621 621
 		if ($filter_name == '') $filter_name = $this->filter_name;
622
-		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
622
+		$all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name);
623 623
 		if (empty($all)) {
624 624
 		        $filters = array();
625 625
             		if ($filter_name != '') {
626
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
626
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
627 627
 			}
628 628
 			$Spotter = new Spotter($this->db);
629 629
 			$all = $Spotter->countOverallMilitaryFlights($filters);
630 630
 		}
631 631
 		return $all;
632 632
 	}
633
-	public function countOverallArrival($stats_airline = '',$filter_name = '') {
633
+	public function countOverallArrival($stats_airline = '', $filter_name = '') {
634 634
 		global $globalStatsFilters;
635 635
 		if ($filter_name == '') $filter_name = $this->filter_name;
636
-		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
636
+		$all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name);
637 637
 		if (empty($all)) {
638 638
 			$filters = array('airlines' => array($stats_airline));
639 639
 			if ($filter_name != '') {
640
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
640
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
641 641
 			}
642 642
 			$Spotter = new Spotter($this->db);
643 643
 			$all = $Spotter->countOverallArrival($filters);
644 644
 		}
645 645
 		return $all;
646 646
 	}
647
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
647
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '') {
648 648
 		global $globalStatsFilters;
649 649
 		if ($filter_name == '') $filter_name = $this->filter_name;
650
-		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
650
+		$all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name);
651 651
 		if (empty($all)) {
652 652
 			$filters = array('airlines' => array($stats_airline));
653 653
 			if ($filter_name != '') {
654
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
654
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
655 655
 			}
656 656
 			$Spotter = new Spotter($this->db);
657 657
 			$all = $Spotter->countOverallAircrafts($filters);
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
                  try {
666 666
                         $sth = $this->db->prepare($query);
667 667
                         $sth->execute(array(':filter_name' => $filter_name));
668
-                } catch(PDOException $e) {
668
+                } catch (PDOException $e) {
669 669
                         echo "error : ".$e->getMessage();
670 670
                 }
671 671
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -674,14 +674,14 @@  discard block
 block discarded – undo
674 674
 		if (empty($all)) {
675 675
             		$filters = array();
676 676
             		if ($filter_name != '') {
677
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
677
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
678 678
 			}
679 679
 			$Spotter = new Spotter($this->db);
680 680
 			$all = $Spotter->countOverallAirlines($filters);
681 681
 		}
682 682
 		return $all;
683 683
 	}
684
-	public function countOverallOwners($stats_airline = '',$filter_name = '') {
684
+	public function countOverallOwners($stats_airline = '', $filter_name = '') {
685 685
 		global $globalStatsFilters;
686 686
 		if ($filter_name == '') $filter_name = $this->filter_name;
687 687
 		/*
@@ -695,25 +695,25 @@  discard block
 block discarded – undo
695 695
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
696 696
                 $all = $result[0]['nb_owner'];
697 697
                 */
698
-		$all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name);
698
+		$all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name);
699 699
 		if (empty($all)) {
700 700
 			$filters = array('airlines' => array($stats_airline));
701 701
 			if ($filter_name != '') {
702
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
702
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
703 703
 			}
704 704
 			$Spotter = new Spotter($this->db);
705 705
 			$all = $Spotter->countOverallOwners($filters);
706 706
 		}
707 707
 		return $all;
708 708
 	}
709
-	public function countOverallPilots($stats_airline = '',$filter_name = '') {
709
+	public function countOverallPilots($stats_airline = '', $filter_name = '') {
710 710
 		global $globalStatsFilters;
711 711
 		if ($filter_name == '') $filter_name = $this->filter_name;
712
-		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
712
+		$all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name);
713 713
 		if (empty($all)) {
714 714
 			$filters = array('airlines' => array($stats_airline));
715 715
 			if ($filter_name != '') {
716
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
716
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
717 717
 			}
718 718
 			$Spotter = new Spotter($this->db);
719 719
 			$all = $Spotter->countOverallPilots($filters);
@@ -721,33 +721,33 @@  discard block
 block discarded – undo
721 721
 		return $all;
722 722
 	}
723 723
 
724
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
724
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
725 725
 		if ($filter_name == '') $filter_name = $this->filter_name;
726 726
 		$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";
727
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
727
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
728 728
                  try {
729 729
                         $sth = $this->db->prepare($query);
730 730
                         $sth->execute($query_values);
731
-                } catch(PDOException $e) {
731
+                } catch (PDOException $e) {
732 732
                         echo "error : ".$e->getMessage();
733 733
                 }
734 734
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
735 735
                 return $all;
736 736
 	}
737
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
737
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
738 738
 		if ($filter_name == '') $filter_name = $this->filter_name;
739 739
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
740
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
740
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
741 741
                  try {
742 742
                         $sth = $this->db->prepare($query);
743 743
                         $sth->execute($query_values);
744
-                } catch(PDOException $e) {
744
+                } catch (PDOException $e) {
745 745
                         echo "error : ".$e->getMessage();
746 746
                 }
747 747
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
748 748
                 return $all;
749 749
         }
750
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
750
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') {
751 751
 		if ($filter_name == '') $filter_name = $this->filter_name;
752 752
     		global $globalArchiveMonths, $globalDBdriver;
753 753
     		if ($globalDBdriver == 'mysql') {
@@ -755,11 +755,11 @@  discard block
 block discarded – undo
755 755
 	        } else {
756 756
             		$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";
757 757
                 }
758
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
758
+                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
759 759
                  try {
760 760
                         $sth = $this->db->prepare($query);
761 761
                         $sth->execute($query_values);
762
-                } catch(PDOException $e) {
762
+                } catch (PDOException $e) {
763 763
                         echo "error : ".$e->getMessage();
764 764
                 }
765 765
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
                  try {
778 778
                         $sth = $this->db->prepare($query);
779 779
                         $sth->execute($query_values);
780
-                } catch(PDOException $e) {
780
+                } catch (PDOException $e) {
781 781
                         echo "error : ".$e->getMessage();
782 782
                 }
783 783
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
                  try {
795 795
                         $sth = $this->db->prepare($query);
796 796
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
797
-                } catch(PDOException $e) {
797
+                } catch (PDOException $e) {
798 798
                         echo "error : ".$e->getMessage();
799 799
                 }
800 800
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
                  try {
812 812
                         $sth = $this->db->prepare($query);
813 813
                         $sth->execute(array(':filter_name' => $filter_name));
814
-                } catch(PDOException $e) {
814
+                } catch (PDOException $e) {
815 815
                         echo "error : ".$e->getMessage();
816 816
                 }
817 817
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
                  try {
829 829
                         $sth = $this->db->prepare($query);
830 830
                         $sth->execute(array(':filter_name' => $filter_name));
831
-                } catch(PDOException $e) {
831
+                } catch (PDOException $e) {
832 832
                         echo "error : ".$e->getMessage();
833 833
                 }
834 834
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -845,14 +845,14 @@  discard block
 block discarded – undo
845 845
                  try {
846 846
                         $sth = $this->db->prepare($query);
847 847
                         $sth->execute(array(':filter_name' => $filter_name));
848
-                } catch(PDOException $e) {
848
+                } catch (PDOException $e) {
849 849
                         echo "error : ".$e->getMessage();
850 850
                 }
851 851
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
852 852
                 return $all[0]['total'];
853 853
         }
854 854
 
855
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
855
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
856 856
 		global $globalDBdriver;
857 857
 		if ($filter_name == '') $filter_name = $this->filter_name;
858 858
 		if ($globalDBdriver == 'mysql') {
@@ -860,15 +860,15 @@  discard block
 block discarded – undo
860 860
                 } else {
861 861
 			$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);"; 
862 862
 		}
863
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
863
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
864 864
                  try {
865 865
                         $sth = $this->db->prepare($query);
866 866
                         $sth->execute($query_values);
867
-                } catch(PDOException $e) {
867
+                } catch (PDOException $e) {
868 868
                         return "error : ".$e->getMessage();
869 869
                 }
870 870
         }
871
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
871
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
872 872
 		global $globalDBdriver;
873 873
 		if ($filter_name == '') $filter_name = $this->filter_name;
874 874
 		if ($globalDBdriver == 'mysql') {
@@ -877,219 +877,219 @@  discard block
 block discarded – undo
877 877
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
878 878
 			$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);"; 
879 879
                 }
880
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
880
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
881 881
                  try {
882 882
                         $sth = $this->db->prepare($query);
883 883
                         $sth->execute($query_values);
884
-                } catch(PDOException $e) {
884
+                } catch (PDOException $e) {
885 885
                         return "error : ".$e->getMessage();
886 886
                 }
887 887
         }
888
-	public function getStatsSource($date,$stats_type = '') {
888
+	public function getStatsSource($date, $stats_type = '') {
889 889
 		if ($stats_type == '') {
890 890
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
891 891
 			$query_values = array(':date' => $date);
892 892
 		} else {
893 893
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
894
-			$query_values = array(':date' => $date,':stats_type' => $stats_type);
894
+			$query_values = array(':date' => $date, ':stats_type' => $stats_type);
895 895
 		}
896 896
                  try {
897 897
                         $sth = $this->db->prepare($query);
898 898
                         $sth->execute($query_values);
899
-                } catch(PDOException $e) {
899
+                } catch (PDOException $e) {
900 900
                         echo "error : ".$e->getMessage();
901 901
                 }
902 902
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
903 903
                 return $all;
904 904
         }
905 905
 
906
-	public function addStatSource($data,$source_name,$stats_type,$date) {
906
+	public function addStatSource($data, $source_name, $stats_type, $date) {
907 907
 		global $globalDBdriver;
908 908
 		if ($globalDBdriver == 'mysql') {
909 909
 			$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";
910 910
 		} else {
911 911
 			$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);"; 
912 912
                 }
913
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
913
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
914 914
                  try {
915 915
                         $sth = $this->db->prepare($query);
916 916
                         $sth->execute($query_values);
917
-                } catch(PDOException $e) {
917
+                } catch (PDOException $e) {
918 918
                         return "error : ".$e->getMessage();
919 919
                 }
920 920
         }
921
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
921
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
922 922
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
923
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
923
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
924 924
                  try {
925 925
                         $sth = $this->db->prepare($query);
926 926
                         $sth->execute($query_values);
927
-                } catch(PDOException $e) {
927
+                } catch (PDOException $e) {
928 928
                         return "error : ".$e->getMessage();
929 929
                 }
930 930
         }
931
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') {
931
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') {
932 932
 		global $globalDBdriver;
933 933
 		if ($globalDBdriver == 'mysql') {
934 934
 			$query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) VALUES (:aircraft_icao,:registration,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
935 935
 		} else {
936 936
 			$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);"; 
937 937
 		}
938
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
938
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
939 939
                  try {
940 940
                         $sth = $this->db->prepare($query);
941 941
                         $sth->execute($query_values);
942
-                } catch(PDOException $e) {
942
+                } catch (PDOException $e) {
943 943
                         return "error : ".$e->getMessage();
944 944
                 }
945 945
         }
946
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') {
946
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') {
947 947
 		global $globalDBdriver;
948 948
 		if ($globalDBdriver == 'mysql') {
949 949
 			$query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) VALUES (:callsign_icao,:airline_icao,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
950 950
 		} else {
951 951
 			$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);"; 
952 952
 		}
953
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
953
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
954 954
                  try {
955 955
                         $sth = $this->db->prepare($query);
956 956
                         $sth->execute($query_values);
957
-                } catch(PDOException $e) {
957
+                } catch (PDOException $e) {
958 958
                         return "error : ".$e->getMessage();
959 959
                 }
960 960
         }
961
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') {
961
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') {
962 962
 		global $globalDBdriver;
963 963
 		if ($globalDBdriver == 'mysql') {
964 964
 			$query = "INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) VALUES (:iso2,:iso3,:name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
965 965
 		} else {
966 966
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
967 967
 		}
968
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
968
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
969 969
                  try {
970 970
                         $sth = $this->db->prepare($query);
971 971
                         $sth->execute($query_values);
972
-                } catch(PDOException $e) {
972
+                } catch (PDOException $e) {
973 973
                         return "error : ".$e->getMessage();
974 974
                 }
975 975
         }
976
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
976
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
977 977
 		global $globalDBdriver;
978 978
 		if ($globalDBdriver == 'mysql') {
979 979
 			$query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline, filter_name) VALUES (:aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, stats_airline = :stats_airline";
980 980
 		} else {
981 981
 			$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);"; 
982 982
 		}
983
-                $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);
983
+                $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);
984 984
                  try {
985 985
                         $sth = $this->db->prepare($query);
986 986
                         $sth->execute($query_values);
987
-                } catch(PDOException $e) {
987
+                } catch (PDOException $e) {
988 988
                         return "error : ".$e->getMessage();
989 989
                 }
990 990
         }
991
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') {
991
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') {
992 992
 		global $globalDBdriver;
993 993
 		if ($globalDBdriver == 'mysql') {
994 994
 			$query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) VALUES (:airline_icao,:airline_name,:cnt,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name";
995 995
 		} else {
996 996
 			$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);"; 
997 997
 		}
998
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
998
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
999 999
                  try {
1000 1000
                         $sth = $this->db->prepare($query);
1001 1001
                         $sth->execute($query_values);
1002
-                } catch(PDOException $e) {
1002
+                } catch (PDOException $e) {
1003 1003
                         return "error : ".$e->getMessage();
1004 1004
                 }
1005 1005
         }
1006
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') {
1006
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') {
1007 1007
 		global $globalDBdriver;
1008 1008
 		if ($globalDBdriver == 'mysql') {
1009 1009
 			$query = "INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) VALUES (:owner_name,:cnt,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
1010 1010
 		} else {
1011 1011
 			$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);"; 
1012 1012
 		}
1013
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1013
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1014 1014
                  try {
1015 1015
                         $sth = $this->db->prepare($query);
1016 1016
                         $sth->execute($query_values);
1017
-                } catch(PDOException $e) {
1017
+                } catch (PDOException $e) {
1018 1018
                         return "error : ".$e->getMessage();
1019 1019
                 }
1020 1020
         }
1021
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') {
1021
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '') {
1022 1022
 		global $globalDBdriver;
1023 1023
 		if ($globalDBdriver == 'mysql') {
1024 1024
 			$query = "INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) VALUES (:pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, pilot_name = :pilot_name";
1025 1025
 		} else {
1026 1026
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1027 1027
 		}
1028
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1028
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1029 1029
                  try {
1030 1030
                         $sth = $this->db->prepare($query);
1031 1031
                         $sth->execute($query_values);
1032
-                } catch(PDOException $e) {
1032
+                } catch (PDOException $e) {
1033 1033
                         return "error : ".$e->getMessage();
1034 1034
                 }
1035 1035
         }
1036
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1036
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1037 1037
 		global $globalDBdriver;
1038 1038
 		if ($globalDBdriver == 'mysql') {
1039 1039
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = departure+:departure";
1040 1040
 		} else {
1041 1041
 			$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);"; 
1042 1042
 		}
1043
-                $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);
1043
+                $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);
1044 1044
                  try {
1045 1045
                         $sth = $this->db->prepare($query);
1046 1046
                         $sth->execute($query_values);
1047
-                } catch(PDOException $e) {
1047
+                } catch (PDOException $e) {
1048 1048
                         return "error : ".$e->getMessage();
1049 1049
                 }
1050 1050
         }
1051
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1051
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1052 1052
 		global $globalDBdriver;
1053 1053
 		if ($globalDBdriver == 'mysql') {
1054 1054
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE departure = :departure";
1055 1055
 		} else {
1056 1056
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1057 1057
 		}
1058
-                $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);
1058
+                $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);
1059 1059
                  try {
1060 1060
                         $sth = $this->db->prepare($query);
1061 1061
                         $sth->execute($query_values);
1062
-                } catch(PDOException $e) {
1062
+                } catch (PDOException $e) {
1063 1063
                         return "error : ".$e->getMessage();
1064 1064
                 }
1065 1065
         }
1066
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1066
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1067 1067
 		global $globalDBdriver;
1068 1068
 		if ($globalDBdriver == 'mysql') {
1069 1069
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival";
1070 1070
 		} else {
1071 1071
 			$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);"; 
1072 1072
 		}
1073
-                $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);
1073
+                $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);
1074 1074
                  try {
1075 1075
                         $sth = $this->db->prepare($query);
1076 1076
                         $sth->execute($query_values);
1077
-                } catch(PDOException $e) {
1077
+                } catch (PDOException $e) {
1078 1078
                         return "error : ".$e->getMessage();
1079 1079
                 }
1080 1080
         }
1081
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1081
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1082 1082
 		global $globalDBdriver;
1083 1083
 		if ($globalDBdriver == 'mysql') {
1084 1084
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE arrival = :arrival";
1085 1085
 		} else {
1086 1086
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1087 1087
 		}
1088
-                $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);
1088
+                $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);
1089 1089
                  try {
1090 1090
                         $sth = $this->db->prepare($query);
1091 1091
                         $sth->execute($query_values);
1092
-                } catch(PDOException $e) {
1092
+                } catch (PDOException $e) {
1093 1093
                         return "error : ".$e->getMessage();
1094 1094
                 }
1095 1095
         }
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
                  try {
1101 1101
                         $sth = $this->db->prepare($query);
1102 1102
                         $sth->execute($query_values);
1103
-                } catch(PDOException $e) {
1103
+                } catch (PDOException $e) {
1104 1104
                         return "error : ".$e->getMessage();
1105 1105
                 }
1106 1106
         }
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
                  try {
1111 1111
                         $sth = $this->db->prepare($query);
1112 1112
                         $sth->execute($query_values);
1113
-                } catch(PDOException $e) {
1113
+                } catch (PDOException $e) {
1114 1114
                         return "error : ".$e->getMessage();
1115 1115
                 }
1116 1116
         }
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
                  try {
1121 1121
                         $sth = $this->db->prepare($query);
1122 1122
                         $sth->execute($query_values);
1123
-                } catch(PDOException $e) {
1123
+                } catch (PDOException $e) {
1124 1124
                         return "error : ".$e->getMessage();
1125 1125
                 }
1126 1126
         }
@@ -1358,33 +1358,33 @@  discard block
 block discarded – undo
1358 1358
 				$last_update_day = $last_update[0]['value'];
1359 1359
 			} else $last_update_day = '2012-12-12 12:12:12';
1360 1360
 			$Spotter = new Spotter($this->db);
1361
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1361
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1362 1362
 			foreach ($alldata as $number) {
1363
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1363
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']);
1364 1364
 			}
1365
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1365
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1366 1366
 			foreach ($alldata as $number) {
1367
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1367
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1368 1368
 			}
1369
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1369
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1370 1370
 			foreach ($alldata as $number) {
1371
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1371
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1372 1372
 			}
1373
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1373
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1374 1374
 			foreach ($alldata as $number) {
1375
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1375
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1376 1376
 			}
1377
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1377
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1378 1378
 			foreach ($alldata as $number) {
1379
-				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1379
+				$this->addStatOwner($number['owner_name'], $number['owner_count']);
1380 1380
 			}
1381
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1381
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1382 1382
 			foreach ($alldata as $number) {
1383
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']);
1383
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name']);
1384 1384
 			}
1385 1385
 			
1386
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1387
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1386
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1387
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1388 1388
 	        	$alldata = array();
1389 1389
 	        	
1390 1390
     			foreach ($pall as $value) {
@@ -1401,12 +1401,12 @@  discard block
 block discarded – undo
1401 1401
     			foreach ($alldata as $key => $row) {
1402 1402
     				$count[$key] = $row['airport_departure_icao_count'];
1403 1403
         		}
1404
-			array_multisort($count,SORT_DESC,$alldata);
1404
+			array_multisort($count, SORT_DESC, $alldata);
1405 1405
 			foreach ($alldata as $number) {
1406
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1406
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1407 1407
 			}
1408
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1409
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1408
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1409
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1410 1410
 	        	$alldata = array();
1411 1411
     			foreach ($pall as $value) {
1412 1412
 	        		$icao = $value['airport_arrival_icao'];
@@ -1422,15 +1422,15 @@  discard block
 block discarded – undo
1422 1422
         		foreach ($alldata as $key => $row) {
1423 1423
         			$count[$key] = $row['airport_arrival_icao_count'];
1424 1424
 	        	}
1425
-    			array_multisort($count,SORT_DESC,$alldata);
1425
+    			array_multisort($count, SORT_DESC, $alldata);
1426 1426
                         foreach ($alldata as $number) {
1427
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1427
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1428 1428
 			}
1429 1429
 			if ($Connection->tableExists('countries')) {
1430 1430
 				$SpotterArchive = new SpotterArchive();
1431
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1431
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1432 1432
 				foreach ($alldata as $number) {
1433
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1433
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1434 1434
 				}
1435 1435
 			}
1436 1436
 			
@@ -1443,31 +1443,31 @@  discard block
 block discarded – undo
1443 1443
 			$lastyear = false;
1444 1444
 			foreach ($alldata as $number) {
1445 1445
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1446
-				$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'])));
1446
+				$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'])));
1447 1447
 			}
1448 1448
 			$alldata = $Spotter->countAllMilitaryMonths();
1449 1449
 			foreach ($alldata as $number) {
1450
-				$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'])));
1450
+				$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'])));
1451 1451
 			}
1452 1452
 			$alldata = $Spotter->countAllMonthsOwners();
1453 1453
 			foreach ($alldata as $number) {
1454
-				$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'])));
1454
+				$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'])));
1455 1455
 			}
1456 1456
 			$alldata = $Spotter->countAllMonthsPilots();
1457 1457
 			foreach ($alldata as $number) {
1458
-				$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'])));
1458
+				$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'])));
1459 1459
 			}
1460 1460
 			$alldata = $Spotter->countAllMonthsAirlines();
1461 1461
 			foreach ($alldata as $number) {
1462
-				$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'])));
1462
+				$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'])));
1463 1463
 			}
1464 1464
 			$alldata = $Spotter->countAllMonthsAircrafts();
1465 1465
 			foreach ($alldata as $number) {
1466
-				$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'])));
1466
+				$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'])));
1467 1467
 			}
1468 1468
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1469 1469
 			foreach ($alldata as $number) {
1470
-				$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'])));
1470
+				$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'])));
1471 1471
 			}
1472 1472
 			echo 'Airports data...'."\n";
1473 1473
 			echo '...Departure'."\n";
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
     			}
1513 1513
     			$alldata = $pall;
1514 1514
 			foreach ($alldata as $number) {
1515
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1515
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1516 1516
 			}
1517 1517
 			echo '...Arrival'."\n";
1518 1518
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
     			}
1555 1555
     			$alldata = $pall;
1556 1556
 			foreach ($alldata as $number) {
1557
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1557
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1558 1558
 			}
1559 1559
 
1560 1560
 			echo 'Flights data...'."\n";
@@ -1562,28 +1562,28 @@  discard block
 block discarded – undo
1562 1562
 			echo '-> countAllDatesLastMonth...'."\n";
1563 1563
 			$alldata = $Spotter->countAllDatesLastMonth();
1564 1564
 			foreach ($alldata as $number) {
1565
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1565
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1566 1566
 			}
1567 1567
 			echo '-> countAllDates...'."\n";
1568 1568
 			$previousdata = $this->countAllDates();
1569 1569
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1570 1570
 			$this->deleteStatFlight('date');
1571
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1571
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1572 1572
 			$values = array();
1573 1573
 			foreach ($alldata as $cnt) {
1574 1574
 				$values[] = $cnt['date_count'];
1575 1575
 			}
1576
-			array_multisort($values,SORT_DESC,$alldata);
1577
-			array_splice($alldata,11);
1576
+			array_multisort($values, SORT_DESC, $alldata);
1577
+			array_splice($alldata, 11);
1578 1578
 			foreach ($alldata as $number) {
1579
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1579
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1580 1580
 			}
1581 1581
 			
1582 1582
 			$this->deleteStatFlight('hour');
1583 1583
 			echo '-> countAllHours...'."\n";
1584 1584
 			$alldata = $Spotter->countAllHours('hour');
1585 1585
 			foreach ($alldata as $number) {
1586
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1586
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1587 1587
 			}
1588 1588
 
1589 1589
 
@@ -1591,29 +1591,29 @@  discard block
 block discarded – undo
1591 1591
 			// Count by airlines
1592 1592
 			echo '--- Stats by airlines ---'."\n";
1593 1593
 			$Spotter = new Spotter($this->db);
1594
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1594
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1595 1595
 			foreach ($alldata as $number) {
1596
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1596
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']);
1597 1597
 			}
1598
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1598
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1599 1599
 			foreach ($alldata as $number) {
1600
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1600
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']);
1601 1601
 			}
1602
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1602
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1603 1603
 			foreach ($alldata as $number) {
1604
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1604
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1605 1605
 			}
1606
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1606
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1607 1607
 			foreach ($alldata as $number) {
1608
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1608
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']);
1609 1609
 			}
1610
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1610
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1611 1611
 			foreach ($alldata as $number) {
1612
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']);
1612
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao']);
1613 1613
 			}
1614 1614
 			
1615
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1616
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1615
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1616
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1617 1617
 	        	//$alldata = array();
1618 1618
     			foreach ($dall as $value) {
1619 1619
     				$icao = $value['airport_departure_icao'];
@@ -1632,10 +1632,10 @@  discard block
 block discarded – undo
1632 1632
     			}
1633 1633
     			$alldata = $pall;
1634 1634
 			foreach ($alldata as $number) {
1635
-				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']);
1635
+				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']);
1636 1636
 			}
1637
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1638
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1637
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1638
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1639 1639
 	        	//$alldata = array();
1640 1640
     			foreach ($dall as $value) {
1641 1641
     				$icao = $value['airport_arrival_icao'];
@@ -1654,30 +1654,30 @@  discard block
 block discarded – undo
1654 1654
     			}
1655 1655
     			$alldata = $pall;
1656 1656
                         foreach ($alldata as $number) {
1657
-				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']);
1657
+				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']);
1658 1658
 			}
1659 1659
 			$Spotter = new Spotter($this->db);
1660 1660
 			$alldata = $Spotter->countAllMonthsByAirlines();
1661 1661
 			$lastyear = false;
1662 1662
 			foreach ($alldata as $number) {
1663 1663
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1664
-				$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']);
1664
+				$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']);
1665 1665
 			}
1666 1666
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1667 1667
 			foreach ($alldata as $number) {
1668
-				$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']);
1668
+				$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']);
1669 1669
 			}
1670 1670
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1671 1671
 			foreach ($alldata as $number) {
1672
-				$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']);
1672
+				$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']);
1673 1673
 			}
1674 1674
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1675 1675
 			foreach ($alldata as $number) {
1676
-				$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']);
1676
+				$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']);
1677 1677
 			}
1678 1678
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1679 1679
 			foreach ($alldata as $number) {
1680
-				$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']);
1680
+				$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']);
1681 1681
 			}
1682 1682
 			echo '...Departure'."\n";
1683 1683
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
     			}
1701 1701
     			$alldata = $pall;
1702 1702
 			foreach ($alldata as $number) {
1703
-				$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']);
1703
+				$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']);
1704 1704
 			}
1705 1705
 			echo '...Arrival'."\n";
1706 1706
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1723,32 +1723,32 @@  discard block
 block discarded – undo
1723 1723
     			}
1724 1724
     			$alldata = $pall;
1725 1725
 			foreach ($alldata as $number) {
1726
-				$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']);
1726
+				$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']);
1727 1727
 			}
1728 1728
 
1729 1729
 			echo 'Flights data...'."\n";
1730 1730
 			echo '-> countAllDatesLastMonth...'."\n";
1731 1731
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1732 1732
 			foreach ($alldata as $number) {
1733
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1733
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1734 1734
 			}
1735 1735
 			echo '-> countAllDates...'."\n";
1736 1736
 			//$previousdata = $this->countAllDatesByAirlines();
1737
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1737
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1738 1738
 			$values = array();
1739 1739
 			foreach ($alldata as $cnt) {
1740 1740
 				$values[] = $cnt['date_count'];
1741 1741
 			}
1742
-			array_multisort($values,SORT_DESC,$alldata);
1743
-			array_splice($alldata,11);
1742
+			array_multisort($values, SORT_DESC, $alldata);
1743
+			array_splice($alldata, 11);
1744 1744
 			foreach ($alldata as $number) {
1745
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1745
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1746 1746
 			}
1747 1747
 			
1748 1748
 			echo '-> countAllHours...'."\n";
1749 1749
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1750 1750
 			foreach ($alldata as $number) {
1751
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1751
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1752 1752
 			}
1753 1753
 			
1754 1754
 
@@ -1759,29 +1759,29 @@  discard block
 block discarded – undo
1759 1759
 				// Count by filter
1760 1760
 				echo '--- Stats by airlines ---'."\n";
1761 1761
 				$Spotter = new Spotter($this->db);
1762
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1762
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1763 1763
 				foreach ($alldata as $number) {
1764
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name);
1764
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name);
1765 1765
 				}
1766
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1766
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1767 1767
 				foreach ($alldata as $number) {
1768
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name);
1768
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name);
1769 1769
 				}
1770
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1770
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1771 1771
 				foreach ($alldata as $number) {
1772
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name);
1772
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name);
1773 1773
 				}
1774
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1774
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1775 1775
 				foreach ($alldata as $number) {
1776
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name);
1776
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name);
1777 1777
 				}
1778
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1778
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1779 1779
 				foreach ($alldata as $number) {
1780
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name);
1780
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name);
1781 1781
 				}
1782 1782
     			
1783
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1784
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1783
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1784
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1785 1785
 		        	//$alldata = array();
1786 1786
 	    			foreach ($dall as $value) {
1787 1787
 	    				$icao = $value['airport_departure_icao'];
@@ -1800,10 +1800,10 @@  discard block
 block discarded – undo
1800 1800
         			}
1801 1801
         			$alldata = $pall;
1802 1802
 				foreach ($alldata as $number) {
1803
-    					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);
1803
+    					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);
1804 1804
 				}
1805
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);
1806
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1805
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter);
1806
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter);
1807 1807
 	    			//$alldata = array();
1808 1808
 				foreach ($dall as $value) {
1809 1809
     					$icao = $value['airport_arrival_icao'];
@@ -1822,30 +1822,30 @@  discard block
 block discarded – undo
1822 1822
         			}
1823 1823
 				$alldata = $pall;
1824 1824
 				foreach ($alldata as $number) {
1825
-					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);
1825
+					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);
1826 1826
 				}
1827 1827
 				$Spotter = new Spotter($this->db);
1828 1828
 				$alldata = $Spotter->countAllMonths($filter);
1829 1829
 				$lastyear = false;
1830 1830
 				foreach ($alldata as $number) {
1831 1831
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1832
-					$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);
1832
+					$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);
1833 1833
 				}
1834 1834
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1835 1835
 				foreach ($alldata as $number) {
1836
-					$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);
1836
+					$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);
1837 1837
 				}
1838 1838
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1839 1839
 				foreach ($alldata as $number) {
1840
-					$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);
1840
+					$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);
1841 1841
 				}
1842 1842
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1843 1843
 				foreach ($alldata as $number) {
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'])),'',$filter_name);
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'])), '', $filter_name);
1845 1845
 				}
1846 1846
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1847 1847
 				foreach ($alldata as $number) {
1848
-					$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);
1848
+					$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);
1849 1849
 				}
1850 1850
 				echo '...Departure'."\n";
1851 1851
 				$pall = $Spotter->getLast7DaysAirportsDeparture($filter);
@@ -1868,7 +1868,7 @@  discard block
 block discarded – undo
1868 1868
     				}
1869 1869
 	    			$alldata = $pall;
1870 1870
 				foreach ($alldata as $number) {
1871
-					$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);
1871
+					$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);
1872 1872
 				}
1873 1873
 				echo '...Arrival'."\n";
1874 1874
 				$pall = $Spotter->getLast7DaysAirportsArrival($filter);
@@ -1891,32 +1891,32 @@  discard block
 block discarded – undo
1891 1891
     				}
1892 1892
     				$alldata = $pall;
1893 1893
 				foreach ($alldata as $number) {
1894
-					$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);
1894
+					$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);
1895 1895
 				}
1896 1896
     
1897 1897
 				echo 'Flights data...'."\n";
1898 1898
 				echo '-> countAllDatesLastMonth...'."\n";
1899 1899
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1900 1900
 				foreach ($alldata as $number) {
1901
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1901
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1902 1902
 				}
1903 1903
 				echo '-> countAllDates...'."\n";
1904 1904
 				$previousdata = $this->countAllDates($filter);
1905
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1905
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1906 1906
 				$values = array();
1907 1907
 				foreach ($alldata as $cnt) {
1908 1908
 					$values[] = $cnt['date_count'];
1909 1909
 				}
1910
-				array_multisort($values,SORT_DESC,$alldata);
1911
-				array_splice($alldata,11);
1910
+				array_multisort($values, SORT_DESC, $alldata);
1911
+				array_splice($alldata, 11);
1912 1912
 				foreach ($alldata as $number) {
1913
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1913
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1914 1914
 				}
1915 1915
 				
1916 1916
 				echo '-> countAllHours...'."\n";
1917
-				$alldata = $Spotter->countAllHours('hour',$filter);
1917
+				$alldata = $Spotter->countAllHours('hour', $filter);
1918 1918
 				foreach ($alldata as $number) {
1919
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
1919
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
1920 1920
 				}
1921 1921
 			}
1922 1922
 	
@@ -1927,16 +1927,16 @@  discard block
 block discarded – undo
1927 1927
 				// SUM all previous month to put as year
1928 1928
 				$previous_year = date('Y');
1929 1929
 				$previous_year--;
1930
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1931
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1932
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1933
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1930
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1931
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1932
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1933
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1934 1934
 				$allairlines = $this->getAllAirlineNames();
1935 1935
 				foreach ($allairlines as $data) {
1936
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1937
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1938
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1939
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1936
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1937
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1938
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1939
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1940 1940
 				}
1941 1941
 				
1942 1942
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
 						try {
1946 1946
 							$sth = $this->db->prepare($query);
1947 1947
 							$sth->execute();
1948
-						} catch(PDOException $e) {
1948
+						} catch (PDOException $e) {
1949 1949
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1950 1950
 						}
1951 1951
 					}
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 					try {
1955 1955
 						$sth = $this->db->prepare($query);
1956 1956
 						$sth->execute();
1957
-					} catch(PDOException $e) {
1957
+					} catch (PDOException $e) {
1958 1958
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1959 1959
 					}
1960 1960
 				}
@@ -1976,7 +1976,7 @@  discard block
 block discarded – undo
1976 1976
 					try {
1977 1977
 						$sth = $this->db->prepare($query);
1978 1978
 						$sth->execute();
1979
-					} catch(PDOException $e) {
1979
+					} catch (PDOException $e) {
1980 1980
 						return "error : ".$e->getMessage();
1981 1981
 					}
1982 1982
 				}
@@ -1990,13 +1990,13 @@  discard block
 block discarded – undo
1990 1990
 				try {
1991 1991
 					$sth = $this->db->prepare($query);
1992 1992
 					$sth->execute();
1993
-				} catch(PDOException $e) {
1993
+				} catch (PDOException $e) {
1994 1994
 					return "error : ".$e->getMessage();
1995 1995
 				}
1996 1996
 			}
1997 1997
 			echo 'Insert last stats update date...'."\n";
1998 1998
 			date_default_timezone_set('UTC');
1999
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1999
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2000 2000
 		//}
2001 2001
 	}
2002 2002
 }
Please login to merge, or discard this patch.
require/class.SpotterLive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter;
Please login to merge, or discard this patch.
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter;
21 21
 		if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter);
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	}
51 51
 
52 52
 	/**
53
-	* Gets all the spotter information based on the latest data entry
54
-	*
55
-	* @return Array the spotter information
56
-	*
57
-	*/
53
+	 * Gets all the spotter information based on the latest data entry
54
+	 *
55
+	 * @return Array the spotter information
56
+	 *
57
+	 */
58 58
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
59 59
 	{
60 60
 		global $globalDBdriver, $globalLiveInterval;
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 
95 95
 	/**
96
-	* Gets Minimal Live Spotter data
97
-	*
98
-	* @return Array the spotter information
99
-	*
100
-	*/
96
+	 * Gets Minimal Live Spotter data
97
+	 *
98
+	 * @return Array the spotter information
99
+	 *
100
+	 */
101 101
 	public function getMinLiveSpotterData($filter = array())
102 102
 	{
103 103
 		global $globalDBdriver, $globalLiveInterval;
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	}
143 143
 
144 144
 	/**
145
-	* Gets Minimal Live Spotter data since xx seconds
146
-	*
147
-	* @return Array the spotter information
148
-	*
149
-	*/
145
+	 * Gets Minimal Live Spotter data since xx seconds
146
+	 *
147
+	 * @return Array the spotter information
148
+	 *
149
+	 */
150 150
 	public function getMinLastLiveSpotterData($filter = array())
151 151
 	{
152 152
 		global $globalDBdriver, $globalLiveInterval;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			$query  = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
161 161
 			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 
162 162
 			ORDER BY spotter_live.flightaware_id, spotter_live.date';
163
-                } else {
163
+				} else {
164 164
 /*
165 165
 			$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 
166 166
 			FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 //			echo $query;
173 173
 		}
174 174
 
175
-    		try {
175
+			try {
176 176
 			$sth = $this->db->prepare($query);
177 177
 			$sth->execute();
178 178
 		} catch(PDOException $e) {
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
 	}
185 185
 
186 186
 	/**
187
-	* Gets number of latest data entry
188
-	*
189
-	* @return String number of entry
190
-	*
191
-	*/
187
+	 * Gets number of latest data entry
188
+	 *
189
+	 * @return String number of entry
190
+	 *
191
+	 */
192 192
 	public function getLiveSpotterCount($filter = array())
193 193
 	{
194 194
 		global $globalDBdriver, $globalLiveInterval;
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
 	}
215 215
 
216 216
 	/**
217
-	* Gets all the spotter information based on the latest data entry and coord
218
-	*
219
-	* @return Array the spotter information
220
-	*
221
-	*/
217
+	 * Gets all the spotter information based on the latest data entry and coord
218
+	 *
219
+	 * @return Array the spotter information
220
+	 *
221
+	 */
222 222
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
223 223
 	{
224 224
 		global $globalDBdriver, $globalLiveInterval;
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 	}
244 244
 
245 245
 	/**
246
-	* Gets all the spotter information based on a user's latitude and longitude
247
-	*
248
-	* @return Array the spotter information
249
-	*
250
-	*/
246
+	 * Gets all the spotter information based on a user's latitude and longitude
247
+	 *
248
+	 * @return Array the spotter information
249
+	 *
250
+	 */
251 251
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
252 252
 	{
253 253
 		$Spotter = new Spotter($this->db);
@@ -257,145 +257,145 @@  discard block
 block discarded – undo
257 257
 				return false;
258 258
 			}
259 259
 		}
260
-        if ($lng != '')
261
-                {
262
-                        if (!is_numeric($lng))
263
-                        {
264
-                                return false;
265
-                        }
266
-                }
267
-
268
-                if ($radius != '')
269
-                {
270
-                        if (!is_numeric($radius))
271
-                        {
272
-                                return false;
273
-                        }
274
-                }
260
+		if ($lng != '')
261
+				{
262
+						if (!is_numeric($lng))
263
+						{
264
+								return false;
265
+						}
266
+				}
267
+
268
+				if ($radius != '')
269
+				{
270
+						if (!is_numeric($radius))
271
+						{
272
+								return false;
273
+						}
274
+				}
275 275
 		$additional_query = '';
276
-        if ($interval != '')
277
-                {
278
-                        if (!is_string($interval))
279
-                        {
280
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
281
-			        return false;
282
-                        } else {
283
-                if ($interval == '1m')
284
-                {
285
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
286
-                } else if ($interval == '15m'){
287
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
288
-                } 
289
-            }
290
-                } else {
291
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
292
-        }
293
-
294
-                $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 
276
+		if ($interval != '')
277
+				{
278
+						if (!is_string($interval))
279
+						{
280
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
281
+					return false;
282
+						} else {
283
+				if ($interval == '1m')
284
+				{
285
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
286
+				} else if ($interval == '15m'){
287
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
288
+				} 
289
+			}
290
+				} else {
291
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
292
+		}
293
+
294
+				$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 
295 295
                    WHERE spotter_live.latitude <> '' 
296 296
                                    AND spotter_live.longitude <> '' 
297 297
                    ".$additional_query."
298 298
                    HAVING distance < :radius  
299 299
                                    ORDER BY distance";
300 300
 
301
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
301
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
302 302
 
303
-                return $spotter_array;
304
-        }
303
+				return $spotter_array;
304
+		}
305 305
 
306 306
     
307
-        /**
308
-	* Gets all the spotter information based on a particular callsign
309
-	*
310
-	* @return Array the spotter information
311
-	*
312
-	*/
307
+		/**
308
+		 * Gets all the spotter information based on a particular callsign
309
+		 *
310
+		 * @return Array the spotter information
311
+		 *
312
+		 */
313 313
 	public function getLastLiveSpotterDataByIdent($ident)
314 314
 	{
315 315
 		$Spotter = new Spotter($this->db);
316 316
 		date_default_timezone_set('UTC');
317 317
 
318 318
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
319
-                $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';
319
+				$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';
320 320
 
321 321
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
322 322
 
323 323
 		return $spotter_array;
324 324
 	}
325 325
 
326
-        /**
327
-	* Gets all the spotter information based on a particular callsign
328
-	*
329
-	* @return Array the spotter information
330
-	*
331
-	*/
326
+		/**
327
+		 * Gets all the spotter information based on a particular callsign
328
+		 *
329
+		 * @return Array the spotter information
330
+		 *
331
+		 */
332 332
 	public function getDateLiveSpotterDataByIdent($ident,$date)
333 333
 	{
334 334
 		$Spotter = new Spotter($this->db);
335 335
 		date_default_timezone_set('UTC');
336 336
 
337 337
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
338
-                $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';
338
+				$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';
339 339
 
340
-                $date = date('c',$date);
340
+				$date = date('c',$date);
341 341
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
342 342
 
343 343
 		return $spotter_array;
344 344
 	}
345 345
 
346
-        /**
347
-	* Gets last spotter information based on a particular callsign
348
-	*
349
-	* @return Array the spotter information
350
-	*
351
-	*/
346
+		/**
347
+		 * Gets last spotter information based on a particular callsign
348
+		 *
349
+		 * @return Array the spotter information
350
+		 *
351
+		 */
352 352
 	public function getLastLiveSpotterDataById($id)
353 353
 	{
354 354
 		$Spotter = new Spotter($this->db);
355 355
 		date_default_timezone_set('UTC');
356 356
 
357 357
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
358
-                $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';
358
+				$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';
359 359
 
360 360
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
361 361
 
362 362
 		return $spotter_array;
363 363
 	}
364 364
 
365
-        /**
366
-	* Gets last spotter information based on a particular callsign
367
-	*
368
-	* @return Array the spotter information
369
-	*
370
-	*/
365
+		/**
366
+		 * Gets last spotter information based on a particular callsign
367
+		 *
368
+		 * @return Array the spotter information
369
+		 *
370
+		 */
371 371
 	public function getDateLiveSpotterDataById($id,$date)
372 372
 	{
373 373
 		$Spotter = new Spotter($this->db);
374 374
 		date_default_timezone_set('UTC');
375 375
 
376 376
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
377
-                $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';
378
-                $date = date('c',$date);
377
+				$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';
378
+				$date = date('c',$date);
379 379
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
380 380
 
381 381
 		return $spotter_array;
382 382
 	}
383 383
 
384
-        /**
385
-	* Gets altitude information based on a particular callsign
386
-	*
387
-	* @return Array the spotter information
388
-	*
389
-	*/
384
+		/**
385
+		 * Gets altitude information based on a particular callsign
386
+		 *
387
+		 * @return Array the spotter information
388
+		 *
389
+		 */
390 390
 	public function getAltitudeLiveSpotterDataByIdent($ident)
391 391
 	{
392 392
 
393 393
 		date_default_timezone_set('UTC');
394 394
 
395 395
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
396
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
396
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
397 397
 
398
-    		try {
398
+			try {
399 399
 			
400 400
 			$sth = $this->db->prepare($query);
401 401
 			$sth->execute(array(':ident' => $ident));
@@ -408,12 +408,12 @@  discard block
 block discarded – undo
408 408
 		return $spotter_array;
409 409
 	}
410 410
 
411
-        /**
412
-	* Gets all the spotter information based on a particular id
413
-	*
414
-	* @return Array the spotter information
415
-	*
416
-	*/
411
+		/**
412
+		 * Gets all the spotter information based on a particular id
413
+		 *
414
+		 * @return Array the spotter information
415
+		 *
416
+		 */
417 417
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
418 418
 	{
419 419
 		global $globalDBdriver, $globalLiveInterval;
@@ -441,18 +441,18 @@  discard block
 block discarded – undo
441 441
 		return $spotter_array;
442 442
 	}
443 443
 
444
-        /**
445
-	* Gets all the spotter information based on a particular ident
446
-	*
447
-	* @return Array the spotter information
448
-	*
449
-	*/
444
+		/**
445
+		 * Gets all the spotter information based on a particular ident
446
+		 *
447
+		 * @return Array the spotter information
448
+		 *
449
+		 */
450 450
 	public function getAllLiveSpotterDataByIdent($ident)
451 451
 	{
452 452
 		date_default_timezone_set('UTC');
453 453
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
454 454
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
455
-    		try {
455
+			try {
456 456
 			
457 457
 			$sth = $this->db->prepare($query);
458 458
 			$sth->execute(array(':ident' => $ident));
@@ -466,23 +466,23 @@  discard block
 block discarded – undo
466 466
 
467 467
 
468 468
 	/**
469
-	* Deletes all info in the table
470
-	*
471
-	* @return String success or false
472
-	*
473
-	*/
469
+	 * Deletes all info in the table
470
+	 *
471
+	 * @return String success or false
472
+	 *
473
+	 */
474 474
 	public function deleteLiveSpotterData()
475 475
 	{
476 476
 		global $globalDBdriver;
477 477
 		if ($globalDBdriver == 'mysql') {
478 478
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
479 479
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
480
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
480
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
481 481
 		} else {
482 482
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
483 483
 		}
484 484
         
485
-    		try {
485
+			try {
486 486
 			
487 487
 			$sth = $this->db->prepare($query);
488 488
 			$sth->execute();
@@ -494,18 +494,18 @@  discard block
 block discarded – undo
494 494
 	}
495 495
 
496 496
 	/**
497
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
498
-	*
499
-	* @return String success or false
500
-	*
501
-	*/
497
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
498
+	 *
499
+	 * @return String success or false
500
+	 *
501
+	 */
502 502
 	public function deleteLiveSpotterDataNotUpdated()
503 503
 	{
504 504
 		global $globalDBdriver, $globalDebug;
505 505
 		if ($globalDBdriver == 'mysql') {
506 506
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
507
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
508
-    			try {
507
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
508
+				try {
509 509
 				
510 510
 				$sth = $this->db->prepare($query);
511 511
 				$sth->execute();
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 				return "error";
514 514
 			}
515 515
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
516
-                        $i = 0;
517
-                        $j =0;
516
+						$i = 0;
517
+						$j =0;
518 518
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
519 519
 			foreach($all as $row)
520 520
 			{
@@ -522,20 +522,20 @@  discard block
 block discarded – undo
522 522
 				$j++;
523 523
 				if ($j == 30) {
524 524
 					if ($globalDebug) echo ".";
525
-				    	try {
525
+						try {
526 526
 						
527 527
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
528 528
 						$sth->execute();
529 529
 					} catch(PDOException $e) {
530 530
 						return "error";
531 531
 					}
532
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
533
-                                	$j = 0;
532
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
533
+									$j = 0;
534 534
 				}
535 535
 				$query_delete .= "'".$row['flightaware_id']."',";
536 536
 			}
537 537
 			if ($i > 0) {
538
-    				try {
538
+					try {
539 539
 					
540 540
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
541 541
 					$sth->execute();
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 			return "success";
547 547
 		} elseif ($globalDBdriver == 'pgsql') {
548 548
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
549
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
550
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
551
-    			try {
549
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
550
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
551
+				try {
552 552
 				
553 553
 				$sth = $this->db->prepare($query);
554 554
 				$sth->execute();
@@ -592,17 +592,17 @@  discard block
 block discarded – undo
592 592
 	}
593 593
 
594 594
 	/**
595
-	* Deletes all info in the table for an ident
596
-	*
597
-	* @return String success or false
598
-	*
599
-	*/
595
+	 * Deletes all info in the table for an ident
596
+	 *
597
+	 * @return String success or false
598
+	 *
599
+	 */
600 600
 	public function deleteLiveSpotterDataByIdent($ident)
601 601
 	{
602 602
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
603 603
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
604 604
         
605
-    		try {
605
+			try {
606 606
 			
607 607
 			$sth = $this->db->prepare($query);
608 608
 			$sth->execute(array(':ident' => $ident));
@@ -614,17 +614,17 @@  discard block
 block discarded – undo
614 614
 	}
615 615
 
616 616
 	/**
617
-	* Deletes all info in the table for an id
618
-	*
619
-	* @return String success or false
620
-	*
621
-	*/
617
+	 * Deletes all info in the table for an id
618
+	 *
619
+	 * @return String success or false
620
+	 *
621
+	 */
622 622
 	public function deleteLiveSpotterDataById($id)
623 623
 	{
624 624
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
625 625
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
626 626
         
627
-    		try {
627
+			try {
628 628
 			
629 629
 			$sth = $this->db->prepare($query);
630 630
 			$sth->execute(array(':id' => $id));
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
 
638 638
 
639 639
 	/**
640
-	* Gets the aircraft ident within the last hour
641
-	*
642
-	* @return String the ident
643
-	*
644
-	*/
640
+	 * Gets the aircraft ident within the last hour
641
+	 *
642
+	 * @return String the ident
643
+	 *
644
+	 */
645 645
 	public function getIdentFromLastHour($ident)
646 646
 	{
647 647
 		global $globalDBdriver, $globalTimezone;
@@ -667,14 +667,14 @@  discard block
 block discarded – undo
667 667
 			$ident_result = $row['ident'];
668 668
 		}
669 669
 		return $ident_result;
670
-        }
670
+		}
671 671
 
672 672
 	/**
673
-	* Check recent aircraft
674
-	*
675
-	* @return String the ident
676
-	*
677
-	*/
673
+	 * Check recent aircraft
674
+	 *
675
+	 * @return String the ident
676
+	 *
677
+	 */
678 678
 	public function checkIdentRecent($ident)
679 679
 	{
680 680
 		global $globalDBdriver, $globalTimezone;
@@ -700,14 +700,14 @@  discard block
 block discarded – undo
700 700
 			$ident_result = $row['flightaware_id'];
701 701
 		}
702 702
 		return $ident_result;
703
-        }
703
+		}
704 704
 
705 705
 	/**
706
-	* Check recent aircraft by id
707
-	*
708
-	* @return String the ident
709
-	*
710
-	*/
706
+	 * Check recent aircraft by id
707
+	 *
708
+	 * @return String the ident
709
+	 *
710
+	 */
711 711
 	public function checkIdRecent($id)
712 712
 	{
713 713
 		global $globalDBdriver, $globalTimezone;
@@ -733,14 +733,14 @@  discard block
 block discarded – undo
733 733
 			$ident_result = $row['flightaware_id'];
734 734
 		}
735 735
 		return $ident_result;
736
-        }
736
+		}
737 737
 
738 738
 	/**
739
-	* Check recent aircraft by ModeS
740
-	*
741
-	* @return String the ModeS
742
-	*
743
-	*/
739
+	 * Check recent aircraft by ModeS
740
+	 *
741
+	 * @return String the ModeS
742
+	 *
743
+	 */
744 744
 	public function checkModeSRecent($modes)
745 745
 	{
746 746
 		global $globalDBdriver, $globalTimezone;
@@ -767,19 +767,19 @@  discard block
 block discarded – undo
767 767
 			$ident_result = $row['flightaware_id'];
768 768
 		}
769 769
 		return $ident_result;
770
-        }
770
+		}
771 771
 
772 772
 	/**
773
-	* Adds a new spotter data
774
-	*
775
-	* @param String $flightaware_id the ID from flightaware
776
-	* @param String $ident the flight ident
777
-	* @param String $aircraft_icao the aircraft type
778
-	* @param String $departure_airport_icao the departure airport
779
-	* @param String $arrival_airport_icao the arrival airport
780
-	* @return String success or false
781
-	*
782
-	*/
773
+	 * Adds a new spotter data
774
+	 *
775
+	 * @param String $flightaware_id the ID from flightaware
776
+	 * @param String $ident the flight ident
777
+	 * @param String $aircraft_icao the aircraft type
778
+	 * @param String $departure_airport_icao the departure airport
779
+	 * @param String $arrival_airport_icao the arrival airport
780
+	 * @return String success or false
781
+	 *
782
+	 */
783 783
 	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 = '')
784 784
 	{
785 785
 		global $globalURL, $globalArchive, $globalDebug;
@@ -915,10 +915,10 @@  discard block
 block discarded – undo
915 915
 		$arrival_airport_country = '';
916 916
 		
917 917
             	
918
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
919
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
920
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
921
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
918
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
919
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
920
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
921
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
922 922
             	
923 923
 		$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) 
924 924
 		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)';
@@ -929,13 +929,13 @@  discard block
 block discarded – undo
929 929
 			
930 930
 			$sth = $this->db->prepare($query);
931 931
 			$sth->execute($query_values);
932
-                } catch(PDOException $e) {
933
-                	return "error : ".$e->getMessage();
934
-                }
932
+				} catch(PDOException $e) {
933
+					return "error : ".$e->getMessage();
934
+				}
935 935
 		if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) {
936
-		    if ($globalDebug) echo '(Add to SBS archive : ';
937
-		    $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);
938
-		    if ($globalDebug) echo $result.')';
936
+			if ($globalDebug) echo '(Add to SBS archive : ';
937
+			$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);
938
+			if ($globalDebug) echo $result.')';
939 939
 		}
940 940
 		return "success";
941 941
 
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@  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, $globalStatsFilter, $globalFilterName;
21
-		if (is_array($globalStatsFilter) && isset($globalStatsFilter[$globalFilterName])) $filter = array_merge($globalStatsFilter[$globalFilterName],$filter);
22
-		if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter);
21
+		if (is_array($globalStatsFilter) && isset($globalStatsFilter[$globalFilterName])) $filter = array_merge($globalStatsFilter[$globalFilterName], $filter);
22
+		if (is_array($globalFilter)) $filter = array_merge($globalFilter, $filter);
23 23
 		$filter_query_join = '';
24 24
 		$filter_query_where = '';
25 25
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
26 26
 			if ($filter['airlines'][0] != '') {
27
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
27
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
28 28
 			}
29 29
 		}
30 30
 		
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
 			$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 ";
33 33
 		}
34 34
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
35
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
35
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
36 36
 		}
37 37
 		if (isset($filter['source']) && !empty($filter['source'])) {
38
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
38
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
39 39
 		}
40 40
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
41 41
 			if ($filter_query_where == '') {
42
-				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
42
+				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
43 43
 			} else {
44
-				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
44
+				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
45 45
 			}
46 46
 		}
47 47
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 		if ($limit != '')
68 68
 		{
69 69
 			$limit_array = explode(',', $limit);
70
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
71
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
70
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
71
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
72 72
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
73 73
 			{
74 74
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
113 113
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
114 114
 
115
-			$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 
115
+			$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 
116 116
 			FROM spotter_live 
117 117
 			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.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao';
118 118
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '30 SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
124 124
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
125 125
 			//$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
126
-			$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 
126
+			$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 
127 127
 			FROM spotter_live
128 128
 			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.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao';
129 129
 		}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		try {
134 134
 			$sth = $this->db->prepare($query);
135 135
 			$sth->execute();
136
-		} catch(PDOException $e) {
136
+		} catch (PDOException $e) {
137 137
 			echo $e->getMessage();
138 138
 			die;
139 139
 		}
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 		global $globalDBdriver, $globalLiveInterval;
154 154
 		date_default_timezone_set('UTC');
155 155
 
156
-		$filter_query = $this->getFilter($filter,true,true);
156
+		$filter_query = $this->getFilter($filter, true, true);
157 157
 
158 158
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
159 159
 		if ($globalDBdriver == 'mysql') {
160 160
 
161
-			$query  = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
161
+			$query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
162 162
 			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 
163 163
 			ORDER BY spotter_live.flightaware_id, spotter_live.date';
164 164
                 } else {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 			FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
168 168
 			".$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao ORDER BY spotter_live.flightaware_id, spotter_live.date';
169 169
 */
170
-			$query  = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
170
+			$query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
171 171
 			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 
172 172
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
173 173
 //			echo $query;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     		try {
177 177
 			$sth = $this->db->prepare($query);
178 178
 			$sth->execute();
179
-		} catch(PDOException $e) {
179
+		} catch (PDOException $e) {
180 180
 			echo $e->getMessage();
181 181
 			die;
182 182
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	public function getLiveSpotterCount($filter = array())
194 194
 	{
195 195
 		global $globalDBdriver, $globalLiveInterval;
196
-		$filter_query = $this->getFilter($filter,true,true);
196
+		$filter_query = $this->getFilter($filter, true, true);
197 197
 
198 198
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
199 199
 		if ($globalDBdriver == 'mysql') {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		try {
207 207
 			$sth = $this->db->prepare($query);
208 208
 			$sth->execute();
209
-		} catch(PDOException $e) {
209
+		} catch (PDOException $e) {
210 210
 			echo $e->getMessage();
211 211
 			die;
212 212
 		}
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 		$filter_query = $this->getFilter($filter);
230 230
 
231 231
 		if (is_array($coord)) {
232
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
233
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
234
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
235
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
232
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
233
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
234
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
235
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
236 236
 		} else return array();
237 237
 		if ($globalDBdriver == 'mysql') {
238 238
 			//$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.")";
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                 if ($interval == '1m')
286 286
                 {
287 287
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
288
-                } else if ($interval == '15m'){
288
+                } else if ($interval == '15m') {
289 289
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
290 290
                 } 
291 291
             }
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
294 294
         }
295 295
 
296
-                $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 
296
+                $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 
297 297
                    WHERE spotter_live.latitude <> '' 
298 298
                                    AND spotter_live.longitude <> '' 
299 299
                    ".$additional_query."
300 300
                    HAVING distance < :radius  
301 301
                                    ORDER BY distance";
302 302
 
303
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
303
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
304 304
 
305 305
                 return $spotter_array;
306 306
         }
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
 		date_default_timezone_set('UTC');
319 319
 
320 320
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
321
-                $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';
321
+                $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';
322 322
 
323
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
323
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
324 324
 
325 325
 		return $spotter_array;
326 326
 	}
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 	* @return Array the spotter information
332 332
 	*
333 333
 	*/
334
-	public function getDateLiveSpotterDataByIdent($ident,$date)
334
+	public function getDateLiveSpotterDataByIdent($ident, $date)
335 335
 	{
336 336
 		$Spotter = new Spotter($this->db);
337 337
 		date_default_timezone_set('UTC');
338 338
 
339 339
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
340
-                $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';
340
+                $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';
341 341
 
342
-                $date = date('c',$date);
343
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
342
+                $date = date('c', $date);
343
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
344 344
 
345 345
 		return $spotter_array;
346 346
 	}
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 		date_default_timezone_set('UTC');
358 358
 
359 359
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
360
-                $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';
360
+                $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';
361 361
 
362
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
362
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
363 363
 
364 364
 		return $spotter_array;
365 365
 	}
@@ -370,15 +370,15 @@  discard block
 block discarded – undo
370 370
 	* @return Array the spotter information
371 371
 	*
372 372
 	*/
373
-	public function getDateLiveSpotterDataById($id,$date)
373
+	public function getDateLiveSpotterDataById($id, $date)
374 374
 	{
375 375
 		$Spotter = new Spotter($this->db);
376 376
 		date_default_timezone_set('UTC');
377 377
 
378 378
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
379
-                $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';
380
-                $date = date('c',$date);
381
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
379
+                $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';
380
+                $date = date('c', $date);
381
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
382 382
 
383 383
 		return $spotter_array;
384 384
 	}
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
 		date_default_timezone_set('UTC');
396 396
 
397 397
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
398
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
398
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
399 399
 
400 400
     		try {
401 401
 			
402 402
 			$sth = $this->db->prepare($query);
403 403
 			$sth->execute(array(':ident' => $ident));
404
-		} catch(PDOException $e) {
404
+		} catch (PDOException $e) {
405 405
 			echo $e->getMessage();
406 406
 			die;
407 407
 		}
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	* @return Array the spotter information
417 417
 	*
418 418
 	*/
419
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
419
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
420 420
 	{
421 421
 		global $globalDBdriver, $globalLiveInterval;
422 422
 		date_default_timezone_set('UTC');
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		try {
436 436
 			$sth = $this->db->prepare($query);
437 437
 			$sth->execute(array(':id' => $id));
438
-		} catch(PDOException $e) {
438
+		} catch (PDOException $e) {
439 439
 			echo $e->getMessage();
440 440
 			die;
441 441
 		}
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
 	{
454 454
 		date_default_timezone_set('UTC');
455 455
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
456
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
456
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
457 457
     		try {
458 458
 			
459 459
 			$sth = $this->db->prepare($query);
460 460
 			$sth->execute(array(':ident' => $ident));
461
-		} catch(PDOException $e) {
461
+		} catch (PDOException $e) {
462 462
 			echo $e->getMessage();
463 463
 			die;
464 464
 		}
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 			
489 489
 			$sth = $this->db->prepare($query);
490 490
 			$sth->execute();
491
-		} catch(PDOException $e) {
491
+		} catch (PDOException $e) {
492 492
 			return "error";
493 493
 		}
494 494
 
@@ -511,14 +511,14 @@  discard block
 block discarded – undo
511 511
 				
512 512
 				$sth = $this->db->prepare($query);
513 513
 				$sth->execute();
514
-			} catch(PDOException $e) {
514
+			} catch (PDOException $e) {
515 515
 				return "error";
516 516
 			}
517 517
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
518 518
                         $i = 0;
519
-                        $j =0;
519
+                        $j = 0;
520 520
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
521
-			foreach($all as $row)
521
+			foreach ($all as $row)
522 522
 			{
523 523
 				$i++;
524 524
 				$j++;
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 					if ($globalDebug) echo ".";
527 527
 				    	try {
528 528
 						
529
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
529
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
530 530
 						$sth->execute();
531
-					} catch(PDOException $e) {
531
+					} catch (PDOException $e) {
532 532
 						return "error";
533 533
 					}
534 534
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
 			if ($i > 0) {
540 540
     				try {
541 541
 					
542
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
542
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
543 543
 					$sth->execute();
544
-				} catch(PDOException $e) {
544
+				} catch (PDOException $e) {
545 545
 					return "error";
546 546
 				}
547 547
 			}
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 				
555 555
 				$sth = $this->db->prepare($query);
556 556
 				$sth->execute();
557
-			} catch(PDOException $e) {
557
+			} catch (PDOException $e) {
558 558
 				return "error";
559 559
 			}
560 560
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -602,13 +602,13 @@  discard block
 block discarded – undo
602 602
 	public function deleteLiveSpotterDataByIdent($ident)
603 603
 	{
604 604
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
605
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
605
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
606 606
         
607 607
     		try {
608 608
 			
609 609
 			$sth = $this->db->prepare($query);
610 610
 			$sth->execute(array(':ident' => $ident));
611
-		} catch(PDOException $e) {
611
+		} catch (PDOException $e) {
612 612
 			return "error";
613 613
 		}
614 614
 
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 	public function deleteLiveSpotterDataById($id)
625 625
 	{
626 626
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
627
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
627
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
628 628
         
629 629
     		try {
630 630
 			
631 631
 			$sth = $this->db->prepare($query);
632 632
 			$sth->execute(array(':id' => $id));
633
-		} catch(PDOException $e) {
633
+		} catch (PDOException $e) {
634 634
 			return "error";
635 635
 		}
636 636
 
@@ -648,13 +648,13 @@  discard block
 block discarded – undo
648 648
 	{
649 649
 		global $globalDBdriver, $globalTimezone;
650 650
 		if ($globalDBdriver == 'mysql') {
651
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
651
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
652 652
 				WHERE spotter_live.ident = :ident 
653 653
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
654 654
 				AND spotter_live.date < UTC_TIMESTAMP()';
655 655
 			$query_data = array(':ident' => $ident);
656 656
 		} else {
657
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
657
+			$query = "SELECT spotter_live.ident FROM spotter_live 
658 658
 				WHERE spotter_live.ident = :ident 
659 659
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
660 660
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -663,8 +663,8 @@  discard block
 block discarded – undo
663 663
 		
664 664
 		$sth = $this->db->prepare($query);
665 665
 		$sth->execute($query_data);
666
-		$ident_result='';
667
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
666
+		$ident_result = '';
667
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
668 668
 		{
669 669
 			$ident_result = $row['ident'];
670 670
 		}
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 	{
682 682
 		global $globalDBdriver, $globalTimezone;
683 683
 		if ($globalDBdriver == 'mysql') {
684
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
684
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
685 685
 				WHERE spotter_live.ident = :ident 
686 686
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
687 687
 //				AND spotter_live.date < UTC_TIMESTAMP()";
688 688
 			$query_data = array(':ident' => $ident);
689 689
 		} else {
690
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
690
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
691 691
 				WHERE spotter_live.ident = :ident 
692 692
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
693 693
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 		
697 697
 		$sth = $this->db->prepare($query);
698 698
 		$sth->execute($query_data);
699
-		$ident_result='';
700
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
699
+		$ident_result = '';
700
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
701 701
 		{
702 702
 			$ident_result = $row['flightaware_id'];
703 703
 		}
@@ -714,13 +714,13 @@  discard block
 block discarded – undo
714 714
 	{
715 715
 		global $globalDBdriver, $globalTimezone;
716 716
 		if ($globalDBdriver == 'mysql') {
717
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
717
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
718 718
 				WHERE spotter_live.flightaware_id = :id 
719 719
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
720 720
 //				AND spotter_live.date < UTC_TIMESTAMP()";
721 721
 			$query_data = array(':id' => $id);
722 722
 		} else {
723
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
723
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
724 724
 				WHERE spotter_live.flightaware_id = :id 
725 725
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
726 726
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
 		
730 730
 		$sth = $this->db->prepare($query);
731 731
 		$sth->execute($query_data);
732
-		$ident_result='';
733
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
732
+		$ident_result = '';
733
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
734 734
 		{
735 735
 			$ident_result = $row['flightaware_id'];
736 736
 		}
@@ -747,13 +747,13 @@  discard block
 block discarded – undo
747 747
 	{
748 748
 		global $globalDBdriver, $globalTimezone;
749 749
 		if ($globalDBdriver == 'mysql') {
750
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
750
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
751 751
 				WHERE spotter_live.ModeS = :modes 
752 752
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
753 753
 //				AND spotter_live.date < UTC_TIMESTAMP()";
754 754
 			$query_data = array(':modes' => $modes);
755 755
 		} else {
756
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
756
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
757 757
 				WHERE spotter_live.ModeS = :modes 
758 758
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
759 759
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
 		
763 763
 		$sth = $this->db->prepare($query);
764 764
 		$sth->execute($query_data);
765
-		$ident_result='';
766
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
765
+		$ident_result = '';
766
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
767 767
 		{
768 768
 			//$ident_result = $row['spotter_live_id'];
769 769
 			$ident_result = $row['flightaware_id'];
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 	* @return String success or false
783 783
 	*
784 784
 	*/
785
-	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 = '')
785
+	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 = '')
786 786
 	{
787 787
 		global $globalURL, $globalArchive, $globalDebug;
788 788
 		$Common = new Common();
@@ -876,26 +876,26 @@  discard block
 block discarded – undo
876 876
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
877 877
 
878 878
         
879
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
880
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
881
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
882
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
883
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
884
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
885
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
886
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
887
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
888
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
889
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
890
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
891
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
892
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
893
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
894
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
895
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
896
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
897
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
898
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
879
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
880
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
881
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
882
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
883
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
884
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
885
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
886
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
887
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
888
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
889
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
890
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
891
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
892
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
893
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
894
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
895
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
896
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
897
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
898
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
899 899
 
900 900
 		$airline_name = '';
901 901
 		$airline_icao = '';
@@ -917,26 +917,26 @@  discard block
 block discarded – undo
917 917
 		$arrival_airport_country = '';
918 918
 		
919 919
             	
920
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
921
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
922
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
923
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
920
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
921
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
922
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
923
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
924 924
             	
925
-		$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) 
925
+		$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) 
926 926
 		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)';
927 927
 
928
-		$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);
928
+		$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);
929 929
 		//$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'],':airline_country' => $airline_array[0]['country'],':airline_type' => $airline_array[0]['type'],':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_array[0]['type'],':aircraft_manufacturer' => $aircraft_array[0]['manufacturer'],':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date);
930 930
 		try {
931 931
 			
932 932
 			$sth = $this->db->prepare($query);
933 933
 			$sth->execute($query_values);
934
-                } catch(PDOException $e) {
934
+                } catch (PDOException $e) {
935 935
                 	return "error : ".$e->getMessage();
936 936
                 }
937 937
 		if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) {
938 938
 		    if ($globalDebug) echo '(Add to SBS archive : ';
939
-		    $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);
939
+		    $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);
940 940
 		    if ($globalDebug) echo $result.')';
941 941
 		}
942 942
 		return "success";
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 
946 946
 	public function getOrderBy()
947 947
 	{
948
-		$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"));
948
+		$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"));
949 949
 		return $orderby;
950 950
 	}
951 951
 
Please login to merge, or discard this patch.
Braces   +68 added lines, -23 removed lines patch added patch discarded remove patch
@@ -18,8 +18,12 @@  discard block
 block discarded – undo
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilter, $globalFilterName;
21
-		if (is_array($globalStatsFilter) && isset($globalStatsFilter[$globalFilterName])) $filter = array_merge($globalStatsFilter[$globalFilterName],$filter);
22
-		if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter);
21
+		if (is_array($globalStatsFilter) && isset($globalStatsFilter[$globalFilterName])) {
22
+			$filter = array_merge($globalStatsFilter[$globalFilterName],$filter);
23
+		}
24
+		if (is_array($globalFilter)) {
25
+			$filter = array_merge($globalFilter,$filter);
26
+		}
23 27
 		$filter_query_join = '';
24 28
 		$filter_query_where = '';
25 29
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
@@ -44,8 +48,11 @@  discard block
 block discarded – undo
44 48
 				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
45 49
 			}
46 50
 		}
47
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
48
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
51
+		if ($filter_query_where == '' && $where) {
52
+			$filter_query_where = ' WHERE';
53
+		} elseif ($filter_query_where != '' && $and) {
54
+			$filter_query_where .= ' AND';
55
+		}
49 56
 		$filter_query = $filter_query_join.$filter_query_where;
50 57
 		return $filter_query;
51 58
 	}
@@ -81,7 +88,9 @@  discard block
 block discarded – undo
81 88
 			$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
82 89
 		}
83 90
 
84
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
91
+		if (!isset($globalLiveInterval)) {
92
+			$globalLiveInterval = '200';
93
+		}
85 94
 		if ($globalDBdriver == 'mysql') {
86 95
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
87 96
 			$query  = 'SELECT spotter_live.* 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.$orderby_query;
@@ -106,7 +115,9 @@  discard block
 block discarded – undo
106 115
 
107 116
 		$filter_query = $this->getFilter($filter);
108 117
 
109
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
118
+		if (!isset($globalLiveInterval)) {
119
+			$globalLiveInterval = '200';
120
+		}
110 121
 		if ($globalDBdriver == 'mysql') {
111 122
 //			$query  = "SELECT spotter_live.* 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$orderby_query";
112 123
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
@@ -155,7 +166,9 @@  discard block
 block discarded – undo
155 166
 
156 167
 		$filter_query = $this->getFilter($filter,true,true);
157 168
 
158
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
169
+		if (!isset($globalLiveInterval)) {
170
+			$globalLiveInterval = '200';
171
+		}
159 172
 		if ($globalDBdriver == 'mysql') {
160 173
 
161 174
 			$query  = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -195,7 +208,9 @@  discard block
 block discarded – undo
195 208
 		global $globalDBdriver, $globalLiveInterval;
196 209
 		$filter_query = $this->getFilter($filter,true,true);
197 210
 
198
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
211
+		if (!isset($globalLiveInterval)) {
212
+			$globalLiveInterval = '200';
213
+		}
199 214
 		if ($globalDBdriver == 'mysql') {
200 215
 			//$query  = 'SELECT COUNT(*) as nb 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;
201 216
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -225,7 +240,9 @@  discard block
 block discarded – undo
225 240
 	{
226 241
 		global $globalDBdriver, $globalLiveInterval;
227 242
 		$Spotter = new Spotter($this->db);
228
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
243
+		if (!isset($globalLiveInterval)) {
244
+			$globalLiveInterval = '200';
245
+		}
229 246
 		$filter_query = $this->getFilter($filter);
230 247
 
231 248
 		if (is_array($coord)) {
@@ -233,7 +250,9 @@  discard block
 block discarded – undo
233 250
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
234 251
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
235 252
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
236
-		} else return array();
253
+		} else {
254
+			return array();
255
+		}
237 256
 		if ($globalDBdriver == 'mysql') {
238 257
 			//$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.")";
239 258
 			$query  = 'SELECT spotter_live.* 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.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -424,11 +443,15 @@  discard block
 block discarded – undo
424 443
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
425 444
 		if ($globalDBdriver == 'mysql') {
426 445
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
427
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
446
+			if ($liveinterval) {
447
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
448
+			}
428 449
 			$query .= ' ORDER BY date';
429 450
 		} else {
430 451
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
431
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
452
+			if ($liveinterval) {
453
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
454
+			}
432 455
 			$query .= ' ORDER BY date';
433 456
 		}
434 457
 
@@ -523,7 +546,9 @@  discard block
 block discarded – undo
523 546
 				$i++;
524 547
 				$j++;
525 548
 				if ($j == 30) {
526
-					if ($globalDebug) echo ".";
549
+					if ($globalDebug) {
550
+						echo ".";
551
+					}
527 552
 				    	try {
528 553
 						
529 554
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -855,7 +880,9 @@  discard block
 block discarded – undo
855 880
 			{
856 881
 				return false;
857 882
 			}
858
-		} else $altitude = 0;
883
+		} else {
884
+			$altitude = 0;
885
+		}
859 886
 
860 887
 		if ($heading != '')
861 888
 		{
@@ -863,7 +890,9 @@  discard block
 block discarded – undo
863 890
 			{
864 891
 				return false;
865 892
 			}
866
-		} else $heading = 0;
893
+		} else {
894
+			$heading = 0;
895
+		}
867 896
 
868 897
 		if ($groundspeed != '')
869 898
 		{
@@ -871,9 +900,13 @@  discard block
 block discarded – undo
871 900
 			{
872 901
 				return false;
873 902
 			}
874
-		} else $groundspeed = 0;
903
+		} else {
904
+			$groundspeed = 0;
905
+		}
875 906
 		date_default_timezone_set('UTC');
876
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
907
+		if ($date == '') {
908
+			$date = date("Y-m-d H:i:s", time());
909
+		}
877 910
 
878 911
         
879 912
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -917,10 +950,18 @@  discard block
 block discarded – undo
917 950
 		$arrival_airport_country = '';
918 951
 		
919 952
             	
920
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
921
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
922
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
923
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
953
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
954
+            		$squawk = NULL;
955
+            	}
956
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
957
+            		$verticalrate = NULL;
958
+            	}
959
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
960
+            		$groundspeed = 0;
961
+            	}
962
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
963
+            		$heading = 0;
964
+            	}
924 965
             	
925 966
 		$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) 
926 967
 		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)';
@@ -935,9 +976,13 @@  discard block
 block discarded – undo
935 976
                 	return "error : ".$e->getMessage();
936 977
                 }
937 978
 		if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) {
938
-		    if ($globalDebug) echo '(Add to SBS archive : ';
979
+		    if ($globalDebug) {
980
+		    	echo '(Add to SBS archive : ';
981
+		    }
939 982
 		    $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);
940
-		    if ($globalDebug) echo $result.')';
983
+		    if ($globalDebug) {
984
+		    	echo $result.')';
985
+		    }
941 986
 		}
942 987
 		return "success";
943 988
 
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Braces   +220 added lines, -82 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1102,8 +1160,11 @@  discard block
 block discarded – undo
1102 1160
     	    if ($Connection->tableExists('aircraft')) {
1103 1161
     		if (!$Connection->tableExists('config')) {
1104 1162
     		    $version = '1';
1105
-    		    if ($update) return self::update_from_1();
1106
-    		    else return $version;
1163
+    		    if ($update) {
1164
+    		    	return self::update_from_1();
1165
+    		    } else {
1166
+    		    	return $version;
1167
+    		    }
1107 1168
 		} else {
1108 1169
     		    $Connection = new Connection();
1109 1170
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1117,106 +1178,183 @@  discard block
 block discarded – undo
1117 1178
     		    if ($update) {
1118 1179
     			if ($result['value'] == '2') {
1119 1180
     			    $error = self::update_from_2();
1120
-    			    if ($error != '') return $error;
1121
-    			    else return self::check_version(true);
1181
+    			    if ($error != '') {
1182
+    			    	return $error;
1183
+    			    } else {
1184
+    			    	return self::check_version(true);
1185
+    			    }
1122 1186
     			} elseif ($result['value'] == '3') {
1123 1187
     			    $error = self::update_from_3();
1124
-    			    if ($error != '') return $error;
1125
-    			    else return self::check_version(true);
1188
+    			    if ($error != '') {
1189
+    			    	return $error;
1190
+    			    } else {
1191
+    			    	return self::check_version(true);
1192
+    			    }
1126 1193
     			} elseif ($result['value'] == '4') {
1127 1194
     			    $error = self::update_from_4();
1128
-    			    if ($error != '') return $error;
1129
-    			    else return self::check_version(true);
1195
+    			    if ($error != '') {
1196
+    			    	return $error;
1197
+    			    } else {
1198
+    			    	return self::check_version(true);
1199
+    			    }
1130 1200
     			} elseif ($result['value'] == '5') {
1131 1201
     			    $error = self::update_from_5();
1132
-    			    if ($error != '') return $error;
1133
-    			    else return self::check_version(true);
1202
+    			    if ($error != '') {
1203
+    			    	return $error;
1204
+    			    } else {
1205
+    			    	return self::check_version(true);
1206
+    			    }
1134 1207
     			} elseif ($result['value'] == '6') {
1135 1208
     			    $error = self::update_from_6();
1136
-    			    if ($error != '') return $error;
1137
-    			    else return self::check_version(true);
1209
+    			    if ($error != '') {
1210
+    			    	return $error;
1211
+    			    } else {
1212
+    			    	return self::check_version(true);
1213
+    			    }
1138 1214
     			} elseif ($result['value'] == '7') {
1139 1215
     			    $error = self::update_from_7();
1140
-    			    if ($error != '') return $error;
1141
-    			    else return self::check_version(true);
1216
+    			    if ($error != '') {
1217
+    			    	return $error;
1218
+    			    } else {
1219
+    			    	return self::check_version(true);
1220
+    			    }
1142 1221
     			} elseif ($result['value'] == '8') {
1143 1222
     			    $error = self::update_from_8();
1144
-    			    if ($error != '') return $error;
1145
-    			    else return self::check_version(true);
1223
+    			    if ($error != '') {
1224
+    			    	return $error;
1225
+    			    } else {
1226
+    			    	return self::check_version(true);
1227
+    			    }
1146 1228
     			} elseif ($result['value'] == '9') {
1147 1229
     			    $error = self::update_from_9();
1148
-    			    if ($error != '') return $error;
1149
-    			    else return self::check_version(true);
1230
+    			    if ($error != '') {
1231
+    			    	return $error;
1232
+    			    } else {
1233
+    			    	return self::check_version(true);
1234
+    			    }
1150 1235
     			} elseif ($result['value'] == '10') {
1151 1236
     			    $error = self::update_from_10();
1152
-    			    if ($error != '') return $error;
1153
-    			    else return self::check_version(true);
1237
+    			    if ($error != '') {
1238
+    			    	return $error;
1239
+    			    } else {
1240
+    			    	return self::check_version(true);
1241
+    			    }
1154 1242
     			} elseif ($result['value'] == '11') {
1155 1243
     			    $error = self::update_from_11();
1156
-    			    if ($error != '') return $error;
1157
-    			    else return self::check_version(true);
1244
+    			    if ($error != '') {
1245
+    			    	return $error;
1246
+    			    } else {
1247
+    			    	return self::check_version(true);
1248
+    			    }
1158 1249
     			} elseif ($result['value'] == '12') {
1159 1250
     			    $error = self::update_from_12();
1160
-    			    if ($error != '') return $error;
1161
-    			    else return self::check_version(true);
1251
+    			    if ($error != '') {
1252
+    			    	return $error;
1253
+    			    } else {
1254
+    			    	return self::check_version(true);
1255
+    			    }
1162 1256
     			} elseif ($result['value'] == '13') {
1163 1257
     			    $error = self::update_from_13();
1164
-    			    if ($error != '') return $error;
1165
-    			    else return self::check_version(true);
1258
+    			    if ($error != '') {
1259
+    			    	return $error;
1260
+    			    } else {
1261
+    			    	return self::check_version(true);
1262
+    			    }
1166 1263
     			} elseif ($result['value'] == '14') {
1167 1264
     			    $error = self::update_from_14();
1168
-    			    if ($error != '') return $error;
1169
-    			    else return self::check_version(true);
1265
+    			    if ($error != '') {
1266
+    			    	return $error;
1267
+    			    } else {
1268
+    			    	return self::check_version(true);
1269
+    			    }
1170 1270
     			} elseif ($result['value'] == '15') {
1171 1271
     			    $error = self::update_from_15();
1172
-    			    if ($error != '') return $error;
1173
-    			    else return self::check_version(true);
1272
+    			    if ($error != '') {
1273
+    			    	return $error;
1274
+    			    } else {
1275
+    			    	return self::check_version(true);
1276
+    			    }
1174 1277
     			} elseif ($result['value'] == '16') {
1175 1278
     			    $error = self::update_from_16();
1176
-    			    if ($error != '') return $error;
1177
-    			    else return self::check_version(true);
1279
+    			    if ($error != '') {
1280
+    			    	return $error;
1281
+    			    } else {
1282
+    			    	return self::check_version(true);
1283
+    			    }
1178 1284
     			} elseif ($result['value'] == '17') {
1179 1285
     			    $error = self::update_from_17();
1180
-    			    if ($error != '') return $error;
1181
-    			    else return self::check_version(true);
1286
+    			    if ($error != '') {
1287
+    			    	return $error;
1288
+    			    } else {
1289
+    			    	return self::check_version(true);
1290
+    			    }
1182 1291
     			} elseif ($result['value'] == '18') {
1183 1292
     			    $error = self::update_from_18();
1184
-    			    if ($error != '') return $error;
1185
-    			    else return self::check_version(true);
1293
+    			    if ($error != '') {
1294
+    			    	return $error;
1295
+    			    } else {
1296
+    			    	return self::check_version(true);
1297
+    			    }
1186 1298
     			} elseif ($result['value'] == '19') {
1187 1299
     			    $error = self::update_from_19();
1188
-    			    if ($error != '') return $error;
1189
-    			    else return self::check_version(true);
1300
+    			    if ($error != '') {
1301
+    			    	return $error;
1302
+    			    } else {
1303
+    			    	return self::check_version(true);
1304
+    			    }
1190 1305
     			} elseif ($result['value'] == '20') {
1191 1306
     			    $error = self::update_from_20();
1192
-    			    if ($error != '') return $error;
1193
-    			    else return self::check_version(true);
1307
+    			    if ($error != '') {
1308
+    			    	return $error;
1309
+    			    } else {
1310
+    			    	return self::check_version(true);
1311
+    			    }
1194 1312
     			} elseif ($result['value'] == '21') {
1195 1313
     			    $error = self::update_from_21();
1196
-    			    if ($error != '') return $error;
1197
-    			    else return self::check_version(true);
1314
+    			    if ($error != '') {
1315
+    			    	return $error;
1316
+    			    } else {
1317
+    			    	return self::check_version(true);
1318
+    			    }
1198 1319
     			} elseif ($result['value'] == '22') {
1199 1320
     			    $error = self::update_from_22();
1200
-    			    if ($error != '') return $error;
1201
-    			    else return self::check_version(true);
1321
+    			    if ($error != '') {
1322
+    			    	return $error;
1323
+    			    } else {
1324
+    			    	return self::check_version(true);
1325
+    			    }
1202 1326
     			} elseif ($result['value'] == '23') {
1203 1327
     			    $error = self::update_from_23();
1204
-    			    if ($error != '') return $error;
1205
-    			    else return self::check_version(true);
1328
+    			    if ($error != '') {
1329
+    			    	return $error;
1330
+    			    } else {
1331
+    			    	return self::check_version(true);
1332
+    			    }
1206 1333
     			} elseif ($result['value'] == '24') {
1207 1334
     			    $error = self::update_from_24();
1208
-    			    if ($error != '') return $error;
1209
-    			    else return self::check_version(true);
1335
+    			    if ($error != '') {
1336
+    			    	return $error;
1337
+    			    } else {
1338
+    			    	return self::check_version(true);
1339
+    			    }
1210 1340
     			} elseif ($result['value'] == '25') {
1211 1341
     			    $error = self::update_from_25();
1212
-    			    if ($error != '') return $error;
1213
-    			    else return self::check_version(true);
1214
-    			} else return '';
1342
+    			    if ($error != '') {
1343
+    			    	return $error;
1344
+    			    } else {
1345
+    			    	return self::check_version(true);
1346
+    			    }
1347
+    			} else {
1348
+    				return '';
1349
+    			}
1350
+    		    } else {
1351
+    		    	return $result['value'];
1215 1352
     		    }
1216
-    		    else return $result['value'];
1217 1353
 		}
1218 1354
 		
1219
-	    } else return $version;
1355
+	    } else {
1356
+	    	return $version;
1357
+	    }
1220 1358
     	}
1221 1359
     	
1222 1360
 }
Please login to merge, or discard this patch.
Indentation   +558 added lines, -558 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1112,129 +1112,129 @@  discard block
 block discarded – undo
1112 1112
 
1113 1113
 
1114 1114
 
1115
-    	public static function check_version($update = false) {
1116
-    	    global $globalDBname;
1117
-    	    $version = 0;
1118
-    	    $Connection = new Connection();
1119
-    	    if ($Connection->tableExists('aircraft')) {
1120
-    		if (!$Connection->tableExists('config')) {
1121
-    		    $version = '1';
1122
-    		    if ($update) return self::update_from_1();
1123
-    		    else return $version;
1115
+		public static function check_version($update = false) {
1116
+			global $globalDBname;
1117
+			$version = 0;
1118
+			$Connection = new Connection();
1119
+			if ($Connection->tableExists('aircraft')) {
1120
+			if (!$Connection->tableExists('config')) {
1121
+				$version = '1';
1122
+				if ($update) return self::update_from_1();
1123
+				else return $version;
1124 1124
 		} else {
1125
-    		    $Connection = new Connection();
1126
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1127
-		    try {
1128
-            		$sth = $Connection->db->prepare($query);
1129
-		        $sth->execute();
1130
-		    } catch(PDOException $e) {
1125
+				$Connection = new Connection();
1126
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1127
+			try {
1128
+					$sth = $Connection->db->prepare($query);
1129
+				$sth->execute();
1130
+			} catch(PDOException $e) {
1131 1131
 			return "error : ".$e->getMessage()."\n";
1132
-    		    }
1133
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1134
-    		    if ($update) {
1135
-    			if ($result['value'] == '2') {
1136
-    			    $error = self::update_from_2();
1137
-    			    if ($error != '') return $error;
1138
-    			    else return self::check_version(true);
1139
-    			} elseif ($result['value'] == '3') {
1140
-    			    $error = self::update_from_3();
1141
-    			    if ($error != '') return $error;
1142
-    			    else return self::check_version(true);
1143
-    			} elseif ($result['value'] == '4') {
1144
-    			    $error = self::update_from_4();
1145
-    			    if ($error != '') return $error;
1146
-    			    else return self::check_version(true);
1147
-    			} elseif ($result['value'] == '5') {
1148
-    			    $error = self::update_from_5();
1149
-    			    if ($error != '') return $error;
1150
-    			    else return self::check_version(true);
1151
-    			} elseif ($result['value'] == '6') {
1152
-    			    $error = self::update_from_6();
1153
-    			    if ($error != '') return $error;
1154
-    			    else return self::check_version(true);
1155
-    			} elseif ($result['value'] == '7') {
1156
-    			    $error = self::update_from_7();
1157
-    			    if ($error != '') return $error;
1158
-    			    else return self::check_version(true);
1159
-    			} elseif ($result['value'] == '8') {
1160
-    			    $error = self::update_from_8();
1161
-    			    if ($error != '') return $error;
1162
-    			    else return self::check_version(true);
1163
-    			} elseif ($result['value'] == '9') {
1164
-    			    $error = self::update_from_9();
1165
-    			    if ($error != '') return $error;
1166
-    			    else return self::check_version(true);
1167
-    			} elseif ($result['value'] == '10') {
1168
-    			    $error = self::update_from_10();
1169
-    			    if ($error != '') return $error;
1170
-    			    else return self::check_version(true);
1171
-    			} elseif ($result['value'] == '11') {
1172
-    			    $error = self::update_from_11();
1173
-    			    if ($error != '') return $error;
1174
-    			    else return self::check_version(true);
1175
-    			} elseif ($result['value'] == '12') {
1176
-    			    $error = self::update_from_12();
1177
-    			    if ($error != '') return $error;
1178
-    			    else return self::check_version(true);
1179
-    			} elseif ($result['value'] == '13') {
1180
-    			    $error = self::update_from_13();
1181
-    			    if ($error != '') return $error;
1182
-    			    else return self::check_version(true);
1183
-    			} elseif ($result['value'] == '14') {
1184
-    			    $error = self::update_from_14();
1185
-    			    if ($error != '') return $error;
1186
-    			    else return self::check_version(true);
1187
-    			} elseif ($result['value'] == '15') {
1188
-    			    $error = self::update_from_15();
1189
-    			    if ($error != '') return $error;
1190
-    			    else return self::check_version(true);
1191
-    			} elseif ($result['value'] == '16') {
1192
-    			    $error = self::update_from_16();
1193
-    			    if ($error != '') return $error;
1194
-    			    else return self::check_version(true);
1195
-    			} elseif ($result['value'] == '17') {
1196
-    			    $error = self::update_from_17();
1197
-    			    if ($error != '') return $error;
1198
-    			    else return self::check_version(true);
1199
-    			} elseif ($result['value'] == '18') {
1200
-    			    $error = self::update_from_18();
1201
-    			    if ($error != '') return $error;
1202
-    			    else return self::check_version(true);
1203
-    			} elseif ($result['value'] == '19') {
1204
-    			    $error = self::update_from_19();
1205
-    			    if ($error != '') return $error;
1206
-    			    else return self::check_version(true);
1207
-    			} elseif ($result['value'] == '20') {
1208
-    			    $error = self::update_from_20();
1209
-    			    if ($error != '') return $error;
1210
-    			    else return self::check_version(true);
1211
-    			} elseif ($result['value'] == '21') {
1212
-    			    $error = self::update_from_21();
1213
-    			    if ($error != '') return $error;
1214
-    			    else return self::check_version(true);
1215
-    			} elseif ($result['value'] == '22') {
1216
-    			    $error = self::update_from_22();
1217
-    			    if ($error != '') return $error;
1218
-    			    else return self::check_version(true);
1219
-    			} elseif ($result['value'] == '23') {
1220
-    			    $error = self::update_from_23();
1221
-    			    if ($error != '') return $error;
1222
-    			    else return self::check_version(true);
1223
-    			} elseif ($result['value'] == '24') {
1224
-    			    $error = self::update_from_24();
1225
-    			    if ($error != '') return $error;
1226
-    			    else return self::check_version(true);
1227
-    			} elseif ($result['value'] == '25') {
1228
-    			    $error = self::update_from_25();
1229
-    			    if ($error != '') return $error;
1230
-    			    else return self::check_version(true);
1231
-    			} else return '';
1232
-    		    }
1233
-    		    else return $result['value'];
1132
+				}
1133
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1134
+				if ($update) {
1135
+				if ($result['value'] == '2') {
1136
+					$error = self::update_from_2();
1137
+					if ($error != '') return $error;
1138
+					else return self::check_version(true);
1139
+				} elseif ($result['value'] == '3') {
1140
+					$error = self::update_from_3();
1141
+					if ($error != '') return $error;
1142
+					else return self::check_version(true);
1143
+				} elseif ($result['value'] == '4') {
1144
+					$error = self::update_from_4();
1145
+					if ($error != '') return $error;
1146
+					else return self::check_version(true);
1147
+				} elseif ($result['value'] == '5') {
1148
+					$error = self::update_from_5();
1149
+					if ($error != '') return $error;
1150
+					else return self::check_version(true);
1151
+				} elseif ($result['value'] == '6') {
1152
+					$error = self::update_from_6();
1153
+					if ($error != '') return $error;
1154
+					else return self::check_version(true);
1155
+				} elseif ($result['value'] == '7') {
1156
+					$error = self::update_from_7();
1157
+					if ($error != '') return $error;
1158
+					else return self::check_version(true);
1159
+				} elseif ($result['value'] == '8') {
1160
+					$error = self::update_from_8();
1161
+					if ($error != '') return $error;
1162
+					else return self::check_version(true);
1163
+				} elseif ($result['value'] == '9') {
1164
+					$error = self::update_from_9();
1165
+					if ($error != '') return $error;
1166
+					else return self::check_version(true);
1167
+				} elseif ($result['value'] == '10') {
1168
+					$error = self::update_from_10();
1169
+					if ($error != '') return $error;
1170
+					else return self::check_version(true);
1171
+				} elseif ($result['value'] == '11') {
1172
+					$error = self::update_from_11();
1173
+					if ($error != '') return $error;
1174
+					else return self::check_version(true);
1175
+				} elseif ($result['value'] == '12') {
1176
+					$error = self::update_from_12();
1177
+					if ($error != '') return $error;
1178
+					else return self::check_version(true);
1179
+				} elseif ($result['value'] == '13') {
1180
+					$error = self::update_from_13();
1181
+					if ($error != '') return $error;
1182
+					else return self::check_version(true);
1183
+				} elseif ($result['value'] == '14') {
1184
+					$error = self::update_from_14();
1185
+					if ($error != '') return $error;
1186
+					else return self::check_version(true);
1187
+				} elseif ($result['value'] == '15') {
1188
+					$error = self::update_from_15();
1189
+					if ($error != '') return $error;
1190
+					else return self::check_version(true);
1191
+				} elseif ($result['value'] == '16') {
1192
+					$error = self::update_from_16();
1193
+					if ($error != '') return $error;
1194
+					else return self::check_version(true);
1195
+				} elseif ($result['value'] == '17') {
1196
+					$error = self::update_from_17();
1197
+					if ($error != '') return $error;
1198
+					else return self::check_version(true);
1199
+				} elseif ($result['value'] == '18') {
1200
+					$error = self::update_from_18();
1201
+					if ($error != '') return $error;
1202
+					else return self::check_version(true);
1203
+				} elseif ($result['value'] == '19') {
1204
+					$error = self::update_from_19();
1205
+					if ($error != '') return $error;
1206
+					else return self::check_version(true);
1207
+				} elseif ($result['value'] == '20') {
1208
+					$error = self::update_from_20();
1209
+					if ($error != '') return $error;
1210
+					else return self::check_version(true);
1211
+				} elseif ($result['value'] == '21') {
1212
+					$error = self::update_from_21();
1213
+					if ($error != '') return $error;
1214
+					else return self::check_version(true);
1215
+				} elseif ($result['value'] == '22') {
1216
+					$error = self::update_from_22();
1217
+					if ($error != '') return $error;
1218
+					else return self::check_version(true);
1219
+				} elseif ($result['value'] == '23') {
1220
+					$error = self::update_from_23();
1221
+					if ($error != '') return $error;
1222
+					else return self::check_version(true);
1223
+				} elseif ($result['value'] == '24') {
1224
+					$error = self::update_from_24();
1225
+					if ($error != '') return $error;
1226
+					else return self::check_version(true);
1227
+				} elseif ($result['value'] == '25') {
1228
+					$error = self::update_from_25();
1229
+					if ($error != '') return $error;
1230
+					else return self::check_version(true);
1231
+				} else return '';
1232
+				}
1233
+				else return $result['value'];
1234 1234
 		}
1235 1235
 		
1236
-	    } else return $version;
1237
-    	}
1236
+		} else return $version;
1237
+		}
1238 1238
     	
1239 1239
 }
1240 1240
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		    try {
1122 1122
             		$sth = $Connection->db->prepare($query);
1123 1123
 		        $sth->execute();
1124
-		    } catch(PDOException $e) {
1124
+		    } catch (PDOException $e) {
1125 1125
 			return "error : ".$e->getMessage()."\n";
1126 1126
     		    }
1127 1127
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
require/class.Spotter.php 4 patches
Indentation   +1265 added lines, -1265 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter;
22 22
 		if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter);
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	}
52 52
 
53 53
 	/**
54
-	* Executes the SQL statements to get the spotter information
55
-	*
56
-	* @param String $query the SQL query
57
-	* @param Array $params parameter of the query
58
-	* @param String $limitQuery the limit query
59
-	* @return Array the spotter information
60
-	*
61
-	*/
54
+	 * Executes the SQL statements to get the spotter information
55
+	 *
56
+	 * @param String $query the SQL query
57
+	 * @param Array $params parameter of the query
58
+	 * @param String $limitQuery the limit query
59
+	 * @return Array the spotter information
60
+	 *
61
+	 */
62 62
 	public function getDataFromDB($query, $params = array(), $limitQuery = '')
63 63
 	{
64 64
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS;
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
222 222
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
223 223
 					} else $temp_array['aircraft_shadow'] = 'default.png';
224
-                                } else {
225
-                            		$temp_array['aircraft_shadow'] = 'default.png';
224
+								} else {
225
+									$temp_array['aircraft_shadow'] = 'default.png';
226 226
 					$temp_array['aircraft_name'] = 'N/A';
227 227
 					$temp_array['aircraft_manufacturer'] = 'N/A';
228
-                            	}
228
+								}
229 229
 			}
230 230
 			$fromsource = NULL;
231 231
 			if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
 	
408 408
 	
409 409
 	/**
410
-	* Gets all the spotter information
411
-	*
412
-	* @return Array the spotter information
413
-	*
414
-	*/
410
+	 * Gets all the spotter information
411
+	 *
412
+	 * @return Array the spotter information
413
+	 *
414
+	 */
415 415
 	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 = '',$filter = array())
416 416
 	{
417 417
 		global $globalTimezone, $globalDBdriver;
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 	
759 759
 	
760 760
 	/**
761
-	* Gets all the spotter information based on the latest data entry
762
-	*
763
-	* @return Array the spotter information
764
-	*
765
-	*/
761
+	 * Gets all the spotter information based on the latest data entry
762
+	 *
763
+	 * @return Array the spotter information
764
+	 *
765
+	 */
766 766
 	public function getLatestSpotterData($limit = '', $sort = '', $filter = array())
767 767
 	{
768 768
 		global $global_query;
@@ -801,12 +801,12 @@  discard block
 block discarded – undo
801 801
 	}
802 802
     
803 803
     
804
-    /**
805
-	* Gets all the spotter information based on a user's latitude and longitude
806
-	*
807
-	* @return Array the spotter information
808
-	*
809
-	*/
804
+	/**
805
+	 * Gets all the spotter information based on a user's latitude and longitude
806
+	 *
807
+	 * @return Array the spotter information
808
+	 *
809
+	 */
810 810
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
811 811
 	{
812 812
 		date_default_timezone_set('UTC');
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 				return false;
835 835
 			}
836 836
 		}
837
-    		$additional_query = '';
837
+			$additional_query = '';
838 838
 		if ($interval != "")
839 839
 		{
840 840
 			if (!is_string($interval))
@@ -874,12 +874,12 @@  discard block
 block discarded – undo
874 874
 	}
875 875
     
876 876
     
877
-    /**
878
-	* Gets all the spotter information sorted by the newest aircraft type
879
-	*
880
-	* @return Array the spotter information
881
-	*
882
-	*/
877
+	/**
878
+	 * Gets all the spotter information sorted by the newest aircraft type
879
+	 *
880
+	 * @return Array the spotter information
881
+	 *
882
+	 */
883 883
 	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
884 884
 	{
885 885
 		global $global_query;
@@ -920,11 +920,11 @@  discard block
 block discarded – undo
920 920
     
921 921
     
922 922
 	/**
923
-	* Gets all the spotter information sorted by the newest aircraft registration
924
-	*
925
-	* @return Array the spotter information
926
-	*
927
-	*/
923
+	 * Gets all the spotter information sorted by the newest aircraft registration
924
+	 *
925
+	 * @return Array the spotter information
926
+	 *
927
+	 */
928 928
 	public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array())
929 929
 	{
930 930
 		global $global_query;
@@ -964,11 +964,11 @@  discard block
 block discarded – undo
964 964
 
965 965
 
966 966
 	/**
967
-	* Gets all the spotter information sorted by the newest airline
968
-	*
969
-	* @return Array the spotter information
970
-	*
971
-	*/
967
+	 * Gets all the spotter information sorted by the newest airline
968
+	 *
969
+	 * @return Array the spotter information
970
+	 *
971
+	 */
972 972
 	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
973 973
 	{
974 974
 		global $global_query;
@@ -1007,12 +1007,12 @@  discard block
 block discarded – undo
1007 1007
 	}
1008 1008
     
1009 1009
     
1010
-    /**
1011
-	* Gets all the spotter information sorted by the newest departure airport
1012
-	*
1013
-	* @return Array the spotter information
1014
-	*
1015
-	*/
1010
+	/**
1011
+	 * Gets all the spotter information sorted by the newest departure airport
1012
+	 *
1013
+	 * @return Array the spotter information
1014
+	 *
1015
+	 */
1016 1016
 	public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array())
1017 1017
 	{
1018 1018
 		global $global_query;
@@ -1054,11 +1054,11 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
 
1056 1056
 	/**
1057
-	* Gets all the spotter information sorted by the newest arrival airport
1058
-	*
1059
-	* @return Array the spotter information
1060
-	*
1061
-	*/
1057
+	 * Gets all the spotter information sorted by the newest arrival airport
1058
+	 *
1059
+	 * @return Array the spotter information
1060
+	 *
1061
+	 */
1062 1062
 	public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array())
1063 1063
 	{
1064 1064
 		global $global_query;
@@ -1097,11 +1097,11 @@  discard block
 block discarded – undo
1097 1097
 	
1098 1098
 
1099 1099
 	/**
1100
-	* Gets all the spotter information based on the spotter id
1101
-	*
1102
-	* @return Array the spotter information
1103
-	*
1104
-	*/
1100
+	 * Gets all the spotter information based on the spotter id
1101
+	 *
1102
+	 * @return Array the spotter information
1103
+	 *
1104
+	 */
1105 1105
 	public function getSpotterDataByID($id = '')
1106 1106
 	{
1107 1107
 		global $global_query;
@@ -1123,11 +1123,11 @@  discard block
 block discarded – undo
1123 1123
 	
1124 1124
 	
1125 1125
 	/**
1126
-	* Gets all the spotter information based on the callsign
1127
-	*
1128
-	* @return Array the spotter information
1129
-	*
1130
-	*/
1126
+	 * Gets all the spotter information based on the callsign
1127
+	 *
1128
+	 * @return Array the spotter information
1129
+	 *
1130
+	 */
1131 1131
 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
1132 1132
 	{
1133 1133
 		global $global_query;
@@ -1180,11 +1180,11 @@  discard block
 block discarded – undo
1180 1180
 	
1181 1181
 	
1182 1182
 	/**
1183
-	* Gets all the spotter information based on the aircraft type
1184
-	*
1185
-	* @return Array the spotter information
1186
-	*
1187
-	*/
1183
+	 * Gets all the spotter information based on the aircraft type
1184
+	 *
1185
+	 * @return Array the spotter information
1186
+	 *
1187
+	 */
1188 1188
 	public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array())
1189 1189
 	{
1190 1190
 		global $global_query;
@@ -1238,11 +1238,11 @@  discard block
 block discarded – undo
1238 1238
 	
1239 1239
 	
1240 1240
 	/**
1241
-	* Gets all the spotter information based on the aircraft registration
1242
-	*
1243
-	* @return Array the spotter information
1244
-	*
1245
-	*/
1241
+	 * Gets all the spotter information based on the aircraft registration
1242
+	 *
1243
+	 * @return Array the spotter information
1244
+	 *
1245
+	 */
1246 1246
 	public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array())
1247 1247
 	{
1248 1248
 		global $global_query;
@@ -1298,11 +1298,11 @@  discard block
 block discarded – undo
1298 1298
 	
1299 1299
 	
1300 1300
 	/**
1301
-	* Gets all the spotter information based on the airline
1302
-	*
1303
-	* @return Array the spotter information
1304
-	*
1305
-	*/
1301
+	 * Gets all the spotter information based on the airline
1302
+	 *
1303
+	 * @return Array the spotter information
1304
+	 *
1305
+	 */
1306 1306
 	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '')
1307 1307
 	{
1308 1308
 		global $global_query;
@@ -1354,11 +1354,11 @@  discard block
 block discarded – undo
1354 1354
 	
1355 1355
 	
1356 1356
 	/**
1357
-	* Gets all the spotter information based on the airport
1358
-	*
1359
-	* @return Array the spotter information
1360
-	*
1361
-	*/
1357
+	 * Gets all the spotter information based on the airport
1358
+	 *
1359
+	 * @return Array the spotter information
1360
+	 *
1361
+	 */
1362 1362
 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '')
1363 1363
 	{
1364 1364
 		global $global_query;
@@ -1411,11 +1411,11 @@  discard block
 block discarded – undo
1411 1411
 
1412 1412
 
1413 1413
 	/**
1414
-	* Gets all the spotter information based on the date
1415
-	*
1416
-	* @return Array the spotter information
1417
-	*
1418
-	*/
1414
+	 * Gets all the spotter information based on the date
1415
+	 *
1416
+	 * @return Array the spotter information
1417
+	 *
1418
+	 */
1419 1419
 	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1420 1420
 	{
1421 1421
 		global $global_query, $globalTimezone, $globalDBdriver;
@@ -1492,11 +1492,11 @@  discard block
 block discarded – undo
1492 1492
 
1493 1493
 
1494 1494
 	/**
1495
-	* Gets all the spotter information based on the country name
1496
-	*
1497
-	* @return Array the spotter information
1498
-	*
1499
-	*/
1495
+	 * Gets all the spotter information based on the country name
1496
+	 *
1497
+	 * @return Array the spotter information
1498
+	 *
1499
+	 */
1500 1500
 	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '')
1501 1501
 	{
1502 1502
 		global $global_query;
@@ -1549,11 +1549,11 @@  discard block
 block discarded – undo
1549 1549
 	
1550 1550
 	
1551 1551
 	/**
1552
-	* Gets all the spotter information based on the manufacturer name
1553
-	*
1554
-	* @return Array the spotter information
1555
-	*
1556
-	*/
1552
+	 * Gets all the spotter information based on the manufacturer name
1553
+	 *
1554
+	 * @return Array the spotter information
1555
+	 *
1556
+	 */
1557 1557
 	public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '')
1558 1558
 	{
1559 1559
 		global $global_query;
@@ -1608,13 +1608,13 @@  discard block
 block discarded – undo
1608 1608
   
1609 1609
   
1610 1610
 	/**
1611
-	* Gets a list of all aircraft that take a route
1612
-	*
1613
-	* @param String $departure_airport_icao ICAO code of departure airport
1614
-	* @param String $arrival_airport_icao ICAO code of arrival airport
1615
-	* @return Array the spotter information
1616
-	*
1617
-	*/
1611
+	 * Gets a list of all aircraft that take a route
1612
+	 *
1613
+	 * @param String $departure_airport_icao ICAO code of departure airport
1614
+	 * @param String $arrival_airport_icao ICAO code of arrival airport
1615
+	 * @return Array the spotter information
1616
+	 *
1617
+	 */
1618 1618
 	public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '')
1619 1619
 	{
1620 1620
 		global $global_query;
@@ -1680,11 +1680,11 @@  discard block
 block discarded – undo
1680 1680
 	
1681 1681
 	
1682 1682
 	/**
1683
-	* Gets all the spotter information based on the special column in the table
1684
-	*
1685
-	* @return Array the spotter information
1686
-	*
1687
-	*/
1683
+	 * Gets all the spotter information based on the special column in the table
1684
+	 *
1685
+	 * @return Array the spotter information
1686
+	 *
1687
+	 */
1688 1688
 	public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array())
1689 1689
 	{
1690 1690
 		global $global_query;
@@ -1723,11 +1723,11 @@  discard block
 block discarded – undo
1723 1723
 	}
1724 1724
 
1725 1725
 	/**
1726
-	* Gets all the highlight based on a aircraft registration
1727
-	*
1728
-	* @return String the highlight text
1729
-	*
1730
-	*/
1726
+	 * Gets all the highlight based on a aircraft registration
1727
+	 *
1728
+	 * @return String the highlight text
1729
+	 *
1730
+	 */
1731 1731
 	public function getHighlightByRegistration($registration,$filter = array())
1732 1732
 	{
1733 1733
 		global $global_query;
@@ -1749,13 +1749,13 @@  discard block
 block discarded – undo
1749 1749
 
1750 1750
 	
1751 1751
 	/**
1752
-	* Gets the squawk usage from squawk code
1753
-	*
1754
-	* @param String $squawk squawk code
1755
-	* @param String $country country
1756
-	* @return String usage
1757
-	*
1758
-	*/
1752
+	 * Gets the squawk usage from squawk code
1753
+	 *
1754
+	 * @param String $squawk squawk code
1755
+	 * @param String $country country
1756
+	 * @return String usage
1757
+	 *
1758
+	 */
1759 1759
 	public function getSquawkUsage($squawk = '',$country = 'FR')
1760 1760
 	{
1761 1761
 		
@@ -1775,12 +1775,12 @@  discard block
 block discarded – undo
1775 1775
 	}
1776 1776
 
1777 1777
 	/**
1778
-	* Gets the airport icao from the iata
1779
-	*
1780
-	* @param String $airport_iata the iata code of the airport
1781
-	* @return String airport iata
1782
-	*
1783
-	*/
1778
+	 * Gets the airport icao from the iata
1779
+	 *
1780
+	 * @param String $airport_iata the iata code of the airport
1781
+	 * @return String airport iata
1782
+	 *
1783
+	 */
1784 1784
 	public function getAirportIcao($airport_iata = '')
1785 1785
 	{
1786 1786
 		
@@ -1799,14 +1799,14 @@  discard block
 block discarded – undo
1799 1799
 	}
1800 1800
 
1801 1801
 	/**
1802
-	* Gets the airport distance
1803
-	*
1804
-	* @param String $airport_icao the icao code of the airport
1805
-	* @param Float $latitude the latitude
1806
-	* @param Float $longitude the longitude
1807
-	* @return Float distance to the airport
1808
-	*
1809
-	*/
1802
+	 * Gets the airport distance
1803
+	 *
1804
+	 * @param String $airport_icao the icao code of the airport
1805
+	 * @param Float $latitude the latitude
1806
+	 * @param Float $longitude the longitude
1807
+	 * @return Float distance to the airport
1808
+	 *
1809
+	 */
1810 1810
 	public function getAirportDistance($airport_icao,$latitude,$longitude)
1811 1811
 	{
1812 1812
 		
@@ -1826,12 +1826,12 @@  discard block
 block discarded – undo
1826 1826
 	}
1827 1827
 	
1828 1828
 	/**
1829
-	* Gets the airport info based on the icao
1830
-	*
1831
-	* @param String $airport the icao code of the airport
1832
-	* @return Array airport information
1833
-	*
1834
-	*/
1829
+	 * Gets the airport info based on the icao
1830
+	 *
1831
+	 * @param String $airport the icao code of the airport
1832
+	 * @return Array airport information
1833
+	 *
1834
+	 */
1835 1835
 	public function getAllAirportInfo($airport = '')
1836 1836
 	{
1837 1837
 		
@@ -1877,12 +1877,12 @@  discard block
 block discarded – undo
1877 1877
 	}
1878 1878
 	
1879 1879
 	/**
1880
-	* Gets the airport info based on the country
1881
-	*
1882
-	* @param Array $countries Airports countries
1883
-	* @return Array airport information
1884
-	*
1885
-	*/
1880
+	 * Gets the airport info based on the country
1881
+	 *
1882
+	 * @param Array $countries Airports countries
1883
+	 * @return Array airport information
1884
+	 *
1885
+	 */
1886 1886
 	public function getAllAirportInfobyCountry($countries)
1887 1887
 	{
1888 1888
 		$lst_countries = '';
@@ -1920,12 +1920,12 @@  discard block
 block discarded – undo
1920 1920
 	}
1921 1921
 	
1922 1922
 	/**
1923
-	* Gets airports info based on the coord
1924
-	*
1925
-	* @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
1926
-	* @return Array airport information
1927
-	*
1928
-	*/
1923
+	 * Gets airports info based on the coord
1924
+	 *
1925
+	 * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
1926
+	 * @return Array airport information
1927
+	 *
1928
+	 */
1929 1929
 	public function getAllAirportInfobyCoord($coord)
1930 1930
 	{
1931 1931
 		global $globalDBdriver;
@@ -1956,12 +1956,12 @@  discard block
 block discarded – undo
1956 1956
 	}
1957 1957
 
1958 1958
 	/**
1959
-	* Gets waypoints info based on the coord
1960
-	*
1961
-	* @param Array $coord waypoints coord
1962
-	* @return Array airport information
1963
-	*
1964
-	*/
1959
+	 * Gets waypoints info based on the coord
1960
+	 *
1961
+	 * @param Array $coord waypoints coord
1962
+	 * @return Array airport information
1963
+	 *
1964
+	 */
1965 1965
 	public function getAllWaypointsInfobyCoord($coord)
1966 1966
 	{
1967 1967
 		if (is_array($coord)) {
@@ -1995,12 +1995,12 @@  discard block
 block discarded – undo
1995 1995
 	
1996 1996
 	
1997 1997
 	/**
1998
-	* Gets the airline info based on the icao code or iata code
1999
-	*
2000
-	* @param String $airline_icao the iata code of the airport
2001
-	* @return Array airport information
2002
-	*
2003
-	*/
1998
+	 * Gets the airline info based on the icao code or iata code
1999
+	 *
2000
+	 * @param String $airline_icao the iata code of the airport
2001
+	 * @return Array airport information
2002
+	 *
2003
+	 */
2004 2004
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2005 2005
 	{
2006 2006
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
 			} else {
2030 2030
 				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2031 2031
 			}
2032
-                        /*
2032
+						/*
2033 2033
 			$airline_array = array();
2034 2034
 			$temp_array = array();
2035 2035
 		
@@ -2052,12 +2052,12 @@  discard block
 block discarded – undo
2052 2052
 	
2053 2053
 	
2054 2054
 	/**
2055
-	* Gets the aircraft info based on the aircraft type
2056
-	*
2057
-	* @param String $aircraft_type the aircraft type
2058
-	* @return Array aircraft information
2059
-	*
2060
-	*/
2055
+	 * Gets the aircraft info based on the aircraft type
2056
+	 *
2057
+	 * @param String $aircraft_type the aircraft type
2058
+	 * @return Array aircraft information
2059
+	 *
2060
+	 */
2061 2061
 	public function getAllAircraftInfo($aircraft_type)
2062 2062
 	{
2063 2063
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2089,12 +2089,12 @@  discard block
 block discarded – undo
2089 2089
 	}
2090 2090
 
2091 2091
 	/**
2092
-	* Gets the aircraft icao based on the aircraft name/type
2093
-	*
2094
-	* @param String $aircraft_type the aircraft type
2095
-	* @return String aircraft information
2096
-	*
2097
-	*/
2092
+	 * Gets the aircraft icao based on the aircraft name/type
2093
+	 *
2094
+	 * @param String $aircraft_type the aircraft type
2095
+	 * @return String aircraft information
2096
+	 *
2097
+	 */
2098 2098
 	public function getAircraftIcao($aircraft_type)
2099 2099
 	{
2100 2100
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2119,12 +2119,12 @@  discard block
 block discarded – undo
2119 2119
 	}
2120 2120
 	
2121 2121
 	/**
2122
-	* Gets the aircraft info based on the aircraft ident
2123
-	*
2124
-	* @param String $aircraft_modes the aircraft ident (hex)
2125
-	* @return String aircraft type
2126
-	*
2127
-	*/
2122
+	 * Gets the aircraft info based on the aircraft ident
2123
+	 *
2124
+	 * @param String $aircraft_modes the aircraft ident (hex)
2125
+	 * @return String aircraft type
2126
+	 *
2127
+	 */
2128 2128
 	public function getAllAircraftType($aircraft_modes)
2129 2129
 	{
2130 2130
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -2141,12 +2141,12 @@  discard block
 block discarded – undo
2141 2141
 	}
2142 2142
 
2143 2143
 	/**
2144
-	* Gets correct aircraft operator corde
2145
-	*
2146
-	* @param String $operator the aircraft operator code (callsign)
2147
-	* @return String aircraft operator code
2148
-	*
2149
-	*/
2144
+	 * Gets correct aircraft operator corde
2145
+	 *
2146
+	 * @param String $operator the aircraft operator code (callsign)
2147
+	 * @return String aircraft operator code
2148
+	 *
2149
+	 */
2150 2150
 	public function getOperator($operator)
2151 2151
 	{
2152 2152
 		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
@@ -2162,16 +2162,16 @@  discard block
 block discarded – undo
2162 2162
 	}
2163 2163
 
2164 2164
 	/**
2165
-	* Gets the aircraft route based on the aircraft callsign
2166
-	*
2167
-	* @param String $callsign the aircraft callsign
2168
-	* @return Array aircraft type
2169
-	*
2170
-	*/
2165
+	 * Gets the aircraft route based on the aircraft callsign
2166
+	 *
2167
+	 * @param String $callsign the aircraft callsign
2168
+	 * @return Array aircraft type
2169
+	 *
2170
+	 */
2171 2171
 	public function getRouteInfo($callsign)
2172 2172
 	{
2173 2173
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2174
-                if ($callsign == '') return array();
2174
+				if ($callsign == '') return array();
2175 2175
 		$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";
2176 2176
 		
2177 2177
 		$sth = $this->db->prepare($query);
@@ -2184,12 +2184,12 @@  discard block
 block discarded – undo
2184 2184
 	}
2185 2185
 	
2186 2186
 	/**
2187
-	* Gets the aircraft info based on the aircraft registration
2188
-	*
2189
-	* @param String $registration the aircraft registration
2190
-	* @return Array aircraft information
2191
-	*
2192
-	*/
2187
+	 * Gets the aircraft info based on the aircraft registration
2188
+	 *
2189
+	 * @param String $registration the aircraft registration
2190
+	 * @return Array aircraft information
2191
+	 *
2192
+	 */
2193 2193
 	public function getAircraftInfoByRegistration($registration)
2194 2194
 	{
2195 2195
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2216,12 +2216,12 @@  discard block
 block discarded – undo
2216 2216
 	}
2217 2217
 	
2218 2218
 	/**
2219
-	* Gets the aircraft owner & base based on the aircraft registration
2220
-	*
2221
-	* @param String $registration the aircraft registration
2222
-	* @return Array aircraft information
2223
-	*
2224
-	*/
2219
+	 * Gets the aircraft owner & base based on the aircraft registration
2220
+	 *
2221
+	 * @param String $registration the aircraft registration
2222
+	 * @return Array aircraft information
2223
+	 *
2224
+	 */
2225 2225
 	public function getAircraftOwnerByRegistration($registration)
2226 2226
 	{
2227 2227
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2237,11 +2237,11 @@  discard block
 block discarded – undo
2237 2237
 	
2238 2238
   
2239 2239
   /**
2240
-	* Gets all flights (but with only little info)
2241
-	*
2242
-	* @return Array basic flight information
2243
-	*
2244
-	*/
2240
+   * Gets all flights (but with only little info)
2241
+   *
2242
+   * @return Array basic flight information
2243
+   *
2244
+   */
2245 2245
 	public function getAllFlightsforSitemap()
2246 2246
 	{
2247 2247
 		//$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 ";
@@ -2249,7 +2249,7 @@  discard block
 block discarded – undo
2249 2249
 		
2250 2250
 		$sth = $this->db->prepare($query);
2251 2251
 		$sth->execute();
2252
-                  /*
2252
+				  /*
2253 2253
 		$flight_array = array();
2254 2254
 		$temp_array = array();
2255 2255
 		
@@ -2271,11 +2271,11 @@  discard block
 block discarded – undo
2271 2271
 	}
2272 2272
   
2273 2273
 	/**
2274
-	* Gets a list of all aircraft manufacturers
2275
-	*
2276
-	* @return Array list of aircraft types
2277
-	*
2278
-	*/
2274
+	 * Gets a list of all aircraft manufacturers
2275
+	 *
2276
+	 * @return Array list of aircraft types
2277
+	 *
2278
+	 */
2279 2279
 	public function getAllManufacturers()
2280 2280
 	{
2281 2281
 		/*
@@ -2304,11 +2304,11 @@  discard block
 block discarded – undo
2304 2304
   
2305 2305
   
2306 2306
   /**
2307
-	* Gets a list of all aircraft types
2308
-	*
2309
-	* @return Array list of aircraft types
2310
-	*
2311
-	*/
2307
+   * Gets a list of all aircraft types
2308
+   *
2309
+   * @return Array list of aircraft types
2310
+   *
2311
+   */
2312 2312
 	public function getAllAircraftTypes()
2313 2313
 	{
2314 2314
 		/*
@@ -2340,11 +2340,11 @@  discard block
 block discarded – undo
2340 2340
 	
2341 2341
 	
2342 2342
 	/**
2343
-	* Gets a list of all aircraft registrations
2344
-	*
2345
-	* @return Array list of aircraft registrations
2346
-	*
2347
-	*/
2343
+	 * Gets a list of all aircraft registrations
2344
+	 *
2345
+	 * @return Array list of aircraft registrations
2346
+	 *
2347
+	 */
2348 2348
 	public function getAllAircraftRegistrations()
2349 2349
 	{
2350 2350
 		$query  = "SELECT DISTINCT spotter_output.registration 
@@ -2369,12 +2369,12 @@  discard block
 block discarded – undo
2369 2369
 	}
2370 2370
 
2371 2371
 	/**
2372
-	* Gets all source name
2373
-	*
2374
-	* @param String type format of source
2375
-	* @return Array list of source name
2376
-	*
2377
-	*/
2372
+	 * Gets all source name
2373
+	 *
2374
+	 * @param String type format of source
2375
+	 * @return Array list of source name
2376
+	 *
2377
+	 */
2378 2378
 	public function getAllSourceName($type = '')
2379 2379
 	{
2380 2380
 		$query_values = array();
@@ -2405,11 +2405,11 @@  discard block
 block discarded – undo
2405 2405
 
2406 2406
 
2407 2407
 	/**
2408
-	* Gets a list of all airline names
2409
-	*
2410
-	* @return Array list of airline names
2411
-	*
2412
-	*/
2408
+	 * Gets a list of all airline names
2409
+	 *
2410
+	 * @return Array list of airline names
2411
+	 *
2412
+	 */
2413 2413
 	public function getAllAirlineNames($airline_type = '')
2414 2414
 	{
2415 2415
 		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
@@ -2452,11 +2452,11 @@  discard block
 block discarded – undo
2452 2452
 	
2453 2453
 	
2454 2454
 	/**
2455
-	* Gets a list of all airline countries
2456
-	*
2457
-	* @return Array list of airline countries
2458
-	*
2459
-	*/
2455
+	 * Gets a list of all airline countries
2456
+	 *
2457
+	 * @return Array list of airline countries
2458
+	 *
2459
+	 */
2460 2460
 	public function getAllAirlineCountries()
2461 2461
 	{
2462 2462
 		
@@ -2485,11 +2485,11 @@  discard block
 block discarded – undo
2485 2485
 	
2486 2486
 	
2487 2487
 	/**
2488
-	* Gets a list of all departure & arrival names
2489
-	*
2490
-	* @return Array list of airport names
2491
-	*
2492
-	*/
2488
+	 * Gets a list of all departure & arrival names
2489
+	 *
2490
+	 * @return Array list of airport names
2491
+	 *
2492
+	 */
2493 2493
 	public function getAllAirportNames()
2494 2494
 	{
2495 2495
 		$airport_array = array();
@@ -2540,11 +2540,11 @@  discard block
 block discarded – undo
2540 2540
 	
2541 2541
 	
2542 2542
 	/**
2543
-	* Gets a list of all departure & arrival airport countries
2544
-	*
2545
-	* @return Array list of airport countries
2546
-	*
2547
-	*/
2543
+	 * Gets a list of all departure & arrival airport countries
2544
+	 *
2545
+	 * @return Array list of airport countries
2546
+	 *
2547
+	 */
2548 2548
 	public function getAllAirportCountries()
2549 2549
 	{
2550 2550
 		$airport_array = array();
@@ -2593,11 +2593,11 @@  discard block
 block discarded – undo
2593 2593
 	
2594 2594
 	
2595 2595
 	/**
2596
-	* Gets a list of all countries (airline, departure airport & arrival airport)
2597
-	*
2598
-	* @return Array list of countries
2599
-	*
2600
-	*/
2596
+	 * Gets a list of all countries (airline, departure airport & arrival airport)
2597
+	 *
2598
+	 * @return Array list of countries
2599
+	 *
2600
+	 */
2601 2601
 	public function getAllCountries()
2602 2602
 	{
2603 2603
 		$Connection= new Connection($this->db);
@@ -2676,11 +2676,11 @@  discard block
 block discarded – undo
2676 2676
 	
2677 2677
 	
2678 2678
 	/**
2679
-	* Gets a list of all idents/callsigns
2680
-	*
2681
-	* @return Array list of ident/callsign names
2682
-	*
2683
-	*/
2679
+	 * Gets a list of all idents/callsigns
2680
+	 *
2681
+	 * @return Array list of ident/callsign names
2682
+	 *
2683
+	 */
2684 2684
 	public function getAllIdents()
2685 2685
 	{
2686 2686
 		$query  = "SELECT DISTINCT spotter_output.ident
@@ -2704,9 +2704,9 @@  discard block
 block discarded – undo
2704 2704
 	}
2705 2705
 
2706 2706
 	/**
2707
-	* Get a list of flights from airport since 7 days
2708
-	* @return Array number, icao, name and city of airports
2709
-	*/
2707
+	 * Get a list of flights from airport since 7 days
2708
+	 * @return Array number, icao, name and city of airports
2709
+	 */
2710 2710
 
2711 2711
 	public function getLast7DaysAirportsDeparture($airport_icao = '') {
2712 2712
 		global $globalTimezone, $globalDBdriver;
@@ -2736,9 +2736,9 @@  discard block
 block discarded – undo
2736 2736
 	}
2737 2737
 
2738 2738
 	/**
2739
-	* Get a list of flights from airport since 7 days
2740
-	* @return Array number, icao, name and city of airports
2741
-	*/
2739
+	 * Get a list of flights from airport since 7 days
2740
+	 * @return Array number, icao, name and city of airports
2741
+	 */
2742 2742
 
2743 2743
 	public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') {
2744 2744
 		global $globalTimezone, $globalDBdriver;
@@ -2768,9 +2768,9 @@  discard block
 block discarded – undo
2768 2768
 	}
2769 2769
 
2770 2770
 	/**
2771
-	* Get a list of flights from detected airport since 7 days
2772
-	* @return Array number, icao, name and city of airports
2773
-	*/
2771
+	 * Get a list of flights from detected airport since 7 days
2772
+	 * @return Array number, icao, name and city of airports
2773
+	 */
2774 2774
 
2775 2775
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '') {
2776 2776
 		global $globalTimezone, $globalDBdriver;
@@ -2811,9 +2811,9 @@  discard block
 block discarded – undo
2811 2811
 	}
2812 2812
 
2813 2813
 	/**
2814
-	* Get a list of flights from detected airport since 7 days
2815
-	* @return Array number, icao, name and city of airports
2816
-	*/
2814
+	 * Get a list of flights from detected airport since 7 days
2815
+	 * @return Array number, icao, name and city of airports
2816
+	 */
2817 2817
 
2818 2818
 	public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') {
2819 2819
 		global $globalTimezone, $globalDBdriver;
@@ -2855,9 +2855,9 @@  discard block
 block discarded – undo
2855 2855
 
2856 2856
 
2857 2857
 	/**
2858
-	* Get a list of flights to airport since 7 days
2859
-	* @return Array number, icao, name and city of airports
2860
-	*/
2858
+	 * Get a list of flights to airport since 7 days
2859
+	 * @return Array number, icao, name and city of airports
2860
+	 */
2861 2861
 
2862 2862
 	public function getLast7DaysAirportsArrival($airport_icao = '') {
2863 2863
 		global $globalTimezone, $globalDBdriver;
@@ -2889,9 +2889,9 @@  discard block
 block discarded – undo
2889 2889
 
2890 2890
 
2891 2891
 	/**
2892
-	* Get a list of flights detected to airport since 7 days
2893
-	* @return Array number, icao, name and city of airports
2894
-	*/
2892
+	 * Get a list of flights detected to airport since 7 days
2893
+	 * @return Array number, icao, name and city of airports
2894
+	 */
2895 2895
 
2896 2896
 	public function getLast7DaysDetectedAirportsArrival($airport_icao = '') {
2897 2897
 		global $globalTimezone, $globalDBdriver;
@@ -2935,9 +2935,9 @@  discard block
 block discarded – undo
2935 2935
 
2936 2936
 
2937 2937
 	/**
2938
-	* Get a list of flights to airport since 7 days
2939
-	* @return Array number, icao, name and city of airports
2940
-	*/
2938
+	 * Get a list of flights to airport since 7 days
2939
+	 * @return Array number, icao, name and city of airports
2940
+	 */
2941 2941
 
2942 2942
 	public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') {
2943 2943
 		global $globalTimezone, $globalDBdriver;
@@ -2969,9 +2969,9 @@  discard block
 block discarded – undo
2969 2969
 
2970 2970
 
2971 2971
 	/**
2972
-	* Get a list of flights detected to airport since 7 days
2973
-	* @return Array number, icao, name and city of airports
2974
-	*/
2972
+	 * Get a list of flights detected to airport since 7 days
2973
+	 * @return Array number, icao, name and city of airports
2974
+	 */
2975 2975
 
2976 2976
 	public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') {
2977 2977
 		global $globalTimezone, $globalDBdriver;
@@ -3015,11 +3015,11 @@  discard block
 block discarded – undo
3015 3015
 
3016 3016
 
3017 3017
 	/**
3018
-	* Gets a list of all dates
3019
-	*
3020
-	* @return Array list of date names
3021
-	*
3022
-	*/
3018
+	 * Gets a list of all dates
3019
+	 *
3020
+	 * @return Array list of date names
3021
+	 *
3022
+	 */
3023 3023
 	public function getAllDates()
3024 3024
 	{
3025 3025
 		global $globalTimezone, $globalDBdriver;
@@ -3060,11 +3060,11 @@  discard block
 block discarded – undo
3060 3060
 	
3061 3061
 	
3062 3062
 	/**
3063
-	* Gets all route combinations
3064
-	*
3065
-	* @return Array the route list
3066
-	*
3067
-	*/
3063
+	 * Gets all route combinations
3064
+	 *
3065
+	 * @return Array the route list
3066
+	 *
3067
+	 */
3068 3068
 	public function getAllRoutes()
3069 3069
 	{
3070 3070
 		$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 
@@ -3090,13 +3090,13 @@  discard block
 block discarded – undo
3090 3090
 	}
3091 3091
 
3092 3092
 	/**
3093
-	* Update ident spotter data
3094
-	*
3095
-	* @param String $flightaware_id the ID from flightaware
3096
-	* @param String $ident the flight ident
3097
-	* @return String success or false
3098
-	*
3099
-	*/	
3093
+	 * Update ident spotter data
3094
+	 *
3095
+	 * @param String $flightaware_id the ID from flightaware
3096
+	 * @param String $ident the flight ident
3097
+	 * @return String success or false
3098
+	 *
3099
+	 */	
3100 3100
 	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3101 3101
 	{
3102 3102
 		if (!is_numeric(substr($ident, 0, 3)))
@@ -3117,14 +3117,14 @@  discard block
 block discarded – undo
3117 3117
 		} else {
3118 3118
 			$airline_array = $this->getAllAirlineInfo("NA");
3119 3119
 		}
3120
-                $airline_name = $airline_array[0]['name'];
3121
-                $airline_icao = $airline_array[0]['icao'];
3122
-                $airline_country = $airline_array[0]['country'];
3123
-                $airline_type = $airline_array[0]['type'];
3120
+				$airline_name = $airline_array[0]['name'];
3121
+				$airline_icao = $airline_array[0]['icao'];
3122
+				$airline_country = $airline_array[0]['country'];
3123
+				$airline_type = $airline_array[0]['type'];
3124 3124
 
3125 3125
 
3126 3126
 		$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';
3127
-                $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);
3127
+				$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);
3128 3128
 
3129 3129
 		try {
3130 3130
 			$sth = $this->db->prepare($query);
@@ -3137,19 +3137,19 @@  discard block
 block discarded – undo
3137 3137
 
3138 3138
 	}
3139 3139
 	/**
3140
-	* Update latest spotter data
3141
-	*
3142
-	* @param String $flightaware_id the ID from flightaware
3143
-	* @param String $ident the flight ident
3144
-	* @param String $arrival_airport_icao the arrival airport
3145
-	* @return String success or false
3146
-	*
3147
-	*/	
3140
+	 * Update latest spotter data
3141
+	 *
3142
+	 * @param String $flightaware_id the ID from flightaware
3143
+	 * @param String $ident the flight ident
3144
+	 * @param String $arrival_airport_icao the arrival airport
3145
+	 * @return String success or false
3146
+	 *
3147
+	 */	
3148 3148
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3149 3149
 	{
3150 3150
 		if ($groundspeed == '') $groundspeed = NULL;
3151 3151
 		$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';
3152
-                $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);
3152
+				$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);
3153 3153
 
3154 3154
 		try {
3155 3155
 			$sth = $this->db->prepare($query);
@@ -3163,32 +3163,32 @@  discard block
 block discarded – undo
3163 3163
 	}
3164 3164
 
3165 3165
 	/**
3166
-	* Adds a new spotter data
3167
-	*
3168
-	* @param String $flightaware_id the ID from flightaware
3169
-	* @param String $ident the flight ident
3170
-	* @param String $aircraft_icao the aircraft type
3171
-	* @param String $departure_airport_icao the departure airport
3172
-	* @param String $arrival_airport_icao the arrival airport
3173
-	* @param String $latitude latitude of flight
3174
-	* @param String $longitude latitude of flight
3175
-	* @param String $waypoints waypoints of flight
3176
-	* @param String $altitude altitude of flight
3177
-	* @param String $heading heading of flight
3178
-	* @param String $groundspeed speed of flight
3179
-	* @param String $date date of flight
3180
-	* @param String $departure_airport_time departure time of flight
3181
-	* @param String $arrival_airport_time arrival time of flight
3182
-	* @param String $squawk squawk code of flight
3183
-	* @param String $route_stop route stop of flight
3184
-	* @param String $highlight highlight or not
3185
-	* @param String $ModeS ModesS code of flight
3186
-	* @param String $registration registration code of flight
3187
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
3188
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
3189
-	* @param String $verticalrate vertival rate of flight
3190
-	* @return String success or false
3191
-	*/
3166
+	 * Adds a new spotter data
3167
+	 *
3168
+	 * @param String $flightaware_id the ID from flightaware
3169
+	 * @param String $ident the flight ident
3170
+	 * @param String $aircraft_icao the aircraft type
3171
+	 * @param String $departure_airport_icao the departure airport
3172
+	 * @param String $arrival_airport_icao the arrival airport
3173
+	 * @param String $latitude latitude of flight
3174
+	 * @param String $longitude latitude of flight
3175
+	 * @param String $waypoints waypoints of flight
3176
+	 * @param String $altitude altitude of flight
3177
+	 * @param String $heading heading of flight
3178
+	 * @param String $groundspeed speed of flight
3179
+	 * @param String $date date of flight
3180
+	 * @param String $departure_airport_time departure time of flight
3181
+	 * @param String $arrival_airport_time arrival time of flight
3182
+	 * @param String $squawk squawk code of flight
3183
+	 * @param String $route_stop route stop of flight
3184
+	 * @param String $highlight highlight or not
3185
+	 * @param String $ModeS ModesS code of flight
3186
+	 * @param String $registration registration code of flight
3187
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
3188
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
3189
+	 * @param String $verticalrate vertival rate of flight
3190
+	 * @return String success or false
3191
+	 */
3192 3192
 	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 = '')
3193 3193
 	{
3194 3194
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed;
@@ -3400,8 +3400,8 @@  discard block
 block discarded – undo
3400 3400
     
3401 3401
 		if ($globalIVAO && $aircraft_icao != '')
3402 3402
 		{
3403
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3404
-            		else $airline_icao = '';
3403
+					if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3404
+					else $airline_icao = '';
3405 3405
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3406 3406
 			if (!isset($image_array[0]['registration']))
3407 3407
 			{
@@ -3432,48 +3432,48 @@  discard block
 block discarded – undo
3432 3432
 	
3433 3433
 		if (count($airline_array) == 0) 
3434 3434
 		{
3435
-                        $airline_array = $this->getAllAirlineInfo('NA');
3436
-                }
3437
-                if (count($aircraft_array) == 0) 
3438
-                {
3439
-                        $aircraft_array = $this->getAllAircraftInfo('NA');
3440
-                }
3441
-                if (count($departure_airport_array) == 0) 
3442
-                {
3443
-                        $departure_airport_array = $this->getAllAirportInfo('NA');
3444
-                }
3445
-                if (count($arrival_airport_array) == 0) 
3446
-                {
3447
-                        $arrival_airport_array = $this->getAllAirportInfo('NA');
3448
-                }
3449
-                if ($registration == '') $registration = 'NA';
3450
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3451
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3452
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3453
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3454
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3455
-                $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) 
3435
+						$airline_array = $this->getAllAirlineInfo('NA');
3436
+				}
3437
+				if (count($aircraft_array) == 0) 
3438
+				{
3439
+						$aircraft_array = $this->getAllAircraftInfo('NA');
3440
+				}
3441
+				if (count($departure_airport_array) == 0) 
3442
+				{
3443
+						$departure_airport_array = $this->getAllAirportInfo('NA');
3444
+				}
3445
+				if (count($arrival_airport_array) == 0) 
3446
+				{
3447
+						$arrival_airport_array = $this->getAllAirportInfo('NA');
3448
+				}
3449
+				if ($registration == '') $registration = 'NA';
3450
+				if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3451
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3452
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3453
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3454
+				if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3455
+				$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) 
3456 3456
                 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)";
3457 3457
 
3458
-                $airline_name = $airline_array[0]['name'];
3459
-                $airline_icao = $airline_array[0]['icao'];
3460
-                $airline_country = $airline_array[0]['country'];
3461
-                $airline_type = $airline_array[0]['type'];
3458
+				$airline_name = $airline_array[0]['name'];
3459
+				$airline_icao = $airline_array[0]['icao'];
3460
+				$airline_country = $airline_array[0]['country'];
3461
+				$airline_type = $airline_array[0]['type'];
3462 3462
 		if ($airline_type == '') {
3463 3463
 			$timeelapsed = microtime(true);
3464 3464
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3465 3465
 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3466 3466
 		}
3467 3467
 		if ($airline_type == null) $airline_type = '';
3468
-                $aircraft_type = $aircraft_array[0]['type'];
3469
-                $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3470
-                $departure_airport_name = $departure_airport_array[0]['name'];
3471
-                $departure_airport_city = $departure_airport_array[0]['city'];
3472
-                $departure_airport_country = $departure_airport_array[0]['country'];
3473
-                $arrival_airport_name = $arrival_airport_array[0]['name'];
3474
-                $arrival_airport_city = $arrival_airport_array[0]['city'];
3475
-                $arrival_airport_country = $arrival_airport_array[0]['country'];
3476
-                $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);
3468
+				$aircraft_type = $aircraft_array[0]['type'];
3469
+				$aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3470
+				$departure_airport_name = $departure_airport_array[0]['name'];
3471
+				$departure_airport_city = $departure_airport_array[0]['city'];
3472
+				$departure_airport_country = $departure_airport_array[0]['country'];
3473
+				$arrival_airport_name = $arrival_airport_array[0]['name'];
3474
+				$arrival_airport_city = $arrival_airport_array[0]['city'];
3475
+				$arrival_airport_country = $arrival_airport_array[0]['country'];
3476
+				$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);
3477 3477
 
3478 3478
 		try {
3479 3479
 		        
@@ -3481,7 +3481,7 @@  discard block
 block discarded – undo
3481 3481
 			$sth->execute($query_values);
3482 3482
 			$this->db = null;
3483 3483
 		} catch (PDOException $e) {
3484
-		    return "error : ".$e->getMessage();
3484
+			return "error : ".$e->getMessage();
3485 3485
 		}
3486 3486
 		
3487 3487
 		return "success";
@@ -3490,11 +3490,11 @@  discard block
 block discarded – undo
3490 3490
 	
3491 3491
   
3492 3492
 	/**
3493
-	* Gets the aircraft ident within the last hour
3494
-	*
3495
-	* @return String the ident
3496
-	*
3497
-	*/
3493
+	 * Gets the aircraft ident within the last hour
3494
+	 *
3495
+	 * @return String the ident
3496
+	 *
3497
+	 */
3498 3498
 	public function getIdentFromLastHour($ident)
3499 3499
 	{
3500 3500
 		global $globalDBdriver, $globalTimezone;
@@ -3510,11 +3510,11 @@  discard block
 block discarded – undo
3510 3510
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3511 3511
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
3512 3512
 			$query_data = array(':ident' => $ident);
3513
-    		}
3513
+			}
3514 3514
 		
3515 3515
 		$sth = $this->db->prepare($query);
3516 3516
 		$sth->execute($query_data);
3517
-    		$ident_result='';
3517
+			$ident_result='';
3518 3518
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3519 3519
 		{
3520 3520
 			$ident_result = $row['ident'];
@@ -3525,11 +3525,11 @@  discard block
 block discarded – undo
3525 3525
 	
3526 3526
 	
3527 3527
 	/**
3528
-	* Gets the aircraft data from the last 20 seconds
3529
-	*
3530
-	* @return Array the spotter data
3531
-	*
3532
-	*/
3528
+	 * Gets the aircraft data from the last 20 seconds
3529
+	 *
3530
+	 * @return Array the spotter data
3531
+	 *
3532
+	 */
3533 3533
 	public function getRealTimeData($q = '')
3534 3534
 	{
3535 3535
 		global $globalDBdriver;
@@ -3573,11 +3573,11 @@  discard block
 block discarded – undo
3573 3573
 	
3574 3574
 	
3575 3575
 	 /**
3576
-	* Gets all airlines that have flown over
3577
-	*
3578
-	* @return Array the airline list
3579
-	*
3580
-	*/
3576
+	  * Gets all airlines that have flown over
3577
+	  *
3578
+	  * @return Array the airline list
3579
+	  *
3580
+	  */
3581 3581
 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3582 3582
 	{
3583 3583
 		global $globalDBdriver;
@@ -3591,7 +3591,7 @@  discard block
 block discarded – undo
3591 3591
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
3592 3592
 			}
3593 3593
 		}
3594
-                if ($sincedate != '') {
3594
+				if ($sincedate != '') {
3595 3595
 			if ($globalDBdriver == 'mysql') {
3596 3596
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
3597 3597
 			} else {
@@ -3618,26 +3618,26 @@  discard block
 block discarded – undo
3618 3618
 	}
3619 3619
 
3620 3620
 	 /**
3621
-	* Gets all pilots that have flown over
3622
-	*
3623
-	* @return Array the pilots list
3624
-	*
3625
-	*/
3621
+	  * Gets all pilots that have flown over
3622
+	  *
3623
+	  * @return Array the pilots list
3624
+	  *
3625
+	  */
3626 3626
 	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3627 3627
 	{
3628 3628
 		global $globalDBdriver;
3629 3629
 		$filter_query = $this->getFilter($filters,true,true);
3630 3630
 		$query  = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3631 3631
 		 			FROM spotter_output".$filter_query." spotter_output.pilot_id <> '' ";
3632
-                if ($olderthanmonths > 0) {
3633
-            		if ($globalDBdriver == 'mysql') {
3632
+				if ($olderthanmonths > 0) {
3633
+					if ($globalDBdriver == 'mysql') {
3634 3634
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
3635 3635
 			} else {
3636 3636
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
3637 3637
 			}
3638 3638
 		}
3639
-                if ($sincedate != '') {
3640
-            		if ($globalDBdriver == 'mysql') {
3639
+				if ($sincedate != '') {
3640
+					if ($globalDBdriver == 'mysql') {
3641 3641
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
3642 3642
 			} else {
3643 3643
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -3664,25 +3664,25 @@  discard block
 block discarded – undo
3664 3664
 	}
3665 3665
 	
3666 3666
 		 /**
3667
-	* Gets all pilots that have flown over
3668
-	*
3669
-	* @return Array the pilots list
3670
-	*
3671
-	*/
3667
+		  * Gets all pilots that have flown over
3668
+		  *
3669
+		  * @return Array the pilots list
3670
+		  *
3671
+		  */
3672 3672
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3673 3673
 	{
3674 3674
 		global $globalDBdriver;
3675 3675
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3676 3676
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
3677
-                if ($olderthanmonths > 0) {
3678
-            		if ($globalDBdriver == 'mysql') {
3677
+				if ($olderthanmonths > 0) {
3678
+					if ($globalDBdriver == 'mysql') {
3679 3679
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
3680 3680
 			} else {
3681 3681
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
3682 3682
 			}
3683 3683
 		}
3684
-                if ($sincedate != '') {
3685
-            		if ($globalDBdriver == 'mysql') {
3684
+				if ($sincedate != '') {
3685
+					if ($globalDBdriver == 'mysql') {
3686 3686
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
3687 3687
 			} else {
3688 3688
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -3710,26 +3710,26 @@  discard block
 block discarded – undo
3710 3710
 	}
3711 3711
 	
3712 3712
 	 /**
3713
-	* Gets all owner that have flown over
3714
-	*
3715
-	* @return Array the pilots list
3716
-	*
3717
-	*/
3713
+	  * Gets all owner that have flown over
3714
+	  *
3715
+	  * @return Array the pilots list
3716
+	  *
3717
+	  */
3718 3718
 	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3719 3719
 	{
3720 3720
 		global $globalDBdriver;
3721 3721
 		$filter_query = $this->getFilter($filters,true,true);
3722 3722
 		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3723 3723
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3724
-                if ($olderthanmonths > 0) {
3725
-            		if ($globalDBdriver == 'mysql') {
3724
+				if ($olderthanmonths > 0) {
3725
+					if ($globalDBdriver == 'mysql') {
3726 3726
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
3727 3727
 			} else {
3728 3728
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
3729 3729
 			}
3730 3730
 		}
3731
-                if ($sincedate != '') {
3732
-            		if ($globalDBdriver == 'mysql') {
3731
+				if ($sincedate != '') {
3732
+					if ($globalDBdriver == 'mysql') {
3733 3733
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
3734 3734
 			} else {
3735 3735
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -3755,25 +3755,25 @@  discard block
 block discarded – undo
3755 3755
 	}
3756 3756
 	
3757 3757
 	 /**
3758
-	* Gets all owner that have flown over
3759
-	*
3760
-	* @return Array the pilots list
3761
-	*
3762
-	*/
3758
+	  * Gets all owner that have flown over
3759
+	  *
3760
+	  * @return Array the pilots list
3761
+	  *
3762
+	  */
3763 3763
 	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3764 3764
 	{
3765 3765
 		global $globalDBdriver;
3766 3766
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3767 3767
 		 			FROM spotter_output WHERE spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3768
-                if ($olderthanmonths > 0) {
3769
-            		if ($globalDBdriver == 'mysql') {
3768
+				if ($olderthanmonths > 0) {
3769
+					if ($globalDBdriver == 'mysql') {
3770 3770
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
3771 3771
 			} else {
3772 3772
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
3773 3773
 			}
3774 3774
 		}
3775
-                if ($sincedate != '') {
3776
-            		if ($globalDBdriver == 'mysql') {
3775
+				if ($sincedate != '') {
3776
+					if ($globalDBdriver == 'mysql') {
3777 3777
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
3778 3778
 			} else {
3779 3779
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -3800,11 +3800,11 @@  discard block
 block discarded – undo
3800 3800
 	}
3801 3801
 
3802 3802
 	/**
3803
-	* Gets all airlines that have flown over by aircraft
3804
-	*
3805
-	* @return Array the airline list
3806
-	*
3807
-	*/
3803
+	 * Gets all airlines that have flown over by aircraft
3804
+	 *
3805
+	 * @return Array the airline list
3806
+	 *
3807
+	 */
3808 3808
 	public function countAllAirlinesByAircraft($aircraft_icao)
3809 3809
 	{
3810 3810
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -3837,11 +3837,11 @@  discard block
 block discarded – undo
3837 3837
 
3838 3838
 
3839 3839
 	/**
3840
-	* Gets all airline countries that have flown over by aircraft
3841
-	*
3842
-	* @return Array the airline country list
3843
-	*
3844
-	*/
3840
+	 * Gets all airline countries that have flown over by aircraft
3841
+	 *
3842
+	 * @return Array the airline country list
3843
+	 *
3844
+	 */
3845 3845
 	public function countAllAirlineCountriesByAircraft($aircraft_icao)
3846 3846
 	{
3847 3847
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -3874,11 +3874,11 @@  discard block
 block discarded – undo
3874 3874
 	
3875 3875
 	
3876 3876
 	/**
3877
-	* Gets all airlines that have flown over by airport
3878
-	*
3879
-	* @return Array the airline list
3880
-	*
3881
-	*/
3877
+	 * Gets all airlines that have flown over by airport
3878
+	 *
3879
+	 * @return Array the airline list
3880
+	 *
3881
+	 */
3882 3882
 	public function countAllAirlinesByAirport($airport_icao)
3883 3883
 	{
3884 3884
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -3910,11 +3910,11 @@  discard block
 block discarded – undo
3910 3910
 
3911 3911
 
3912 3912
 	/**
3913
-	* Gets all airline countries that have flown over by airport icao
3914
-	*
3915
-	* @return Array the airline country list
3916
-	*
3917
-	*/
3913
+	 * Gets all airline countries that have flown over by airport icao
3914
+	 *
3915
+	 * @return Array the airline country list
3916
+	 *
3917
+	 */
3918 3918
 	public function countAllAirlineCountriesByAirport($airport_icao)
3919 3919
 	{
3920 3920
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -3945,11 +3945,11 @@  discard block
 block discarded – undo
3945 3945
 
3946 3946
 
3947 3947
 	/**
3948
-	* Gets all airlines that have flown over by aircraft manufacturer
3949
-	*
3950
-	* @return Array the airline list
3951
-	*
3952
-	*/
3948
+	 * Gets all airlines that have flown over by aircraft manufacturer
3949
+	 *
3950
+	 * @return Array the airline list
3951
+	 *
3952
+	 */
3953 3953
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer)
3954 3954
 	{
3955 3955
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -3981,11 +3981,11 @@  discard block
 block discarded – undo
3981 3981
 
3982 3982
 
3983 3983
 	/**
3984
-	* Gets all airline countries that have flown over by aircraft manufacturer
3985
-	*
3986
-	* @return Array the airline country list
3987
-	*
3988
-	*/
3984
+	 * Gets all airline countries that have flown over by aircraft manufacturer
3985
+	 *
3986
+	 * @return Array the airline country list
3987
+	 *
3988
+	 */
3989 3989
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer)
3990 3990
 	{
3991 3991
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4015,11 +4015,11 @@  discard block
 block discarded – undo
4015 4015
 
4016 4016
 
4017 4017
 	/**
4018
-	* Gets all airlines that have flown over by date
4019
-	*
4020
-	* @return Array the airline list
4021
-	*
4022
-	*/
4018
+	 * Gets all airlines that have flown over by date
4019
+	 *
4020
+	 * @return Array the airline list
4021
+	 *
4022
+	 */
4023 4023
 	public function countAllAirlinesByDate($date)
4024 4024
 	{
4025 4025
 		global $globalTimezone, $globalDBdriver;
@@ -4065,11 +4065,11 @@  discard block
 block discarded – undo
4065 4065
 	
4066 4066
 	
4067 4067
 	/**
4068
-	* Gets all airline countries that have flown over by date
4069
-	*
4070
-	* @return Array the airline country list
4071
-	*
4072
-	*/
4068
+	 * Gets all airline countries that have flown over by date
4069
+	 *
4070
+	 * @return Array the airline country list
4071
+	 *
4072
+	 */
4073 4073
 	public function countAllAirlineCountriesByDate($date)
4074 4074
 	{
4075 4075
 		global $globalTimezone, $globalDBdriver;
@@ -4113,11 +4113,11 @@  discard block
 block discarded – undo
4113 4113
 
4114 4114
 
4115 4115
 	/**
4116
-	* Gets all airlines that have flown over by ident/callsign
4117
-	*
4118
-	* @return Array the airline list
4119
-	*
4120
-	*/
4116
+	 * Gets all airlines that have flown over by ident/callsign
4117
+	 *
4118
+	 * @return Array the airline list
4119
+	 *
4120
+	 */
4121 4121
 	public function countAllAirlinesByIdent($ident)
4122 4122
 	{
4123 4123
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4148,11 +4148,11 @@  discard block
 block discarded – undo
4148 4148
 	}
4149 4149
 
4150 4150
 	/**
4151
-	* Gets all airlines that have flown over by route
4152
-	*
4153
-	* @return Array the airline list
4154
-	*
4155
-	*/
4151
+	 * Gets all airlines that have flown over by route
4152
+	 *
4153
+	 * @return Array the airline list
4154
+	 *
4155
+	 */
4156 4156
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao)
4157 4157
 	{
4158 4158
 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
@@ -4184,11 +4184,11 @@  discard block
 block discarded – undo
4184 4184
 	}
4185 4185
 
4186 4186
 	/**
4187
-	* Gets all airline countries that have flown over by route
4188
-	*
4189
-	* @return Array the airline country list
4190
-	*
4191
-	*/
4187
+	 * Gets all airline countries that have flown over by route
4188
+	 *
4189
+	 * @return Array the airline country list
4190
+	 *
4191
+	 */
4192 4192
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao)
4193 4193
 	{
4194 4194
 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
@@ -4220,11 +4220,11 @@  discard block
 block discarded – undo
4220 4220
 
4221 4221
 
4222 4222
 	/**
4223
-	* Gets all airlines that have flown over by country
4224
-	*
4225
-	* @return Array the airline list
4226
-	*
4227
-	*/
4223
+	 * Gets all airlines that have flown over by country
4224
+	 *
4225
+	 * @return Array the airline list
4226
+	 *
4227
+	 */
4228 4228
 	public function countAllAirlinesByCountry($country)
4229 4229
 	{
4230 4230
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4255,11 +4255,11 @@  discard block
 block discarded – undo
4255 4255
 
4256 4256
 
4257 4257
 	/**
4258
-	* Gets all airline countries that have flown over by country
4259
-	*
4260
-	* @return Array the airline country list
4261
-	*
4262
-	*/
4258
+	 * Gets all airline countries that have flown over by country
4259
+	 *
4260
+	 * @return Array the airline country list
4261
+	 *
4262
+	 */
4263 4263
 	public function countAllAirlineCountriesByCountry($country)
4264 4264
 	{
4265 4265
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4289,11 +4289,11 @@  discard block
 block discarded – undo
4289 4289
 
4290 4290
 
4291 4291
 	/**
4292
-	* Gets all airlines countries
4293
-	*
4294
-	* @return Array the airline country list
4295
-	*
4296
-	*/
4292
+	 * Gets all airlines countries
4293
+	 *
4294
+	 * @return Array the airline country list
4295
+	 *
4296
+	 */
4297 4297
 	public function countAllAirlineCountries($limit = true)
4298 4298
 	{
4299 4299
 		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4319,11 +4319,11 @@  discard block
 block discarded – undo
4319 4319
 	}
4320 4320
 
4321 4321
 	/**
4322
-	* Gets all number of flight over countries
4323
-	*
4324
-	* @return Array the airline country list
4325
-	*
4326
-	*/
4322
+	 * Gets all number of flight over countries
4323
+	 *
4324
+	 * @return Array the airline country list
4325
+	 *
4326
+	 */
4327 4327
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
4328 4328
 	{
4329 4329
 		global $globalDBdriver;
@@ -4335,15 +4335,15 @@  discard block
 block discarded – undo
4335 4335
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
4336 4336
 					FROM countries c, spotter_live s
4337 4337
 					WHERE c.iso2 = s.over_country ";
4338
-                if ($olderthanmonths > 0) {
4338
+				if ($olderthanmonths > 0) {
4339 4339
 			if ($globalDBdriver == 'mysql') {
4340 4340
 				$query .= 'AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
4341 4341
 			} else {
4342 4342
 				$query .= "AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4343 4343
 			}
4344 4344
 		}
4345
-                if ($sincedate != '') {
4346
-            		if ($globalDBdriver == 'mysql') {
4345
+				if ($sincedate != '') {
4346
+					if ($globalDBdriver == 'mysql') {
4347 4347
 				$query .= "AND spotter_live.date > '".$sincedate."' ";
4348 4348
 			} else {
4349 4349
 				$query .= "AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4373,11 +4373,11 @@  discard block
 block discarded – undo
4373 4373
 	
4374 4374
 	
4375 4375
 	/**
4376
-	* Gets all aircraft types that have flown over
4377
-	*
4378
-	* @return Array the aircraft list
4379
-	*
4380
-	*/
4376
+	 * Gets all aircraft types that have flown over
4377
+	 *
4378
+	 * @return Array the aircraft list
4379
+	 *
4380
+	 */
4381 4381
 	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
4382 4382
 	{
4383 4383
 		global $globalDBdriver;
@@ -4420,11 +4420,11 @@  discard block
 block discarded – undo
4420 4420
 	}
4421 4421
 
4422 4422
 	/**
4423
-	* Gets all aircraft types that have flown over by airline
4424
-	*
4425
-	* @return Array the aircraft list
4426
-	*
4427
-	*/
4423
+	 * Gets all aircraft types that have flown over by airline
4424
+	 *
4425
+	 * @return Array the aircraft list
4426
+	 *
4427
+	 */
4428 4428
 	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
4429 4429
 	{
4430 4430
 		global $globalDBdriver;
@@ -4468,11 +4468,11 @@  discard block
 block discarded – undo
4468 4468
 
4469 4469
 
4470 4470
 	/**
4471
-	* Gets all aircraft registration that have flown over by aircaft icao
4472
-	*
4473
-	* @return Array the aircraft list
4474
-	*
4475
-	*/
4471
+	 * Gets all aircraft registration that have flown over by aircaft icao
4472
+	 *
4473
+	 * @return Array the aircraft list
4474
+	 *
4475
+	 */
4476 4476
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao)
4477 4477
 	{
4478 4478
 		$Image = new Image($this->db);
@@ -4511,11 +4511,11 @@  discard block
 block discarded – undo
4511 4511
 
4512 4512
 
4513 4513
 	/**
4514
-	* Gets all aircraft types that have flown over by airline icao
4515
-	*
4516
-	* @return Array the aircraft list
4517
-	*
4518
-	*/
4514
+	 * Gets all aircraft types that have flown over by airline icao
4515
+	 *
4516
+	 * @return Array the aircraft list
4517
+	 *
4518
+	 */
4519 4519
 	public function countAllAircraftTypesByAirline($airline_icao)
4520 4520
 	{
4521 4521
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -4545,11 +4545,11 @@  discard block
 block discarded – undo
4545 4545
 
4546 4546
 
4547 4547
 	/**
4548
-	* Gets all aircraft registration that have flown over by airline icao
4549
-	*
4550
-	* @return Array the aircraft list
4551
-	*
4552
-	*/
4548
+	 * Gets all aircraft registration that have flown over by airline icao
4549
+	 *
4550
+	 * @return Array the aircraft list
4551
+	 *
4552
+	 */
4553 4553
 	public function countAllAircraftRegistrationByAirline($airline_icao)
4554 4554
 	{
4555 4555
 		$Image = new Image($this->db);
@@ -4587,11 +4587,11 @@  discard block
 block discarded – undo
4587 4587
 
4588 4588
 
4589 4589
 	/**
4590
-	* Gets all aircraft manufacturer that have flown over by airline icao
4591
-	*
4592
-	* @return Array the aircraft list
4593
-	*
4594
-	*/
4590
+	 * Gets all aircraft manufacturer that have flown over by airline icao
4591
+	 *
4592
+	 * @return Array the aircraft list
4593
+	 *
4594
+	 */
4595 4595
 	public function countAllAircraftManufacturerByAirline($airline_icao)
4596 4596
 	{
4597 4597
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -4620,11 +4620,11 @@  discard block
 block discarded – undo
4620 4620
 
4621 4621
 
4622 4622
 	/**
4623
-	* Gets all aircraft types that have flown over by airline icao
4624
-	*
4625
-	* @return Array the aircraft list
4626
-	*
4627
-	*/
4623
+	 * Gets all aircraft types that have flown over by airline icao
4624
+	 *
4625
+	 * @return Array the aircraft list
4626
+	 *
4627
+	 */
4628 4628
 	public function countAllAircraftTypesByAirport($airport_icao)
4629 4629
 	{
4630 4630
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4653,11 +4653,11 @@  discard block
 block discarded – undo
4653 4653
 
4654 4654
 
4655 4655
 	/**
4656
-	* Gets all aircraft registration that have flown over by airport icao
4657
-	*
4658
-	* @return Array the aircraft list
4659
-	*
4660
-	*/
4656
+	 * Gets all aircraft registration that have flown over by airport icao
4657
+	 *
4658
+	 * @return Array the aircraft list
4659
+	 *
4660
+	 */
4661 4661
 	public function countAllAircraftRegistrationByAirport($airport_icao)
4662 4662
 	{
4663 4663
 		$Image = new Image($this->db);
@@ -4695,11 +4695,11 @@  discard block
 block discarded – undo
4695 4695
 	
4696 4696
 	
4697 4697
 	/**
4698
-	* Gets all aircraft manufacturer that have flown over by airport icao
4699
-	*
4700
-	* @return Array the aircraft list
4701
-	*
4702
-	*/
4698
+	 * Gets all aircraft manufacturer that have flown over by airport icao
4699
+	 *
4700
+	 * @return Array the aircraft list
4701
+	 *
4702
+	 */
4703 4703
 	public function countAllAircraftManufacturerByAirport($airport_icao)
4704 4704
 	{
4705 4705
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4726,11 +4726,11 @@  discard block
 block discarded – undo
4726 4726
 	}
4727 4727
 
4728 4728
 	/**
4729
-	* Gets all aircraft types that have flown over by aircraft manufacturer
4730
-	*
4731
-	* @return Array the aircraft list
4732
-	*
4733
-	*/
4729
+	 * Gets all aircraft types that have flown over by aircraft manufacturer
4730
+	 *
4731
+	 * @return Array the aircraft list
4732
+	 *
4733
+	 */
4734 4734
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer)
4735 4735
 	{
4736 4736
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4757,11 +4757,11 @@  discard block
 block discarded – undo
4757 4757
 
4758 4758
 
4759 4759
 	/**
4760
-	* Gets all aircraft registration that have flown over by aircaft manufacturer
4761
-	*
4762
-	* @return Array the aircraft list
4763
-	*
4764
-	*/
4760
+	 * Gets all aircraft registration that have flown over by aircaft manufacturer
4761
+	 *
4762
+	 * @return Array the aircraft list
4763
+	 *
4764
+	 */
4765 4765
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer)
4766 4766
 	{
4767 4767
 		$Image = new Image($this->db);
@@ -4797,11 +4797,11 @@  discard block
 block discarded – undo
4797 4797
 	}
4798 4798
 
4799 4799
 	/**
4800
-	* Gets all aircraft types that have flown over by date
4801
-	*
4802
-	* @return Array the aircraft list
4803
-	*
4804
-	*/
4800
+	 * Gets all aircraft types that have flown over by date
4801
+	 *
4802
+	 * @return Array the aircraft list
4803
+	 *
4804
+	 */
4805 4805
 	public function countAllAircraftTypesByDate($date)
4806 4806
 	{
4807 4807
 		global $globalTimezone, $globalDBdriver;
@@ -4844,11 +4844,11 @@  discard block
 block discarded – undo
4844 4844
 
4845 4845
 
4846 4846
 	/**
4847
-	* Gets all aircraft registration that have flown over by date
4848
-	*
4849
-	* @return Array the aircraft list
4850
-	*
4851
-	*/
4847
+	 * Gets all aircraft registration that have flown over by date
4848
+	 *
4849
+	 * @return Array the aircraft list
4850
+	 *
4851
+	 */
4852 4852
 	public function countAllAircraftRegistrationByDate($date)
4853 4853
 	{
4854 4854
 		global $globalTimezone, $globalDBdriver;
@@ -4900,11 +4900,11 @@  discard block
 block discarded – undo
4900 4900
 
4901 4901
 
4902 4902
 	/**
4903
-	* Gets all aircraft manufacturer that have flown over by date
4904
-	*
4905
-	* @return Array the aircraft manufacturer list
4906
-	*
4907
-	*/
4903
+	 * Gets all aircraft manufacturer that have flown over by date
4904
+	 *
4905
+	 * @return Array the aircraft manufacturer list
4906
+	 *
4907
+	 */
4908 4908
 	public function countAllAircraftManufacturerByDate($date)
4909 4909
 	{
4910 4910
 		global $globalTimezone, $globalDBdriver;
@@ -4947,11 +4947,11 @@  discard block
 block discarded – undo
4947 4947
 
4948 4948
 
4949 4949
 	/**
4950
-	* Gets all aircraft types that have flown over by ident/callsign
4951
-	*
4952
-	* @return Array the aircraft list
4953
-	*
4954
-	*/
4950
+	 * Gets all aircraft types that have flown over by ident/callsign
4951
+	 *
4952
+	 * @return Array the aircraft list
4953
+	 *
4954
+	 */
4955 4955
 	public function countAllAircraftTypesByIdent($ident)
4956 4956
 	{
4957 4957
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4981,11 +4981,11 @@  discard block
 block discarded – undo
4981 4981
 
4982 4982
 
4983 4983
 	/**
4984
-	* Gets all aircraft registration that have flown over by ident/callsign
4985
-	*
4986
-	* @return Array the aircraft list
4987
-	*
4988
-	*/
4984
+	 * Gets all aircraft registration that have flown over by ident/callsign
4985
+	 *
4986
+	 * @return Array the aircraft list
4987
+	 *
4988
+	 */
4989 4989
 	public function countAllAircraftRegistrationByIdent($ident)
4990 4990
 	{
4991 4991
 		$Image = new Image($this->db);
@@ -5025,11 +5025,11 @@  discard block
 block discarded – undo
5025 5025
 
5026 5026
 
5027 5027
 	/**
5028
-	* Gets all aircraft manufacturer that have flown over by ident/callsign
5029
-	*
5030
-	* @return Array the aircraft manufacturer list
5031
-	*
5032
-	*/
5028
+	 * Gets all aircraft manufacturer that have flown over by ident/callsign
5029
+	 *
5030
+	 * @return Array the aircraft manufacturer list
5031
+	 *
5032
+	 */
5033 5033
 	public function countAllAircraftManufacturerByIdent($ident)
5034 5034
 	{
5035 5035
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -5056,11 +5056,11 @@  discard block
 block discarded – undo
5056 5056
 
5057 5057
 
5058 5058
 	/**
5059
-	* Gets all aircraft types that have flown over by route
5060
-	*
5061
-	* @return Array the aircraft list
5062
-	*
5063
-	*/
5059
+	 * Gets all aircraft types that have flown over by route
5060
+	 *
5061
+	 * @return Array the aircraft list
5062
+	 *
5063
+	 */
5064 5064
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao)
5065 5065
 	{
5066 5066
 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
@@ -5089,11 +5089,11 @@  discard block
 block discarded – undo
5089 5089
 	}
5090 5090
 
5091 5091
 	/**
5092
-	* Gets all aircraft registration that have flown over by route
5093
-	*
5094
-	* @return Array the aircraft list
5095
-	*
5096
-	*/
5092
+	 * Gets all aircraft registration that have flown over by route
5093
+	 *
5094
+	 * @return Array the aircraft list
5095
+	 *
5096
+	 */
5097 5097
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao)
5098 5098
 	{
5099 5099
 		$Image = new Image($this->db);
@@ -5135,11 +5135,11 @@  discard block
 block discarded – undo
5135 5135
 	
5136 5136
 	
5137 5137
 	/**
5138
-	* Gets all aircraft manufacturer that have flown over by route
5139
-	*
5140
-	* @return Array the aircraft manufacturer list
5141
-	*
5142
-	*/
5138
+	 * Gets all aircraft manufacturer that have flown over by route
5139
+	 *
5140
+	 * @return Array the aircraft manufacturer list
5141
+	 *
5142
+	 */
5143 5143
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao)
5144 5144
 	{
5145 5145
 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
@@ -5173,11 +5173,11 @@  discard block
 block discarded – undo
5173 5173
 	
5174 5174
 	
5175 5175
 	/**
5176
-	* Gets all aircraft types that have flown over by country
5177
-	*
5178
-	* @return Array the aircraft list
5179
-	*
5180
-	*/
5176
+	 * Gets all aircraft types that have flown over by country
5177
+	 *
5178
+	 * @return Array the aircraft list
5179
+	 *
5180
+	 */
5181 5181
 	public function countAllAircraftTypesByCountry($country)
5182 5182
 	{
5183 5183
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -5209,11 +5209,11 @@  discard block
 block discarded – undo
5209 5209
 
5210 5210
 
5211 5211
 	/**
5212
-	* Gets all aircraft registration that have flown over by country
5213
-	*
5214
-	* @return Array the aircraft list
5215
-	*
5216
-	*/
5212
+	 * Gets all aircraft registration that have flown over by country
5213
+	 *
5214
+	 * @return Array the aircraft list
5215
+	 *
5216
+	 */
5217 5217
 	public function countAllAircraftRegistrationByCountry($country)
5218 5218
 	{
5219 5219
 		$Image = new Image($this->db);
@@ -5254,11 +5254,11 @@  discard block
 block discarded – undo
5254 5254
 	
5255 5255
 	
5256 5256
 	/**
5257
-	* Gets all aircraft manufacturer that have flown over by country
5258
-	*
5259
-	* @return Array the aircraft manufacturer list
5260
-	*
5261
-	*/
5257
+	 * Gets all aircraft manufacturer that have flown over by country
5258
+	 *
5259
+	 * @return Array the aircraft manufacturer list
5260
+	 *
5261
+	 */
5262 5262
 	public function countAllAircraftManufacturerByCountry($country)
5263 5263
 	{
5264 5264
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -5290,17 +5290,17 @@  discard block
 block discarded – undo
5290 5290
 	
5291 5291
 	
5292 5292
 	/**
5293
-	* Gets all aircraft manufacturers that have flown over
5294
-	*
5295
-	* @return Array the aircraft list
5296
-	*
5297
-	*/
5293
+	 * Gets all aircraft manufacturers that have flown over
5294
+	 *
5295
+	 * @return Array the aircraft list
5296
+	 *
5297
+	 */
5298 5298
 	public function countAllAircraftManufacturers($filter = array())
5299 5299
 	{
5300 5300
 		$filter_query = $this->getFilter($filter,true,true);
5301 5301
 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5302 5302
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
5303
-                $query .= " GROUP BY spotter_output.aircraft_manufacturer
5303
+				$query .= " GROUP BY spotter_output.aircraft_manufacturer
5304 5304
 					ORDER BY aircraft_manufacturer_count DESC
5305 5305
 					LIMIT 10";
5306 5306
       
@@ -5325,11 +5325,11 @@  discard block
 block discarded – undo
5325 5325
 	
5326 5326
 	
5327 5327
 	/**
5328
-	* Gets all aircraft registrations that have flown over
5329
-	*
5330
-	* @return Array the aircraft list
5331
-	*
5332
-	*/
5328
+	 * Gets all aircraft registrations that have flown over
5329
+	 *
5330
+	 * @return Array the aircraft list
5331
+	 *
5332
+	 */
5333 5333
 	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5334 5334
 	{
5335 5335
 		global $globalDBdriver;
@@ -5337,15 +5337,15 @@  discard block
 block discarded – undo
5337 5337
 		$filter_query = $this->getFilter($filters,true,true);
5338 5338
 		$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    
5339 5339
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
5340
-                if ($olderthanmonths > 0) {
5341
-            		if ($globalDBdriver == 'mysql') {
5340
+				if ($olderthanmonths > 0) {
5341
+					if ($globalDBdriver == 'mysql') {
5342 5342
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
5343 5343
 			} else {
5344 5344
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
5345 5345
 			}
5346 5346
 		}
5347
-                if ($sincedate != '') {
5348
-            		if ($globalDBdriver == 'mysql') {
5347
+				if ($sincedate != '') {
5348
+					if ($globalDBdriver == 'mysql') {
5349 5349
 				$query .= " AND spotter_output.date > '".$sincedate."'";
5350 5350
 			} else {
5351 5351
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -5354,7 +5354,7 @@  discard block
 block discarded – undo
5354 5354
 
5355 5355
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5356 5356
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5357
-                $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5357
+				$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5358 5358
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5359 5359
 		
5360 5360
 		$sth = $this->db->prepare($query);
@@ -5385,11 +5385,11 @@  discard block
 block discarded – undo
5385 5385
 
5386 5386
 
5387 5387
 	/**
5388
-	* Gets all aircraft registrations that have flown over
5389
-	*
5390
-	* @return Array the aircraft list
5391
-	*
5392
-	*/
5388
+	 * Gets all aircraft registrations that have flown over
5389
+	 *
5390
+	 * @return Array the aircraft list
5391
+	 *
5392
+	 */
5393 5393
 	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
5394 5394
 	{
5395 5395
 		global $globalDBdriver;
@@ -5397,15 +5397,15 @@  discard block
 block discarded – undo
5397 5397
 		$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    
5398 5398
                     FROM spotter_output 
5399 5399
                     WHERE spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
5400
-                if ($olderthanmonths > 0) {
5401
-            		if ($globalDBdriver == 'mysql') {
5400
+				if ($olderthanmonths > 0) {
5401
+					if ($globalDBdriver == 'mysql') {
5402 5402
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
5403 5403
 			} else {
5404 5404
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
5405 5405
 			}
5406 5406
 		}
5407
-                if ($sincedate != '') {
5408
-            		if ($globalDBdriver == 'mysql') {
5407
+				if ($sincedate != '') {
5408
+					if ($globalDBdriver == 'mysql') {
5409 5409
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
5410 5410
 			} else {
5411 5411
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -5414,7 +5414,7 @@  discard block
 block discarded – undo
5414 5414
 
5415 5415
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5416 5416
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5417
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5417
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5418 5418
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5419 5419
 		
5420 5420
 		$sth = $this->db->prepare($query);
@@ -5446,35 +5446,35 @@  discard block
 block discarded – undo
5446 5446
 	
5447 5447
 	
5448 5448
 	/**
5449
-	* Gets all departure airports of the airplanes that have flown over
5450
-	*
5451
-	* @return Array the airport list
5452
-	*
5453
-	*/
5449
+	 * Gets all departure airports of the airplanes that have flown over
5450
+	 *
5451
+	 * @return Array the airport list
5452
+	 *
5453
+	 */
5454 5454
 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5455 5455
 	{
5456 5456
 		global $globalDBdriver;
5457 5457
 		$filter_query = $this->getFilter($filters,true,true);
5458 5458
 		$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 
5459 5459
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA'";
5460
-                if ($olderthanmonths > 0) {
5461
-            		if ($globalDBdriver == 'mysql') {
5460
+				if ($olderthanmonths > 0) {
5461
+					if ($globalDBdriver == 'mysql') {
5462 5462
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
5463 5463
 			} else {
5464 5464
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
5465 5465
 			}
5466
-                }
5467
-                if ($sincedate != '') {
5468
-            		if ($globalDBdriver == 'mysql') {
5466
+				}
5467
+				if ($sincedate != '') {
5468
+					if ($globalDBdriver == 'mysql') {
5469 5469
 				$query .= " AND spotter_output.date > '".$sincedate."'";
5470 5470
 			} else {
5471 5471
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
5472 5472
 			}
5473 5473
 		}
5474 5474
 
5475
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5476
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5477
-                $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5475
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5476
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5477
+				$query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5478 5478
 				ORDER BY airport_departure_icao_count DESC";
5479 5479
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5480 5480
       
@@ -5498,35 +5498,35 @@  discard block
 block discarded – undo
5498 5498
 	}
5499 5499
 
5500 5500
 	/**
5501
-	* Gets all departure airports of the airplanes that have flown over
5502
-	*
5503
-	* @return Array the airport list
5504
-	*
5505
-	*/
5501
+	 * Gets all departure airports of the airplanes that have flown over
5502
+	 *
5503
+	 * @return Array the airport list
5504
+	 *
5505
+	 */
5506 5506
 	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
5507 5507
 	{
5508 5508
 		global $globalDBdriver;
5509 5509
 		$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 
5510 5510
 								FROM spotter_output
5511 5511
                     WHERE spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' ";
5512
-                if ($olderthanmonths > 0) {
5513
-            		if ($globalDBdriver == 'mysql') {
5512
+				if ($olderthanmonths > 0) {
5513
+					if ($globalDBdriver == 'mysql') {
5514 5514
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
5515 5515
 			} else {
5516 5516
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
5517 5517
 			}
5518
-                }
5519
-                if ($sincedate != '') {
5520
-            		if ($globalDBdriver == 'mysql') {
5518
+				}
5519
+				if ($sincedate != '') {
5520
+					if ($globalDBdriver == 'mysql') {
5521 5521
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
5522 5522
 			} else {
5523 5523
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
5524 5524
 			}
5525 5525
 		}
5526 5526
 
5527
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5528
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5529
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5527
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5528
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5529
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5530 5530
 				ORDER BY airport_departure_icao_count DESC";
5531 5531
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5532 5532
       
@@ -5551,34 +5551,34 @@  discard block
 block discarded – undo
5551 5551
 	}
5552 5552
 
5553 5553
 	/**
5554
-	* Gets all detected departure airports of the airplanes that have flown over
5555
-	*
5556
-	* @return Array the airport list
5557
-	*
5558
-	*/
5554
+	 * Gets all detected departure airports of the airplanes that have flown over
5555
+	 *
5556
+	 * @return Array the airport list
5557
+	 *
5558
+	 */
5559 5559
 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5560 5560
 	{
5561 5561
 		global $globalDBdriver;
5562 5562
 		$filter_query = $this->getFilter($filters,true,true);
5563 5563
 		$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
5564 5564
 				FROM spotter_output, airport".$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";
5565
-                if ($olderthanmonths > 0) {
5566
-            		if ($globalDBdriver == 'mysql') {
5565
+				if ($olderthanmonths > 0) {
5566
+					if ($globalDBdriver == 'mysql') {
5567 5567
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
5568 5568
 			} else {
5569 5569
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
5570 5570
 			}
5571
-                }
5572
-                if ($sincedate != '') {
5573
-            		if ($globalDBdriver == 'mysql') {
5571
+				}
5572
+				if ($sincedate != '') {
5573
+					if ($globalDBdriver == 'mysql') {
5574 5574
 				$query .= " AND spotter_output.date > '".$sincedate."'";
5575 5575
 			} else {
5576 5576
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
5577 5577
 			}
5578 5578
 		}
5579
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5580
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5581
-                $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5579
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5580
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5581
+				$query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5582 5582
 				ORDER BY airport_departure_icao_count DESC";
5583 5583
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5584 5584
       
@@ -5602,35 +5602,35 @@  discard block
 block discarded – undo
5602 5602
 	}
5603 5603
 	
5604 5604
 	/**
5605
-	* Gets all detected departure airports of the airplanes that have flown over
5606
-	*
5607
-	* @return Array the airport list
5608
-	*
5609
-	*/
5605
+	 * Gets all detected departure airports of the airplanes that have flown over
5606
+	 *
5607
+	 * @return Array the airport list
5608
+	 *
5609
+	 */
5610 5610
 	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
5611 5611
 	{
5612 5612
 		global $globalDBdriver;
5613 5613
 		$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
5614 5614
 				FROM spotter_output, airport
5615 5615
                     WHERE 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 ";
5616
-                if ($olderthanmonths > 0) {
5617
-            		if ($globalDBdriver == 'mysql') {
5616
+				if ($olderthanmonths > 0) {
5617
+					if ($globalDBdriver == 'mysql') {
5618 5618
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
5619 5619
 			} else {
5620 5620
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
5621 5621
 			}
5622
-                }
5623
-                if ($sincedate != '') {
5624
-            		if ($globalDBdriver == 'mysql') {
5622
+				}
5623
+				if ($sincedate != '') {
5624
+					if ($globalDBdriver == 'mysql') {
5625 5625
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
5626 5626
 			} else {
5627 5627
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
5628 5628
 			}
5629 5629
 		}
5630 5630
 
5631
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5632
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5633
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5631
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5632
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5633
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5634 5634
 				ORDER BY airport_departure_icao_count DESC";
5635 5635
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5636 5636
       
@@ -5655,11 +5655,11 @@  discard block
 block discarded – undo
5655 5655
 	}	
5656 5656
 	
5657 5657
 	/**
5658
-	* Gets all departure airports of the airplanes that have flown over based on an airline icao
5659
-	*
5660
-	* @return Array the airport list
5661
-	*
5662
-	*/
5658
+	 * Gets all departure airports of the airplanes that have flown over based on an airline icao
5659
+	 *
5660
+	 * @return Array the airport list
5661
+	 *
5662
+	 */
5663 5663
 	public function countAllDepartureAirportsByAirline($airline_icao)
5664 5664
 	{
5665 5665
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -5694,11 +5694,11 @@  discard block
 block discarded – undo
5694 5694
 	
5695 5695
 	
5696 5696
 	/**
5697
-	* Gets all departure airports by country of the airplanes that have flown over based on an airline icao
5698
-	*
5699
-	* @return Array the airport list
5700
-	*
5701
-	*/
5697
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airline icao
5698
+	 *
5699
+	 * @return Array the airport list
5700
+	 *
5701
+	 */
5702 5702
 	public function countAllDepartureAirportCountriesByAirline($airline_icao)
5703 5703
 	{
5704 5704
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -5730,11 +5730,11 @@  discard block
 block discarded – undo
5730 5730
 	
5731 5731
 	
5732 5732
 	/**
5733
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft icao
5734
-	*
5735
-	* @return Array the airport list
5736
-	*
5737
-	*/
5733
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft icao
5734
+	 *
5735
+	 * @return Array the airport list
5736
+	 *
5737
+	 */
5738 5738
 	public function countAllDepartureAirportsByAircraft($aircraft_icao)
5739 5739
 	{
5740 5740
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -5768,11 +5768,11 @@  discard block
 block discarded – undo
5768 5768
 	
5769 5769
 	
5770 5770
 	/**
5771
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
5772
-	*
5773
-	* @return Array the airport list
5774
-	*
5775
-	*/
5771
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
5772
+	 *
5773
+	 * @return Array the airport list
5774
+	 *
5775
+	 */
5776 5776
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao)
5777 5777
 	{
5778 5778
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -5803,11 +5803,11 @@  discard block
 block discarded – undo
5803 5803
 	
5804 5804
 	
5805 5805
 	/**
5806
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft registration
5807
-	*
5808
-	* @return Array the airport list
5809
-	*
5810
-	*/
5806
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft registration
5807
+	 *
5808
+	 * @return Array the airport list
5809
+	 *
5810
+	 */
5811 5811
 	public function countAllDepartureAirportsByRegistration($registration)
5812 5812
 	{
5813 5813
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -5841,11 +5841,11 @@  discard block
 block discarded – undo
5841 5841
 	
5842 5842
 	
5843 5843
 	/**
5844
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
5845
-	*
5846
-	* @return Array the airport list
5847
-	*
5848
-	*/
5844
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
5845
+	 *
5846
+	 * @return Array the airport list
5847
+	 *
5848
+	 */
5849 5849
 	public function countAllDepartureAirportCountriesByRegistration($registration)
5850 5850
 	{
5851 5851
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -5876,11 +5876,11 @@  discard block
 block discarded – undo
5876 5876
 	
5877 5877
 	
5878 5878
 	/**
5879
-	* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
5880
-	*
5881
-	* @return Array the airport list
5882
-	*
5883
-	*/
5879
+	 * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
5880
+	 *
5881
+	 * @return Array the airport list
5882
+	 *
5883
+	 */
5884 5884
 	public function countAllDepartureAirportsByAirport($airport_icao)
5885 5885
 	{
5886 5886
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -5914,11 +5914,11 @@  discard block
 block discarded – undo
5914 5914
 	
5915 5915
 	
5916 5916
 	/**
5917
-	* Gets all departure airports by country of the airplanes that have flown over based on an airport icao
5918
-	*
5919
-	* @return Array the airport list
5920
-	*
5921
-	*/
5917
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airport icao
5918
+	 *
5919
+	 * @return Array the airport list
5920
+	 *
5921
+	 */
5922 5922
 	public function countAllDepartureAirportCountriesByAirport($airport_icao)
5923 5923
 	{
5924 5924
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -5950,11 +5950,11 @@  discard block
 block discarded – undo
5950 5950
 	
5951 5951
 	
5952 5952
 	/**
5953
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
5954
-	*
5955
-	* @return Array the airport list
5956
-	*
5957
-	*/
5953
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
5954
+	 *
5955
+	 * @return Array the airport list
5956
+	 *
5957
+	 */
5958 5958
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer)
5959 5959
 	{
5960 5960
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -5988,11 +5988,11 @@  discard block
 block discarded – undo
5988 5988
 	
5989 5989
 	
5990 5990
 	/**
5991
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
5992
-	*
5993
-	* @return Array the airport list
5994
-	*
5995
-	*/
5991
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
5992
+	 *
5993
+	 * @return Array the airport list
5994
+	 *
5995
+	 */
5996 5996
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer)
5997 5997
 	{
5998 5998
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -6023,11 +6023,11 @@  discard block
 block discarded – undo
6023 6023
 	
6024 6024
 	
6025 6025
 	/**
6026
-	* Gets all departure airports of the airplanes that have flown over based on a date
6027
-	*
6028
-	* @return Array the airport list
6029
-	*
6030
-	*/
6026
+	 * Gets all departure airports of the airplanes that have flown over based on a date
6027
+	 *
6028
+	 * @return Array the airport list
6029
+	 *
6030
+	 */
6031 6031
 	public function countAllDepartureAirportsByDate($date)
6032 6032
 	{
6033 6033
 		global $globalTimezone, $globalDBdriver;
@@ -6075,11 +6075,11 @@  discard block
 block discarded – undo
6075 6075
 	
6076 6076
 	
6077 6077
 	/**
6078
-	* Gets all departure airports by country of the airplanes that have flown over based on a date
6079
-	*
6080
-	* @return Array the airport list
6081
-	*
6082
-	*/
6078
+	 * Gets all departure airports by country of the airplanes that have flown over based on a date
6079
+	 *
6080
+	 * @return Array the airport list
6081
+	 *
6082
+	 */
6083 6083
 	public function countAllDepartureAirportCountriesByDate($date)
6084 6084
 	{
6085 6085
 		global $globalTimezone, $globalDBdriver;
@@ -6123,11 +6123,11 @@  discard block
 block discarded – undo
6123 6123
 	
6124 6124
 	
6125 6125
 	/**
6126
-	* Gets all departure airports of the airplanes that have flown over based on a ident/callsign
6127
-	*
6128
-	* @return Array the airport list
6129
-	*
6130
-	*/
6126
+	 * Gets all departure airports of the airplanes that have flown over based on a ident/callsign
6127
+	 *
6128
+	 * @return Array the airport list
6129
+	 *
6130
+	 */
6131 6131
 	public function countAllDepartureAirportsByIdent($ident)
6132 6132
 	{
6133 6133
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -6162,11 +6162,11 @@  discard block
 block discarded – undo
6162 6162
 	
6163 6163
 	
6164 6164
 	/**
6165
-	* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
6166
-	*
6167
-	* @return Array the airport list
6168
-	*
6169
-	*/
6165
+	 * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
6166
+	 *
6167
+	 * @return Array the airport list
6168
+	 *
6169
+	 */
6170 6170
 	public function countAllDepartureAirportCountriesByIdent($ident)
6171 6171
 	{
6172 6172
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -6198,11 +6198,11 @@  discard block
 block discarded – undo
6198 6198
 	
6199 6199
 	
6200 6200
 	/**
6201
-	* Gets all departure airports of the airplanes that have flown over based on a country
6202
-	*
6203
-	* @return Array the airport list
6204
-	*
6205
-	*/
6201
+	 * Gets all departure airports of the airplanes that have flown over based on a country
6202
+	 *
6203
+	 * @return Array the airport list
6204
+	 *
6205
+	 */
6206 6206
 	public function countAllDepartureAirportsByCountry($country)
6207 6207
 	{
6208 6208
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -6236,11 +6236,11 @@  discard block
 block discarded – undo
6236 6236
 
6237 6237
 
6238 6238
 	/**
6239
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
6240
-	*
6241
-	* @return Array the airport list
6242
-	*
6243
-	*/
6239
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
6240
+	 *
6241
+	 * @return Array the airport list
6242
+	 *
6243
+	 */
6244 6244
 	public function countAllDepartureAirportCountriesByCountry($country)
6245 6245
 	{
6246 6246
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -6271,40 +6271,40 @@  discard block
 block discarded – undo
6271 6271
 	
6272 6272
 
6273 6273
 	/**
6274
-	* Gets all arrival airports of the airplanes that have flown over
6275
-	*
6276
-	* @return Array the airport list
6277
-	*
6278
-	*/
6274
+	 * Gets all arrival airports of the airplanes that have flown over
6275
+	 *
6276
+	 * @return Array the airport list
6277
+	 *
6278
+	 */
6279 6279
 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
6280 6280
 	{
6281 6281
 		global $globalDBdriver;
6282 6282
 		$filter_query = $this->getFilter($filters,true,true);
6283 6283
 		$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 
6284 6284
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
6285
-                if ($olderthanmonths > 0) {
6286
-            		if ($globalDBdriver == 'mysql') {
6285
+				if ($olderthanmonths > 0) {
6286
+					if ($globalDBdriver == 'mysql') {
6287 6287
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6288 6288
 			} else {
6289 6289
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6290 6290
 			}
6291
-                if ($sincedate != '') {
6292
-            		if ($globalDBdriver == 'mysql') {
6291
+				if ($sincedate != '') {
6292
+					if ($globalDBdriver == 'mysql') {
6293 6293
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6294 6294
 			} else {
6295 6295
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6296 6296
 			}
6297 6297
 		}
6298
-            		if ($globalDBdriver == 'mysql') {
6298
+					if ($globalDBdriver == 'mysql') {
6299 6299
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6300 6300
 			} else {
6301 6301
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6302 6302
 			}
6303 6303
 		}
6304 6304
 
6305
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6306
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6307
-                $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6305
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6306
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6307
+				$query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6308 6308
 					ORDER BY airport_arrival_icao_count DESC";
6309 6309
 		if ($limit) $query .= " LIMIT 10";
6310 6310
       
@@ -6333,40 +6333,40 @@  discard block
 block discarded – undo
6333 6333
 	}
6334 6334
 
6335 6335
 	/**
6336
-	* Gets all arrival airports of the airplanes that have flown over
6337
-	*
6338
-	* @return Array the airport list
6339
-	*
6340
-	*/
6336
+	 * Gets all arrival airports of the airplanes that have flown over
6337
+	 *
6338
+	 * @return Array the airport list
6339
+	 *
6340
+	 */
6341 6341
 	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false)
6342 6342
 	{
6343 6343
 		global $globalDBdriver;
6344 6344
 		$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 
6345 6345
 								FROM spotter_output 
6346 6346
                     WHERE spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' ";
6347
-                if ($olderthanmonths > 0) {
6348
-            		if ($globalDBdriver == 'mysql') {
6347
+				if ($olderthanmonths > 0) {
6348
+					if ($globalDBdriver == 'mysql') {
6349 6349
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6350 6350
 			} else {
6351 6351
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6352 6352
 			}
6353
-                if ($sincedate != '') {
6354
-            		if ($globalDBdriver == 'mysql') {
6353
+				if ($sincedate != '') {
6354
+					if ($globalDBdriver == 'mysql') {
6355 6355
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6356 6356
 			} else {
6357 6357
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6358 6358
 			}
6359 6359
 		}
6360
-            		if ($globalDBdriver == 'mysql') {
6360
+					if ($globalDBdriver == 'mysql') {
6361 6361
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6362 6362
 			} else {
6363 6363
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6364 6364
 			}
6365 6365
 		}
6366 6366
 
6367
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6368
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6369
-                $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6367
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6368
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6369
+				$query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6370 6370
 					ORDER BY airport_arrival_icao_count DESC";
6371 6371
 		if ($limit) $query .= " LIMIT 10";
6372 6372
       
@@ -6397,39 +6397,39 @@  discard block
 block discarded – undo
6397 6397
 
6398 6398
 
6399 6399
 	/**
6400
-	* Gets all detected arrival airports of the airplanes that have flown over
6401
-	*
6402
-	* @return Array the airport list
6403
-	*
6404
-	*/
6400
+	 * Gets all detected arrival airports of the airplanes that have flown over
6401
+	 *
6402
+	 * @return Array the airport list
6403
+	 *
6404
+	 */
6405 6405
 	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
6406 6406
 	{
6407 6407
 		global $globalDBdriver;
6408 6408
 		$filter_query = $this->getFilter($filters,true,true);
6409 6409
 		$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 
6410 6410
 			FROM spotter_output, airport".$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";
6411
-                if ($olderthanmonths > 0) {
6412
-            		if ($globalDBdriver == 'mysql') {
6411
+				if ($olderthanmonths > 0) {
6412
+					if ($globalDBdriver == 'mysql') {
6413 6413
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6414 6414
 			} else {
6415 6415
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6416 6416
 			}
6417
-                if ($sincedate != '') {
6418
-            		if ($globalDBdriver == 'mysql') {
6417
+				if ($sincedate != '') {
6418
+					if ($globalDBdriver == 'mysql') {
6419 6419
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6420 6420
 			} else {
6421 6421
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6422 6422
 			}
6423 6423
 		}
6424
-            		if ($globalDBdriver == 'mysql') {
6424
+					if ($globalDBdriver == 'mysql') {
6425 6425
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6426 6426
 			} else {
6427 6427
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6428 6428
 			}
6429 6429
 		}
6430
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6431
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6432
-                $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6430
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6431
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6432
+				$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6433 6433
 					ORDER BY airport_arrival_icao_count DESC";
6434 6434
 		if ($limit) $query .= " LIMIT 10";
6435 6435
       
@@ -6458,40 +6458,40 @@  discard block
 block discarded – undo
6458 6458
 	}
6459 6459
 	
6460 6460
 	/**
6461
-	* Gets all detected arrival airports of the airplanes that have flown over
6462
-	*
6463
-	* @return Array the airport list
6464
-	*
6465
-	*/
6461
+	 * Gets all detected arrival airports of the airplanes that have flown over
6462
+	 *
6463
+	 * @return Array the airport list
6464
+	 *
6465
+	 */
6466 6466
 	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false)
6467 6467
 	{
6468 6468
 		global $globalDBdriver;
6469 6469
 		$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 
6470 6470
 			FROM spotter_output, airport 
6471 6471
                     WHERE 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 ";
6472
-                if ($olderthanmonths > 0) {
6473
-            		if ($globalDBdriver == 'mysql') {
6472
+				if ($olderthanmonths > 0) {
6473
+					if ($globalDBdriver == 'mysql') {
6474 6474
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6475 6475
 			} else {
6476 6476
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6477 6477
 			}
6478
-                if ($sincedate != '') {
6479
-            		if ($globalDBdriver == 'mysql') {
6478
+				if ($sincedate != '') {
6479
+					if ($globalDBdriver == 'mysql') {
6480 6480
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6481 6481
 			} else {
6482 6482
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6483 6483
 			}
6484 6484
 		}
6485
-            		if ($globalDBdriver == 'mysql') {
6485
+					if ($globalDBdriver == 'mysql') {
6486 6486
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6487 6487
 			} else {
6488 6488
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6489 6489
 			}
6490 6490
 		}
6491 6491
 
6492
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6493
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6494
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6492
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6493
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6494
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6495 6495
 					ORDER BY airport_arrival_icao_count DESC";
6496 6496
 		if ($limit) $query .= " LIMIT 10";
6497 6497
       
@@ -6521,11 +6521,11 @@  discard block
 block discarded – undo
6521 6521
 	}	
6522 6522
 	
6523 6523
 	/**
6524
-	* Gets all arrival airports of the airplanes that have flown over based on an airline icao
6525
-	*
6526
-	* @return Array the airport list
6527
-	*
6528
-	*/
6524
+	 * Gets all arrival airports of the airplanes that have flown over based on an airline icao
6525
+	 *
6526
+	 * @return Array the airport list
6527
+	 *
6528
+	 */
6529 6529
 	public function countAllArrivalAirportsByAirline($airline_icao)
6530 6530
 	{
6531 6531
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -6559,11 +6559,11 @@  discard block
 block discarded – undo
6559 6559
 	
6560 6560
 	
6561 6561
 	/**
6562
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
6563
-	*
6564
-	* @return Array the airport list
6565
-	*
6566
-	*/
6562
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
6563
+	 *
6564
+	 * @return Array the airport list
6565
+	 *
6566
+	 */
6567 6567
 	public function countAllArrivalAirportCountriesByAirline($airline_icao)
6568 6568
 	{
6569 6569
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -6594,11 +6594,11 @@  discard block
 block discarded – undo
6594 6594
 	
6595 6595
 	
6596 6596
 	/**
6597
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
6598
-	*
6599
-	* @return Array the airport list
6600
-	*
6601
-	*/
6597
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
6598
+	 *
6599
+	 * @return Array the airport list
6600
+	 *
6601
+	 */
6602 6602
 	public function countAllArrivalAirportsByAircraft($aircraft_icao)
6603 6603
 	{
6604 6604
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -6633,11 +6633,11 @@  discard block
 block discarded – undo
6633 6633
 	
6634 6634
 	
6635 6635
 	/**
6636
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
6637
-	*
6638
-	* @return Array the airport list
6639
-	*
6640
-	*/
6636
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
6637
+	 *
6638
+	 * @return Array the airport list
6639
+	 *
6640
+	 */
6641 6641
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao)
6642 6642
 	{
6643 6643
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -6668,11 +6668,11 @@  discard block
 block discarded – undo
6668 6668
 	
6669 6669
 	
6670 6670
 	/**
6671
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
6672
-	*
6673
-	* @return Array the airport list
6674
-	*
6675
-	*/
6671
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
6672
+	 *
6673
+	 * @return Array the airport list
6674
+	 *
6675
+	 */
6676 6676
 	public function countAllArrivalAirportsByRegistration($registration)
6677 6677
 	{
6678 6678
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -6706,11 +6706,11 @@  discard block
 block discarded – undo
6706 6706
 	
6707 6707
 	
6708 6708
 	/**
6709
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
6710
-	*
6711
-	* @return Array the airport list
6712
-	*
6713
-	*/
6709
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
6710
+	 *
6711
+	 * @return Array the airport list
6712
+	 *
6713
+	 */
6714 6714
 	public function countAllArrivalAirportCountriesByRegistration($registration)
6715 6715
 	{
6716 6716
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -6742,11 +6742,11 @@  discard block
 block discarded – undo
6742 6742
 	
6743 6743
 	
6744 6744
 	/**
6745
-	* Gets all arrival airports of the airplanes that have flown over based on an departure airport
6746
-	*
6747
-	* @return Array the airport list
6748
-	*
6749
-	*/
6745
+	 * Gets all arrival airports of the airplanes that have flown over based on an departure airport
6746
+	 *
6747
+	 * @return Array the airport list
6748
+	 *
6749
+	 */
6750 6750
 	public function countAllArrivalAirportsByAirport($airport_icao)
6751 6751
 	{
6752 6752
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -6780,11 +6780,11 @@  discard block
 block discarded – undo
6780 6780
 	
6781 6781
 	
6782 6782
 	/**
6783
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
6784
-	*
6785
-	* @return Array the airport list
6786
-	*
6787
-	*/
6783
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
6784
+	 *
6785
+	 * @return Array the airport list
6786
+	 *
6787
+	 */
6788 6788
 	public function countAllArrivalAirportCountriesByAirport($airport_icao)
6789 6789
 	{
6790 6790
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -6815,11 +6815,11 @@  discard block
 block discarded – undo
6815 6815
 	
6816 6816
 	
6817 6817
 	/**
6818
-	* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
6819
-	*
6820
-	* @return Array the airport list
6821
-	*
6822
-	*/
6818
+	 * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
6819
+	 *
6820
+	 * @return Array the airport list
6821
+	 *
6822
+	 */
6823 6823
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer)
6824 6824
 	{
6825 6825
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -6854,11 +6854,11 @@  discard block
 block discarded – undo
6854 6854
 	
6855 6855
 	
6856 6856
 	/**
6857
-	* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
6858
-	*
6859
-	* @return Array the airport list
6860
-	*
6861
-	*/
6857
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
6858
+	 *
6859
+	 * @return Array the airport list
6860
+	 *
6861
+	 */
6862 6862
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer)
6863 6863
 	{
6864 6864
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -6890,11 +6890,11 @@  discard block
 block discarded – undo
6890 6890
 	
6891 6891
 	
6892 6892
 	/**
6893
-	* Gets all arrival airports of the airplanes that have flown over based on a date
6894
-	*
6895
-	* @return Array the airport list
6896
-	*
6897
-	*/
6893
+	 * Gets all arrival airports of the airplanes that have flown over based on a date
6894
+	 *
6895
+	 * @return Array the airport list
6896
+	 *
6897
+	 */
6898 6898
 	public function countAllArrivalAirportsByDate($date)
6899 6899
 	{
6900 6900
 		global $globalTimezone, $globalDBdriver;
@@ -6941,11 +6941,11 @@  discard block
 block discarded – undo
6941 6941
 	
6942 6942
 	
6943 6943
 	/**
6944
-	* Gets all arrival airports by country of the airplanes that have flown over based on a date
6945
-	*
6946
-	* @return Array the airport list
6947
-	*
6948
-	*/
6944
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a date
6945
+	 *
6946
+	 * @return Array the airport list
6947
+	 *
6948
+	 */
6949 6949
 	public function countAllArrivalAirportCountriesByDate($date)
6950 6950
 	{
6951 6951
 		global $globalTimezone, $globalDBdriver;
@@ -6989,11 +6989,11 @@  discard block
 block discarded – undo
6989 6989
 	
6990 6990
 	
6991 6991
 	/**
6992
-	* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
6993
-	*
6994
-	* @return Array the airport list
6995
-	*
6996
-	*/
6992
+	 * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
6993
+	 *
6994
+	 * @return Array the airport list
6995
+	 *
6996
+	 */
6997 6997
 	public function countAllArrivalAirportsByIdent($ident)
6998 6998
 	{
6999 6999
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -7027,11 +7027,11 @@  discard block
 block discarded – undo
7027 7027
 	
7028 7028
 	
7029 7029
 	/**
7030
-	* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
7031
-	*
7032
-	* @return Array the airport list
7033
-	*
7034
-	*/
7030
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
7031
+	 *
7032
+	 * @return Array the airport list
7033
+	 *
7034
+	 */
7035 7035
 	public function countAllArrivalAirportCountriesByIdent($ident)
7036 7036
 	{
7037 7037
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -7063,11 +7063,11 @@  discard block
 block discarded – undo
7063 7063
 	
7064 7064
 	
7065 7065
 	/**
7066
-	* Gets all arrival airports of the airplanes that have flown over based on a country
7067
-	*
7068
-	* @return Array the airport list
7069
-	*
7070
-	*/
7066
+	 * Gets all arrival airports of the airplanes that have flown over based on a country
7067
+	 *
7068
+	 * @return Array the airport list
7069
+	 *
7070
+	 */
7071 7071
 	public function countAllArrivalAirportsByCountry($country)
7072 7072
 	{
7073 7073
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -7101,11 +7101,11 @@  discard block
 block discarded – undo
7101 7101
 	
7102 7102
 	
7103 7103
 	/**
7104
-	* Gets all arrival airports by country of the airplanes that have flown over based on a country
7105
-	*
7106
-	* @return Array the airport list
7107
-	*
7108
-	*/
7104
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a country
7105
+	 *
7106
+	 * @return Array the airport list
7107
+	 *
7108
+	 */
7109 7109
 	public function countAllArrivalAirportCountriesByCountry($country)
7110 7110
 	{
7111 7111
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -7137,11 +7137,11 @@  discard block
 block discarded – undo
7137 7137
 
7138 7138
 
7139 7139
 	/**
7140
-	* Counts all airport departure countries
7141
-	*
7142
-	* @return Array the airport departure list
7143
-	*
7144
-	*/
7140
+	 * Counts all airport departure countries
7141
+	 *
7142
+	 * @return Array the airport departure list
7143
+	 *
7144
+	 */
7145 7145
 	public function countAllDepartureCountries($filters = array())
7146 7146
 	{
7147 7147
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7171,11 +7171,11 @@  discard block
 block discarded – undo
7171 7171
 	
7172 7172
 	
7173 7173
 	/**
7174
-	* Counts all airport arrival countries
7175
-	*
7176
-	* @return Array the airport arrival list
7177
-	*
7178
-	*/
7174
+	 * Counts all airport arrival countries
7175
+	 *
7176
+	 * @return Array the airport arrival list
7177
+	 *
7178
+	 */
7179 7179
 	public function countAllArrivalCountries($limit = true,$filters = array())
7180 7180
 	{
7181 7181
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7208,11 +7208,11 @@  discard block
 block discarded – undo
7208 7208
 
7209 7209
 
7210 7210
 	/**
7211
-	* Gets all route combinations
7212
-	*
7213
-	* @return Array the route list
7214
-	*
7215
-	*/
7211
+	 * Gets all route combinations
7212
+	 *
7213
+	 * @return Array the route list
7214
+	 *
7215
+	 */
7216 7216
 	public function countAllRoutes()
7217 7217
 	{
7218 7218
 		
@@ -7252,11 +7252,11 @@  discard block
 block discarded – undo
7252 7252
 	
7253 7253
 	
7254 7254
 	/**
7255
-	* Gets all route combinations based on an aircraft
7256
-	*
7257
-	* @return Array the route list
7258
-	*
7259
-	*/
7255
+	 * Gets all route combinations based on an aircraft
7256
+	 *
7257
+	 * @return Array the route list
7258
+	 *
7259
+	 */
7260 7260
 	public function countAllRoutesByAircraft($aircraft_icao)
7261 7261
 	{
7262 7262
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -7294,11 +7294,11 @@  discard block
 block discarded – undo
7294 7294
 	
7295 7295
 	
7296 7296
 	/**
7297
-	* Gets all route combinations based on an aircraft registration
7298
-	*
7299
-	* @return Array the route list
7300
-	*
7301
-	*/
7297
+	 * Gets all route combinations based on an aircraft registration
7298
+	 *
7299
+	 * @return Array the route list
7300
+	 *
7301
+	 */
7302 7302
 	public function countAllRoutesByRegistration($registration)
7303 7303
 	{
7304 7304
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
@@ -7337,11 +7337,11 @@  discard block
 block discarded – undo
7337 7337
 	
7338 7338
 	
7339 7339
 	/**
7340
-	* Gets all route combinations based on an airline
7341
-	*
7342
-	* @return Array the route list
7343
-	*
7344
-	*/
7340
+	 * Gets all route combinations based on an airline
7341
+	 *
7342
+	 * @return Array the route list
7343
+	 *
7344
+	 */
7345 7345
 	public function countAllRoutesByAirline($airline_icao)
7346 7346
 	{
7347 7347
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -7380,11 +7380,11 @@  discard block
 block discarded – undo
7380 7380
 	
7381 7381
 	
7382 7382
 	/**
7383
-	* Gets all route combinations based on an airport
7384
-	*
7385
-	* @return Array the route list
7386
-	*
7387
-	*/
7383
+	 * Gets all route combinations based on an airport
7384
+	 *
7385
+	 * @return Array the route list
7386
+	 *
7387
+	 */
7388 7388
 	public function countAllRoutesByAirport($airport_icao)
7389 7389
 	{
7390 7390
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -7423,11 +7423,11 @@  discard block
 block discarded – undo
7423 7423
 	
7424 7424
 	
7425 7425
 	/**
7426
-	* Gets all route combinations based on an country
7427
-	*
7428
-	* @return Array the route list
7429
-	*
7430
-	*/
7426
+	 * Gets all route combinations based on an country
7427
+	 *
7428
+	 * @return Array the route list
7429
+	 *
7430
+	 */
7431 7431
 	public function countAllRoutesByCountry($country)
7432 7432
 	{
7433 7433
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -7465,11 +7465,11 @@  discard block
 block discarded – undo
7465 7465
 
7466 7466
 
7467 7467
 	/**
7468
-	* Gets all route combinations based on an date
7469
-	*
7470
-	* @return Array the route list
7471
-	*
7472
-	*/
7468
+	 * Gets all route combinations based on an date
7469
+	 *
7470
+	 * @return Array the route list
7471
+	 *
7472
+	 */
7473 7473
 	public function countAllRoutesByDate($date)
7474 7474
 	{
7475 7475
 		global $globalTimezone, $globalDBdriver;
@@ -7520,11 +7520,11 @@  discard block
 block discarded – undo
7520 7520
 	
7521 7521
 	
7522 7522
 	/**
7523
-	* Gets all route combinations based on an ident/callsign
7524
-	*
7525
-	* @return Array the route list
7526
-	*
7527
-	*/
7523
+	 * Gets all route combinations based on an ident/callsign
7524
+	 *
7525
+	 * @return Array the route list
7526
+	 *
7527
+	 */
7528 7528
 	public function countAllRoutesByIdent($ident)
7529 7529
 	{
7530 7530
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -7562,11 +7562,11 @@  discard block
 block discarded – undo
7562 7562
 	
7563 7563
 	
7564 7564
 	/**
7565
-	* Gets all route combinations based on an manufacturer
7566
-	*
7567
-	* @return Array the route list
7568
-	*
7569
-	*/
7565
+	 * Gets all route combinations based on an manufacturer
7566
+	 *
7567
+	 * @return Array the route list
7568
+	 *
7569
+	 */
7570 7570
 	public function countAllRoutesByManufacturer($aircraft_manufacturer)
7571 7571
 	{
7572 7572
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -7605,11 +7605,11 @@  discard block
 block discarded – undo
7605 7605
 	
7606 7606
 	
7607 7607
 	/**
7608
-	* Gets all route combinations with waypoints
7609
-	*
7610
-	* @return Array the route list
7611
-	*
7612
-	*/
7608
+	 * Gets all route combinations with waypoints
7609
+	 *
7610
+	 * @return Array the route list
7611
+	 *
7612
+	 */
7613 7613
 	public function countAllRoutesWithWaypoints()
7614 7614
 	{
7615 7615
 		$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
@@ -7649,11 +7649,11 @@  discard block
 block discarded – undo
7649 7649
 	
7650 7650
 	
7651 7651
 	/**
7652
-	* Gets all callsigns that have flown over
7653
-	*
7654
-	* @return Array the callsign list
7655
-	*
7656
-	*/
7652
+	 * Gets all callsigns that have flown over
7653
+	 *
7654
+	 * @return Array the callsign list
7655
+	 *
7656
+	 */
7657 7657
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
7658 7658
 	{
7659 7659
 		global $globalDBdriver;
@@ -7691,11 +7691,11 @@  discard block
 block discarded – undo
7691 7691
 	}
7692 7692
 
7693 7693
 	/**
7694
-	* Gets all callsigns that have flown over
7695
-	*
7696
-	* @return Array the callsign list
7697
-	*
7698
-	*/
7694
+	 * Gets all callsigns that have flown over
7695
+	 *
7696
+	 * @return Array the callsign list
7697
+	 *
7698
+	 */
7699 7699
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
7700 7700
 	{
7701 7701
 		global $globalDBdriver;
@@ -7736,11 +7736,11 @@  discard block
 block discarded – undo
7736 7736
 
7737 7737
 
7738 7738
 	/**
7739
-	* Counts all dates
7740
-	*
7741
-	* @return Array the date list
7742
-	*
7743
-	*/
7739
+	 * Counts all dates
7740
+	 *
7741
+	 * @return Array the date list
7742
+	 *
7743
+	 */
7744 7744
 	public function countAllDates($filters = array())
7745 7745
 	{
7746 7746
 		global $globalTimezone, $globalDBdriver;
@@ -7785,11 +7785,11 @@  discard block
 block discarded – undo
7785 7785
 	}
7786 7786
 	
7787 7787
 	/**
7788
-	* Counts all dates
7789
-	*
7790
-	* @return Array the date list
7791
-	*
7792
-	*/
7788
+	 * Counts all dates
7789
+	 *
7790
+	 * @return Array the date list
7791
+	 *
7792
+	 */
7793 7793
 	public function countAllDatesByAirlines()
7794 7794
 	{
7795 7795
 		global $globalTimezone, $globalDBdriver;
@@ -7835,11 +7835,11 @@  discard block
 block discarded – undo
7835 7835
 	}	
7836 7836
 	
7837 7837
 	/**
7838
-	* Counts all dates during the last 7 days
7839
-	*
7840
-	* @return Array the date list
7841
-	*
7842
-	*/
7838
+	 * Counts all dates during the last 7 days
7839
+	 *
7840
+	 * @return Array the date list
7841
+	 *
7842
+	 */
7843 7843
 	public function countAllDatesLast7Days($filters = array())
7844 7844
 	{
7845 7845
 		global $globalTimezone, $globalDBdriver;
@@ -7861,7 +7861,7 @@  discard block
 block discarded – undo
7861 7861
 			$query .= " GROUP BY date_name 
7862 7862
 								ORDER BY date_name ASC";
7863 7863
 			$query_data = array(':offset' => $offset);
7864
-    		}
7864
+			}
7865 7865
 		
7866 7866
 		$sth = $this->db->prepare($query);
7867 7867
 		$sth->execute($query_data);
@@ -7881,11 +7881,11 @@  discard block
 block discarded – undo
7881 7881
 	}
7882 7882
 
7883 7883
 	/**
7884
-	* Counts all dates during the last month
7885
-	*
7886
-	* @return Array the date list
7887
-	*
7888
-	*/
7884
+	 * Counts all dates during the last month
7885
+	 *
7886
+	 * @return Array the date list
7887
+	 *
7888
+	 */
7889 7889
 	public function countAllDatesLastMonth($filters = array())
7890 7890
 	{
7891 7891
 		global $globalTimezone, $globalDBdriver;
@@ -7907,7 +7907,7 @@  discard block
 block discarded – undo
7907 7907
 			$query .= " GROUP BY date_name 
7908 7908
 								ORDER BY date_name ASC";
7909 7909
 			$query_data = array(':offset' => $offset);
7910
-    		}
7910
+			}
7911 7911
 		
7912 7912
 		$sth = $this->db->prepare($query);
7913 7913
 		$sth->execute($query_data);
@@ -7928,11 +7928,11 @@  discard block
 block discarded – undo
7928 7928
 
7929 7929
 
7930 7930
 	/**
7931
-	* Counts all dates during the last month
7932
-	*
7933
-	* @return Array the date list
7934
-	*
7935
-	*/
7931
+	 * Counts all dates during the last month
7932
+	 *
7933
+	 * @return Array the date list
7934
+	 *
7935
+	 */
7936 7936
 	public function countAllDatesLastMonthByAirlines()
7937 7937
 	{
7938 7938
 		global $globalTimezone, $globalDBdriver;
@@ -7956,7 +7956,7 @@  discard block
 block discarded – undo
7956 7956
 								GROUP BY spotter_output.airline_icao, date_name 
7957 7957
 								ORDER BY date_name ASC";
7958 7958
 			$query_data = array(':offset' => $offset);
7959
-    		}
7959
+			}
7960 7960
 		
7961 7961
 		$sth = $this->db->prepare($query);
7962 7962
 		$sth->execute($query_data);
@@ -7978,11 +7978,11 @@  discard block
 block discarded – undo
7978 7978
 	
7979 7979
 
7980 7980
 	/**
7981
-	* Counts all month
7982
-	*
7983
-	* @return Array the month list
7984
-	*
7985
-	*/
7981
+	 * Counts all month
7982
+	 *
7983
+	 * @return Array the month list
7984
+	 *
7985
+	 */
7986 7986
 	public function countAllMonths($filters = array())
7987 7987
 	{
7988 7988
 		global $globalTimezone, $globalDBdriver;
@@ -8026,11 +8026,11 @@  discard block
 block discarded – undo
8026 8026
 	}
8027 8027
 
8028 8028
 	/**
8029
-	* Counts all month
8030
-	*
8031
-	* @return Array the month list
8032
-	*
8033
-	*/
8029
+	 * Counts all month
8030
+	 *
8031
+	 * @return Array the month list
8032
+	 *
8033
+	 */
8034 8034
 	public function countAllMonthsByAirlines()
8035 8035
 	{
8036 8036
 		global $globalTimezone, $globalDBdriver;
@@ -8075,11 +8075,11 @@  discard block
 block discarded – undo
8075 8075
 	}
8076 8076
 
8077 8077
 	/**
8078
-	* Counts all military month
8079
-	*
8080
-	* @return Array the month list
8081
-	*
8082
-	*/
8078
+	 * Counts all military month
8079
+	 *
8080
+	 * @return Array the month list
8081
+	 *
8082
+	 */
8083 8083
 	public function countAllMilitaryMonths()
8084 8084
 	{
8085 8085
 		global $globalTimezone, $globalDBdriver;
@@ -8122,11 +8122,11 @@  discard block
 block discarded – undo
8122 8122
 	}
8123 8123
 	
8124 8124
 	/**
8125
-	* Counts all month owners
8126
-	*
8127
-	* @return Array the month list
8128
-	*
8129
-	*/
8125
+	 * Counts all month owners
8126
+	 *
8127
+	 * @return Array the month list
8128
+	 *
8129
+	 */
8130 8130
 	public function countAllMonthsOwners()
8131 8131
 	{
8132 8132
 		global $globalTimezone, $globalDBdriver;
@@ -8169,11 +8169,11 @@  discard block
 block discarded – undo
8169 8169
 	}
8170 8170
 	
8171 8171
 	/**
8172
-	* Counts all month owners
8173
-	*
8174
-	* @return Array the month list
8175
-	*
8176
-	*/
8172
+	 * Counts all month owners
8173
+	 *
8174
+	 * @return Array the month list
8175
+	 *
8176
+	 */
8177 8177
 	public function countAllMonthsOwnersByAirlines()
8178 8178
 	{
8179 8179
 		global $globalTimezone, $globalDBdriver;
@@ -8217,11 +8217,11 @@  discard block
 block discarded – undo
8217 8217
 	}
8218 8218
 
8219 8219
 	/**
8220
-	* Counts all month pilot
8221
-	*
8222
-	* @return Array the month list
8223
-	*
8224
-	*/
8220
+	 * Counts all month pilot
8221
+	 *
8222
+	 * @return Array the month list
8223
+	 *
8224
+	 */
8225 8225
 	public function countAllMonthsPilots()
8226 8226
 	{
8227 8227
 		global $globalTimezone, $globalDBdriver;
@@ -8264,11 +8264,11 @@  discard block
 block discarded – undo
8264 8264
 	}
8265 8265
 	
8266 8266
 	/**
8267
-	* Counts all month pilot
8268
-	*
8269
-	* @return Array the month list
8270
-	*
8271
-	*/
8267
+	 * Counts all month pilot
8268
+	 *
8269
+	 * @return Array the month list
8270
+	 *
8271
+	 */
8272 8272
 	public function countAllMonthsPilotsByAirlines()
8273 8273
 	{
8274 8274
 		global $globalTimezone, $globalDBdriver;
@@ -8312,11 +8312,11 @@  discard block
 block discarded – undo
8312 8312
 	}
8313 8313
 
8314 8314
 	/**
8315
-	* Counts all month airline
8316
-	*
8317
-	* @return Array the month list
8318
-	*
8319
-	*/
8315
+	 * Counts all month airline
8316
+	 *
8317
+	 * @return Array the month list
8318
+	 *
8319
+	 */
8320 8320
 	public function countAllMonthsAirlines()
8321 8321
 	{
8322 8322
 		global $globalTimezone, $globalDBdriver;
@@ -8359,11 +8359,11 @@  discard block
 block discarded – undo
8359 8359
 	}
8360 8360
 	
8361 8361
 	/**
8362
-	* Counts all month aircraft
8363
-	*
8364
-	* @return Array the month list
8365
-	*
8366
-	*/
8362
+	 * Counts all month aircraft
8363
+	 *
8364
+	 * @return Array the month list
8365
+	 *
8366
+	 */
8367 8367
 	public function countAllMonthsAircrafts()
8368 8368
 	{
8369 8369
 		global $globalTimezone, $globalDBdriver;
@@ -8407,11 +8407,11 @@  discard block
 block discarded – undo
8407 8407
 	
8408 8408
 
8409 8409
 	/**
8410
-	* Counts all month aircraft
8411
-	*
8412
-	* @return Array the month list
8413
-	*
8414
-	*/
8410
+	 * Counts all month aircraft
8411
+	 *
8412
+	 * @return Array the month list
8413
+	 *
8414
+	 */
8415 8415
 	public function countAllMonthsAircraftsByAirlines()
8416 8416
 	{
8417 8417
 		global $globalTimezone, $globalDBdriver;
@@ -8455,11 +8455,11 @@  discard block
 block discarded – undo
8455 8455
 	}
8456 8456
 
8457 8457
 	/**
8458
-	* Counts all month real arrival
8459
-	*
8460
-	* @return Array the month list
8461
-	*
8462
-	*/
8458
+	 * Counts all month real arrival
8459
+	 *
8460
+	 * @return Array the month list
8461
+	 *
8462
+	 */
8463 8463
 	public function countAllMonthsRealArrivals()
8464 8464
 	{
8465 8465
 		global $globalTimezone, $globalDBdriver;
@@ -8503,11 +8503,11 @@  discard block
 block discarded – undo
8503 8503
 	
8504 8504
 
8505 8505
 	/**
8506
-	* Counts all month real arrival
8507
-	*
8508
-	* @return Array the month list
8509
-	*
8510
-	*/
8506
+	 * Counts all month real arrival
8507
+	 *
8508
+	 * @return Array the month list
8509
+	 *
8510
+	 */
8511 8511
 	public function countAllMonthsRealArrivalsByAirlines()
8512 8512
 	{
8513 8513
 		global $globalTimezone, $globalDBdriver;
@@ -8552,11 +8552,11 @@  discard block
 block discarded – undo
8552 8552
 	
8553 8553
 
8554 8554
 	/**
8555
-	* Counts all dates during the last year
8556
-	*
8557
-	* @return Array the date list
8558
-	*
8559
-	*/
8555
+	 * Counts all dates during the last year
8556
+	 *
8557
+	 * @return Array the date list
8558
+	 *
8559
+	 */
8560 8560
 	public function countAllMonthsLastYear($filters)
8561 8561
 	{
8562 8562
 		global $globalTimezone, $globalDBdriver;
@@ -8578,7 +8578,7 @@  discard block
 block discarded – undo
8578 8578
 			$query .= " GROUP BY year_name, month_name
8579 8579
 								ORDER BY year_name, month_name ASC";
8580 8580
 			$query_data = array(':offset' => $offset);
8581
-    		}
8581
+			}
8582 8582
 		
8583 8583
 		$sth = $this->db->prepare($query);
8584 8584
 		$sth->execute($query_data);
@@ -8601,11 +8601,11 @@  discard block
 block discarded – undo
8601 8601
 	
8602 8602
 	
8603 8603
 	/**
8604
-	* Counts all hours
8605
-	*
8606
-	* @return Array the hour list
8607
-	*
8608
-	*/
8604
+	 * Counts all hours
8605
+	 *
8606
+	 * @return Array the hour list
8607
+	 *
8608
+	 */
8609 8609
 	public function countAllHours($orderby,$filters = array())
8610 8610
 	{
8611 8611
 		global $globalTimezone, $globalDBdriver;
@@ -8666,11 +8666,11 @@  discard block
 block discarded – undo
8666 8666
 	}
8667 8667
 	
8668 8668
 	/**
8669
-	* Counts all hours
8670
-	*
8671
-	* @return Array the hour list
8672
-	*
8673
-	*/
8669
+	 * Counts all hours
8670
+	 *
8671
+	 * @return Array the hour list
8672
+	 *
8673
+	 */
8674 8674
 	public function countAllHoursByAirlines($orderby)
8675 8675
 	{
8676 8676
 		global $globalTimezone, $globalDBdriver;
@@ -8734,11 +8734,11 @@  discard block
 block discarded – undo
8734 8734
 
8735 8735
 
8736 8736
 	/**
8737
-	* Counts all hours by airline
8738
-	*
8739
-	* @return Array the hour list
8740
-	*
8741
-	*/
8737
+	 * Counts all hours by airline
8738
+	 *
8739
+	 * @return Array the hour list
8740
+	 *
8741
+	 */
8742 8742
 	public function countAllHoursByAirline($airline_icao)
8743 8743
 	{
8744 8744
 		global $globalTimezone, $globalDBdriver;
@@ -8785,11 +8785,11 @@  discard block
 block discarded – undo
8785 8785
 	
8786 8786
 	
8787 8787
 	/**
8788
-	* Counts all hours by aircraft
8789
-	*
8790
-	* @return Array the hour list
8791
-	*
8792
-	*/
8788
+	 * Counts all hours by aircraft
8789
+	 *
8790
+	 * @return Array the hour list
8791
+	 *
8792
+	 */
8793 8793
 	public function countAllHoursByAircraft($aircraft_icao)
8794 8794
 	{
8795 8795
 		global $globalTimezone, $globalDBdriver;
@@ -8833,11 +8833,11 @@  discard block
 block discarded – undo
8833 8833
 	
8834 8834
 	
8835 8835
 	/**
8836
-	* Counts all hours by aircraft registration
8837
-	*
8838
-	* @return Array the hour list
8839
-	*
8840
-	*/
8836
+	 * Counts all hours by aircraft registration
8837
+	 *
8838
+	 * @return Array the hour list
8839
+	 *
8840
+	 */
8841 8841
 	public function countAllHoursByRegistration($registration)
8842 8842
 	{
8843 8843
 		global $globalTimezone, $globalDBdriver;
@@ -8881,11 +8881,11 @@  discard block
 block discarded – undo
8881 8881
 	
8882 8882
 	
8883 8883
 	/**
8884
-	* Counts all hours by airport
8885
-	*
8886
-	* @return Array the hour list
8887
-	*
8888
-	*/
8884
+	 * Counts all hours by airport
8885
+	 *
8886
+	 * @return Array the hour list
8887
+	 *
8888
+	 */
8889 8889
 	public function countAllHoursByAirport($airport_icao)
8890 8890
 	{
8891 8891
 		global $globalTimezone, $globalDBdriver;
@@ -8930,11 +8930,11 @@  discard block
 block discarded – undo
8930 8930
 	
8931 8931
 	
8932 8932
 	/**
8933
-	* Counts all hours by manufacturer
8934
-	*
8935
-	* @return Array the hour list
8936
-	*
8937
-	*/
8933
+	 * Counts all hours by manufacturer
8934
+	 *
8935
+	 * @return Array the hour list
8936
+	 *
8937
+	 */
8938 8938
 	public function countAllHoursByManufacturer($aircraft_manufacturer)
8939 8939
 	{
8940 8940
 		global $globalTimezone, $globalDBdriver;
@@ -8979,11 +8979,11 @@  discard block
 block discarded – undo
8979 8979
 	
8980 8980
 	
8981 8981
 	/**
8982
-	* Counts all hours by date
8983
-	*
8984
-	* @return Array the hour list
8985
-	*
8986
-	*/
8982
+	 * Counts all hours by date
8983
+	 *
8984
+	 * @return Array the hour list
8985
+	 *
8986
+	 */
8987 8987
 	public function countAllHoursByDate($date)
8988 8988
 	{
8989 8989
 		global $globalTimezone, $globalDBdriver;
@@ -9028,11 +9028,11 @@  discard block
 block discarded – undo
9028 9028
 	
9029 9029
 	
9030 9030
 	/**
9031
-	* Counts all hours by a ident/callsign
9032
-	*
9033
-	* @return Array the hour list
9034
-	*
9035
-	*/
9031
+	 * Counts all hours by a ident/callsign
9032
+	 *
9033
+	 * @return Array the hour list
9034
+	 *
9035
+	 */
9036 9036
 	public function countAllHoursByIdent($ident)
9037 9037
 	{
9038 9038
 		global $globalTimezone, $globalDBdriver;
@@ -9078,11 +9078,11 @@  discard block
 block discarded – undo
9078 9078
 	
9079 9079
 	
9080 9080
 	/**
9081
-	* Counts all hours by route
9082
-	*
9083
-	* @return Array the hour list
9084
-	*
9085
-	*/
9081
+	 * Counts all hours by route
9082
+	 *
9083
+	 * @return Array the hour list
9084
+	 *
9085
+	 */
9086 9086
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao)
9087 9087
 	{
9088 9088
 		global $globalTimezone, $globalDBdriver;
@@ -9127,11 +9127,11 @@  discard block
 block discarded – undo
9127 9127
 	
9128 9128
 	
9129 9129
 	/**
9130
-	* Counts all hours by country
9131
-	*
9132
-	* @return Array the hour list
9133
-	*
9134
-	*/
9130
+	 * Counts all hours by country
9131
+	 *
9132
+	 * @return Array the hour list
9133
+	 *
9134
+	 */
9135 9135
 	public function countAllHoursByCountry($country)
9136 9136
 	{
9137 9137
 		global $globalTimezone, $globalDBdriver;
@@ -9177,11 +9177,11 @@  discard block
 block discarded – undo
9177 9177
 
9178 9178
 
9179 9179
 	/**
9180
-	* Counts all aircraft that have flown over
9181
-	*
9182
-	* @return Integer the number of aircrafts
9183
-	*
9184
-	*/
9180
+	 * Counts all aircraft that have flown over
9181
+	 *
9182
+	 * @return Integer the number of aircrafts
9183
+	 *
9184
+	 */
9185 9185
 	public function countOverallAircrafts($filters = array())
9186 9186
 	{
9187 9187
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9193,11 +9193,11 @@  discard block
 block discarded – undo
9193 9193
 	}
9194 9194
 
9195 9195
 	/**
9196
-	* Counts all flight that really arrival
9197
-	*
9198
-	* @return Integer the number of aircrafts
9199
-	*
9200
-	*/
9196
+	 * Counts all flight that really arrival
9197
+	 *
9198
+	 * @return Integer the number of aircrafts
9199
+	 *
9200
+	 */
9201 9201
 	public function countOverallArrival($filters = array())
9202 9202
 	{
9203 9203
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9210,11 +9210,11 @@  discard block
 block discarded – undo
9210 9210
 	}
9211 9211
 
9212 9212
 	/**
9213
-	* Counts all pilots that have flown over
9214
-	*
9215
-	* @return Integer the number of pilots
9216
-	*
9217
-	*/
9213
+	 * Counts all pilots that have flown over
9214
+	 *
9215
+	 * @return Integer the number of pilots
9216
+	 *
9217
+	 */
9218 9218
 	public function countOverallPilots($filters = array())
9219 9219
 	{
9220 9220
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9226,11 +9226,11 @@  discard block
 block discarded – undo
9226 9226
 	}
9227 9227
 
9228 9228
 	/**
9229
-	* Counts all owners that have flown over
9230
-	*
9231
-	* @return Integer the number of owners
9232
-	*
9233
-	*/
9229
+	 * Counts all owners that have flown over
9230
+	 *
9231
+	 * @return Integer the number of owners
9232
+	 *
9233
+	 */
9234 9234
 	public function countOverallOwners($filters = array())
9235 9235
 	{
9236 9236
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9243,11 +9243,11 @@  discard block
 block discarded – undo
9243 9243
 	
9244 9244
 	
9245 9245
 	/**
9246
-	* Counts all flights that have flown over
9247
-	*
9248
-	* @return Integer the number of flights
9249
-	*
9250
-	*/
9246
+	 * Counts all flights that have flown over
9247
+	 *
9248
+	 * @return Integer the number of flights
9249
+	 *
9250
+	 */
9251 9251
 	public function countOverallFlights($filters = array())
9252 9252
 	{
9253 9253
 		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
@@ -9260,11 +9260,11 @@  discard block
 block discarded – undo
9260 9260
 	}
9261 9261
 	
9262 9262
 	/**
9263
-	* Counts all military flights that have flown over
9264
-	*
9265
-	* @return Integer the number of flights
9266
-	*
9267
-	*/
9263
+	 * Counts all military flights that have flown over
9264
+	 *
9265
+	 * @return Integer the number of flights
9266
+	 *
9267
+	 */
9268 9268
 	public function countOverallMilitaryFlights($filters = array())
9269 9269
 	{
9270 9270
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9279,11 +9279,11 @@  discard block
 block discarded – undo
9279 9279
 	
9280 9280
 	
9281 9281
 	/**
9282
-	* Counts all airlines that have flown over
9283
-	*
9284
-	* @return Integer the number of airlines
9285
-	*
9286
-	*/
9282
+	 * Counts all airlines that have flown over
9283
+	 *
9284
+	 * @return Integer the number of airlines
9285
+	 *
9286
+	 */
9287 9287
 	public function countOverallAirlines($filters = array())
9288 9288
 	{
9289 9289
 		$query  = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
@@ -9297,11 +9297,11 @@  discard block
 block discarded – undo
9297 9297
 
9298 9298
   
9299 9299
 	/**
9300
-	* Counts all hours of today
9301
-	*
9302
-	* @return Array the hour list
9303
-	*
9304
-	*/
9300
+	 * Counts all hours of today
9301
+	 *
9302
+	 * @return Array the hour list
9303
+	 *
9304
+	 */
9305 9305
 	public function countAllHoursFromToday()
9306 9306
 	{
9307 9307
 		global $globalTimezone, $globalDBdriver;
@@ -9342,11 +9342,11 @@  discard block
 block discarded – undo
9342 9342
 	}
9343 9343
     
9344 9344
 	/**
9345
-	* Gets all the spotter information based on calculated upcoming flights
9346
-	*
9347
-	* @return Array the spotter information
9348
-	*
9349
-	*/
9345
+	 * Gets all the spotter information based on calculated upcoming flights
9346
+	 *
9347
+	 * @return Array the spotter information
9348
+	 *
9349
+	 */
9350 9350
 	public function getUpcomingFlights($limit = '', $sort = '')
9351 9351
 	{
9352 9352
 		global $global_query, $globalDBdriver, $globalTimezone;
@@ -9422,12 +9422,12 @@  discard block
 block discarded – undo
9422 9422
 	}
9423 9423
     
9424 9424
     
9425
-     /**
9426
-	* Gets the Barrie Spotter ID based on the FlightAware ID
9427
-	*
9428
-	* @return Integer the Barrie Spotter ID
9425
+	 /**
9426
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
9427
+	  *
9428
+	  * @return Integer the Barrie Spotter ID
9429 9429
 q	*
9430
-	*/
9430
+	  */
9431 9431
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
9432 9432
 	{
9433 9433
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -9448,13 +9448,13 @@  discard block
 block discarded – undo
9448 9448
   
9449 9449
  
9450 9450
 	/**
9451
-	* Parses a date string
9452
-	*
9453
-	* @param String $dateString the date string
9454
-	* @param String $timezone the timezone of a user
9455
-	* @return Array the time information
9456
-	*
9457
-	*/
9451
+	 * Parses a date string
9452
+	 *
9453
+	 * @param String $dateString the date string
9454
+	 * @param String $timezone the timezone of a user
9455
+	 * @return Array the time information
9456
+	 *
9457
+	 */
9458 9458
 	public function parseDateString($dateString, $timezone = '')
9459 9459
 	{
9460 9460
 		$time_array = array();
@@ -9490,12 +9490,12 @@  discard block
 block discarded – undo
9490 9490
 	
9491 9491
 	
9492 9492
 	/**
9493
-	* Parses the direction degrees to working
9494
-	*
9495
-	* @param Float $direction the direction in degrees
9496
-	* @return Array the direction information
9497
-	*
9498
-	*/
9493
+	 * Parses the direction degrees to working
9494
+	 *
9495
+	 * @param Float $direction the direction in degrees
9496
+	 * @return Array the direction information
9497
+	 *
9498
+	 */
9499 9499
 	public function parseDirection($direction = 0)
9500 9500
 	{
9501 9501
 		if ($direction == '') $direction = 0;
@@ -9574,12 +9574,12 @@  discard block
 block discarded – undo
9574 9574
 	
9575 9575
 	
9576 9576
 	/**
9577
-	* Gets the aircraft registration
9578
-	*
9579
-	* @param String $flightaware_id the flight aware id
9580
-	* @return String the aircraft registration
9581
-	*
9582
-	*/
9577
+	 * Gets the aircraft registration
9578
+	 *
9579
+	 * @param String $flightaware_id the flight aware id
9580
+	 * @return String the aircraft registration
9581
+	 *
9582
+	 */
9583 9583
 	
9584 9584
 	public function getAircraftRegistration($flightaware_id)
9585 9585
 	{
@@ -9608,12 +9608,12 @@  discard block
 block discarded – undo
9608 9608
 
9609 9609
 
9610 9610
 	/**
9611
-	* Gets the aircraft registration from ModeS
9612
-	*
9613
-	* @param String $aircraft_modes the flight ModeS in hex
9614
-	* @return String the aircraft registration
9615
-	*
9616
-	*/
9611
+	 * Gets the aircraft registration from ModeS
9612
+	 *
9613
+	 * @param String $aircraft_modes the flight ModeS in hex
9614
+	 * @return String the aircraft registration
9615
+	 *
9616
+	 */
9617 9617
 	public function getAircraftRegistrationBymodeS($aircraft_modes)
9618 9618
 	{
9619 9619
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -9625,19 +9625,19 @@  discard block
 block discarded – undo
9625 9625
     
9626 9626
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
9627 9627
 		if (count($row) > 0) {
9628
-		    //return $row['Registration'];
9629
-		    return $row['registration'];
9628
+			//return $row['Registration'];
9629
+			return $row['registration'];
9630 9630
 		} else return '';
9631 9631
 	
9632 9632
 	}
9633 9633
 
9634 9634
 	/**
9635
-	* Gets the aircraft type from ModeS
9636
-	*
9637
-	* @param String $aircraft_modes the flight ModeS in hex
9638
-	* @return String the aircraft type
9639
-	*
9640
-	*/
9635
+	 * Gets the aircraft type from ModeS
9636
+	 *
9637
+	 * @param String $aircraft_modes the flight ModeS in hex
9638
+	 * @return String the aircraft type
9639
+	 *
9640
+	 */
9641 9641
 	public function getAircraftTypeBymodeS($aircraft_modes)
9642 9642
 	{
9643 9643
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -9649,19 +9649,19 @@  discard block
 block discarded – undo
9649 9649
     
9650 9650
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
9651 9651
 		if (count($row) > 0) {
9652
-		    if ($row['type_flight'] == null) return '';
9653
-		    else return $row['type_flight'];
9652
+			if ($row['type_flight'] == null) return '';
9653
+			else return $row['type_flight'];
9654 9654
 		} else return '';
9655 9655
 	
9656 9656
 	}
9657 9657
 
9658 9658
 	/**
9659
-	* Gets Countrie from latitude/longitude
9660
-	*
9661
-	* @param Float $latitude latitute of the flight
9662
-	* @param Float $longitude longitute of the flight
9663
-	* @return String the countrie
9664
-	*/
9659
+	 * Gets Countrie from latitude/longitude
9660
+	 *
9661
+	 * @param Float $latitude latitute of the flight
9662
+	 * @param Float $longitude longitute of the flight
9663
+	 * @return String the countrie
9664
+	 */
9665 9665
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
9666 9666
 	{
9667 9667
 		global $globalDBdriver, $globalDebug;
@@ -9694,12 +9694,12 @@  discard block
 block discarded – undo
9694 9694
 	}
9695 9695
 
9696 9696
 	/**
9697
-	* converts the registration code using the country prefix
9698
-	*
9699
-	* @param String $registration the aircraft registration
9700
-	* @return String the aircraft registration
9701
-	*
9702
-	*/
9697
+	 * converts the registration code using the country prefix
9698
+	 *
9699
+	 * @param String $registration the aircraft registration
9700
+	 * @return String the aircraft registration
9701
+	 *
9702
+	 */
9703 9703
 	public function convertAircraftRegistration($registration)
9704 9704
 	{
9705 9705
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -9751,12 +9751,12 @@  discard block
 block discarded – undo
9751 9751
 	}
9752 9752
 
9753 9753
 	/**
9754
-	* Country from the registration code
9755
-	*
9756
-	* @param String $registration the aircraft registration
9757
-	* @return String the country
9758
-	*
9759
-	*/
9754
+	 * Country from the registration code
9755
+	 *
9756
+	 * @param String $registration the aircraft registration
9757
+	 * @return String the country
9758
+	 *
9759
+	 */
9760 9760
 	public function countryFromAircraftRegistration($registration)
9761 9761
 	{
9762 9762
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -9775,8 +9775,8 @@  discard block
 block discarded – undo
9775 9775
 				$country = $row['country'];
9776 9776
 			}
9777 9777
 		} else {
9778
-    			$registration_1 = substr($registration, 0, 1);
9779
-		        $registration_2 = substr($registration, 0, 2);
9778
+				$registration_1 = substr($registration, 0, 1);
9779
+				$registration_2 = substr($registration, 0, 2);
9780 9780
 
9781 9781
 			$country = '';
9782 9782
 			//first get the prefix based on two characters
@@ -9812,11 +9812,11 @@  discard block
 block discarded – undo
9812 9812
 	}
9813 9813
 	
9814 9814
 	/**
9815
-	* Set a new highlight value for a flight
9816
-	*
9817
-	* @param String $flightaware_id flightaware_id from spotter_output table
9818
-	* @param String $highlight New highlight value
9819
-	*/
9815
+	 * Set a new highlight value for a flight
9816
+	 *
9817
+	 * @param String $flightaware_id flightaware_id from spotter_output table
9818
+	 * @param String $highlight New highlight value
9819
+	 */
9820 9820
 	public function setHighlightFlight($flightaware_id,$highlight) {
9821 9821
 		
9822 9822
 		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
@@ -9825,12 +9825,12 @@  discard block
 block discarded – undo
9825 9825
 	}
9826 9826
 	
9827 9827
 	/**
9828
-	* Gets the short url from bit.ly
9829
-	*
9830
-	* @param String $url the full url
9831
-	* @return String the bit.ly url
9832
-	*
9833
-	*/
9828
+	 * Gets the short url from bit.ly
9829
+	 *
9830
+	 * @param String $url the full url
9831
+	 * @return String the bit.ly url
9832
+	 *
9833
+	 */
9834 9834
 	public function getBitlyURL($url)
9835 9835
 	{
9836 9836
 		global $globalBitlyAccessToken;
@@ -10119,11 +10119,11 @@  discard block
 block discarded – undo
10119 10119
 			$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 
10120 10120
 	                      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)) 
10121 10121
 	                      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;";
10122
-                } else {
10122
+				} else {
10123 10123
 			$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 
10124 10124
 	                      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)) 
10125 10125
 	                      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;";
10126
-    		}
10126
+			}
10127 10127
 		$sth = $this->db->prepare($query);
10128 10128
 		$sth->execute();
10129 10129
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	* Get SQL query part for filter used
17 17
 	* @param Array $filter the filter
18
-	* @return Array the SQL part
18
+	* @return string the SQL part
19 19
 	*/
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter;
@@ -8612,6 +8612,7 @@  discard block
 block discarded – undo
8612 8612
 	/**
8613 8613
 	* Counts all hours
8614 8614
 	*
8615
+	* @param string $orderby
8615 8616
 	* @return Array the hour list
8616 8617
 	*
8617 8618
 	*/
@@ -8677,6 +8678,7 @@  discard block
 block discarded – undo
8677 8678
 	/**
8678 8679
 	* Counts all hours
8679 8680
 	*
8681
+	* @param string $orderby
8680 8682
 	* @return Array the hour list
8681 8683
 	*
8682 8684
 	*/
@@ -9501,7 +9503,7 @@  discard block
 block discarded – undo
9501 9503
 	/**
9502 9504
 	* Parses the direction degrees to working
9503 9505
 	*
9504
-	* @param Float $direction the direction in degrees
9506
+	* @param integer $direction the direction in degrees
9505 9507
 	* @return Array the direction information
9506 9508
 	*
9507 9509
 	*/
Please login to merge, or discard this patch.
Braces   +661 added lines, -229 removed lines patch added patch discarded remove patch
@@ -19,8 +19,12 @@  discard block
 block discarded – undo
19 19
 	*/
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
22
-		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter);
23
-		if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter);
22
+		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23
+			$filter = array_merge($globalStatsFilters[$globalFilterName],$filter);
24
+		}
25
+		if (is_array($globalFilter)) {
26
+			$filter = array_merge($globalFilter,$filter);
27
+		}
24 28
 		$filter_query_join = '';
25 29
 		$filter_query_where = '';
26 30
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
@@ -45,8 +49,11 @@  discard block
 block discarded – undo
45 49
 				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
46 50
 			}
47 51
 		}
48
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
49
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
52
+		if ($filter_query_where == '' && $where) {
53
+			$filter_query_where = ' WHERE';
54
+		} elseif ($filter_query_where != '' && $and) {
55
+			$filter_query_where .= ' AND';
56
+		}
50 57
 		$filter_query = $filter_query_join.$filter_query_where;
51 58
 		return $filter_query;
52 59
 	}
@@ -66,10 +73,18 @@  discard block
 block discarded – undo
66 73
 		$Image = new Image($this->db);
67 74
 		$Schedule = new Schedule($this->db);
68 75
 		$ACARS = new ACARS($this->db);
69
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
70
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
71
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
72
-		if (!isset($globalVAM)) $globalVAM = FALSE;
76
+		if (!isset($globalIVAO)) {
77
+			$globalIVAO = FALSE;
78
+		}
79
+		if (!isset($globalVATSIM)) {
80
+			$globalVATSIM = FALSE;
81
+		}
82
+		if (!isset($globalphpVMS)) {
83
+			$globalphpVMS = FALSE;
84
+		}
85
+		if (!isset($globalVAM)) {
86
+			$globalVAM = FALSE;
87
+		}
73 88
 		date_default_timezone_set('UTC');
74 89
 		
75 90
 		if (!is_string($query))
@@ -116,21 +131,35 @@  discard block
 block discarded – undo
116 131
 			} else {
117 132
 				$temp_array['spotter_id'] = '';
118 133
 			}
119
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
120
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
134
+			if (isset($row['flightaware_id'])) {
135
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
136
+			}
137
+			if (isset($row['modes'])) {
138
+				$temp_array['modes'] = $row['modes'];
139
+			}
121 140
 			$temp_array['ident'] = $row['ident'];
122 141
 			if (isset($row['registration']) && $row['registration'] != '') {
123 142
 				$temp_array['registration'] = $row['registration'];
124 143
 			} elseif (isset($temp_array['modes'])) {
125 144
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
126
-			} else $temp_array['registration'] = '';
127
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
145
+			} else {
146
+				$temp_array['registration'] = '';
147
+			}
148
+			if (isset($row['aircraft_icao'])) {
149
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
150
+			}
128 151
 			
129 152
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
130 153
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
131
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
132
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
133
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
154
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
155
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
156
+			}
157
+			if (isset($row['latitude'])) {
158
+				$temp_array['latitude'] = $row['latitude'];
159
+			}
160
+			if (isset($row['longitude'])) {
161
+				$temp_array['longitude'] = $row['longitude'];
162
+			}
134 163
 			/*
135 164
 			if (Connection->tableExists('countries')) {
136 165
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -140,8 +169,12 @@  discard block
 block discarded – undo
140 169
 				}
141 170
 			}
142 171
 			*/
143
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
144
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
172
+			if (isset($row['waypoints'])) {
173
+				$temp_array['waypoints'] = $row['waypoints'];
174
+			}
175
+			if (isset($row['format_source'])) {
176
+				$temp_array['format_source'] = $row['format_source'];
177
+			}
145 178
 			if (isset($row['route_stop'])) {
146 179
 				$temp_array['route_stop'] = $row['route_stop'];
147 180
 				if ($row['route_stop'] != '') {
@@ -160,13 +193,19 @@  discard block
 block discarded – undo
160 193
 					}
161 194
 				}
162 195
 			}
163
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
196
+			if (isset($row['altitude'])) {
197
+				$temp_array['altitude'] = $row['altitude'];
198
+			}
164 199
 			if (isset($row['heading'])) {
165 200
 				$temp_array['heading'] = $row['heading'];
166 201
 				$heading_direction = $this->parseDirection($row['heading']);
167
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
202
+				if (isset($heading_direction[0]['direction_fullname'])) {
203
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
204
+				}
205
+			}
206
+			if (isset($row['ground_speed'])) {
207
+				$temp_array['ground_speed'] = $row['ground_speed'];
168 208
 			}
169
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
170 209
 			$temp_array['image'] = "";
171 210
 			$temp_array['image_thumbnail'] = "";
172 211
 			$temp_array['image_source'] = "";
@@ -174,7 +213,9 @@  discard block
 block discarded – undo
174 213
  
175 214
 			if (isset($row['highlight'])) {
176 215
 				$temp_array['highlight'] = $row['highlight'];
177
-			} else $temp_array['highlight'] = '';
216
+			} else {
217
+				$temp_array['highlight'] = '';
218
+			}
178 219
 			
179 220
 			if (isset($row['date'])) {
180 221
 				$dateArray = $this->parseDateString($row['date']);
@@ -222,7 +263,9 @@  discard block
 block discarded – undo
222 263
 				
223 264
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
224 265
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
225
-					} else $temp_array['aircraft_shadow'] = 'default.png';
266
+					} else {
267
+						$temp_array['aircraft_shadow'] = 'default.png';
268
+					}
226 269
                                 } else {
227 270
                             		$temp_array['aircraft_shadow'] = 'default.png';
228 271
 					$temp_array['aircraft_name'] = 'N/A';
@@ -230,11 +273,17 @@  discard block
 block discarded – undo
230 273
                             	}
231 274
 			}
232 275
 			$fromsource = NULL;
233
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
234
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
235
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
236
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
237
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
276
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
277
+				$fromsource = $globalAirlinesSource;
278
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
279
+				$fromsource = 'vatsim';
280
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
281
+				$fromsource = 'ivao';
282
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
283
+				$fromsource = 'vatsim';
284
+			} elseif (isset($globalIVAO) && $globalIVAO) {
285
+				$fromsource = 'ivao';
286
+			}
238 287
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
239 288
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
240 289
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -257,12 +306,18 @@  discard block
 block discarded – undo
257 306
 				}
258 307
 			} else {
259 308
 				$temp_array['airline_icao'] = $row['airline_icao'];
260
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
261
-				else $temp_array['airline_iata'] = '';
309
+				if (isset($row['airline_iata'])) {
310
+					$temp_array['airline_iata'] = $row['airline_iata'];
311
+				} else {
312
+					$temp_array['airline_iata'] = '';
313
+				}
262 314
 				$temp_array['airline_name'] = $row['airline_name'];
263 315
 				$temp_array['airline_country'] = $row['airline_country'];
264
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
265
-				else $temp_array['airline_callsign'] = 'N/A';
316
+				if (isset($row['airline_callsign'])) {
317
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
318
+				} else {
319
+					$temp_array['airline_callsign'] = 'N/A';
320
+				}
266 321
 				$temp_array['airline_type'] = $row['airline_type'];
267 322
 			}
268 323
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
@@ -278,7 +333,9 @@  discard block
 block discarded – undo
278 333
 			}
279 334
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
280 335
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
281
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
336
+				if ($owner_info['owner'] != '') {
337
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
338
+				}
282 339
 				$temp_array['aircraft_base'] = $owner_info['base'];
283 340
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
284 341
 			}
@@ -286,9 +343,14 @@  discard block
 block discarded – undo
286 343
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
287 344
 			{
288 345
 				if ($globalIVAO) {
289
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
290
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
291
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
346
+					if (isset($temp_array['airline_icao'])) {
347
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
348
+					} else {
349
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
350
+					}
351
+				} else {
352
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
353
+				}
292 354
 				if (count($image_array) > 0) {
293 355
 					$temp_array['image'] = $image_array[0]['image'];
294 356
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -338,7 +400,9 @@  discard block
 block discarded – undo
338 400
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
339 401
 			if ($row['departure_airport_icao'] != '') {
340 402
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
341
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
403
+				if (!isset($departure_airport_array[0]['name'])) {
404
+					$departure_airport_array = $this->getAllAirportInfo('NA');
405
+				}
342 406
 			/*
343 407
 			} elseif ($row['departure_airport_name'] != '') {
344 408
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -346,7 +410,9 @@  discard block
 block discarded – undo
346 410
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
347 411
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
348 412
 			*/
349
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
413
+			} else {
414
+				$departure_airport_array = $this->getAllAirportInfo('NA');
415
+			}
350 416
 			if (isset($departure_airport_array[0]['name'])) {
351 417
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
352 418
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -366,8 +432,12 @@  discard block
 block discarded – undo
366 432
 			
367 433
 			if ($row['arrival_airport_icao'] != '') {
368 434
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
369
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
370
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
435
+				if (count($arrival_airport_array) == 0) {
436
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
437
+				}
438
+			} else {
439
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
440
+			}
371 441
 			if (isset($arrival_airport_array[0]['name'])) {
372 442
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
373 443
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -383,27 +453,45 @@  discard block
 block discarded – undo
383 453
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
384 454
 			}
385 455
 			*/
386
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
387
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
388
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
389
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
390
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
456
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
457
+				$temp_array['pilot_id'] = $row['pilot_id'];
458
+			}
459
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
460
+				$temp_array['pilot_name'] = $row['pilot_name'];
461
+			}
462
+			if (isset($row['source_name']) && $row['source_name'] != '') {
463
+				$temp_array['source_name'] = $row['source_name'];
464
+			}
465
+			if (isset($row['over_country']) && $row['over_country'] != '') {
466
+				$temp_array['over_country'] = $row['over_country'];
467
+			}
468
+			if (isset($row['distance']) && $row['distance'] != '') {
469
+				$temp_array['distance'] = $row['distance'];
470
+			}
391 471
 			if (isset($row['squawk'])) {
392 472
 				$temp_array['squawk'] = $row['squawk'];
393 473
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
394 474
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
395
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
475
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
476
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
477
+					}
396 478
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
397 479
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
398
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
399
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
480
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
481
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
482
+					}
483
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
484
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
485
+				}
400 486
 			}
401 487
     			
402 488
 			$temp_array['query_number_rows'] = $num_rows;
403 489
 			
404 490
 			$spotter_array[] = $temp_array;
405 491
 		}
406
-		if ($num_rows == 0) return array();
492
+		if ($num_rows == 0) {
493
+			return array();
494
+		}
407 495
 		$spotter_array[0]['query_number_rows'] = $num_rows;
408 496
 		return $spotter_array;
409 497
 	}	
@@ -436,7 +524,9 @@  discard block
 block discarded – undo
436 524
 				foreach ($q_array as $q_item){
437 525
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
438 526
 					$additional_query .= " AND (";
439
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
527
+					if (is_int($q_item)) {
528
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
529
+					}
440 530
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
441 531
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
442 532
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -457,7 +547,9 @@  discard block
 block discarded – undo
457 547
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
458 548
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
459 549
 					$translate = $Translation->ident2icao($q_item);
460
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
550
+					if ($translate != $q_item) {
551
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
552
+					}
461 553
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
462 554
 					$additional_query .= ")";
463 555
 				}
@@ -684,7 +776,9 @@  discard block
 block discarded – undo
684 776
 				date_default_timezone_set($globalTimezone);
685 777
 				$datetime = new DateTime();
686 778
 				$offset = $datetime->format('P');
687
-			} else $offset = '+00:00';
779
+			} else {
780
+				$offset = '+00:00';
781
+			}
688 782
 
689 783
 			if ($date_array[1] != "")
690 784
 			{
@@ -716,8 +810,12 @@  discard block
 block discarded – undo
716 810
 			{
717 811
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
718 812
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
719
-			} else $limit_query = "";
720
-		} else $limit_query = "";
813
+			} else {
814
+				$limit_query = "";
815
+			}
816
+		} else {
817
+			$limit_query = "";
818
+		}
721 819
 
722 820
 
723 821
 		if ($sort != "")
@@ -785,8 +883,12 @@  discard block
 block discarded – undo
785 883
 			{
786 884
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
787 885
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
788
-			} else $limit_query = "";
789
-		} else $limit_query = "";
886
+			} else {
887
+				$limit_query = "";
888
+			}
889
+		} else {
890
+			$limit_query = "";
891
+		}
790 892
 		
791 893
 		if ($sort != "")
792 894
 		{
@@ -1110,7 +1212,9 @@  discard block
 block discarded – undo
1110 1212
 		global $global_query;
1111 1213
 		
1112 1214
 		date_default_timezone_set('UTC');
1113
-		if ($id == '') return array();
1215
+		if ($id == '') {
1216
+			return array();
1217
+		}
1114 1218
 		$additional_query = "spotter_output.spotter_id = :id";
1115 1219
 		$query_values = array(':id' => $id);
1116 1220
 
@@ -1747,7 +1851,9 @@  discard block
 block discarded – undo
1747 1851
 		{
1748 1852
 			$highlight = $row['highlight'];
1749 1853
 		}
1750
-		if (isset($highlight)) return $highlight;
1854
+		if (isset($highlight)) {
1855
+			return $highlight;
1856
+		}
1751 1857
 	}
1752 1858
 
1753 1859
 	
@@ -1775,7 +1881,9 @@  discard block
 block discarded – undo
1775 1881
 		$sth->closeCursor();
1776 1882
 		if (count($row) > 0) {
1777 1883
 			return $row['usage'];
1778
-		} else return '';
1884
+		} else {
1885
+			return '';
1886
+		}
1779 1887
 	}
1780 1888
 
1781 1889
 	/**
@@ -1800,7 +1908,9 @@  discard block
 block discarded – undo
1800 1908
 		$sth->closeCursor();
1801 1909
 		if (count($row) > 0) {
1802 1910
 			return $row['icao'];
1803
-		} else return '';
1911
+		} else {
1912
+			return '';
1913
+		}
1804 1914
 	}
1805 1915
 
1806 1916
 	/**
@@ -1828,7 +1938,9 @@  discard block
 block discarded – undo
1828 1938
 			$airport_longitude = $row['longitude'];
1829 1939
 			$Common = new Common();
1830 1940
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1831
-		} else return '';
1941
+		} else {
1942
+			return '';
1943
+		}
1832 1944
 	}
1833 1945
 	
1834 1946
 	/**
@@ -1940,7 +2052,9 @@  discard block
 block discarded – undo
1940 2052
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1941 2053
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1942 2054
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1943
-		} else return array();
2055
+		} else {
2056
+			return array();
2057
+		}
1944 2058
 		if ($globalDBdriver == 'mysql') {
1945 2059
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
1946 2060
 		} else {
@@ -1975,7 +2089,9 @@  discard block
 block discarded – undo
1975 2089
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1976 2090
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1977 2091
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1978
-		} else return array();
2092
+		} else {
2093
+			return array();
2094
+		}
1979 2095
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
1980 2096
 		$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.")";
1981 2097
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2010,7 +2126,9 @@  discard block
 block discarded – undo
2010 2126
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2011 2127
 	{
2012 2128
 		global $globalUseRealAirlines;
2013
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2129
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2130
+			$fromsource = NULL;
2131
+		}
2014 2132
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2015 2133
 		if ($airline_icao == 'NA') {
2016 2134
 			$airline_array = array();
@@ -2060,7 +2178,9 @@  discard block
 block discarded – undo
2060 2178
 				$sth->execute(array(':fromsource' => $fromsource));
2061 2179
 				$row = $sth->fetch(PDO::FETCH_ASSOC);
2062 2180
 				$sth->closeCursor();
2063
-				if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao);
2181
+				if ($row['nb'] == 0) {
2182
+					$result = $this->getAllAirlineInfo($airline_icao);
2183
+				}
2064 2184
 			}
2065 2185
 			return $result;
2066 2186
 		}
@@ -2124,15 +2244,20 @@  discard block
 block discarded – undo
2124 2244
 				'A320-211' => 'A320',
2125 2245
 				'747-8i' => 'B748',
2126 2246
 				'A380' => 'A388');
2127
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2247
+		if (isset($all_aircraft[$aircraft_type])) {
2248
+			return $all_aircraft[$aircraft_type];
2249
+		}
2128 2250
 
2129 2251
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2130 2252
 		$aircraft_type = strtoupper($aircraft_type);
2131 2253
 		$sth = $this->db->prepare($query);
2132 2254
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2133 2255
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2134
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2135
-		else return '';
2256
+		if (isset($result[0]['icao'])) {
2257
+			return $result[0]['icao'];
2258
+		} else {
2259
+			return '';
2260
+		}
2136 2261
 	}
2137 2262
 	
2138 2263
 	/**
@@ -2155,7 +2280,9 @@  discard block
 block discarded – undo
2155 2280
 		$sth->closeCursor();
2156 2281
 		if (isset($row['icaotypecode'])) {
2157 2282
 			return $row['icaotypecode'];
2158
-		} else return '';
2283
+		} else {
2284
+			return '';
2285
+		}
2159 2286
 	}
2160 2287
 
2161 2288
 	/**
@@ -2177,7 +2304,9 @@  discard block
 block discarded – undo
2177 2304
 		$sth->closeCursor();
2178 2305
 		if (isset($row['operator_correct'])) {
2179 2306
 			return $row['operator_correct'];
2180
-		} else return $operator;
2307
+		} else {
2308
+			return $operator;
2309
+		}
2181 2310
 	}
2182 2311
 
2183 2312
 	/**
@@ -2190,7 +2319,9 @@  discard block
 block discarded – undo
2190 2319
 	public function getRouteInfo($callsign)
2191 2320
 	{
2192 2321
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2193
-                if ($callsign == '') return array();
2322
+                if ($callsign == '') {
2323
+                	return array();
2324
+                }
2194 2325
 		$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";
2195 2326
 		
2196 2327
 		$sth = $this->db->prepare($query);
@@ -2200,7 +2331,9 @@  discard block
 block discarded – undo
2200 2331
 		$sth->closeCursor();
2201 2332
 		if (count($row) > 0) {
2202 2333
 			return $row;
2203
-		} else return array();
2334
+		} else {
2335
+			return array();
2336
+		}
2204 2337
 	}
2205 2338
 	
2206 2339
 	/**
@@ -2253,7 +2386,9 @@  discard block
 block discarded – undo
2253 2386
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2254 2387
 			$sth->closeCursor();
2255 2388
 			return $result;
2256
-		} else return array();
2389
+		} else {
2390
+			return array();
2391
+		}
2257 2392
 	}
2258 2393
 	
2259 2394
   
@@ -2409,8 +2544,11 @@  discard block
 block discarded – undo
2409 2544
 		$query .= " ORDER BY spotter_output.source_name ASC";
2410 2545
 
2411 2546
 		$sth = $this->db->prepare($query);
2412
-		if (!empty($query_values)) $sth->execute($query_values);
2413
-		else $sth->execute();
2547
+		if (!empty($query_values)) {
2548
+			$sth->execute($query_values);
2549
+		} else {
2550
+			$sth->execute();
2551
+		}
2414 2552
 
2415 2553
 		$source_array = array();
2416 2554
 		$temp_array = array();
@@ -2442,9 +2580,13 @@  discard block
 block discarded – undo
2442 2580
 								WHERE spotter_output.airline_icao <> '' 
2443 2581
 								ORDER BY spotter_output.airline_name ASC";
2444 2582
 			*/
2445
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2446
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2447
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2583
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2584
+				$forsource = $globalAirlinesSource;
2585
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2586
+				$forsource = 'vatsim';
2587
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2588
+				$forsource = 'ivao';
2589
+			}
2448 2590
 			if ($forsource === NULL) {
2449 2591
 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC";
2450 2592
 				$query_data = array();
@@ -2742,7 +2884,9 @@  discard block
 block discarded – undo
2742 2884
 			date_default_timezone_set($globalTimezone);
2743 2885
 			$datetime = new DateTime();
2744 2886
 			$offset = $datetime->format('P');
2745
-		} else $offset = '+00:00';
2887
+		} else {
2888
+			$offset = '+00:00';
2889
+		}
2746 2890
 		if ($airport_icao == '') {
2747 2891
 			if ($globalDBdriver == 'mysql') {
2748 2892
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -2774,7 +2918,9 @@  discard block
 block discarded – undo
2774 2918
 			date_default_timezone_set($globalTimezone);
2775 2919
 			$datetime = new DateTime();
2776 2920
 			$offset = $datetime->format('P');
2777
-		} else $offset = '+00:00';
2921
+		} else {
2922
+			$offset = '+00:00';
2923
+		}
2778 2924
 		if ($airport_icao == '') {
2779 2925
 			if ($globalDBdriver == 'mysql') {
2780 2926
 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -2806,7 +2952,9 @@  discard block
 block discarded – undo
2806 2952
 			date_default_timezone_set($globalTimezone);
2807 2953
 			$datetime = new DateTime();
2808 2954
 			$offset = $datetime->format('P');
2809
-		} else $offset = '+00:00';
2955
+		} else {
2956
+			$offset = '+00:00';
2957
+		}
2810 2958
 		if ($airport_icao == '') {
2811 2959
 			if ($globalDBdriver == 'mysql') {
2812 2960
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2849,7 +2997,9 @@  discard block
 block discarded – undo
2849 2997
 			date_default_timezone_set($globalTimezone);
2850 2998
 			$datetime = new DateTime();
2851 2999
 			$offset = $datetime->format('P');
2852
-		} else $offset = '+00:00';
3000
+		} else {
3001
+			$offset = '+00:00';
3002
+		}
2853 3003
 		if ($airport_icao == '') {
2854 3004
 			if ($globalDBdriver == 'mysql') {
2855 3005
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2893,7 +3043,9 @@  discard block
 block discarded – undo
2893 3043
 			date_default_timezone_set($globalTimezone);
2894 3044
 			$datetime = new DateTime();
2895 3045
 			$offset = $datetime->format('P');
2896
-		} else $offset = '+00:00';
3046
+		} else {
3047
+			$offset = '+00:00';
3048
+		}
2897 3049
 		if ($airport_icao == '') {
2898 3050
 			if ($globalDBdriver == 'mysql') {
2899 3051
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -2927,7 +3079,9 @@  discard block
 block discarded – undo
2927 3079
 			date_default_timezone_set($globalTimezone);
2928 3080
 			$datetime = new DateTime();
2929 3081
 			$offset = $datetime->format('P');
2930
-		} else $offset = '+00:00';
3082
+		} else {
3083
+			$offset = '+00:00';
3084
+		}
2931 3085
 		if ($airport_icao == '') {
2932 3086
 			if ($globalDBdriver == 'mysql') {
2933 3087
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2973,7 +3127,9 @@  discard block
 block discarded – undo
2973 3127
 			date_default_timezone_set($globalTimezone);
2974 3128
 			$datetime = new DateTime();
2975 3129
 			$offset = $datetime->format('P');
2976
-		} else $offset = '+00:00';
3130
+		} else {
3131
+			$offset = '+00:00';
3132
+		}
2977 3133
 		if ($airport_icao == '') {
2978 3134
 			if ($globalDBdriver == 'mysql') {
2979 3135
 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3007,7 +3163,9 @@  discard block
 block discarded – undo
3007 3163
 			date_default_timezone_set($globalTimezone);
3008 3164
 			$datetime = new DateTime();
3009 3165
 			$offset = $datetime->format('P');
3010
-		} else $offset = '+00:00';
3166
+		} else {
3167
+			$offset = '+00:00';
3168
+		}
3011 3169
 		if ($airport_icao == '') {
3012 3170
 			if ($globalDBdriver == 'mysql') {
3013 3171
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3055,7 +3213,9 @@  discard block
 block discarded – undo
3055 3213
 			date_default_timezone_set($globalTimezone);
3056 3214
 			$datetime = new DateTime();
3057 3215
 			$offset = $datetime->format('P');
3058
-		} else $offset = '+00:00';
3216
+		} else {
3217
+			$offset = '+00:00';
3218
+		}
3059 3219
 
3060 3220
 		if ($globalDBdriver == 'mysql') {
3061 3221
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3175,7 +3335,9 @@  discard block
 block discarded – undo
3175 3335
 	*/	
3176 3336
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3177 3337
 	{
3178
-		if ($groundspeed == '') $groundspeed = NULL;
3338
+		if ($groundspeed == '') {
3339
+			$groundspeed = NULL;
3340
+		}
3179 3341
 		$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';
3180 3342
                 $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);
3181 3343
 
@@ -3225,10 +3387,18 @@  discard block
 block discarded – undo
3225 3387
 		$Image = new Image($this->db);
3226 3388
 		$Common = new Common();
3227 3389
 		
3228
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3229
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3230
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3231
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3390
+		if (!isset($globalIVAO)) {
3391
+			$globalIVAO = FALSE;
3392
+		}
3393
+		if (!isset($globalVATSIM)) {
3394
+			$globalVATSIM = FALSE;
3395
+		}
3396
+		if (!isset($globalphpVMS)) {
3397
+			$globalphpVMS = FALSE;
3398
+		}
3399
+		if (!isset($globalVAM)) {
3400
+			$globalVAM = FALSE;
3401
+		}
3232 3402
 		date_default_timezone_set('UTC');
3233 3403
 		
3234 3404
 		//getting the registration
@@ -3241,23 +3411,33 @@  discard block
 block discarded – undo
3241 3411
 				if ($ModeS != '') {
3242 3412
 					$timeelapsed = microtime(true);
3243 3413
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3244
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3414
+					if ($globalDebugTimeElapsed) {
3415
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3416
+					}
3245 3417
 				} else {
3246 3418
 					$myhex = explode('-',$flightaware_id);
3247 3419
 					if (count($myhex) > 0) {
3248 3420
 						$timeelapsed = microtime(true);
3249 3421
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3250
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3422
+						if ($globalDebugTimeElapsed) {
3423
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3424
+						}
3251 3425
 					}
3252 3426
 				}
3253 3427
 			}
3254 3428
 		}
3255 3429
 		$fromsource = NULL;
3256
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3257
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3258
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3259
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3260
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3430
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3431
+			$fromsource = $globalAirlinesSource;
3432
+		} elseif ($format_source == 'vatsimtxt') {
3433
+			$fromsource = 'vatsim';
3434
+		} elseif ($format_source == 'whazzup') {
3435
+			$fromsource = 'ivao';
3436
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3437
+			$fromsource = 'vatsim';
3438
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3439
+			$fromsource = 'ivao';
3440
+		}
3261 3441
 		//getting the airline information
3262 3442
 		if ($ident != "")
3263 3443
 		{
@@ -3281,15 +3461,21 @@  discard block
 block discarded – undo
3281 3461
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3282 3462
 						$airline_array = $this->getAllAirlineInfo("NA");
3283 3463
 					}
3284
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3464
+					if ($globalDebugTimeElapsed) {
3465
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3466
+					}
3285 3467
 
3286 3468
 				} else {
3287 3469
 					$timeelapsed = microtime(true);
3288 3470
 					$airline_array = $this->getAllAirlineInfo("NA");
3289
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3471
+					if ($globalDebugTimeElapsed) {
3472
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3473
+					}
3290 3474
 				}
3291 3475
 			}
3292
-		} else $airline_array = array();
3476
+		} else {
3477
+			$airline_array = array();
3478
+		}
3293 3479
 		
3294 3480
 		//getting the aircraft information
3295 3481
 		$aircraft_array = array();
@@ -3303,27 +3489,37 @@  discard block
 block discarded – undo
3303 3489
 				{
3304 3490
 					$timeelapsed = microtime(true);
3305 3491
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3306
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3492
+					if ($globalDebugTimeElapsed) {
3493
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3494
+					}
3307 3495
 				} else {
3308 3496
 					$timeelapsed = microtime(true);
3309 3497
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3310
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3498
+					if ($globalDebugTimeElapsed) {
3499
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3500
+					}
3311 3501
 				}
3312 3502
 			}
3313 3503
 		} else {
3314 3504
 			if ($ModeS != '') {
3315 3505
 				$timeelapsed = microtime(true);
3316 3506
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3317
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3507
+				if ($globalDebugTimeElapsed) {
3508
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3509
+				}
3318 3510
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3319 3511
 				{
3320 3512
 					$timeelapsed = microtime(true);
3321 3513
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3322
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3514
+					if ($globalDebugTimeElapsed) {
3515
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3516
+					}
3323 3517
 				} else {
3324 3518
 					$timeelapsed = microtime(true);
3325 3519
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3326
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3520
+					if ($globalDebugTimeElapsed) {
3521
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3522
+					}
3327 3523
 				}
3328 3524
 			}
3329 3525
 		}
@@ -3338,7 +3534,9 @@  discard block
 block discarded – undo
3338 3534
 			} else {
3339 3535
 				$timeelapsed = microtime(true);
3340 3536
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3341
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3537
+				if ($globalDebugTimeElapsed) {
3538
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3539
+				}
3342 3540
 			}
3343 3541
 		}
3344 3542
 		
@@ -3352,7 +3550,9 @@  discard block
 block discarded – undo
3352 3550
 			} else {
3353 3551
 				$timeelapsed = microtime(true);
3354 3552
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3355
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3553
+				if ($globalDebugTimeElapsed) {
3554
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3555
+				}
3356 3556
 			}
3357 3557
 		}
3358 3558
 
@@ -3387,7 +3587,9 @@  discard block
 block discarded – undo
3387 3587
 			{
3388 3588
 				return false;
3389 3589
 			}
3390
-		} else $altitude = 0;
3590
+		} else {
3591
+			$altitude = 0;
3592
+		}
3391 3593
 		
3392 3594
 		if ($heading != "")
3393 3595
 		{
@@ -3416,7 +3618,9 @@  discard block
 block discarded – undo
3416 3618
 		{
3417 3619
 			$timeelapsed = microtime(true);
3418 3620
 			$image_array = $Image->getSpotterImage($registration);
3419
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3621
+			if ($globalDebugTimeElapsed) {
3622
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3623
+			}
3420 3624
 			if (!isset($image_array[0]['registration']))
3421 3625
 			{
3422 3626
 				//echo "Add image !!!! \n";
@@ -3424,14 +3628,21 @@  discard block
 block discarded – undo
3424 3628
 			}
3425 3629
 			$timeelapsed = microtime(true);
3426 3630
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3427
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3428
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3631
+			if ($globalDebugTimeElapsed) {
3632
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3633
+			}
3634
+			if ($owner_info['owner'] != '') {
3635
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
3636
+			}
3429 3637
 		}
3430 3638
     
3431 3639
 		if ($globalIVAO && $aircraft_icao != '')
3432 3640
 		{
3433
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3434
-            		else $airline_icao = '';
3641
+            		if (isset($airline_array[0]['icao'])) {
3642
+            			$airline_icao = $airline_array[0]['icao'];
3643
+            		} else {
3644
+            			$airline_icao = '';
3645
+            		}
3435 3646
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3436 3647
 			if (!isset($image_array[0]['registration']))
3437 3648
 			{
@@ -3476,12 +3687,24 @@  discard block
 block discarded – undo
3476 3687
                 {
3477 3688
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3478 3689
                 }
3479
-                if ($registration == '') $registration = 'NA';
3480
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3481
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3482
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3483
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3484
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3690
+                if ($registration == '') {
3691
+                	$registration = 'NA';
3692
+                }
3693
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
3694
+                	$squawk = NULL;
3695
+                }
3696
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
3697
+                	$verticalrate = NULL;
3698
+                }
3699
+                if ($heading == '' || $Common->isInteger($heading) === false) {
3700
+                	$heading = 0;
3701
+                }
3702
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
3703
+                	$groundspeed = 0;
3704
+                }
3705
+                if (!isset($aircraft_owner)) {
3706
+                	$aircraft_owner = NULL;
3707
+                }
3485 3708
                 $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) 
3486 3709
                 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)";
3487 3710
 
@@ -3492,9 +3715,13 @@  discard block
 block discarded – undo
3492 3715
 		if ($airline_type == '') {
3493 3716
 			$timeelapsed = microtime(true);
3494 3717
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3495
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3718
+			if ($globalDebugTimeElapsed) {
3719
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3720
+			}
3721
+		}
3722
+		if ($airline_type == null) {
3723
+			$airline_type = '';
3496 3724
 		}
3497
-		if ($airline_type == null) $airline_type = '';
3498 3725
                 $aircraft_type = $aircraft_array[0]['type'];
3499 3726
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3500 3727
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -3629,7 +3856,9 @@  discard block
 block discarded – undo
3629 3856
 			}
3630 3857
 		}
3631 3858
 		$query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3632
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3859
+		if ($limit) {
3860
+			$query .= " LIMIT 10 OFFSET 0";
3861
+		}
3633 3862
 		
3634 3863
 		$sth = $this->db->prepare($query);
3635 3864
 		$sth->execute();
@@ -3674,7 +3903,9 @@  discard block
 block discarded – undo
3674 3903
 			}
3675 3904
 		}
3676 3905
 		$query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC";
3677
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3906
+		if ($limit) {
3907
+			$query .= " LIMIT 10 OFFSET 0";
3908
+		}
3678 3909
       
3679 3910
 		
3680 3911
 		$sth = $this->db->prepare($query);
@@ -3719,7 +3950,9 @@  discard block
 block discarded – undo
3719 3950
 			}
3720 3951
 		}
3721 3952
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC";
3722
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3953
+		if ($limit) {
3954
+			$query .= " LIMIT 10 OFFSET 0";
3955
+		}
3723 3956
       
3724 3957
 		
3725 3958
 		$sth = $this->db->prepare($query);
@@ -3766,7 +3999,9 @@  discard block
 block discarded – undo
3766 3999
 			}
3767 4000
 		}
3768 4001
 		$query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
3769
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4002
+		if ($limit) {
4003
+			$query .= " LIMIT 10 OFFSET 0";
4004
+		}
3770 4005
       
3771 4006
 		
3772 4007
 		$sth = $this->db->prepare($query);
@@ -3811,7 +4046,9 @@  discard block
 block discarded – undo
3811 4046
 			}
3812 4047
 		}
3813 4048
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
3814
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4049
+		if ($limit) {
4050
+			$query .= " LIMIT 10 OFFSET 0";
4051
+		}
3815 4052
       
3816 4053
 		
3817 4054
 		$sth = $this->db->prepare($query);
@@ -4054,7 +4291,9 @@  discard block
 block discarded – undo
4054 4291
 			date_default_timezone_set($globalTimezone);
4055 4292
 			$datetime = new DateTime($date);
4056 4293
 			$offset = $datetime->format('P');
4057
-		} else $offset = '+00:00';
4294
+		} else {
4295
+			$offset = '+00:00';
4296
+		}
4058 4297
 
4059 4298
 		if ($globalDBdriver == 'mysql') {
4060 4299
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4102,7 +4341,9 @@  discard block
 block discarded – undo
4102 4341
 			date_default_timezone_set($globalTimezone);
4103 4342
 			$datetime = new DateTime($date);
4104 4343
 			$offset = $datetime->format('P');
4105
-		} else $offset = '+00:00';
4344
+		} else {
4345
+			$offset = '+00:00';
4346
+		}
4106 4347
 		
4107 4348
 		if ($globalDBdriver == 'mysql') {
4108 4349
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4320,7 +4561,9 @@  discard block
 block discarded – undo
4320 4561
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
4321 4562
 					GROUP BY spotter_output.airline_country
4322 4563
 					ORDER BY airline_country_count DESC";
4323
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4564
+		if ($limit) {
4565
+			$query .= " LIMIT 10 OFFSET 0";
4566
+		}
4324 4567
       
4325 4568
 		$sth = $this->db->prepare($query);
4326 4569
 		$sth->execute();
@@ -4348,7 +4591,9 @@  discard block
 block discarded – undo
4348 4591
 		global $globalDBdriver;
4349 4592
 		$filter_query = $this->getFilter($filters,true,true);
4350 4593
 		$Connection= new Connection($this->db);
4351
-		if (!$Connection->tableExists('countries')) return array();
4594
+		if (!$Connection->tableExists('countries')) {
4595
+			return array();
4596
+		}
4352 4597
 		/*
4353 4598
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
4354 4599
 					FROM countries c, spotter_output s
@@ -4373,7 +4618,9 @@  discard block
 block discarded – undo
4373 4618
 		}
4374 4619
 
4375 4620
 		$query .= "GROUP BY c.name ORDER BY nb DESC";
4376
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4621
+		if ($limit) {
4622
+			$query .= " LIMIT 10 OFFSET 0";
4623
+		}
4377 4624
       
4378 4625
 		
4379 4626
 		$sth = $this->db->prepare($query);
@@ -4423,7 +4670,9 @@  discard block
 block discarded – undo
4423 4670
 		}
4424 4671
 
4425 4672
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4426
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4673
+		if ($limit) {
4674
+			$query .= " LIMIT 10 OFFSET 0";
4675
+		}
4427 4676
  
4428 4677
 		$sth = $this->db->prepare($query);
4429 4678
 		$sth->execute();
@@ -4469,7 +4718,9 @@  discard block
 block discarded – undo
4469 4718
 		}
4470 4719
 
4471 4720
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4472
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4721
+		if ($limit) {
4722
+			$query .= " LIMIT 10 OFFSET 0";
4723
+		}
4473 4724
  
4474 4725
 		$sth = $this->db->prepare($query);
4475 4726
 		$sth->execute();
@@ -4522,7 +4773,9 @@  discard block
 block discarded – undo
4522 4773
 			if($row['registration'] != "")
4523 4774
 			{
4524 4775
 				$image_array = $Image->getSpotterImage($row['registration']);
4525
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4776
+				if (isset($image_array[0]['image_thumbnail'])) {
4777
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4778
+				}
4526 4779
 			}
4527 4780
 			$temp_array['registration_count'] = $row['registration_count'];
4528 4781
 
@@ -4597,7 +4850,9 @@  discard block
 block discarded – undo
4597 4850
 			if($row['registration'] != "")
4598 4851
 			{
4599 4852
 				$image_array = $Image->getSpotterImage($row['registration']);
4600
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4853
+				if (isset($image_array[0]['image_thumbnail'])) {
4854
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4855
+				}
4601 4856
 			}
4602 4857
 			$temp_array['registration_count'] = $row['registration_count'];
4603 4858
 
@@ -4830,7 +5085,9 @@  discard block
 block discarded – undo
4830 5085
 			date_default_timezone_set($globalTimezone);
4831 5086
 			$datetime = new DateTime($date);
4832 5087
 			$offset = $datetime->format('P');
4833
-		} else $offset = '+00:00';
5088
+		} else {
5089
+			$offset = '+00:00';
5090
+		}
4834 5091
 
4835 5092
 		if ($globalDBdriver == 'mysql') {
4836 5093
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -4877,7 +5134,9 @@  discard block
 block discarded – undo
4877 5134
 			date_default_timezone_set($globalTimezone);
4878 5135
 			$datetime = new DateTime($date);
4879 5136
 			$offset = $datetime->format('P');
4880
-		} else $offset = '+00:00';
5137
+		} else {
5138
+			$offset = '+00:00';
5139
+		}
4881 5140
 
4882 5141
 		if ($globalDBdriver == 'mysql') {
4883 5142
 			$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    
@@ -4931,7 +5190,9 @@  discard block
 block discarded – undo
4931 5190
 			date_default_timezone_set($globalTimezone);
4932 5191
 			$datetime = new DateTime($date);
4933 5192
 			$offset = $datetime->format('P');
4934
-		} else $offset = '+00:00';
5193
+		} else {
5194
+			$offset = '+00:00';
5195
+		}
4935 5196
 
4936 5197
 		if ($globalDBdriver == 'mysql') {
4937 5198
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5029,8 +5290,11 @@  discard block
 block discarded – undo
5029 5290
 			if($row['registration'] != "")
5030 5291
 			{
5031 5292
 				$image_array = $Image->getSpotterImage($row['registration']);
5032
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5033
-				else $temp_array['image_thumbnail'] = '';
5293
+				if (isset($image_array[0]['image_thumbnail'])) {
5294
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5295
+				} else {
5296
+					$temp_array['image_thumbnail'] = '';
5297
+				}
5034 5298
 			}
5035 5299
 			$temp_array['registration_count'] = $row['registration_count'];
5036 5300
 			$aircraft_array[] = $temp_array;
@@ -5137,7 +5401,9 @@  discard block
 block discarded – undo
5137 5401
 			if($row['registration'] != "")
5138 5402
 			{
5139 5403
 				$image_array = $Image->getSpotterImage($row['registration']);
5140
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5404
+				if (isset($image_array[0]['image_thumbnail'])) {
5405
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5406
+				}
5141 5407
 			}
5142 5408
 			$temp_array['registration_count'] = $row['registration_count'];
5143 5409
           
@@ -5254,7 +5520,9 @@  discard block
 block discarded – undo
5254 5520
 			if($row['registration'] != "")
5255 5521
 			{
5256 5522
 				$image_array = $Image->getSpotterImage($row['registration']);
5257
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5523
+				if (isset($image_array[0]['image_thumbnail'])) {
5524
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5525
+				}
5258 5526
 			}
5259 5527
 			$temp_array['registration_count'] = $row['registration_count'];
5260 5528
           
@@ -5366,7 +5634,9 @@  discard block
 block discarded – undo
5366 5634
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5367 5635
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5368 5636
                 $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5369
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5637
+		if ($limit) {
5638
+			$query .= " LIMIT 10 OFFSET 0";
5639
+		}
5370 5640
 		
5371 5641
 		$sth = $this->db->prepare($query);
5372 5642
 		$sth->execute();
@@ -5385,7 +5655,9 @@  discard block
 block discarded – undo
5385 5655
 			if($row['registration'] != "")
5386 5656
 			{
5387 5657
 				$image_array = $Image->getSpotterImage($row['registration']);
5388
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5658
+				if (isset($image_array[0]['image_thumbnail'])) {
5659
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5660
+				}
5389 5661
 			}
5390 5662
           
5391 5663
 			$aircraft_array[] = $temp_array;
@@ -5426,7 +5698,9 @@  discard block
 block discarded – undo
5426 5698
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5427 5699
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5428 5700
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5429
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5701
+		if ($limit) {
5702
+			$query .= " LIMIT 10 OFFSET 0";
5703
+		}
5430 5704
 		
5431 5705
 		$sth = $this->db->prepare($query);
5432 5706
 		$sth->execute();
@@ -5446,7 +5720,9 @@  discard block
 block discarded – undo
5446 5720
 			if($row['registration'] != "")
5447 5721
 			{
5448 5722
 				$image_array = $Image->getSpotterImage($row['registration']);
5449
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5723
+				if (isset($image_array[0]['image_thumbnail'])) {
5724
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5725
+				}
5450 5726
 			}
5451 5727
           
5452 5728
 			$aircraft_array[] = $temp_array;
@@ -5487,7 +5763,9 @@  discard block
 block discarded – undo
5487 5763
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5488 5764
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5489 5765
 				ORDER BY airport_departure_icao_count DESC";
5490
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5766
+		if ($limit) {
5767
+			$query .= " LIMIT 10 OFFSET 0";
5768
+		}
5491 5769
       
5492 5770
 		$sth = $this->db->prepare($query);
5493 5771
 		$sth->execute();
@@ -5539,7 +5817,9 @@  discard block
 block discarded – undo
5539 5817
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5540 5818
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5541 5819
 				ORDER BY airport_departure_icao_count DESC";
5542
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5820
+		if ($limit) {
5821
+			$query .= " LIMIT 10 OFFSET 0";
5822
+		}
5543 5823
       
5544 5824
 		$sth = $this->db->prepare($query);
5545 5825
 		$sth->execute();
@@ -5591,7 +5871,9 @@  discard block
 block discarded – undo
5591 5871
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5592 5872
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5593 5873
 				ORDER BY airport_departure_icao_count DESC";
5594
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5874
+		if ($limit) {
5875
+			$query .= " LIMIT 10 OFFSET 0";
5876
+		}
5595 5877
       
5596 5878
 		$sth = $this->db->prepare($query);
5597 5879
 		$sth->execute();
@@ -5643,7 +5925,9 @@  discard block
 block discarded – undo
5643 5925
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5644 5926
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5645 5927
 				ORDER BY airport_departure_icao_count DESC";
5646
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5928
+		if ($limit) {
5929
+			$query .= " LIMIT 10 OFFSET 0";
5930
+		}
5647 5931
       
5648 5932
 		$sth = $this->db->prepare($query);
5649 5933
 		$sth->execute();
@@ -6038,7 +6322,9 @@  discard block
 block discarded – undo
6038 6322
 			date_default_timezone_set($globalTimezone);
6039 6323
 			$datetime = new DateTime($date);
6040 6324
 			$offset = $datetime->format('P');
6041
-		} else $offset = '+00:00';
6325
+		} else {
6326
+			$offset = '+00:00';
6327
+		}
6042 6328
 
6043 6329
 		if ($globalDBdriver == 'mysql') {
6044 6330
 			$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 
@@ -6088,7 +6374,9 @@  discard block
 block discarded – undo
6088 6374
 			date_default_timezone_set($globalTimezone);
6089 6375
 			$datetime = new DateTime($date);
6090 6376
 			$offset = $datetime->format('P');
6091
-		} else $offset = '+00:00';
6377
+		} else {
6378
+			$offset = '+00:00';
6379
+		}
6092 6380
 
6093 6381
 		if ($globalDBdriver == 'mysql') {
6094 6382
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -6301,7 +6589,9 @@  discard block
 block discarded – undo
6301 6589
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6302 6590
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6303 6591
 					ORDER BY airport_arrival_icao_count DESC";
6304
-		if ($limit) $query .= " LIMIT 10";
6592
+		if ($limit) {
6593
+			$query .= " LIMIT 10";
6594
+		}
6305 6595
       
6306 6596
 		
6307 6597
 		$sth = $this->db->prepare($query);
@@ -6321,7 +6611,9 @@  discard block
 block discarded – undo
6321 6611
 			if ($icaoaskey) {
6322 6612
 				$icao = $row['arrival_airport_icao'];
6323 6613
 				$airport_array[$icao] = $temp_array;
6324
-			} else $airport_array[] = $temp_array;
6614
+			} else {
6615
+				$airport_array[] = $temp_array;
6616
+			}
6325 6617
 		}
6326 6618
 
6327 6619
 		return $airport_array;
@@ -6363,7 +6655,9 @@  discard block
 block discarded – undo
6363 6655
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6364 6656
                 $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6365 6657
 					ORDER BY airport_arrival_icao_count DESC";
6366
-		if ($limit) $query .= " LIMIT 10";
6658
+		if ($limit) {
6659
+			$query .= " LIMIT 10";
6660
+		}
6367 6661
       
6368 6662
 		
6369 6663
 		$sth = $this->db->prepare($query);
@@ -6384,7 +6678,9 @@  discard block
 block discarded – undo
6384 6678
 			if ($icaoaskey) {
6385 6679
 				$icao = $row['arrival_airport_icao'];
6386 6680
 				$airport_array[$icao] = $temp_array;
6387
-			} else $airport_array[] = $temp_array;
6681
+			} else {
6682
+				$airport_array[] = $temp_array;
6683
+			}
6388 6684
 		}
6389 6685
 
6390 6686
 		return $airport_array;
@@ -6426,7 +6722,9 @@  discard block
 block discarded – undo
6426 6722
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6427 6723
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6428 6724
 					ORDER BY airport_arrival_icao_count DESC";
6429
-		if ($limit) $query .= " LIMIT 10";
6725
+		if ($limit) {
6726
+			$query .= " LIMIT 10";
6727
+		}
6430 6728
       
6431 6729
 		
6432 6730
 		$sth = $this->db->prepare($query);
@@ -6446,7 +6744,9 @@  discard block
 block discarded – undo
6446 6744
 			if ($icaoaskey) {
6447 6745
 				$icao = $row['arrival_airport_icao'];
6448 6746
 				$airport_array[$icao] = $temp_array;
6449
-			} else $airport_array[] = $temp_array;
6747
+			} else {
6748
+				$airport_array[] = $temp_array;
6749
+			}
6450 6750
 		}
6451 6751
 
6452 6752
 		return $airport_array;
@@ -6488,7 +6788,9 @@  discard block
 block discarded – undo
6488 6788
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6489 6789
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6490 6790
 					ORDER BY airport_arrival_icao_count DESC";
6491
-		if ($limit) $query .= " LIMIT 10";
6791
+		if ($limit) {
6792
+			$query .= " LIMIT 10";
6793
+		}
6492 6794
       
6493 6795
 		
6494 6796
 		$sth = $this->db->prepare($query);
@@ -6509,7 +6811,9 @@  discard block
 block discarded – undo
6509 6811
 			if ($icaoaskey) {
6510 6812
 				$icao = $row['arrival_airport_icao'];
6511 6813
 				$airport_array[$icao] = $temp_array;
6512
-			} else $airport_array[] = $temp_array;
6814
+			} else {
6815
+				$airport_array[] = $temp_array;
6816
+			}
6513 6817
 		}
6514 6818
 
6515 6819
 		return $airport_array;
@@ -6890,7 +7194,9 @@  discard block
 block discarded – undo
6890 7194
 			date_default_timezone_set($globalTimezone);
6891 7195
 			$datetime = new DateTime($date);
6892 7196
 			$offset = $datetime->format('P');
6893
-		} else $offset = '+00:00';
7197
+		} else {
7198
+			$offset = '+00:00';
7199
+		}
6894 7200
 
6895 7201
 		if ($globalDBdriver == 'mysql') {
6896 7202
 			$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 
@@ -6940,7 +7246,9 @@  discard block
 block discarded – undo
6940 7246
 			date_default_timezone_set($globalTimezone);
6941 7247
 			$datetime = new DateTime($date);
6942 7248
 			$offset = $datetime->format('P');
6943
-		} else $offset = '+00:00';
7249
+		} else {
7250
+			$offset = '+00:00';
7251
+		}
6944 7252
 
6945 7253
 		if ($globalDBdriver == 'mysql') {
6946 7254
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -7163,7 +7471,9 @@  discard block
 block discarded – undo
7163 7471
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
7164 7472
 		$query .= " GROUP BY spotter_output.arrival_airport_country
7165 7473
 					ORDER BY airport_arrival_country_count DESC";
7166
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7474
+		if ($limit) {
7475
+			$query .= " LIMIT 10 OFFSET 0";
7476
+		}
7167 7477
       
7168 7478
 		
7169 7479
 		$sth = $this->db->prepare($query);
@@ -7450,7 +7760,9 @@  discard block
 block discarded – undo
7450 7760
 			date_default_timezone_set($globalTimezone);
7451 7761
 			$datetime = new DateTime($date);
7452 7762
 			$offset = $datetime->format('P');
7453
-		} else $offset = '+00:00';
7763
+		} else {
7764
+			$offset = '+00:00';
7765
+		}
7454 7766
 		
7455 7767
 		if ($globalDBdriver == 'mysql') {
7456 7768
 			$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
@@ -7626,15 +7938,23 @@  discard block
 block discarded – undo
7626 7938
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7627 7939
                     FROM spotter_output".$filter_query." spotter_output.ident <> '' ";
7628 7940
 		 if ($olderthanmonths > 0) {
7629
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
7630
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7941
+			if ($globalDBdriver == 'mysql') {
7942
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
7943
+			} else {
7944
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7945
+			}
7631 7946
 		}
7632 7947
 		if ($sincedate != '') {
7633
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
7634
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7948
+			if ($globalDBdriver == 'mysql') {
7949
+				$query .= " AND spotter_output.date > '".$sincedate."'";
7950
+			} else {
7951
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7952
+			}
7635 7953
 		}
7636 7954
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
7637
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7955
+		if ($limit) {
7956
+			$query .= " LIMIT 10 OFFSET 0";
7957
+		}
7638 7958
       		
7639 7959
 		$sth = $this->db->prepare($query);
7640 7960
 		$sth->execute();
@@ -7668,15 +7988,23 @@  discard block
 block discarded – undo
7668 7988
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7669 7989
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
7670 7990
 		 if ($olderthanmonths > 0) {
7671
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7672
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7991
+			if ($globalDBdriver == 'mysql') {
7992
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7993
+			} else {
7994
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7995
+			}
7673 7996
 		}
7674 7997
 		if ($sincedate != '') {
7675
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
7676
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
7998
+			if ($globalDBdriver == 'mysql') {
7999
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
8000
+			} else {
8001
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
8002
+			}
7677 8003
 		}
7678 8004
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
7679
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
8005
+		if ($limit) {
8006
+			$query .= " LIMIT 10 OFFSET 0";
8007
+		}
7680 8008
       		
7681 8009
 		$sth = $this->db->prepare($query);
7682 8010
 		$sth->execute();
@@ -7713,7 +8041,9 @@  discard block
 block discarded – undo
7713 8041
 			date_default_timezone_set($globalTimezone);
7714 8042
 			$datetime = new DateTime();
7715 8043
 			$offset = $datetime->format('P');
7716
-		} else $offset = '+00:00';
8044
+		} else {
8045
+			$offset = '+00:00';
8046
+		}
7717 8047
 
7718 8048
 		if ($globalDBdriver == 'mysql') {
7719 8049
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7762,7 +8092,9 @@  discard block
 block discarded – undo
7762 8092
 			date_default_timezone_set($globalTimezone);
7763 8093
 			$datetime = new DateTime();
7764 8094
 			$offset = $datetime->format('P');
7765
-		} else $offset = '+00:00';
8095
+		} else {
8096
+			$offset = '+00:00';
8097
+		}
7766 8098
 		$filter_query = $this->getFilter($filters,true,true);
7767 8099
 		if ($globalDBdriver == 'mysql') {
7768 8100
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7811,7 +8143,9 @@  discard block
 block discarded – undo
7811 8143
 			date_default_timezone_set($globalTimezone);
7812 8144
 			$datetime = new DateTime();
7813 8145
 			$offset = $datetime->format('P');
7814
-		} else $offset = '+00:00';
8146
+		} else {
8147
+			$offset = '+00:00';
8148
+		}
7815 8149
 		$filter_query = $this->getFilter($filters,true,true);
7816 8150
 		if ($globalDBdriver == 'mysql') {
7817 8151
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7857,7 +8191,9 @@  discard block
 block discarded – undo
7857 8191
 			date_default_timezone_set($globalTimezone);
7858 8192
 			$datetime = new DateTime();
7859 8193
 			$offset = $datetime->format('P');
7860
-		} else $offset = '+00:00';
8194
+		} else {
8195
+			$offset = '+00:00';
8196
+		}
7861 8197
 		$filter_query = $this->getFilter($filters,true,true);
7862 8198
 		if ($globalDBdriver == 'mysql') {
7863 8199
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7905,7 +8241,9 @@  discard block
 block discarded – undo
7905 8241
 			date_default_timezone_set($globalTimezone);
7906 8242
 			$datetime = new DateTime();
7907 8243
 			$offset = $datetime->format('P');
7908
-		} else $offset = '+00:00';
8244
+		} else {
8245
+			$offset = '+00:00';
8246
+		}
7909 8247
 		
7910 8248
 		if ($globalDBdriver == 'mysql') {
7911 8249
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7953,7 +8291,9 @@  discard block
 block discarded – undo
7953 8291
 			date_default_timezone_set($globalTimezone);
7954 8292
 			$datetime = new DateTime();
7955 8293
 			$offset = $datetime->format('P');
7956
-		} else $offset = '+00:00';
8294
+		} else {
8295
+			$offset = '+00:00';
8296
+		}
7957 8297
 
7958 8298
 		if ($globalDBdriver == 'mysql') {
7959 8299
 			$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
@@ -8000,7 +8340,9 @@  discard block
 block discarded – undo
8000 8340
 			date_default_timezone_set($globalTimezone);
8001 8341
 			$datetime = new DateTime();
8002 8342
 			$offset = $datetime->format('P');
8003
-		} else $offset = '+00:00';
8343
+		} else {
8344
+			$offset = '+00:00';
8345
+		}
8004 8346
 
8005 8347
 		if ($globalDBdriver == 'mysql') {
8006 8348
 			$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
@@ -8048,7 +8390,9 @@  discard block
 block discarded – undo
8048 8390
 			date_default_timezone_set($globalTimezone);
8049 8391
 			$datetime = new DateTime();
8050 8392
 			$offset = $datetime->format('P');
8051
-		} else $offset = '+00:00';
8393
+		} else {
8394
+			$offset = '+00:00';
8395
+		}
8052 8396
 		$filter_query = $this->getFilter($filters,true,true);
8053 8397
 		if ($globalDBdriver == 'mysql') {
8054 8398
 			$query  = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -8093,7 +8437,9 @@  discard block
 block discarded – undo
8093 8437
 			date_default_timezone_set($globalTimezone);
8094 8438
 			$datetime = new DateTime();
8095 8439
 			$offset = $datetime->format('P');
8096
-		} else $offset = '+00:00';
8440
+		} else {
8441
+			$offset = '+00:00';
8442
+		}
8097 8443
 		$filter_query = $this->getFilter($filters,true,true);
8098 8444
 
8099 8445
 		if ($globalDBdriver == 'mysql') {
@@ -8140,7 +8486,9 @@  discard block
 block discarded – undo
8140 8486
 			date_default_timezone_set($globalTimezone);
8141 8487
 			$datetime = new DateTime();
8142 8488
 			$offset = $datetime->format('P');
8143
-		} else $offset = '+00:00';
8489
+		} else {
8490
+			$offset = '+00:00';
8491
+		}
8144 8492
 
8145 8493
 		if ($globalDBdriver == 'mysql') {
8146 8494
 			$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
@@ -8186,7 +8534,9 @@  discard block
 block discarded – undo
8186 8534
 			date_default_timezone_set($globalTimezone);
8187 8535
 			$datetime = new DateTime();
8188 8536
 			$offset = $datetime->format('P');
8189
-		} else $offset = '+00:00';
8537
+		} else {
8538
+			$offset = '+00:00';
8539
+		}
8190 8540
 		$filter_query = $this->getFilter($filters,true,true);
8191 8541
 
8192 8542
 		if ($globalDBdriver == 'mysql') {
@@ -8233,7 +8583,9 @@  discard block
 block discarded – undo
8233 8583
 			date_default_timezone_set($globalTimezone);
8234 8584
 			$datetime = new DateTime();
8235 8585
 			$offset = $datetime->format('P');
8236
-		} else $offset = '+00:00';
8586
+		} else {
8587
+			$offset = '+00:00';
8588
+		}
8237 8589
 
8238 8590
 		if ($globalDBdriver == 'mysql') {
8239 8591
 			$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
@@ -8280,7 +8632,9 @@  discard block
 block discarded – undo
8280 8632
 			date_default_timezone_set($globalTimezone);
8281 8633
 			$datetime = new DateTime();
8282 8634
 			$offset = $datetime->format('P');
8283
-		} else $offset = '+00:00';
8635
+		} else {
8636
+			$offset = '+00:00';
8637
+		}
8284 8638
 
8285 8639
 		if ($globalDBdriver == 'mysql') {
8286 8640
 			$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
@@ -8325,7 +8679,9 @@  discard block
 block discarded – undo
8325 8679
 			date_default_timezone_set($globalTimezone);
8326 8680
 			$datetime = new DateTime();
8327 8681
 			$offset = $datetime->format('P');
8328
-		} else $offset = '+00:00';
8682
+		} else {
8683
+			$offset = '+00:00';
8684
+		}
8329 8685
 		$filter_query = $this->getFilter($filters,true,true);
8330 8686
 
8331 8687
 		if ($globalDBdriver == 'mysql') {
@@ -8373,7 +8729,9 @@  discard block
 block discarded – undo
8373 8729
 			date_default_timezone_set($globalTimezone);
8374 8730
 			$datetime = new DateTime();
8375 8731
 			$offset = $datetime->format('P');
8376
-		} else $offset = '+00:00';
8732
+		} else {
8733
+			$offset = '+00:00';
8734
+		}
8377 8735
 
8378 8736
 		if ($globalDBdriver == 'mysql') {
8379 8737
 			$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
@@ -8419,7 +8777,9 @@  discard block
 block discarded – undo
8419 8777
 			date_default_timezone_set($globalTimezone);
8420 8778
 			$datetime = new DateTime();
8421 8779
 			$offset = $datetime->format('P');
8422
-		} else $offset = '+00:00';
8780
+		} else {
8781
+			$offset = '+00:00';
8782
+		}
8423 8783
 		$filter_query = $this->getFilter($filters,true,true);
8424 8784
 
8425 8785
 		if ($globalDBdriver == 'mysql') {
@@ -8467,7 +8827,9 @@  discard block
 block discarded – undo
8467 8827
 			date_default_timezone_set($globalTimezone);
8468 8828
 			$datetime = new DateTime();
8469 8829
 			$offset = $datetime->format('P');
8470
-		} else $offset = '+00:00';
8830
+		} else {
8831
+			$offset = '+00:00';
8832
+		}
8471 8833
 
8472 8834
 		if ($globalDBdriver == 'mysql') {
8473 8835
 			$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
@@ -8514,7 +8876,9 @@  discard block
 block discarded – undo
8514 8876
 			date_default_timezone_set($globalTimezone);
8515 8877
 			$datetime = new DateTime();
8516 8878
 			$offset = $datetime->format('P');
8517
-		} else $offset = '+00:00';
8879
+		} else {
8880
+			$offset = '+00:00';
8881
+		}
8518 8882
 		$filter_query = $this->getFilter($filters,true,true);
8519 8883
 		if ($globalDBdriver == 'mysql') {
8520 8884
 			$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
@@ -8563,7 +8927,9 @@  discard block
 block discarded – undo
8563 8927
 			date_default_timezone_set($globalTimezone);
8564 8928
 			$datetime = new DateTime();
8565 8929
 			$offset = $datetime->format('P');
8566
-		} else $offset = '+00:00';
8930
+		} else {
8931
+			$offset = '+00:00';
8932
+		}
8567 8933
 
8568 8934
 		$orderby_sql = '';
8569 8935
 		if ($orderby == "hour")
@@ -8629,7 +8995,9 @@  discard block
 block discarded – undo
8629 8995
 			date_default_timezone_set($globalTimezone);
8630 8996
 			$datetime = new DateTime();
8631 8997
 			$offset = $datetime->format('P');
8632
-		} else $offset = '+00:00';
8998
+		} else {
8999
+			$offset = '+00:00';
9000
+		}
8633 9001
 
8634 9002
 		$orderby_sql = '';
8635 9003
 		if ($orderby == "hour")
@@ -8696,7 +9064,9 @@  discard block
 block discarded – undo
8696 9064
 			date_default_timezone_set($globalTimezone);
8697 9065
 			$datetime = new DateTime();
8698 9066
 			$offset = $datetime->format('P');
8699
-		} else $offset = '+00:00';
9067
+		} else {
9068
+			$offset = '+00:00';
9069
+		}
8700 9070
 
8701 9071
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8702 9072
 
@@ -8747,7 +9117,9 @@  discard block
 block discarded – undo
8747 9117
 			date_default_timezone_set($globalTimezone);
8748 9118
 			$datetime = new DateTime();
8749 9119
 			$offset = $datetime->format('P');
8750
-		} else $offset = '+00:00';
9120
+		} else {
9121
+			$offset = '+00:00';
9122
+		}
8751 9123
 
8752 9124
 		if ($globalDBdriver == 'mysql') {
8753 9125
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8794,7 +9166,9 @@  discard block
 block discarded – undo
8794 9166
 			date_default_timezone_set($globalTimezone);
8795 9167
 			$datetime = new DateTime();
8796 9168
 			$offset = $datetime->format('P');
8797
-		} else $offset = '+00:00';
9169
+		} else {
9170
+			$offset = '+00:00';
9171
+		}
8798 9172
 
8799 9173
 		if ($globalDBdriver == 'mysql') {
8800 9174
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8841,7 +9215,9 @@  discard block
 block discarded – undo
8841 9215
 			date_default_timezone_set($globalTimezone);
8842 9216
 			$datetime = new DateTime();
8843 9217
 			$offset = $datetime->format('P');
8844
-		} else $offset = '+00:00';
9218
+		} else {
9219
+			$offset = '+00:00';
9220
+		}
8845 9221
 
8846 9222
 		if ($globalDBdriver == 'mysql') {
8847 9223
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8889,7 +9265,9 @@  discard block
 block discarded – undo
8889 9265
 			date_default_timezone_set($globalTimezone);
8890 9266
 			$datetime = new DateTime();
8891 9267
 			$offset = $datetime->format('P');
8892
-		} else $offset = '+00:00';
9268
+		} else {
9269
+			$offset = '+00:00';
9270
+		}
8893 9271
 
8894 9272
 		if ($globalDBdriver == 'mysql') {
8895 9273
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8937,7 +9315,9 @@  discard block
 block discarded – undo
8937 9315
 			date_default_timezone_set($globalTimezone);
8938 9316
 			$datetime = new DateTime($date);
8939 9317
 			$offset = $datetime->format('P');
8940
-		} else $offset = '+00:00';
9318
+		} else {
9319
+			$offset = '+00:00';
9320
+		}
8941 9321
 
8942 9322
 		if ($globalDBdriver == 'mysql') {
8943 9323
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8985,7 +9365,9 @@  discard block
 block discarded – undo
8985 9365
 			date_default_timezone_set($globalTimezone);
8986 9366
 			$datetime = new DateTime();
8987 9367
 			$offset = $datetime->format('P');
8988
-		} else $offset = '+00:00';
9368
+		} else {
9369
+			$offset = '+00:00';
9370
+		}
8989 9371
 
8990 9372
 		if ($globalDBdriver == 'mysql') {
8991 9373
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9035,7 +9417,9 @@  discard block
 block discarded – undo
9035 9417
 			date_default_timezone_set($globalTimezone);
9036 9418
 			$datetime = new DateTime();
9037 9419
 			$offset = $datetime->format('P');
9038
-		} else $offset = '+00:00';
9420
+		} else {
9421
+			$offset = '+00:00';
9422
+		}
9039 9423
 
9040 9424
 		if ($globalDBdriver == 'mysql') {
9041 9425
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9082,7 +9466,9 @@  discard block
 block discarded – undo
9082 9466
 			date_default_timezone_set($globalTimezone);
9083 9467
 			$datetime = new DateTime();
9084 9468
 			$offset = $datetime->format('P');
9085
-		} else $offset = '+00:00';
9469
+		} else {
9470
+			$offset = '+00:00';
9471
+		}
9086 9472
 
9087 9473
 		if ($globalDBdriver == 'mysql') {
9088 9474
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9250,7 +9636,9 @@  discard block
 block discarded – undo
9250 9636
 			date_default_timezone_set($globalTimezone);
9251 9637
 			$datetime = new DateTime();
9252 9638
 			$offset = $datetime->format('P');
9253
-		} else $offset = '+00:00';
9639
+		} else {
9640
+			$offset = '+00:00';
9641
+		}
9254 9642
 
9255 9643
 		if ($globalDBdriver == 'mysql') {
9256 9644
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9436,7 +9824,9 @@  discard block
 block discarded – undo
9436 9824
 	*/
9437 9825
 	public function parseDirection($direction = 0)
9438 9826
 	{
9439
-		if ($direction == '') $direction = 0;
9827
+		if ($direction == '') {
9828
+			$direction = 0;
9829
+		}
9440 9830
 		$direction_array = array();
9441 9831
 		$temp_array = array();
9442 9832
 
@@ -9537,7 +9927,9 @@  discard block
 block discarded – undo
9537 9927
 		if (isset($result->AirlineFlightInfoResult))
9538 9928
 		{
9539 9929
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
9540
-		} else return '';
9930
+		} else {
9931
+			return '';
9932
+		}
9541 9933
 		
9542 9934
 		$registration = $this->convertAircraftRegistration($registration);
9543 9935
 		
@@ -9566,7 +9958,9 @@  discard block
 block discarded – undo
9566 9958
 		if (count($row) > 0) {
9567 9959
 		    //return $row['Registration'];
9568 9960
 		    return $row['registration'];
9569
-		} else return '';
9961
+		} else {
9962
+			return '';
9963
+		}
9570 9964
 	
9571 9965
 	}
9572 9966
 
@@ -9589,9 +9983,14 @@  discard block
 block discarded – undo
9589 9983
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
9590 9984
 		$sth->closeCursor();
9591 9985
 		if (count($row) > 0) {
9592
-		    if ($row['type_flight'] == null) return '';
9593
-		    else return $row['type_flight'];
9594
-		} else return '';
9986
+		    if ($row['type_flight'] == null) {
9987
+		    	return '';
9988
+		    } else {
9989
+		    	return $row['type_flight'];
9990
+		    }
9991
+		} else {
9992
+			return '';
9993
+		}
9595 9994
 	
9596 9995
 	}
9597 9996
 
@@ -9609,7 +10008,9 @@  discard block
 block discarded – undo
9609 10008
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9610 10009
 	
9611 10010
 		$Connection = new Connection($this->db);
9612
-		if (!$Connection->tableExists('countries')) return '';
10011
+		if (!$Connection->tableExists('countries')) {
10012
+			return '';
10013
+		}
9613 10014
 	
9614 10015
 		try {
9615 10016
 			/*
@@ -9629,9 +10030,13 @@  discard block
 block discarded – undo
9629 10030
 			$sth->closeCursor();
9630 10031
 			if (count($row) > 0) {
9631 10032
 				return $row;
9632
-			} else return '';
10033
+			} else {
10034
+				return '';
10035
+			}
9633 10036
 		} catch (PDOException $e) {
9634
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
10037
+			if (isset($globalDebug) && $globalDebug) {
10038
+				echo 'Error : '.$e->getMessage()."\n";
10039
+			}
9635 10040
 			return '';
9636 10041
 		}
9637 10042
 	
@@ -9779,7 +10184,9 @@  discard block
 block discarded – undo
9779 10184
 	{
9780 10185
 		global $globalBitlyAccessToken;
9781 10186
 		
9782
-		if ($globalBitlyAccessToken == '') return $url;
10187
+		if ($globalBitlyAccessToken == '') {
10188
+			return $url;
10189
+		}
9783 10190
         
9784 10191
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
9785 10192
 		
@@ -9928,7 +10335,9 @@  discard block
 block discarded – undo
9928 10335
 		
9929 10336
 
9930 10337
 		// routes
9931
-		if ($globalDebug) print "Routes...\n";
10338
+		if ($globalDebug) {
10339
+			print "Routes...\n";
10340
+		}
9932 10341
 		if ($globalDBdriver == 'mysql') {
9933 10342
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
9934 10343
 		} else {
@@ -9947,7 +10356,9 @@  discard block
 block discarded – undo
9947 10356
 			}
9948 10357
 		}
9949 10358
 		
9950
-		if ($globalDebug) print "Airlines...\n";
10359
+		if ($globalDebug) {
10360
+			print "Airlines...\n";
10361
+		}
9951 10362
 		//airlines
9952 10363
 		if ($globalDBdriver == 'mysql') {
9953 10364
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -9961,10 +10372,15 @@  discard block
 block discarded – undo
9961 10372
 			if (is_numeric(substr($row['ident'], -1, 1)))
9962 10373
 			{
9963 10374
 				$fromsource = NULL;
9964
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
9965
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
9966
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
9967
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
10375
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
10376
+					$fromsource = 'vatsim';
10377
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
10378
+					$fromsource = 'ivao';
10379
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
10380
+					$fromsource = 'vatsim';
10381
+				} elseif (isset($globalIVAO) && $globalIVAO) {
10382
+					$fromsource = 'ivao';
10383
+				}
9968 10384
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
9969 10385
 				if (isset($airline_array[0]['name'])) {
9970 10386
 					$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";
@@ -9974,13 +10390,17 @@  discard block
 block discarded – undo
9974 10390
 			}
9975 10391
 		}
9976 10392
 
9977
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
10393
+		if ($globalDebug) {
10394
+			print "Remove Duplicate in aircraft_modes...\n";
10395
+		}
9978 10396
 		//duplicate modes
9979 10397
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
9980 10398
 		$sth = $this->db->prepare($query);
9981 10399
 		$sth->execute();
9982 10400
 		
9983
-		if ($globalDebug) print "Aircraft...\n";
10401
+		if ($globalDebug) {
10402
+			print "Aircraft...\n";
10403
+		}
9984 10404
 		//aircraft
9985 10405
 		if ($globalDBdriver == 'mysql') {
9986 10406
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -10023,26 +10443,38 @@  discard block
 block discarded – undo
10023 10443
 				 if (isset($closestAirports[0])) {
10024 10444
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
10025 10445
 						$airport_icao = $closestAirports[0]['icao'];
10026
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10446
+						if ($globalDebug) {
10447
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10448
+						}
10027 10449
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
10028 10450
 						foreach ($closestAirports as $airport) {
10029 10451
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
10030 10452
 								$airport_icao = $airport['icao'];
10031
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10453
+								if ($globalDebug) {
10454
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10455
+								}
10032 10456
 								break;
10033 10457
 							}
10034 10458
 						}
10035 10459
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
10036 10460
 						$airport_icao = $closestAirports[0]['icao'];
10037
-						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";
10461
+						if ($globalDebug) {
10462
+							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";
10463
+						}
10038 10464
 					} else {
10039
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10465
+						if ($globalDebug) {
10466
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10467
+						}
10040 10468
 					}
10041 10469
 				} else {
10042
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
10470
+					if ($globalDebug) {
10471
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
10472
+					}
10043 10473
 				}
10044 10474
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
10045
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
10475
+					if ($globalDebug) {
10476
+						echo "Updating airport to ".$airport_icao."...\n";
10477
+					}
10046 10478
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10047 10479
 					$sthu = $this->db->prepare($update_query);
10048 10480
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
Spacing   +972 added lines, -972 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT spotter_output.* FROM spotter_output";
6 6
 
7
-class Spotter{
7
+class Spotter {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -17,15 +17,15 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
22
-		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter);
23
-		if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter);
22
+		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName], $filter);
23
+		if (is_array($globalFilter)) $filter = array_merge($globalFilter, $filter);
24 24
 		$filter_query_join = '';
25 25
 		$filter_query_where = '';
26 26
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
27 27
 			if ($filter['airlines'][0] != '') {
28
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
28
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
29 29
 			}
30 30
 		}
31 31
 		
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_output.flightaware_id ";
34 34
 		}
35 35
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
36
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
36
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
37 37
 		}
38 38
 		if (isset($filter['source']) && !empty($filter['source'])) {
39
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
39
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
40 40
 		}
41 41
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
42 42
 			if ($filter_query_where == '') {
43
-				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
43
+				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
44 44
 			} else {
45
-				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
45
+				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
46 46
 			}
47 47
 		}
48 48
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			$sth = $this->db->prepare($query.$limitQuery);
91 91
 			$sth->execute($params);
92 92
 		} catch (PDOException $e) {
93
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
93
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
94 94
 			exit();
95 95
 		}
96 96
 		
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		$spotter_array = array();
101 101
 		
102 102
 
103
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
103
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
104 104
 		{
105 105
 			$num_rows++;
106 106
 			$temp_array = array();
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			if (isset($row['route_stop'])) {
146 146
 				$temp_array['route_stop'] = $row['route_stop'];
147 147
 				if ($row['route_stop'] != '') {
148
-					$allroute = explode(' ',$row['route_stop']);
148
+					$allroute = explode(' ', $row['route_stop']);
149 149
 			
150 150
 					foreach ($allroute as $route) {
151 151
 						$route_airport_array = $this->getAllAirportInfo($route);
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 				{
201 201
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
202 202
 				} else {
203
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
203
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
204 204
 				}
205 205
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
206
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
207
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
206
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
207
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
208 208
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
209 209
 			}
210 210
 			
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
239 239
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
240 240
 					if (is_numeric(substr($row['ident'], 2, 1))) {
241
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource);
241
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2), $fromsource);
242 242
 					} elseif (is_numeric(substr($row['ident'], 3, 1))) {
243
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
243
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
244 244
 					} else {
245 245
 						$airline_array = $this->getAllAirlineInfo('NA');
246 246
 					}
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 				$temp_array['airline_type'] = $row['airline_type'];
267 267
 			}
268 268
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
269
-				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3));
269
+				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3));
270 270
 				//$acars_array = ACARS->getLiveAcarsData('BA40YL');
271 271
 				if (count($acars_array) > 0) {
272 272
 					$temp_array['acars'] = $acars_array;
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
284 284
 			}
285 285
 
286
-			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
286
+			if ($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
287 287
 			{
288 288
 				if ($globalIVAO) {
289
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
290
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
289
+					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
290
+					else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
291 291
 				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
292 292
 				if (count($image_array) > 0) {
293 293
 					$temp_array['image'] = $image_array[0]['image'];
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') {
311 311
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
312 312
 			}
313
-			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
313
+			if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
314 314
 				$schedule_array = $Schedule->getSchedule($temp_array['ident']);
315 315
 				//print_r($schedule_array);
316 316
 				if (count($schedule_array) > 0) {
@@ -391,12 +391,12 @@  discard block
 block discarded – undo
391 391
 			if (isset($row['squawk'])) {
392 392
 				$temp_array['squawk'] = $row['squawk'];
393 393
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
394
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
395
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
394
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
395
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
396 396
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
397
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
398
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
399
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
397
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']);
398
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
399
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
400 400
 			}
401 401
     			
402 402
 			$temp_array['query_number_rows'] = $num_rows;
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	* @return Array the spotter information
416 416
 	*
417 417
 	*/
418
-	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 = '',$filter = array())
418
+	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 = '', $filter = array())
419 419
 	{
420 420
 		global $globalTimezone, $globalDBdriver;
421 421
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 
426 426
 		$query_values = array();
427 427
 		$additional_query = '';
428
-		$filter_query = $this->getFilter($filter,true,true);
428
+		$filter_query = $this->getFilter($filter, true, true);
429 429
 		if ($q != "")
430 430
 		{
431 431
 			if (!is_string($q))
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 				return false;
434 434
 			} else {
435 435
 				$q_array = explode(" ", $q);
436
-				foreach ($q_array as $q_item){
437
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
436
+				foreach ($q_array as $q_item) {
437
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
438 438
 					$additional_query .= " AND (";
439 439
 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
440 440
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -466,37 +466,37 @@  discard block
 block discarded – undo
466 466
 
467 467
 		if ($registration != "")
468 468
 		{
469
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
469
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
470 470
 			if (!is_string($registration))
471 471
 			{
472 472
 				return false;
473 473
 			} else {
474 474
 				$additional_query .= " AND spotter_output.registration = :registration";
475
-				$query_values = array_merge($query_values,array(':registration' => $registration));
475
+				$query_values = array_merge($query_values, array(':registration' => $registration));
476 476
 			}
477 477
 		}
478 478
 
479 479
 		if ($aircraft_icao != "")
480 480
 		{
481
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
481
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
482 482
 			if (!is_string($aircraft_icao))
483 483
 			{
484 484
 				return false;
485 485
 			} else {
486 486
 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao";
487
-				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao));
487
+				$query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao));
488 488
 			}
489 489
 		}
490 490
 
491 491
 		if ($aircraft_manufacturer != "")
492 492
 		{
493
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
493
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
494 494
 			if (!is_string($aircraft_manufacturer))
495 495
 			{
496 496
 				return false;
497 497
 			} else {
498 498
 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer";
499
-				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer));
499
+				$query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer));
500 500
 			}
501 501
 		}
502 502
 
@@ -512,25 +512,25 @@  discard block
 block discarded – undo
512 512
 
513 513
 		if ($airline_icao != "")
514 514
 		{
515
-			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
515
+			$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
516 516
 			if (!is_string($airline_icao))
517 517
 			{
518 518
 				return false;
519 519
 			} else {
520 520
 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao";
521
-				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao));
521
+				$query_values = array_merge($query_values, array(':airline_icao' => $airline_icao));
522 522
 			}
523 523
 		}
524 524
 
525 525
 		if ($airline_country != "")
526 526
 		{
527
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
527
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
528 528
 			if (!is_string($airline_country))
529 529
 			{
530 530
 				return false;
531 531
 			} else {
532 532
 				$additional_query .= " AND spotter_output.airline_country = :airline_country";
533
-				$query_values = array_merge($query_values,array(':airline_country' => $airline_country));
533
+				$query_values = array_merge($query_values, array(':airline_country' => $airline_country));
534 534
 			}
535 535
 		}
536 536
 
@@ -557,31 +557,31 @@  discard block
 block discarded – undo
557 557
 
558 558
 		if ($airport != "")
559 559
 		{
560
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
560
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
561 561
 			if (!is_string($airport))
562 562
 			{
563 563
 				return false;
564 564
 			} else {
565 565
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)";
566
-				$query_values = array_merge($query_values,array(':airport' => $airport));
566
+				$query_values = array_merge($query_values, array(':airport' => $airport));
567 567
 			}
568 568
 		}
569 569
 
570 570
 		if ($airport_country != "")
571 571
 		{
572
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
572
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
573 573
 			if (!is_string($airport_country))
574 574
 			{
575 575
 				return false;
576 576
 			} else {
577 577
 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)";
578
-				$query_values = array_merge($query_values,array(':airport_country' => $airport_country));
578
+				$query_values = array_merge($query_values, array(':airport_country' => $airport_country));
579 579
 			}
580 580
 		}
581 581
     
582 582
 		if ($callsign != "")
583 583
 		{
584
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
584
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
585 585
 			if (!is_string($callsign))
586 586
 			{
587 587
 				return false;
@@ -589,79 +589,79 @@  discard block
 block discarded – undo
589 589
 				$translate = $Translation->ident2icao($callsign);
590 590
 				if ($translate != $callsign) {
591 591
 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)";
592
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
592
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
593 593
 				} else {
594 594
 					$additional_query .= " AND spotter_output.ident = :callsign";
595
-					$query_values = array_merge($query_values,array(':callsign' => $callsign));
595
+					$query_values = array_merge($query_values, array(':callsign' => $callsign));
596 596
 				}
597 597
 			}
598 598
 		}
599 599
 
600 600
 		if ($owner != "")
601 601
 		{
602
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
602
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
603 603
 			if (!is_string($owner))
604 604
 			{
605 605
 				return false;
606 606
 			} else {
607 607
 				$additional_query .= " AND spotter_output.owner_name = :owner";
608
-				$query_values = array_merge($query_values,array(':owner' => $owner));
608
+				$query_values = array_merge($query_values, array(':owner' => $owner));
609 609
 			}
610 610
 		}
611 611
 
612 612
 		if ($pilot_name != "")
613 613
 		{
614
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
614
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
615 615
 			if (!is_string($pilot_name))
616 616
 			{
617 617
 				return false;
618 618
 			} else {
619 619
 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name";
620
-				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name));
620
+				$query_values = array_merge($query_values, array(':pilot_name' => $pilot_name));
621 621
 			}
622 622
 		}
623 623
 
624 624
 		if ($pilot_id != "")
625 625
 		{
626
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
626
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
627 627
 			if (!is_string($pilot_id))
628 628
 			{
629 629
 				return false;
630 630
 			} else {
631 631
 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id";
632
-				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id));
632
+				$query_values = array_merge($query_values, array(':pilot_id' => $pilot_id));
633 633
 			}
634 634
 		}
635 635
 
636 636
 		if ($departure_airport_route != "")
637 637
 		{
638
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
638
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
639 639
 			if (!is_string($departure_airport_route))
640 640
 			{
641 641
 				return false;
642 642
 			} else {
643 643
 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route";
644
-				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route));
644
+				$query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route));
645 645
 			}
646 646
 		}
647 647
 
648 648
 		if ($arrival_airport_route != "")
649 649
 		{
650
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
650
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
651 651
 			if (!is_string($arrival_airport_route))
652 652
 			{
653 653
 				return false;
654 654
 			} else {
655 655
 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route";
656
-				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route));
656
+				$query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route));
657 657
 			}
658 658
 		}
659 659
 
660 660
 		if ($altitude != "")
661 661
 		{
662 662
 			$altitude_array = explode(",", $altitude);
663
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
664
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
663
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
664
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
665 665
 
666 666
 			if ($altitude_array[1] != "")
667 667
 			{                
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
 		if ($date_posted != "")
678 678
 		{
679 679
 			$date_array = explode(",", $date_posted);
680
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
681
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
680
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
681
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
682 682
 
683 683
 			if ($globalTimezone != '') {
684 684
 				date_default_timezone_set($globalTimezone);
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 		{
710 710
 			$limit_array = explode(",", $limit);
711 711
 			
712
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
713
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
712
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
713
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
714 714
 			
715 715
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
716 716
 			{
@@ -739,23 +739,23 @@  discard block
 block discarded – undo
739 739
 
740 740
 
741 741
 		if ($origLat != "" && $origLon != "" && $dist != "") {
742
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
742
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
743 743
 
744 744
 			if ($globalDBdriver == 'mysql') {
745
-				$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 
745
+				$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 
746 746
 						FROM spotter_output, spotter_archive".$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)) 
747 747
 						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;
748 748
 			} else {
749
-				$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 
749
+				$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 
750 750
 						FROM spotter_output, spotter_archive".$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)) 
751 751
 						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;
752 752
 			}
753 753
 		} else {		
754
-			$query  = "SELECT spotter_output.* FROM spotter_output ".$filter_query." spotter_output.ident <> '' 
754
+			$query = "SELECT spotter_output.* FROM spotter_output ".$filter_query." spotter_output.ident <> '' 
755 755
 					".$additional_query."
756 756
 					".$orderby_query;
757 757
 		}
758
-		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query);
758
+		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
759 759
 		return $spotter_array;
760 760
 	}
761 761
 	
@@ -778,8 +778,8 @@  discard block
 block discarded – undo
778 778
 		{
779 779
 			$limit_array = explode(",", $limit);
780 780
 			
781
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
782
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
781
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
782
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
783 783
 			
784 784
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
785 785
 			{
@@ -796,9 +796,9 @@  discard block
 block discarded – undo
796 796
 			$orderby_query = " ORDER BY spotter_output.date DESC";
797 797
 		}
798 798
 
799
-		$query  = $global_query.$filter_query." ".$orderby_query;
799
+		$query = $global_query.$filter_query." ".$orderby_query;
800 800
 
801
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query);
801
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
802 802
 
803 803
 		return $spotter_array;
804 804
 	}
@@ -844,34 +844,34 @@  discard block
 block discarded – undo
844 844
 			{
845 845
 				return false;
846 846
 			} else {
847
-				if ($interval == "30m"){
847
+				if ($interval == "30m") {
848 848
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date ';
849
-				} else if ($interval == "1h"){
849
+				} else if ($interval == "1h") {
850 850
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date ';
851
-				} else if ($interval == "3h"){
851
+				} else if ($interval == "3h") {
852 852
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date ';
853
-				} else if ($interval == "6h"){
853
+				} else if ($interval == "6h") {
854 854
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date ';
855
-				} else if ($interval == "12h"){
855
+				} else if ($interval == "12h") {
856 856
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date ';
857
-				} else if ($interval == "24h"){
857
+				} else if ($interval == "24h") {
858 858
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date ';
859
-				} else if ($interval == "7d"){
859
+				} else if ($interval == "7d") {
860 860
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date ';
861
-				} else if ($interval == "30d"){
861
+				} else if ($interval == "30d") {
862 862
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date ';
863 863
 				} 
864 864
 			}
865 865
 		}
866 866
 
867
-		$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 
867
+		$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 
868 868
                    WHERE spotter_output.latitude <> '' 
869 869
 				   AND spotter_output.longitude <> '' 
870 870
                    ".$additional_query."
871 871
                    HAVING distance < :radius  
872 872
 				   ORDER BY distance";
873 873
 
874
-		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query);
874
+		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query);
875 875
 
876 876
 		return $spotter_array;
877 877
 	}
@@ -883,21 +883,21 @@  discard block
 block discarded – undo
883 883
 	* @return Array the spotter information
884 884
 	*
885 885
 	*/
886
-	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
886
+	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '', $filter = array())
887 887
 	{
888 888
 		global $global_query;
889 889
 		
890 890
 		date_default_timezone_set('UTC');
891 891
 
892
-		$filter_query = $this->getFilter($filter,true,true);
892
+		$filter_query = $this->getFilter($filter, true, true);
893 893
 
894 894
 		$limit_query = '';
895 895
 		if ($limit != "")
896 896
 		{
897 897
 			$limit_array = explode(",", $limit);
898 898
 			
899
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
900
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
899
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
900
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
901 901
 			
902 902
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
903 903
 			{
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
915 915
 		}
916 916
 
917
-		$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;
917
+		$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;
918 918
 
919 919
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
920 920
 
@@ -933,15 +933,15 @@  discard block
 block discarded – undo
933 933
 		global $global_query;
934 934
 		
935 935
 		date_default_timezone_set('UTC');
936
-		$filter_query = $this->getFilter($filter,true,true);
936
+		$filter_query = $this->getFilter($filter, true, true);
937 937
 
938 938
 		$limit_query = '';
939 939
 		if ($limit != "")
940 940
 		{
941 941
 			$limit_array = explode(",", $limit);
942 942
 			
943
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
944
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
943
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
944
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
945 945
 			
946 946
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
947 947
 			{
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
959 959
 		}
960 960
 
961
-		$query  = $global_query." ".$filter_query." spotter_output.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;
961
+		$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;
962 962
 
963 963
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
964 964
 
@@ -972,20 +972,20 @@  discard block
 block discarded – undo
972 972
 	* @return Array the spotter information
973 973
 	*
974 974
 	*/
975
-	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
975
+	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '', $filter = array())
976 976
 	{
977 977
 		global $global_query;
978 978
 		
979 979
 		date_default_timezone_set('UTC');
980
-		$filter_query = $this->getFilter($filter,true,true);
980
+		$filter_query = $this->getFilter($filter, true, true);
981 981
 		
982 982
 		$limit_query = '';
983 983
 		if ($limit != "")
984 984
 		{
985 985
 			$limit_array = explode(",", $limit);
986 986
 			
987
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
988
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
987
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
988
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
989 989
 			
990 990
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
991 991
 			{
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1003 1003
 		}
1004 1004
 
1005
-		$query  = $global_query." ".$filter_query." spotter_output.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;
1005
+		$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;
1006 1006
 
1007 1007
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1008 1008
 
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 		
1023 1023
 		date_default_timezone_set('UTC');
1024 1024
 		
1025
-		$filter_query = $this->getFilter($filter,true,true);
1025
+		$filter_query = $this->getFilter($filter, true, true);
1026 1026
 		
1027 1027
 		$limit_query = '';
1028 1028
 		
@@ -1030,8 +1030,8 @@  discard block
 block discarded – undo
1030 1030
 		{
1031 1031
 			$limit_array = explode(",", $limit);
1032 1032
 			
1033
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1034
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1033
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1034
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1035 1035
 			
1036 1036
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1037 1037
 			{
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1049 1049
 		}
1050 1050
 
1051
-		$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;
1051
+		$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;
1052 1052
 
1053 1053
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1054 1054
 
@@ -1067,14 +1067,14 @@  discard block
 block discarded – undo
1067 1067
 		global $global_query;
1068 1068
 		
1069 1069
 		date_default_timezone_set('UTC');
1070
-		$filter_query = $this->getFilter($filter,true,true);
1070
+		$filter_query = $this->getFilter($filter, true, true);
1071 1071
 		$limit_query = '';
1072 1072
 		if ($limit != "")
1073 1073
 		{
1074 1074
 			$limit_array = explode(",", $limit);
1075 1075
 			
1076
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1077
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1076
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1077
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1078 1078
 			
1079 1079
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1080 1080
 			{
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1092 1092
 		}
1093 1093
 
1094
-		$query  = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1094
+		$query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1095 1095
 
1096 1096
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1097 1097
 
@@ -1115,9 +1115,9 @@  discard block
 block discarded – undo
1115 1115
 		$query_values = array(':id' => $id);
1116 1116
 
1117 1117
 		//$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1118
-		$query  = $global_query." WHERE ".$additional_query." ";
1118
+		$query = $global_query." WHERE ".$additional_query." ";
1119 1119
 
1120
-		$spotter_array = $this->getDataFromDB($query,$query_values);
1120
+		$spotter_array = $this->getDataFromDB($query, $query_values);
1121 1121
 
1122 1122
 		return $spotter_array;
1123 1123
 	}
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
 		{
1156 1156
 			$limit_array = explode(",", $limit);
1157 1157
 			
1158
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1159
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1158
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1159
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1160 1160
 			
1161 1161
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1162 1162
 			{
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		$query_values = array();
1198 1198
 		$limit_query = '';
1199 1199
 		$additional_query = '';
1200
-		$filter_query = $this->getFilter($filter,true,true);
1200
+		$filter_query = $this->getFilter($filter, true, true);
1201 1201
 		
1202 1202
 		if ($aircraft_type != "")
1203 1203
 		{
@@ -1214,8 +1214,8 @@  discard block
 block discarded – undo
1214 1214
 		{
1215 1215
 			$limit_array = explode(",", $limit);
1216 1216
 			
1217
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1218
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1217
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1218
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1219 1219
 			
1220 1220
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1221 1221
 			{
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 		$query_values = array();
1256 1256
 		$limit_query = '';
1257 1257
 		$additional_query = '';
1258
-		$filter_query = $this->getFilter($filter,true,true);
1258
+		$filter_query = $this->getFilter($filter, true, true);
1259 1259
 		
1260 1260
 		if ($registration != "")
1261 1261
 		{
@@ -1272,8 +1272,8 @@  discard block
 block discarded – undo
1272 1272
 		{
1273 1273
 			$limit_array = explode(",", $limit);
1274 1274
 			
1275
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1276
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1275
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1276
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1277 1277
 			
1278 1278
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1279 1279
 			{
@@ -1331,8 +1331,8 @@  discard block
 block discarded – undo
1331 1331
 		{
1332 1332
 			$limit_array = explode(",", $limit);
1333 1333
 			
1334
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1335
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1334
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1335
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1336 1336
 			
1337 1337
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1338 1338
 			{
@@ -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
 			{
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
 	* @return Array the spotter information
1420 1420
 	*
1421 1421
 	*/
1422
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1422
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
1423 1423
 	{
1424 1424
 		global $global_query, $globalTimezone, $globalDBdriver;
1425 1425
 		
@@ -1429,19 +1429,19 @@  discard block
 block discarded – undo
1429 1429
 
1430 1430
 		$filter_query = '';
1431 1431
 		if (isset($filter['source']) && !empty($filter['source'])) {
1432
-			$filter_query = " AND format_source IN ('".implode("','",$filter['source'])."')";
1432
+			$filter_query = " AND format_source IN ('".implode("','", $filter['source'])."')";
1433 1433
 		}
1434 1434
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
1435
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
1435
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
1436 1436
 		}
1437 1437
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
1438 1438
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
1439 1439
 		}
1440 1440
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
1441
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
1441
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
1442 1442
 		}
1443 1443
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
1444
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
1444
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
1445 1445
 		}
1446 1446
 	
1447 1447
 		
@@ -1469,8 +1469,8 @@  discard block
 block discarded – undo
1469 1469
 		{
1470 1470
 			$limit_array = explode(",", $limit);
1471 1471
 			
1472
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1473
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1472
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1473
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1474 1474
 			
1475 1475
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1476 1476
 			{
@@ -1525,8 +1525,8 @@  discard block
 block discarded – undo
1525 1525
 		{
1526 1526
 			$limit_array = explode(",", $limit);
1527 1527
 			
1528
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1529
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1528
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1529
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1530 1530
 			
1531 1531
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1532 1532
 			{
@@ -1582,8 +1582,8 @@  discard block
 block discarded – undo
1582 1582
 		{
1583 1583
 			$limit_array = explode(",", $limit);
1584 1584
 			
1585
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1586
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1585
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1586
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1587 1587
 			
1588 1588
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1589 1589
 			{
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 			{
1632 1632
 				return false;
1633 1633
 			} else {
1634
-				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1634
+				$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1635 1635
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)";
1636 1636
 				$query_values = array(':departure_airport_icao' => $departure_airport_icao);
1637 1637
 			}
@@ -1643,9 +1643,9 @@  discard block
 block discarded – undo
1643 1643
 			{
1644 1644
 				return false;
1645 1645
 			} else {
1646
-				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1646
+				$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1647 1647
 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)";
1648
-				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao));
1648
+				$query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao));
1649 1649
 			}
1650 1650
 		}
1651 1651
 		
@@ -1653,8 +1653,8 @@  discard block
 block discarded – undo
1653 1653
 		{
1654 1654
 			$limit_array = explode(",", $limit);
1655 1655
 			
1656
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1657
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1656
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1657
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1658 1658
 			
1659 1659
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1660 1660
 			{
@@ -1693,15 +1693,15 @@  discard block
 block discarded – undo
1693 1693
 		global $global_query;
1694 1694
 		
1695 1695
 		date_default_timezone_set('UTC');
1696
-		$filter_query = $this->getFilter($filter,true,true);
1696
+		$filter_query = $this->getFilter($filter, true, true);
1697 1697
 		$limit_query = '';
1698 1698
 		
1699 1699
 		if ($limit != "")
1700 1700
 		{
1701 1701
 			$limit_array = explode(",", $limit);
1702 1702
 			
1703
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1704
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1703
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1704
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1705 1705
 			
1706 1706
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1707 1707
 			{
@@ -1718,7 +1718,7 @@  discard block
 block discarded – undo
1718 1718
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1719 1719
 		}
1720 1720
 
1721
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1721
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1722 1722
 
1723 1723
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1724 1724
 
@@ -1731,19 +1731,19 @@  discard block
 block discarded – undo
1731 1731
 	* @return String the highlight text
1732 1732
 	*
1733 1733
 	*/
1734
-	public function getHighlightByRegistration($registration,$filter = array())
1734
+	public function getHighlightByRegistration($registration, $filter = array())
1735 1735
 	{
1736 1736
 		global $global_query;
1737 1737
 		
1738 1738
 		date_default_timezone_set('UTC');
1739
-		$filter_query = $this->getFilter($filter,true,true);
1740
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
1739
+		$filter_query = $this->getFilter($filter, true, true);
1740
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
1741 1741
 		
1742
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1742
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1743 1743
 		$sth = $this->db->prepare($query);
1744 1744
 		$sth->execute(array(':registration' => $registration));
1745 1745
 
1746
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1746
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1747 1747
 		{
1748 1748
 			$highlight = $row['highlight'];
1749 1749
 		}
@@ -1759,14 +1759,14 @@  discard block
 block discarded – undo
1759 1759
 	* @return String usage
1760 1760
 	*
1761 1761
 	*/
1762
-	public function getSquawkUsage($squawk = '',$country = 'FR')
1762
+	public function getSquawkUsage($squawk = '', $country = 'FR')
1763 1763
 	{
1764 1764
 		
1765
-		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING);
1766
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
1765
+		$squawk = filter_var($squawk, FILTER_SANITIZE_STRING);
1766
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
1767 1767
 
1768 1768
 		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
1769
-		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country);
1769
+		$query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country);
1770 1770
 		
1771 1771
 		$sth = $this->db->prepare($query);
1772 1772
 		$sth->execute($query_values);
@@ -1788,9 +1788,9 @@  discard block
 block discarded – undo
1788 1788
 	public function getAirportIcao($airport_iata = '')
1789 1789
 	{
1790 1790
 		
1791
-		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING);
1791
+		$airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING);
1792 1792
 
1793
-		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
1793
+		$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
1794 1794
 		$query_values = array(':airport' => $airport_iata);
1795 1795
 		
1796 1796
 		$sth = $this->db->prepare($query);
@@ -1812,12 +1812,12 @@  discard block
 block discarded – undo
1812 1812
 	* @return Float distance to the airport
1813 1813
 	*
1814 1814
 	*/
1815
-	public function getAirportDistance($airport_icao,$latitude,$longitude)
1815
+	public function getAirportDistance($airport_icao, $latitude, $longitude)
1816 1816
 	{
1817 1817
 		
1818
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
1818
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
1819 1819
 
1820
-		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
1820
+		$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
1821 1821
 		$query_values = array(':airport' => $airport_icao);
1822 1822
 		$sth = $this->db->prepare($query);
1823 1823
 		$sth->execute($query_values);
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
 			$airport_latitude = $row['latitude'];
1828 1828
 			$airport_longitude = $row['longitude'];
1829 1829
 			$Common = new Common();
1830
-			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1830
+			return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude);
1831 1831
 		} else return '';
1832 1832
 	}
1833 1833
 	
@@ -1841,11 +1841,11 @@  discard block
 block discarded – undo
1841 1841
 	public function getAllAirportInfo($airport = '')
1842 1842
 	{
1843 1843
 		
1844
-		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
1844
+		$airport = filter_var($airport, FILTER_SANITIZE_STRING);
1845 1845
 
1846 1846
 		$query_values = array();
1847 1847
 		if ($airport == 'NA') {
1848
-			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' => ''));
1848
+			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' => ''));
1849 1849
 		} elseif ($airport == '') {
1850 1850
 			$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";
1851 1851
 		} else {
@@ -1893,14 +1893,14 @@  discard block
 block discarded – undo
1893 1893
 	{
1894 1894
 		$lst_countries = '';
1895 1895
 		foreach ($countries as $country) {
1896
-			$country = filter_var($country,FILTER_SANITIZE_STRING);
1896
+			$country = filter_var($country, FILTER_SANITIZE_STRING);
1897 1897
 			if ($lst_countries == '') {
1898 1898
 				$lst_countries = "'".$country."'";
1899 1899
 			} else {
1900 1900
 				$lst_countries .= ",'".$country."'";
1901 1901
 			}
1902 1902
 		}
1903
-		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
1903
+		$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
1904 1904
 		
1905 1905
 		$sth = $this->db->prepare($query);
1906 1906
 		$sth->execute();
@@ -1908,7 +1908,7 @@  discard block
 block discarded – undo
1908 1908
 		$airport_array = array();
1909 1909
 		$temp_array = array();
1910 1910
 		
1911
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1911
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1912 1912
 		{
1913 1913
 			$temp_array['name'] = $row['name'];
1914 1914
 			$temp_array['city'] = $row['city'];
@@ -1936,10 +1936,10 @@  discard block
 block discarded – undo
1936 1936
 	{
1937 1937
 		global $globalDBdriver;
1938 1938
 		if (is_array($coord)) {
1939
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1940
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1941
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1942
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1939
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1940
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1941
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1942
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1943 1943
 		} else return array();
1944 1944
 		if ($globalDBdriver == 'mysql') {
1945 1945
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
     
1952 1952
 		$airport_array = array();
1953 1953
 		
1954
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1954
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1955 1955
 		{
1956 1956
 			$temp_array = $row;
1957 1957
 
@@ -1971,13 +1971,13 @@  discard block
 block discarded – undo
1971 1971
 	public function getAllWaypointsInfobyCoord($coord)
1972 1972
 	{
1973 1973
 		if (is_array($coord)) {
1974
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1975
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1976
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1977
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1974
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1975
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1976
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1977
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1978 1978
 		} else return array();
1979 1979
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
1980
-		$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.")";
1980
+		$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.")";
1981 1981
 		//$query  = "SELECT waypoints.* FROM waypoints";
1982 1982
 		//$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";
1983 1983
 		//$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;
@@ -1989,7 +1989,7 @@  discard block
 block discarded – undo
1989 1989
     
1990 1990
 		$waypoints_array = array();
1991 1991
 		
1992
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1992
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1993 1993
 		{
1994 1994
 			$temp_array = $row;
1995 1995
 
@@ -2011,10 +2011,10 @@  discard block
 block discarded – undo
2011 2011
 	{
2012 2012
 		global $globalUseRealAirlines;
2013 2013
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2014
-		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2014
+		$airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING));
2015 2015
 		if ($airline_icao == 'NA') {
2016 2016
 			$airline_array = array();
2017
-			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2017
+			$airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2018 2018
 			return $airline_array;
2019 2019
 		} else {
2020 2020
 			if (strlen($airline_icao) == 2) {
@@ -2035,7 +2035,7 @@  discard block
 block discarded – undo
2035 2035
 			if ($fromsource === NULL) {
2036 2036
 				$sth->execute(array(':airline_icao' => $airline_icao));
2037 2037
 			} else {
2038
-				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2038
+				$sth->execute(array(':airline_icao' => $airline_icao, ':fromsource' => $fromsource));
2039 2039
 			}
2040 2040
                         /*
2041 2041
 			$airline_array = array();
@@ -2077,12 +2077,12 @@  discard block
 block discarded – undo
2077 2077
 	*/
2078 2078
 	public function getAllAircraftInfo($aircraft_type)
2079 2079
 	{
2080
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2080
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2081 2081
 
2082 2082
 		if ($aircraft_type == 'NA') {
2083
-			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2083
+			return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2084 2084
 		}
2085
-		$query  = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type";
2085
+		$query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type";
2086 2086
 		
2087 2087
 		$sth = $this->db->prepare($query);
2088 2088
 		$sth->execute(array(':aircraft_type' => $aircraft_type));
@@ -2114,7 +2114,7 @@  discard block
 block discarded – undo
2114 2114
 	*/
2115 2115
 	public function getAircraftIcao($aircraft_type)
2116 2116
 	{
2117
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2117
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2118 2118
 		$all_aircraft = array('737-300' => 'B733',
2119 2119
 				'777-200' => 'B772',
2120 2120
 				'777-200ER' => 'B772',
@@ -2126,10 +2126,10 @@  discard block
 block discarded – undo
2126 2126
 				'A380' => 'A388');
2127 2127
 		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2128 2128
 
2129
-		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2129
+		$query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2130 2130
 		$aircraft_type = strtoupper($aircraft_type);
2131 2131
 		$sth = $this->db->prepare($query);
2132
-		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2132
+		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%', ':aircraft_type' => $aircraft_type,));
2133 2133
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2134 2134
 		if (isset($result[0]['icao'])) return $result[0]['icao'];
2135 2135
 		else return '';
@@ -2144,9 +2144,9 @@  discard block
 block discarded – undo
2144 2144
 	*/
2145 2145
 	public function getAllAircraftType($aircraft_modes)
2146 2146
 	{
2147
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
2147
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
2148 2148
 
2149
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
2149
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
2150 2150
 		
2151 2151
 		$sth = $this->db->prepare($query);
2152 2152
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -2167,8 +2167,8 @@  discard block
 block discarded – undo
2167 2167
 	*/
2168 2168
 	public function getOperator($operator)
2169 2169
 	{
2170
-		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
2171
-		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2170
+		$operator = filter_var($operator, FILTER_SANITIZE_STRING);
2171
+		$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2172 2172
 		
2173 2173
 		$sth = $this->db->prepare($query);
2174 2174
 		$sth->execute(array(':operator' => $operator));
@@ -2189,9 +2189,9 @@  discard block
 block discarded – undo
2189 2189
 	*/
2190 2190
 	public function getRouteInfo($callsign)
2191 2191
 	{
2192
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2192
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2193 2193
                 if ($callsign == '') return array();
2194
-		$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";
2194
+		$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";
2195 2195
 		
2196 2196
 		$sth = $this->db->prepare($query);
2197 2197
 		$sth->execute(array(':callsign' => $callsign));
@@ -2212,9 +2212,9 @@  discard block
 block discarded – undo
2212 2212
 	*/
2213 2213
 	public function getAircraftInfoByRegistration($registration)
2214 2214
 	{
2215
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2215
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2216 2216
 
2217
-		$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";
2217
+		$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";
2218 2218
 		
2219 2219
 		$sth = $this->db->prepare($query);
2220 2220
 		$sth->execute(array(':registration' => $registration));
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
 		$aircraft_array = array();
2223 2223
 		$temp_array = array();
2224 2224
 		
2225
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2225
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2226 2226
 		{
2227 2227
 			$temp_array['airline_icao'] = $row['airline_icao'];
2228 2228
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
 	*/
2245 2245
 	public function getAircraftOwnerByRegistration($registration)
2246 2246
 	{
2247
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2247
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2248 2248
 		$Connection = new Connection($this->db);
2249 2249
 		if ($Connection->tableExists('aircraft_owner')) {
2250 2250
 			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
 	public function getAllFlightsforSitemap()
2267 2267
 	{
2268 2268
 		//$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 ";
2269
-		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2269
+		$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2270 2270
 		
2271 2271
 		$sth = $this->db->prepare($query);
2272 2272
 		$sth->execute();
@@ -2313,7 +2313,7 @@  discard block
 block discarded – undo
2313 2313
 		$manufacturer_array = array();
2314 2314
 		$temp_array = array();
2315 2315
 		
2316
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2316
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2317 2317
 		{
2318 2318
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
2319 2319
 
@@ -2347,7 +2347,7 @@  discard block
 block discarded – undo
2347 2347
 		$aircraft_array = array();
2348 2348
 		$temp_array = array();
2349 2349
 		
2350
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2350
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2351 2351
 		{
2352 2352
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
2353 2353
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
@@ -2368,7 +2368,7 @@  discard block
 block discarded – undo
2368 2368
 	*/
2369 2369
 	public function getAllAircraftRegistrations()
2370 2370
 	{
2371
-		$query  = "SELECT DISTINCT spotter_output.registration 
2371
+		$query = "SELECT DISTINCT spotter_output.registration 
2372 2372
 				FROM spotter_output  
2373 2373
 				WHERE spotter_output.registration <> '' 
2374 2374
 				ORDER BY spotter_output.registration ASC";
@@ -2379,7 +2379,7 @@  discard block
 block discarded – undo
2379 2379
 		$aircraft_array = array();
2380 2380
 		$temp_array = array();
2381 2381
 		
2382
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2382
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2383 2383
 		{
2384 2384
 			$temp_array['registration'] = $row['registration'];
2385 2385
 
@@ -2399,7 +2399,7 @@  discard block
 block discarded – undo
2399 2399
 	public function getAllSourceName($type = '')
2400 2400
 	{
2401 2401
 		$query_values = array();
2402
-		$query  = "SELECT DISTINCT spotter_output.source_name 
2402
+		$query = "SELECT DISTINCT spotter_output.source_name 
2403 2403
 				FROM spotter_output  
2404 2404
 				WHERE spotter_output.source_name <> ''";
2405 2405
 		if ($type != '') {
@@ -2415,7 +2415,7 @@  discard block
 block discarded – undo
2415 2415
 		$source_array = array();
2416 2416
 		$temp_array = array();
2417 2417
 		
2418
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2418
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2419 2419
 		{
2420 2420
 			$temp_array['source_name'] = $row['source_name'];
2421 2421
 			$source_array[] = $temp_array;
@@ -2431,10 +2431,10 @@  discard block
 block discarded – undo
2431 2431
 	* @return Array list of airline names
2432 2432
 	*
2433 2433
 	*/
2434
-	public function getAllAirlineNames($airline_type = '',$forsource = NULL)
2434
+	public function getAllAirlineNames($airline_type = '', $forsource = NULL)
2435 2435
 	{
2436
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2437
-		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
2436
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2437
+		$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
2438 2438
 		if ($airline_type == '' || $airline_type == 'all') {
2439 2439
 			/*
2440 2440
 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
@@ -2453,7 +2453,7 @@  discard block
 block discarded – undo
2453 2453
 				$query_data = array(':forsource' => $forsource);
2454 2454
 			}
2455 2455
 		} else {
2456
-			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2456
+			$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2457 2457
 					FROM spotter_output
2458 2458
 					WHERE spotter_output.airline_icao <> '' 
2459 2459
 					AND spotter_output.airline_type = :airline_type 
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
 		$airline_array = array();
2468 2468
 		$temp_array = array();
2469 2469
 		
2470
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2470
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2471 2471
 		{
2472 2472
 			$temp_array['airline_icao'] = $row['airline_icao'];
2473 2473
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 	public function getAllAirlineCountries()
2489 2489
 	{
2490 2490
 		
2491
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2491
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2492 2492
 				FROM spotter_output  
2493 2493
 				WHERE spotter_output.airline_country <> '' 
2494 2494
 				ORDER BY spotter_output.airline_country ASC";
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
 		$airline_array = array();
2501 2501
 		$temp_array = array();
2502 2502
 		
2503
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2503
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2504 2504
 		{
2505 2505
 			$temp_array['airline_country'] = $row['airline_country'];
2506 2506
 
@@ -2522,7 +2522,7 @@  discard block
 block discarded – undo
2522 2522
 	{
2523 2523
 		$airport_array = array();
2524 2524
 
2525
-		$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
2525
+		$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
2526 2526
 				FROM spotter_output 
2527 2527
 				WHERE spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' 
2528 2528
 				ORDER BY spotter_output.departure_airport_city ASC";
@@ -2532,7 +2532,7 @@  discard block
 block discarded – undo
2532 2532
 		$sth->execute();
2533 2533
 
2534 2534
 		$temp_array = array();
2535
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2535
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2536 2536
 		{
2537 2537
 			$temp_array['airport_icao'] = $row['airport_icao'];
2538 2538
 			$temp_array['airport_name'] = $row['airport_name'];
@@ -2542,7 +2542,7 @@  discard block
 block discarded – undo
2542 2542
 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array;
2543 2543
 		}
2544 2544
 
2545
-		$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
2545
+		$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
2546 2546
 								FROM spotter_output 
2547 2547
 								WHERE spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
2548 2548
 								ORDER BY spotter_output.arrival_airport_city ASC";
@@ -2550,7 +2550,7 @@  discard block
 block discarded – undo
2550 2550
 		$sth = $this->db->prepare($query);
2551 2551
 		$sth->execute();
2552 2552
 
2553
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2553
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2554 2554
 			{
2555 2555
 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao'])
2556 2556
 		//	{
@@ -2590,14 +2590,14 @@  discard block
 block discarded – undo
2590 2590
    
2591 2591
 		$temp_array = array();
2592 2592
 		
2593
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2593
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2594 2594
 		{
2595 2595
 			$temp_array['airport_country'] = $row['airport_country'];
2596 2596
 
2597 2597
 			$airport_array[$row['airport_country']] = $temp_array;
2598 2598
 		}
2599 2599
 								
2600
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2600
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2601 2601
 								FROM spotter_output
2602 2602
 								WHERE spotter_output.arrival_airport_country <> '' 
2603 2603
 								ORDER BY spotter_output.arrival_airport_country ASC";
@@ -2605,7 +2605,7 @@  discard block
 block discarded – undo
2605 2605
 		$sth = $this->db->prepare($query);
2606 2606
 		$sth->execute();
2607 2607
 		
2608
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2608
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2609 2609
 		{
2610 2610
 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country'])
2611 2611
 			{
@@ -2628,9 +2628,9 @@  discard block
 block discarded – undo
2628 2628
 	*/
2629 2629
 	public function getAllCountries()
2630 2630
 	{
2631
-		$Connection= new Connection($this->db);
2631
+		$Connection = new Connection($this->db);
2632 2632
 		if ($Connection->tableExists('countries')) {
2633
-			$query  = "SELECT countries.name AS airport_country
2633
+			$query = "SELECT countries.name AS airport_country
2634 2634
 				FROM countries
2635 2635
 				ORDER BY countries.name ASC";
2636 2636
 			$sth = $this->db->prepare($query);
@@ -2639,13 +2639,13 @@  discard block
 block discarded – undo
2639 2639
 			$temp_array = array();
2640 2640
 			$country_array = array();
2641 2641
 		
2642
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
2642
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2643 2643
 			{
2644 2644
 				$temp_array['country'] = $row['airport_country'];
2645 2645
 				$country_array[$row['airport_country']] = $temp_array;
2646 2646
 			}
2647 2647
 		} else {
2648
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
2648
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
2649 2649
 								FROM spotter_output
2650 2650
 								WHERE spotter_output.departure_airport_country <> '' 
2651 2651
 								ORDER BY spotter_output.departure_airport_country ASC";
@@ -2655,13 +2655,13 @@  discard block
 block discarded – undo
2655 2655
    
2656 2656
 			$temp_array = array();
2657 2657
 			$country_array = array();
2658
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
2658
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2659 2659
 			{
2660 2660
 				$temp_array['country'] = $row['airport_country'];
2661 2661
 				$country_array[$row['airport_country']] = $temp_array;
2662 2662
 			}
2663 2663
 
2664
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2664
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2665 2665
 								FROM spotter_output
2666 2666
 								WHERE spotter_output.arrival_airport_country <> '' 
2667 2667
 								ORDER BY spotter_output.arrival_airport_country ASC";
@@ -2669,7 +2669,7 @@  discard block
 block discarded – undo
2669 2669
 		$sth = $this->db->prepare($query);
2670 2670
 		$sth->execute();
2671 2671
 		
2672
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2672
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2673 2673
 		{
2674 2674
 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country'])
2675 2675
 			{
@@ -2679,7 +2679,7 @@  discard block
 block discarded – undo
2679 2679
 			}
2680 2680
 		}
2681 2681
 		
2682
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2682
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2683 2683
 								FROM spotter_output  
2684 2684
 								WHERE spotter_output.airline_country <> '' 
2685 2685
 								ORDER BY spotter_output.airline_country ASC";
@@ -2687,7 +2687,7 @@  discard block
 block discarded – undo
2687 2687
 		$sth = $this->db->prepare($query);
2688 2688
 		$sth->execute();
2689 2689
 		
2690
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2690
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2691 2691
 		{
2692 2692
 			if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country'])
2693 2693
 			{
@@ -2711,7 +2711,7 @@  discard block
 block discarded – undo
2711 2711
 	*/
2712 2712
 	public function getAllIdents()
2713 2713
 	{
2714
-		$query  = "SELECT DISTINCT spotter_output.ident
2714
+		$query = "SELECT DISTINCT spotter_output.ident
2715 2715
 								FROM spotter_output
2716 2716
 								WHERE spotter_output.ident <> '' 
2717 2717
 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0";
@@ -2722,7 +2722,7 @@  discard block
 block discarded – undo
2722 2722
 		$ident_array = array();
2723 2723
 		$temp_array = array();
2724 2724
 		
2725
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2725
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2726 2726
 		{
2727 2727
 			$temp_array['ident'] = $row['ident'];
2728 2728
 			$ident_array[] = $temp_array;
@@ -3058,12 +3058,12 @@  discard block
 block discarded – undo
3058 3058
 		} else $offset = '+00:00';
3059 3059
 
3060 3060
 		if ($globalDBdriver == 'mysql') {
3061
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3061
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3062 3062
 								FROM spotter_output
3063 3063
 								WHERE spotter_output.date <> '' 
3064 3064
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
3065 3065
 		} else {
3066
-			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3066
+			$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3067 3067
 								FROM spotter_output
3068 3068
 								WHERE spotter_output.date <> '' 
3069 3069
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
@@ -3075,7 +3075,7 @@  discard block
 block discarded – undo
3075 3075
 		$date_array = array();
3076 3076
 		$temp_array = array();
3077 3077
 		
3078
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3078
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3079 3079
 		{
3080 3080
 			$temp_array['date'] = $row['date'];
3081 3081
 
@@ -3095,7 +3095,7 @@  discard block
 block discarded – undo
3095 3095
 	*/
3096 3096
 	public function getAllRoutes()
3097 3097
 	{
3098
-		$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 
3098
+		$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 
3099 3099
 				FROM spotter_output
3100 3100
 				WHERE spotter_output.ident <> '' 
3101 3101
 				GROUP BY route
@@ -3106,7 +3106,7 @@  discard block
 block discarded – undo
3106 3106
 
3107 3107
 		$routes_array = array();
3108 3108
 		$temp_array = array();
3109
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3109
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3110 3110
 		{
3111 3111
 			$temp_array['route'] = $row['route'];
3112 3112
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -3125,21 +3125,21 @@  discard block
 block discarded – undo
3125 3125
 	* @return String success or false
3126 3126
 	*
3127 3127
 	*/	
3128
-	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3128
+	public function updateIdentSpotterData($flightaware_id = '', $ident = '', $fromsource = NULL)
3129 3129
 	{
3130 3130
 		if (!is_numeric(substr($ident, 0, 3)))
3131 3131
 		{
3132 3132
 			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3133
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3133
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3134 3134
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3135
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3135
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3136 3136
 			} else {
3137 3137
 				$airline_array = $this->getAllAirlineInfo("NA");
3138 3138
 			}
3139 3139
 			if (count($airline_array) == 0) {
3140 3140
 				$airline_array = $this->getAllAirlineInfo("NA");
3141 3141
 			}
3142
-			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3142
+			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3143 3143
 				$airline_array = $this->getAllAirlineInfo("NA");
3144 3144
 			}
3145 3145
 		} else {
@@ -3152,7 +3152,7 @@  discard block
 block discarded – undo
3152 3152
 
3153 3153
 
3154 3154
 		$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';
3155
-                $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);
3155
+                $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);
3156 3156
 
3157 3157
 		try {
3158 3158
 			$sth = $this->db->prepare($query);
@@ -3173,11 +3173,11 @@  discard block
 block discarded – undo
3173 3173
 	* @return String success or false
3174 3174
 	*
3175 3175
 	*/	
3176
-	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3176
+	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '', $arrival_airport_time = '')
3177 3177
 	{
3178 3178
 		if ($groundspeed == '') $groundspeed = NULL;
3179 3179
 		$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';
3180
-                $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);
3180
+                $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);
3181 3181
 
3182 3182
 		try {
3183 3183
 			$sth = $this->db->prepare($query);
@@ -3217,7 +3217,7 @@  discard block
 block discarded – undo
3217 3217
 	* @param String $verticalrate vertival rate of flight
3218 3218
 	* @return String success or false
3219 3219
 	*/
3220
-	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 = '')
3220
+	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 = '')
3221 3221
 	{
3222 3222
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
3223 3223
 		
@@ -3241,13 +3241,13 @@  discard block
 block discarded – undo
3241 3241
 				if ($ModeS != '') {
3242 3242
 					$timeelapsed = microtime(true);
3243 3243
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3244
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3244
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3245 3245
 				} else {
3246
-					$myhex = explode('-',$flightaware_id);
3246
+					$myhex = explode('-', $flightaware_id);
3247 3247
 					if (count($myhex) > 0) {
3248 3248
 						$timeelapsed = microtime(true);
3249 3249
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3250
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3250
+						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3251 3251
 					}
3252 3252
 				}
3253 3253
 			}
@@ -3269,24 +3269,24 @@  discard block
 block discarded – undo
3269 3269
 				{
3270 3270
 					$timeelapsed = microtime(true);
3271 3271
 					if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3272
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3272
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3273 3273
 					} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3274
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3274
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3275 3275
 					} else {
3276 3276
 						$airline_array = $this->getAllAirlineInfo("NA");
3277 3277
 					}
3278 3278
 					if (count($airline_array) == 0) {
3279 3279
 						$airline_array = $this->getAllAirlineInfo("NA");
3280 3280
 					}
3281
-					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3281
+					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3282 3282
 						$airline_array = $this->getAllAirlineInfo("NA");
3283 3283
 					}
3284
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3284
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3285 3285
 
3286 3286
 				} else {
3287 3287
 					$timeelapsed = microtime(true);
3288 3288
 					$airline_array = $this->getAllAirlineInfo("NA");
3289
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3289
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3290 3290
 				}
3291 3291
 			}
3292 3292
 		} else $airline_array = array();
@@ -3303,27 +3303,27 @@  discard block
 block discarded – undo
3303 3303
 				{
3304 3304
 					$timeelapsed = microtime(true);
3305 3305
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3306
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3306
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3307 3307
 				} else {
3308 3308
 					$timeelapsed = microtime(true);
3309 3309
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3310
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3310
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3311 3311
 				}
3312 3312
 			}
3313 3313
 		} else {
3314 3314
 			if ($ModeS != '') {
3315 3315
 				$timeelapsed = microtime(true);
3316 3316
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3317
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3317
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3318 3318
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3319 3319
 				{
3320 3320
 					$timeelapsed = microtime(true);
3321 3321
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3322
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3322
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3323 3323
 				} else {
3324 3324
 					$timeelapsed = microtime(true);
3325 3325
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3326
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3326
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3327 3327
 				}
3328 3328
 			}
3329 3329
 		}
@@ -3338,7 +3338,7 @@  discard block
 block discarded – undo
3338 3338
 			} else {
3339 3339
 				$timeelapsed = microtime(true);
3340 3340
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3341
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3341
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3342 3342
 			}
3343 3343
 		}
3344 3344
 		
@@ -3352,7 +3352,7 @@  discard block
 block discarded – undo
3352 3352
 			} else {
3353 3353
 				$timeelapsed = microtime(true);
3354 3354
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3355
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3355
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3356 3356
 			}
3357 3357
 		}
3358 3358
 
@@ -3416,7 +3416,7 @@  discard block
 block discarded – undo
3416 3416
 		{
3417 3417
 			$timeelapsed = microtime(true);
3418 3418
 			$image_array = $Image->getSpotterImage($registration);
3419
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3419
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3420 3420
 			if (!isset($image_array[0]['registration']))
3421 3421
 			{
3422 3422
 				//echo "Add image !!!! \n";
@@ -3424,7 +3424,7 @@  discard block
 block discarded – undo
3424 3424
 			}
3425 3425
 			$timeelapsed = microtime(true);
3426 3426
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3427
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3427
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3428 3428
 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3429 3429
 		}
3430 3430
     
@@ -3432,33 +3432,33 @@  discard block
 block discarded – undo
3432 3432
 		{
3433 3433
             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3434 3434
             		else $airline_icao = '';
3435
-			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3435
+			$image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao);
3436 3436
 			if (!isset($image_array[0]['registration']))
3437 3437
 			{
3438 3438
 				//echo "Add image !!!! \n";
3439
-				$Image->addSpotterImage('',$aircraft_icao,$airline_icao);
3439
+				$Image->addSpotterImage('', $aircraft_icao, $airline_icao);
3440 3440
 			}
3441 3441
 		}
3442 3442
     
3443
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
3444
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3445
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
3446
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3447
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3448
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3449
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3450
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3451
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
3452
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3453
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
3454
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3455
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
3456
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
3457
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
3458
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
3459
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
3460
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
3461
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
3443
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
3444
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3445
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
3446
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3447
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3448
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3449
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3450
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3451
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
3452
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3453
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
3454
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3455
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
3456
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
3457
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
3458
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
3459
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
3460
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
3461
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
3462 3462
 	
3463 3463
 		if (count($airline_array) == 0) 
3464 3464
 		{
@@ -3482,7 +3482,7 @@  discard block
 block discarded – undo
3482 3482
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3483 3483
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3484 3484
                 if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3485
-                $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) 
3485
+                $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) 
3486 3486
                 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)";
3487 3487
 
3488 3488
                 $airline_name = $airline_array[0]['name'];
@@ -3492,7 +3492,7 @@  discard block
 block discarded – undo
3492 3492
 		if ($airline_type == '') {
3493 3493
 			$timeelapsed = microtime(true);
3494 3494
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3495
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3495
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3496 3496
 		}
3497 3497
 		if ($airline_type == null) $airline_type = '';
3498 3498
                 $aircraft_type = $aircraft_array[0]['type'];
@@ -3503,7 +3503,7 @@  discard block
 block discarded – undo
3503 3503
                 $arrival_airport_name = $arrival_airport_array[0]['name'];
3504 3504
                 $arrival_airport_city = $arrival_airport_array[0]['city'];
3505 3505
                 $arrival_airport_country = $arrival_airport_array[0]['country'];
3506
-                $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);
3506
+                $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);
3507 3507
 
3508 3508
 		try {
3509 3509
 		        
@@ -3529,13 +3529,13 @@  discard block
 block discarded – undo
3529 3529
 	{
3530 3530
 		global $globalDBdriver, $globalTimezone;
3531 3531
 		if ($globalDBdriver == 'mysql') {
3532
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3532
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3533 3533
 								WHERE spotter_output.ident = :ident 
3534 3534
 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
3535 3535
 								AND spotter_output.date < UTC_TIMESTAMP()";
3536 3536
 			$query_data = array(':ident' => $ident);
3537 3537
 		} else {
3538
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3538
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3539 3539
 								WHERE spotter_output.ident = :ident 
3540 3540
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3541 3541
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
@@ -3544,8 +3544,8 @@  discard block
 block discarded – undo
3544 3544
 		
3545 3545
 		$sth = $this->db->prepare($query);
3546 3546
 		$sth->execute($query_data);
3547
-    		$ident_result='';
3548
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3547
+    		$ident_result = '';
3548
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3549 3549
 		{
3550 3550
 			$ident_result = $row['ident'];
3551 3551
 		}
@@ -3571,8 +3571,8 @@  discard block
 block discarded – undo
3571 3571
 				return false;
3572 3572
 			} else {
3573 3573
 				$q_array = explode(" ", $q);
3574
-				foreach ($q_array as $q_item){
3575
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
3574
+				foreach ($q_array as $q_item) {
3575
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
3576 3576
 					$additional_query .= " AND (";
3577 3577
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
3578 3578
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
@@ -3587,11 +3587,11 @@  discard block
 block discarded – undo
3587 3587
 			}
3588 3588
 		}
3589 3589
 		if ($globalDBdriver == 'mysql') {
3590
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3590
+			$query = "SELECT spotter_output.* FROM spotter_output 
3591 3591
 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
3592 3592
 				AND spotter_output.date < UTC_TIMESTAMP()";
3593 3593
 		} else {
3594
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3594
+			$query = "SELECT spotter_output.* FROM spotter_output 
3595 3595
 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
3596 3596
 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
3597 3597
 		}
@@ -3608,11 +3608,11 @@  discard block
 block discarded – undo
3608 3608
 	* @return Array the airline list
3609 3609
 	*
3610 3610
 	*/
3611
-	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3611
+	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3612 3612
 	{
3613 3613
 		global $globalDBdriver;
3614
-		$filter_query = $this->getFilter($filters,true,true);
3615
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3614
+		$filter_query = $this->getFilter($filters, true, true);
3615
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3616 3616
 		 			FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA' ";
3617 3617
 		if ($olderthanmonths > 0) {
3618 3618
 			if ($globalDBdriver == 'mysql') {
@@ -3636,7 +3636,7 @@  discard block
 block discarded – undo
3636 3636
  
3637 3637
 		$airline_array = array();
3638 3638
 		$temp_array = array();
3639
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3639
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3640 3640
 		{
3641 3641
 			$temp_array['airline_name'] = $row['airline_name'];
3642 3642
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3653,11 +3653,11 @@  discard block
 block discarded – undo
3653 3653
 	* @return Array the pilots list
3654 3654
 	*
3655 3655
 	*/
3656
-	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3656
+	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3657 3657
 	{
3658 3658
 		global $globalDBdriver;
3659
-		$filter_query = $this->getFilter($filters,true,true);
3660
-		$query  = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3659
+		$filter_query = $this->getFilter($filters, true, true);
3660
+		$query = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3661 3661
 		 			FROM spotter_output".$filter_query." spotter_output.pilot_id <> '' ";
3662 3662
                 if ($olderthanmonths > 0) {
3663 3663
             		if ($globalDBdriver == 'mysql') {
@@ -3683,7 +3683,7 @@  discard block
 block discarded – undo
3683 3683
 		$airline_array = array();
3684 3684
 		$temp_array = array();
3685 3685
         
3686
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3686
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3687 3687
 		{
3688 3688
 			$temp_array['pilot_name'] = $row['pilot_name'];
3689 3689
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -3702,7 +3702,7 @@  discard block
 block discarded – undo
3702 3702
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3703 3703
 	{
3704 3704
 		global $globalDBdriver;
3705
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3705
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3706 3706
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
3707 3707
                 if ($olderthanmonths > 0) {
3708 3708
             		if ($globalDBdriver == 'mysql') {
@@ -3728,7 +3728,7 @@  discard block
 block discarded – undo
3728 3728
 		$airline_array = array();
3729 3729
 		$temp_array = array();
3730 3730
         
3731
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3731
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3732 3732
 		{
3733 3733
 			$temp_array['pilot_name'] = $row['pilot_name'];
3734 3734
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -3745,11 +3745,11 @@  discard block
 block discarded – undo
3745 3745
 	* @return Array the pilots list
3746 3746
 	*
3747 3747
 	*/
3748
-	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3748
+	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3749 3749
 	{
3750 3750
 		global $globalDBdriver;
3751
-		$filter_query = $this->getFilter($filters,true,true);
3752
-		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3751
+		$filter_query = $this->getFilter($filters, true, true);
3752
+		$query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3753 3753
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3754 3754
                 if ($olderthanmonths > 0) {
3755 3755
             		if ($globalDBdriver == 'mysql') {
@@ -3775,7 +3775,7 @@  discard block
 block discarded – undo
3775 3775
 		$airline_array = array();
3776 3776
 		$temp_array = array();
3777 3777
         
3778
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3778
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3779 3779
 		{
3780 3780
 			$temp_array['owner_name'] = $row['owner_name'];
3781 3781
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -3790,11 +3790,11 @@  discard block
 block discarded – undo
3790 3790
 	* @return Array the pilots list
3791 3791
 	*
3792 3792
 	*/
3793
-	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3793
+	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3794 3794
 	{
3795 3795
 		global $globalDBdriver;
3796
-		$filter_query = $this->getFilter($filters,true,true);
3797
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3796
+		$filter_query = $this->getFilter($filters, true, true);
3797
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3798 3798
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3799 3799
                 if ($olderthanmonths > 0) {
3800 3800
             		if ($globalDBdriver == 'mysql') {
@@ -3820,7 +3820,7 @@  discard block
 block discarded – undo
3820 3820
 		$airline_array = array();
3821 3821
 		$temp_array = array();
3822 3822
         
3823
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3823
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3824 3824
 		{
3825 3825
 			$temp_array['owner_name'] = $row['owner_name'];
3826 3826
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -3836,11 +3836,11 @@  discard block
 block discarded – undo
3836 3836
 	* @return Array the airline list
3837 3837
 	*
3838 3838
 	*/
3839
-	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
3839
+	public function countAllAirlinesByAircraft($aircraft_icao, $filters = array())
3840 3840
 	{
3841
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3842
-		$filter_query = $this->getFilter($filters,true,true);
3843
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3841
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3842
+		$filter_query = $this->getFilter($filters, true, true);
3843
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3844 3844
 		 			FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
3845 3845
                     GROUP BY spotter_output.airline_name
3846 3846
 					ORDER BY airline_count DESC";
@@ -3852,7 +3852,7 @@  discard block
 block discarded – undo
3852 3852
 		$airline_array = array();
3853 3853
 		$temp_array = array();
3854 3854
         
3855
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3855
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3856 3856
 		{
3857 3857
 			$temp_array['airline_name'] = $row['airline_name'];
3858 3858
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3872,11 +3872,11 @@  discard block
 block discarded – undo
3872 3872
 	* @return Array the airline country list
3873 3873
 	*
3874 3874
 	*/
3875
-	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
3875
+	public function countAllAirlineCountriesByAircraft($aircraft_icao, $filters = array())
3876 3876
 	{
3877
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3878
-		$filter_query = $this->getFilter($filters,true,true);
3879
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3877
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3878
+		$filter_query = $this->getFilter($filters, true, true);
3879
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3880 3880
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
3881 3881
                     GROUP BY spotter_output.airline_country
3882 3882
 					ORDER BY airline_country_count DESC
@@ -3889,7 +3889,7 @@  discard block
 block discarded – undo
3889 3889
 		$airline_country_array = array();
3890 3890
 		$temp_array = array();
3891 3891
         
3892
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3892
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3893 3893
 		{
3894 3894
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3895 3895
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3908,11 +3908,11 @@  discard block
 block discarded – undo
3908 3908
 	* @return Array the airline list
3909 3909
 	*
3910 3910
 	*/
3911
-	public function countAllAirlinesByAirport($airport_icao,$filters = array())
3911
+	public function countAllAirlinesByAirport($airport_icao, $filters = array())
3912 3912
 	{
3913
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
3914
-		$filter_query = $this->getFilter($filters,true,true);
3915
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3913
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
3914
+		$filter_query = $this->getFilter($filters, true, true);
3915
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3916 3916
 		 			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 ) 
3917 3917
                     GROUP BY spotter_output.airline_name
3918 3918
 					ORDER BY airline_count DESC";
@@ -3924,7 +3924,7 @@  discard block
 block discarded – undo
3924 3924
 		$airline_array = array();
3925 3925
 		$temp_array = array();
3926 3926
         
3927
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3927
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3928 3928
 		{
3929 3929
 			$temp_array['airline_name'] = $row['airline_name'];
3930 3930
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3943,11 +3943,11 @@  discard block
 block discarded – undo
3943 3943
 	* @return Array the airline country list
3944 3944
 	*
3945 3945
 	*/
3946
-	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
3946
+	public function countAllAirlineCountriesByAirport($airport_icao, $filters = array())
3947 3947
 	{
3948
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
3949
-		$filter_query = $this->getFilter($filters,true,true);
3950
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3948
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
3949
+		$filter_query = $this->getFilter($filters, true, true);
3950
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3951 3951
 		 			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 )
3952 3952
 					GROUP BY spotter_output.airline_country
3953 3953
 					ORDER BY airline_country_count DESC
@@ -3960,7 +3960,7 @@  discard block
 block discarded – undo
3960 3960
 		$airline_country_array = array();
3961 3961
 		$temp_array = array();
3962 3962
         
3963
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3963
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3964 3964
 		{
3965 3965
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3966 3966
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3977,11 +3977,11 @@  discard block
 block discarded – undo
3977 3977
 	* @return Array the airline list
3978 3978
 	*
3979 3979
 	*/
3980
-	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
3980
+	public function countAllAirlinesByManufacturer($aircraft_manufacturer, $filters = array())
3981 3981
 	{
3982
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
3983
-		$filter_query = $this->getFilter($filters,true,true);
3984
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3982
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
3983
+		$filter_query = $this->getFilter($filters, true, true);
3984
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3985 3985
 		 			FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
3986 3986
 					GROUP BY spotter_output.airline_name
3987 3987
 					ORDER BY airline_count DESC";
@@ -3992,7 +3992,7 @@  discard block
 block discarded – undo
3992 3992
 		$airline_array = array();
3993 3993
 		$temp_array = array();
3994 3994
         
3995
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3995
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3996 3996
 		{
3997 3997
 			$temp_array['airline_name'] = $row['airline_name'];
3998 3998
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4012,11 +4012,11 @@  discard block
 block discarded – undo
4012 4012
 	* @return Array the airline country list
4013 4013
 	*
4014 4014
 	*/
4015
-	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4015
+	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer, $filters = array())
4016 4016
 	{
4017
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4018
-		$filter_query = $this->getFilter($filters,true,true);
4019
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4017
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4018
+		$filter_query = $this->getFilter($filters, true, true);
4019
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4020 4020
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4021 4021
 					GROUP BY spotter_output.airline_country
4022 4022
 					ORDER BY airline_country_count DESC
@@ -4029,7 +4029,7 @@  discard block
 block discarded – undo
4029 4029
 		$airline_country_array = array();
4030 4030
 		$temp_array = array();
4031 4031
         
4032
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4032
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4033 4033
 		{
4034 4034
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4035 4035
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4045,11 +4045,11 @@  discard block
 block discarded – undo
4045 4045
 	* @return Array the airline list
4046 4046
 	*
4047 4047
 	*/
4048
-	public function countAllAirlinesByDate($date,$filters = array())
4048
+	public function countAllAirlinesByDate($date, $filters = array())
4049 4049
 	{
4050 4050
 		global $globalTimezone, $globalDBdriver;
4051
-		$filter_query = $this->getFilter($filters,true,true);
4052
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4051
+		$filter_query = $this->getFilter($filters, true, true);
4052
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4053 4053
 		if ($globalTimezone != '') {
4054 4054
 			date_default_timezone_set($globalTimezone);
4055 4055
 			$datetime = new DateTime($date);
@@ -4057,12 +4057,12 @@  discard block
 block discarded – undo
4057 4057
 		} else $offset = '+00:00';
4058 4058
 
4059 4059
 		if ($globalDBdriver == 'mysql') {
4060
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4060
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4061 4061
 		 			FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4062 4062
 					GROUP BY spotter_output.airline_name
4063 4063
 					ORDER BY airline_count DESC";
4064 4064
 		} else {
4065
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4065
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4066 4066
 		 			FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4067 4067
 					GROUP BY spotter_output.airline_name
4068 4068
 					ORDER BY airline_count DESC";
@@ -4073,7 +4073,7 @@  discard block
 block discarded – undo
4073 4073
 
4074 4074
 		$airline_array = array();
4075 4075
 		$temp_array = array();
4076
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4076
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4077 4077
 		{
4078 4078
 			$temp_array['airline_name'] = $row['airline_name'];
4079 4079
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4093,11 +4093,11 @@  discard block
 block discarded – undo
4093 4093
 	* @return Array the airline country list
4094 4094
 	*
4095 4095
 	*/
4096
-	public function countAllAirlineCountriesByDate($date,$filters = array())
4096
+	public function countAllAirlineCountriesByDate($date, $filters = array())
4097 4097
 	{
4098 4098
 		global $globalTimezone, $globalDBdriver;
4099
-		$filter_query = $this->getFilter($filters,true,true);
4100
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4099
+		$filter_query = $this->getFilter($filters, true, true);
4100
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4101 4101
 		if ($globalTimezone != '') {
4102 4102
 			date_default_timezone_set($globalTimezone);
4103 4103
 			$datetime = new DateTime($date);
@@ -4105,13 +4105,13 @@  discard block
 block discarded – undo
4105 4105
 		} else $offset = '+00:00';
4106 4106
 		
4107 4107
 		if ($globalDBdriver == 'mysql') {
4108
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4108
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4109 4109
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4110 4110
 					GROUP BY spotter_output.airline_country
4111 4111
 					ORDER BY airline_country_count DESC
4112 4112
 					LIMIT 10 OFFSET 0";
4113 4113
 		} else {
4114
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4114
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4115 4115
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4116 4116
 					GROUP BY spotter_output.airline_country
4117 4117
 					ORDER BY airline_country_count DESC
@@ -4123,7 +4123,7 @@  discard block
 block discarded – undo
4123 4123
  
4124 4124
 		$airline_country_array = array();
4125 4125
 		$temp_array = array();
4126
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4126
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4127 4127
 		{
4128 4128
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4129 4129
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4140,11 +4140,11 @@  discard block
 block discarded – undo
4140 4140
 	* @return Array the airline list
4141 4141
 	*
4142 4142
 	*/
4143
-	public function countAllAirlinesByIdent($ident,$filters = array())
4143
+	public function countAllAirlinesByIdent($ident, $filters = array())
4144 4144
 	{
4145
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4146
-		$filter_query = $this->getFilter($filters,true,true);
4147
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4145
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4146
+		$filter_query = $this->getFilter($filters, true, true);
4147
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4148 4148
 		 		FROM spotter_output".$filter_query." spotter_output.ident = :ident  
4149 4149
 				GROUP BY spotter_output.airline_name
4150 4150
 				ORDER BY airline_count DESC";
@@ -4156,7 +4156,7 @@  discard block
 block discarded – undo
4156 4156
 		$airline_array = array();
4157 4157
 		$temp_array = array();
4158 4158
         
4159
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4159
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4160 4160
 		{
4161 4161
 			$temp_array['airline_name'] = $row['airline_name'];
4162 4162
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4174,25 +4174,25 @@  discard block
 block discarded – undo
4174 4174
 	* @return Array the airline list
4175 4175
 	*
4176 4176
 	*/
4177
-	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4177
+	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4178 4178
 	{
4179
-		$filter_query = $this->getFilter($filters,true,true);
4180
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4181
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4179
+		$filter_query = $this->getFilter($filters, true, true);
4180
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4181
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4182 4182
 
4183
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4183
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4184 4184
 		 			FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4185 4185
 					GROUP BY spotter_output.airline_name
4186 4186
 					ORDER BY airline_count DESC";
4187 4187
       
4188 4188
 		
4189 4189
 		$sth = $this->db->prepare($query);
4190
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4190
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4191 4191
       
4192 4192
 		$airline_array = array();
4193 4193
 		$temp_array = array();
4194 4194
         
4195
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4195
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4196 4196
 		{
4197 4197
 			$temp_array['airline_name'] = $row['airline_name'];
4198 4198
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4210,13 +4210,13 @@  discard block
 block discarded – undo
4210 4210
 	* @return Array the airline country list
4211 4211
 	*
4212 4212
 	*/
4213
-	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4213
+	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4214 4214
 	{
4215
-		$filter_query = $this->getFilter($filters,true,true);
4216
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4217
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4215
+		$filter_query = $this->getFilter($filters, true, true);
4216
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4217
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4218 4218
       
4219
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4219
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4220 4220
 		 		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) 
4221 4221
 				GROUP BY spotter_output.airline_country
4222 4222
 				ORDER BY airline_country_count DESC
@@ -4224,11 +4224,11 @@  discard block
 block discarded – undo
4224 4224
       
4225 4225
 		
4226 4226
 		$sth = $this->db->prepare($query);
4227
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4227
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4228 4228
       
4229 4229
 		$airline_country_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['airline_country_count'] = $row['airline_country_count'];
4234 4234
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4246,11 +4246,11 @@  discard block
 block discarded – undo
4246 4246
 	* @return Array the airline list
4247 4247
 	*
4248 4248
 	*/
4249
-	public function countAllAirlinesByCountry($country,$filters = array())
4249
+	public function countAllAirlinesByCountry($country, $filters = array())
4250 4250
 	{
4251
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4252
-		$filter_query = $this->getFilter($filters,true,true);
4253
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4251
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4252
+		$filter_query = $this->getFilter($filters, true, true);
4253
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4254 4254
 		 		FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
4255 4255
 				GROUP BY spotter_output.airline_name
4256 4256
 				ORDER BY airline_count DESC";
@@ -4261,7 +4261,7 @@  discard block
 block discarded – undo
4261 4261
 
4262 4262
 		$airline_array = array();
4263 4263
 		$temp_array = array();
4264
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4264
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4265 4265
 		{
4266 4266
 			$temp_array['airline_name'] = $row['airline_name'];
4267 4267
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4280,11 +4280,11 @@  discard block
 block discarded – undo
4280 4280
 	* @return Array the airline country list
4281 4281
 	*
4282 4282
 	*/
4283
-	public function countAllAirlineCountriesByCountry($country,$filters = array())
4283
+	public function countAllAirlineCountriesByCountry($country, $filters = array())
4284 4284
 	{
4285
-		$filter_query = $this->getFilter($filters,true,true);
4286
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4287
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4285
+		$filter_query = $this->getFilter($filters, true, true);
4286
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4287
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4288 4288
 		 		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 
4289 4289
 				GROUP BY spotter_output.airline_country
4290 4290
 				ORDER BY airline_country_count DESC
@@ -4296,7 +4296,7 @@  discard block
 block discarded – undo
4296 4296
 
4297 4297
 		$airline_country_array = array();
4298 4298
 		$temp_array = array();
4299
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4299
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4300 4300
 		{
4301 4301
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4302 4302
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4315,8 +4315,8 @@  discard block
 block discarded – undo
4315 4315
 	*/
4316 4316
 	public function countAllAirlineCountries($limit = true, $filters = array())
4317 4317
 	{
4318
-		$filter_query = $this->getFilter($filters,true,true);
4319
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4318
+		$filter_query = $this->getFilter($filters, true, true);
4319
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4320 4320
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
4321 4321
 					GROUP BY spotter_output.airline_country
4322 4322
 					ORDER BY airline_country_count DESC";
@@ -4327,7 +4327,7 @@  discard block
 block discarded – undo
4327 4327
 
4328 4328
 		$airline_array = array();
4329 4329
 		$temp_array = array();
4330
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4330
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4331 4331
 		{
4332 4332
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4333 4333
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4343,11 +4343,11 @@  discard block
 block discarded – undo
4343 4343
 	* @return Array the airline country list
4344 4344
 	*
4345 4345
 	*/
4346
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
4346
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
4347 4347
 	{
4348 4348
 		global $globalDBdriver;
4349 4349
 		//$filter_query = $this->getFilter($filters,true,true);
4350
-		$Connection= new Connection($this->db);
4350
+		$Connection = new Connection($this->db);
4351 4351
 		if (!$Connection->tableExists('countries')) return array();
4352 4352
 		/*
4353 4353
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -4382,7 +4382,7 @@  discard block
 block discarded – undo
4382 4382
 		$flight_array = array();
4383 4383
 		$temp_array = array();
4384 4384
         
4385
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4385
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4386 4386
 		{
4387 4387
 			$temp_array['flight_count'] = $row['nb'];
4388 4388
 			$temp_array['flight_country'] = $row['name'];
@@ -4400,12 +4400,12 @@  discard block
 block discarded – undo
4400 4400
 	* @return Array the aircraft list
4401 4401
 	*
4402 4402
 	*/
4403
-	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
4403
+	public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4404 4404
 	{
4405 4405
 		global $globalDBdriver;
4406
-		$filter_query = $this->getFilter($filters,true,true);
4406
+		$filter_query = $this->getFilter($filters, true, true);
4407 4407
 
4408
-		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4408
+		$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4409 4409
 		    FROM spotter_output ".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> ''";
4410 4410
 		if ($olderthanmonths > 0) {
4411 4411
 			if ($globalDBdriver == 'mysql') {
@@ -4430,7 +4430,7 @@  discard block
 block discarded – undo
4430 4430
 
4431 4431
 		$aircraft_array = array();
4432 4432
 		$temp_array = array();
4433
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4433
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4434 4434
 		{
4435 4435
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4436 4436
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4447,11 +4447,11 @@  discard block
 block discarded – undo
4447 4447
 	* @return Array the aircraft list
4448 4448
 	*
4449 4449
 	*/
4450
-	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
4450
+	public function countAllAircraftTypesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4451 4451
 	{
4452 4452
 		global $globalDBdriver;
4453
-		$filter_query = $this->getFilter($filters,true,true);
4454
-		$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 
4453
+		$filter_query = $this->getFilter($filters, true, true);
4454
+		$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 
4455 4455
 		    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' ";
4456 4456
 		if ($olderthanmonths > 0) {
4457 4457
 			if ($globalDBdriver == 'mysql') {
@@ -4476,7 +4476,7 @@  discard block
 block discarded – undo
4476 4476
 
4477 4477
 		$aircraft_array = array();
4478 4478
 		$temp_array = array();
4479
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4479
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4480 4480
 		{
4481 4481
 			$temp_array['airline_icao'] = $row['airline_icao'];
4482 4482
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -4495,13 +4495,13 @@  discard block
 block discarded – undo
4495 4495
 	* @return Array the aircraft list
4496 4496
 	*
4497 4497
 	*/
4498
-	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
4498
+	public function countAllAircraftRegistrationByAircraft($aircraft_icao, $filters = array())
4499 4499
 	{
4500 4500
 		$Image = new Image($this->db);
4501
-		$filter_query = $this->getFilter($filters,true,true);
4502
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4501
+		$filter_query = $this->getFilter($filters, true, true);
4502
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4503 4503
 
4504
-		$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  
4504
+		$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  
4505 4505
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
4506 4506
 				GROUP BY spotter_output.registration 
4507 4507
 				ORDER BY registration_count DESC";
@@ -4512,14 +4512,14 @@  discard block
 block discarded – undo
4512 4512
 		$aircraft_array = array();
4513 4513
 		$temp_array = array();
4514 4514
         
4515
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4515
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4516 4516
 		{
4517 4517
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4518 4518
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4519 4519
 			$temp_array['registration'] = $row['registration'];
4520 4520
 			$temp_array['airline_name'] = $row['airline_name'];
4521 4521
 			$temp_array['image_thumbnail'] = "";
4522
-			if($row['registration'] != "")
4522
+			if ($row['registration'] != "")
4523 4523
 			{
4524 4524
 				$image_array = $Image->getSpotterImage($row['registration']);
4525 4525
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4538,11 +4538,11 @@  discard block
 block discarded – undo
4538 4538
 	* @return Array the aircraft list
4539 4539
 	*
4540 4540
 	*/
4541
-	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
4541
+	public function countAllAircraftTypesByAirline($airline_icao, $filters = array())
4542 4542
 	{
4543
-		$filter_query = $this->getFilter($filters,true,true);
4544
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4545
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4543
+		$filter_query = $this->getFilter($filters, true, true);
4544
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4545
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4546 4546
 				FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
4547 4547
 				GROUP BY spotter_output.aircraft_name 
4548 4548
 				ORDER BY aircraft_icao_count DESC";
@@ -4553,7 +4553,7 @@  discard block
 block discarded – undo
4553 4553
 		$aircraft_array = array();
4554 4554
 		$temp_array = array();
4555 4555
 
4556
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4556
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4557 4557
 		{
4558 4558
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4559 4559
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4571,13 +4571,13 @@  discard block
 block discarded – undo
4571 4571
 	* @return Array the aircraft list
4572 4572
 	*
4573 4573
 	*/
4574
-	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
4574
+	public function countAllAircraftRegistrationByAirline($airline_icao, $filters = array())
4575 4575
 	{
4576
-		$filter_query = $this->getFilter($filters,true,true);
4576
+		$filter_query = $this->getFilter($filters, true, true);
4577 4577
 		$Image = new Image($this->db);
4578
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4578
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4579 4579
 
4580
-		$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   
4580
+		$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   
4581 4581
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
4582 4582
 				GROUP BY spotter_output.registration 
4583 4583
 				ORDER BY registration_count DESC";
@@ -4587,14 +4587,14 @@  discard block
 block discarded – undo
4587 4587
 
4588 4588
 		$aircraft_array = array();
4589 4589
 		$temp_array = array();
4590
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4590
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4591 4591
 		{
4592 4592
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4593 4593
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4594 4594
 			$temp_array['registration'] = $row['registration'];
4595 4595
 			$temp_array['airline_name'] = $row['airline_name'];
4596 4596
 			$temp_array['image_thumbnail'] = "";
4597
-			if($row['registration'] != "")
4597
+			if ($row['registration'] != "")
4598 4598
 			{
4599 4599
 				$image_array = $Image->getSpotterImage($row['registration']);
4600 4600
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4613,11 +4613,11 @@  discard block
 block discarded – undo
4613 4613
 	* @return Array the aircraft list
4614 4614
 	*
4615 4615
 	*/
4616
-	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
4616
+	public function countAllAircraftManufacturerByAirline($airline_icao, $filters = array())
4617 4617
 	{
4618
-		$filter_query = $this->getFilter($filters,true,true);
4619
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4620
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4618
+		$filter_query = $this->getFilter($filters, true, true);
4619
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4620
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4621 4621
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao 
4622 4622
 				GROUP BY spotter_output.aircraft_manufacturer 
4623 4623
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -4628,7 +4628,7 @@  discard block
 block discarded – undo
4628 4628
 		$aircraft_array = array();
4629 4629
 		$temp_array = array();
4630 4630
 
4631
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4631
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4632 4632
 		{
4633 4633
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4634 4634
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4645,12 +4645,12 @@  discard block
 block discarded – undo
4645 4645
 	* @return Array the aircraft list
4646 4646
 	*
4647 4647
 	*/
4648
-	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
4648
+	public function countAllAircraftTypesByAirport($airport_icao, $filters = array())
4649 4649
 	{
4650
-		$filter_query = $this->getFilter($filters,true,true);
4651
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4650
+		$filter_query = $this->getFilter($filters, true, true);
4651
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4652 4652
 
4653
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4653
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4654 4654
 				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) 
4655 4655
 				GROUP BY spotter_output.aircraft_name 
4656 4656
 				ORDER BY aircraft_icao_count DESC";
@@ -4660,7 +4660,7 @@  discard block
 block discarded – undo
4660 4660
 
4661 4661
 		$aircraft_array = array();
4662 4662
 		$temp_array = array();
4663
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4663
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4664 4664
 		{
4665 4665
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4666 4666
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4678,13 +4678,13 @@  discard block
 block discarded – undo
4678 4678
 	* @return Array the aircraft list
4679 4679
 	*
4680 4680
 	*/
4681
-	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
4681
+	public function countAllAircraftRegistrationByAirport($airport_icao, $filters = array())
4682 4682
 	{
4683
-		$filter_query = $this->getFilter($filters,true,true);
4683
+		$filter_query = $this->getFilter($filters, true, true);
4684 4684
 		$Image = new Image($this->db);
4685
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4685
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4686 4686
 
4687
-		$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  
4687
+		$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  
4688 4688
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   
4689 4689
                     GROUP BY spotter_output.registration 
4690 4690
 					ORDER BY registration_count DESC";
@@ -4695,14 +4695,14 @@  discard block
 block discarded – undo
4695 4695
 
4696 4696
 		$aircraft_array = array();
4697 4697
 		$temp_array = array();
4698
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4698
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4699 4699
 		{
4700 4700
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4701 4701
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4702 4702
 			$temp_array['registration'] = $row['registration'];
4703 4703
 			$temp_array['airline_name'] = $row['airline_name'];
4704 4704
 			$temp_array['image_thumbnail'] = "";
4705
-			if($row['registration'] != "")
4705
+			if ($row['registration'] != "")
4706 4706
 			{
4707 4707
 				$image_array = $Image->getSpotterImage($row['registration']);
4708 4708
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4720,11 +4720,11 @@  discard block
 block discarded – undo
4720 4720
 	* @return Array the aircraft list
4721 4721
 	*
4722 4722
 	*/
4723
-	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
4723
+	public function countAllAircraftManufacturerByAirport($airport_icao, $filters = array())
4724 4724
 	{
4725
-		$filter_query = $this->getFilter($filters,true,true);
4726
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4727
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4725
+		$filter_query = $this->getFilter($filters, true, true);
4726
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4727
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4728 4728
                     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)  
4729 4729
                     GROUP BY spotter_output.aircraft_manufacturer 
4730 4730
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -4735,7 +4735,7 @@  discard block
 block discarded – undo
4735 4735
 
4736 4736
 		$aircraft_array = array();
4737 4737
 		$temp_array = array();
4738
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4738
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4739 4739
 		{
4740 4740
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4741 4741
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4750,12 +4750,12 @@  discard block
 block discarded – undo
4750 4750
 	* @return Array the aircraft list
4751 4751
 	*
4752 4752
 	*/
4753
-	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
4753
+	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer, $filters = array())
4754 4754
 	{
4755
-		$filter_query = $this->getFilter($filters,true,true);
4756
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4755
+		$filter_query = $this->getFilter($filters, true, true);
4756
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4757 4757
 
4758
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4758
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4759 4759
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
4760 4760
                     GROUP BY spotter_output.aircraft_name 
4761 4761
 					ORDER BY aircraft_icao_count DESC";
@@ -4764,7 +4764,7 @@  discard block
 block discarded – undo
4764 4764
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4765 4765
 		$aircraft_array = array();
4766 4766
 		$temp_array = array();
4767
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4767
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4768 4768
 		{
4769 4769
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4770 4770
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4783,11 +4783,11 @@  discard block
 block discarded – undo
4783 4783
 	*/
4784 4784
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
4785 4785
 	{
4786
-		$filter_query = $this->getFilter($filters,true,true);
4786
+		$filter_query = $this->getFilter($filters, true, true);
4787 4787
 		$Image = new Image($this->db);
4788
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4788
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4789 4789
 
4790
-		$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   
4790
+		$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   
4791 4791
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
4792 4792
                     GROUP BY spotter_output.registration 
4793 4793
 					ORDER BY registration_count DESC";
@@ -4797,14 +4797,14 @@  discard block
 block discarded – undo
4797 4797
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4798 4798
 		$aircraft_array = array();
4799 4799
 		$temp_array = array();
4800
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4800
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4801 4801
 		{
4802 4802
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4803 4803
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4804 4804
 			$temp_array['registration'] = $row['registration'];
4805 4805
 			$temp_array['airline_name'] = $row['airline_name'];
4806 4806
 			$temp_array['image_thumbnail'] = "";
4807
-			if($row['registration'] != "")
4807
+			if ($row['registration'] != "")
4808 4808
 			{
4809 4809
 				$image_array = $Image->getSpotterImage($row['registration']);
4810 4810
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4821,11 +4821,11 @@  discard block
 block discarded – undo
4821 4821
 	* @return Array the aircraft list
4822 4822
 	*
4823 4823
 	*/
4824
-	public function countAllAircraftTypesByDate($date,$filters = array())
4824
+	public function countAllAircraftTypesByDate($date, $filters = array())
4825 4825
 	{
4826 4826
 		global $globalTimezone, $globalDBdriver;
4827
-		$filter_query = $this->getFilter($filters,true,true);
4828
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4827
+		$filter_query = $this->getFilter($filters, true, true);
4828
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4829 4829
 		if ($globalTimezone != '') {
4830 4830
 			date_default_timezone_set($globalTimezone);
4831 4831
 			$datetime = new DateTime($date);
@@ -4833,12 +4833,12 @@  discard block
 block discarded – undo
4833 4833
 		} else $offset = '+00:00';
4834 4834
 
4835 4835
 		if ($globalDBdriver == 'mysql') {
4836
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4836
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4837 4837
 					FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
4838 4838
 					GROUP BY spotter_output.aircraft_name 
4839 4839
 					ORDER BY aircraft_icao_count DESC";
4840 4840
 		} else {
4841
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4841
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4842 4842
 					FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
4843 4843
 					GROUP BY spotter_output.aircraft_name 
4844 4844
 					ORDER BY aircraft_icao_count DESC";
@@ -4849,7 +4849,7 @@  discard block
 block discarded – undo
4849 4849
 
4850 4850
 		$aircraft_array = array();
4851 4851
 		$temp_array = array();
4852
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4852
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4853 4853
 		{
4854 4854
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4855 4855
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4867,12 +4867,12 @@  discard block
 block discarded – undo
4867 4867
 	* @return Array the aircraft list
4868 4868
 	*
4869 4869
 	*/
4870
-	public function countAllAircraftRegistrationByDate($date,$filters = array())
4870
+	public function countAllAircraftRegistrationByDate($date, $filters = array())
4871 4871
 	{
4872 4872
 		global $globalTimezone, $globalDBdriver;
4873
-		$filter_query = $this->getFilter($filters,true,true);
4873
+		$filter_query = $this->getFilter($filters, true, true);
4874 4874
 		$Image = new Image($this->db);
4875
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4875
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4876 4876
 		if ($globalTimezone != '') {
4877 4877
 			date_default_timezone_set($globalTimezone);
4878 4878
 			$datetime = new DateTime($date);
@@ -4880,12 +4880,12 @@  discard block
 block discarded – undo
4880 4880
 		} else $offset = '+00:00';
4881 4881
 
4882 4882
 		if ($globalDBdriver == 'mysql') {
4883
-			$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    
4883
+			$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    
4884 4884
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4885 4885
 					GROUP BY spotter_output.registration 
4886 4886
 					ORDER BY registration_count DESC";
4887 4887
 		} else {
4888
-			$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    
4888
+			$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    
4889 4889
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4890 4890
 					GROUP BY spotter_output.registration 
4891 4891
 					ORDER BY registration_count DESC";
@@ -4896,14 +4896,14 @@  discard block
 block discarded – undo
4896 4896
 
4897 4897
 		$aircraft_array = array();
4898 4898
 		$temp_array = array();
4899
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4899
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4900 4900
 		{
4901 4901
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4902 4902
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4903 4903
 			$temp_array['registration'] = $row['registration'];
4904 4904
 			$temp_array['airline_name'] = $row['airline_name'];
4905 4905
 			$temp_array['image_thumbnail'] = "";
4906
-			if($row['registration'] != "")
4906
+			if ($row['registration'] != "")
4907 4907
 			{
4908 4908
 				$image_array = $Image->getSpotterImage($row['registration']);
4909 4909
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4922,11 +4922,11 @@  discard block
 block discarded – undo
4922 4922
 	* @return Array the aircraft manufacturer list
4923 4923
 	*
4924 4924
 	*/
4925
-	public function countAllAircraftManufacturerByDate($date,$filters = array())
4925
+	public function countAllAircraftManufacturerByDate($date, $filters = array())
4926 4926
 	{
4927 4927
 		global $globalTimezone, $globalDBdriver;
4928
-		$filter_query = $this->getFilter($filters,true,true);
4929
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4928
+		$filter_query = $this->getFilter($filters, true, true);
4929
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4930 4930
 		if ($globalTimezone != '') {
4931 4931
 			date_default_timezone_set($globalTimezone);
4932 4932
 			$datetime = new DateTime($date);
@@ -4934,12 +4934,12 @@  discard block
 block discarded – undo
4934 4934
 		} else $offset = '+00:00';
4935 4935
 
4936 4936
 		if ($globalDBdriver == 'mysql') {
4937
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4937
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4938 4938
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4939 4939
 				GROUP BY spotter_output.aircraft_manufacturer 
4940 4940
 				ORDER BY aircraft_manufacturer_count DESC";
4941 4941
 		} else {
4942
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4942
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4943 4943
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4944 4944
 				GROUP BY spotter_output.aircraft_manufacturer 
4945 4945
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -4951,7 +4951,7 @@  discard block
 block discarded – undo
4951 4951
 		$aircraft_array = array();
4952 4952
 		$temp_array = array();
4953 4953
 
4954
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4954
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4955 4955
 		{
4956 4956
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4957 4957
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4968,11 +4968,11 @@  discard block
 block discarded – undo
4968 4968
 	* @return Array the aircraft list
4969 4969
 	*
4970 4970
 	*/
4971
-	public function countAllAircraftTypesByIdent($ident,$filters = array())
4971
+	public function countAllAircraftTypesByIdent($ident, $filters = array())
4972 4972
 	{
4973
-		$filter_query = $this->getFilter($filters,true,true);
4974
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4975
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4973
+		$filter_query = $this->getFilter($filters, true, true);
4974
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4975
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4976 4976
 				FROM spotter_output".$filter_query." spotter_output.ident = :ident 
4977 4977
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
4978 4978
 				ORDER BY aircraft_icao_count DESC";
@@ -4983,7 +4983,7 @@  discard block
 block discarded – undo
4983 4983
 		$aircraft_array = array();
4984 4984
 		$temp_array = array();
4985 4985
 
4986
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4986
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4987 4987
 		{
4988 4988
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4989 4989
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5001,13 +5001,13 @@  discard block
 block discarded – undo
5001 5001
 	* @return Array the aircraft list
5002 5002
 	*
5003 5003
 	*/
5004
-	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5004
+	public function countAllAircraftRegistrationByIdent($ident, $filters = array())
5005 5005
 	{
5006
-		$filter_query = $this->getFilter($filters,true,true);
5006
+		$filter_query = $this->getFilter($filters, true, true);
5007 5007
 		$Image = new Image($this->db);
5008
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5008
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5009 5009
 
5010
-		$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  
5010
+		$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  
5011 5011
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident   
5012 5012
                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5013 5013
 		    ORDER BY registration_count DESC";
@@ -5019,14 +5019,14 @@  discard block
 block discarded – undo
5019 5019
 		$aircraft_array = array();
5020 5020
 		$temp_array = array();
5021 5021
         
5022
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5022
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5023 5023
 		{
5024 5024
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5025 5025
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5026 5026
 			$temp_array['registration'] = $row['registration'];
5027 5027
 			$temp_array['airline_name'] = $row['airline_name'];
5028 5028
 			$temp_array['image_thumbnail'] = "";
5029
-			if($row['registration'] != "")
5029
+			if ($row['registration'] != "")
5030 5030
 			{
5031 5031
 				$image_array = $Image->getSpotterImage($row['registration']);
5032 5032
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5045,11 +5045,11 @@  discard block
 block discarded – undo
5045 5045
 	* @return Array the aircraft manufacturer list
5046 5046
 	*
5047 5047
 	*/
5048
-	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
5048
+	public function countAllAircraftManufacturerByIdent($ident, $filters = array())
5049 5049
 	{
5050
-		$filter_query = $this->getFilter($filters,true,true);
5051
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5052
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5050
+		$filter_query = $this->getFilter($filters, true, true);
5051
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5052
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5053 5053
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident  
5054 5054
                     GROUP BY spotter_output.aircraft_manufacturer 
5055 5055
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -5059,7 +5059,7 @@  discard block
 block discarded – undo
5059 5059
 		$sth->execute(array(':ident' => $ident));
5060 5060
 		$aircraft_array = array();
5061 5061
 		$temp_array = array();
5062
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5062
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5063 5063
 		{
5064 5064
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5065 5065
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5075,24 +5075,24 @@  discard block
 block discarded – undo
5075 5075
 	* @return Array the aircraft list
5076 5076
 	*
5077 5077
 	*/
5078
-	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
5078
+	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
5079 5079
 	{
5080
-		$filter_query = $this->getFilter($filters,true,true);
5081
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5082
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5080
+		$filter_query = $this->getFilter($filters, true, true);
5081
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5082
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5083 5083
 		
5084 5084
 
5085
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5085
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5086 5086
                     FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
5087 5087
                     GROUP BY spotter_output.aircraft_name 
5088 5088
 					ORDER BY aircraft_icao_count DESC";
5089 5089
  
5090 5090
 		
5091 5091
 		$sth = $this->db->prepare($query);
5092
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5092
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5093 5093
 		$aircraft_array = array();
5094 5094
 		$temp_array = array();
5095
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5095
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5096 5096
 		{
5097 5097
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5098 5098
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5108,33 +5108,33 @@  discard block
 block discarded – undo
5108 5108
 	* @return Array the aircraft list
5109 5109
 	*
5110 5110
 	*/
5111
-	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
5111
+	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
5112 5112
 	{
5113
-		$filter_query = $this->getFilter($filters,true,true);
5113
+		$filter_query = $this->getFilter($filters, true, true);
5114 5114
 		$Image = new Image($this->db);
5115
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5116
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5115
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5116
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5117 5117
 
5118
-		$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   
5118
+		$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   
5119 5119
                     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)   
5120 5120
                     GROUP BY spotter_output.registration 
5121 5121
 					ORDER BY registration_count DESC";
5122 5122
 
5123 5123
 		
5124 5124
 		$sth = $this->db->prepare($query);
5125
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5125
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5126 5126
       
5127 5127
 		$aircraft_array = array();
5128 5128
 		$temp_array = array();
5129 5129
         
5130
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5130
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5131 5131
 		{
5132 5132
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5133 5133
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5134 5134
 			$temp_array['registration'] = $row['registration'];
5135 5135
 			$temp_array['airline_name'] = $row['airline_name'];
5136 5136
 			$temp_array['image_thumbnail'] = "";
5137
-			if($row['registration'] != "")
5137
+			if ($row['registration'] != "")
5138 5138
 			{
5139 5139
 				$image_array = $Image->getSpotterImage($row['registration']);
5140 5140
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5154,25 +5154,25 @@  discard block
 block discarded – undo
5154 5154
 	* @return Array the aircraft manufacturer list
5155 5155
 	*
5156 5156
 	*/
5157
-	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
5157
+	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
5158 5158
 	{
5159
-		$filter_query = $this->getFilter($filters,true,true);
5160
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5161
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5159
+		$filter_query = $this->getFilter($filters, true, true);
5160
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5161
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5162 5162
 
5163
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5163
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5164 5164
                     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) 
5165 5165
                     GROUP BY spotter_output.aircraft_manufacturer 
5166 5166
 					ORDER BY aircraft_manufacturer_count DESC";
5167 5167
 
5168 5168
 		
5169 5169
 		$sth = $this->db->prepare($query);
5170
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5170
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5171 5171
       
5172 5172
 		$aircraft_array = array();
5173 5173
 		$temp_array = array();
5174 5174
         
5175
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5175
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5176 5176
 		{
5177 5177
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5178 5178
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5192,11 +5192,11 @@  discard block
 block discarded – undo
5192 5192
 	* @return Array the aircraft list
5193 5193
 	*
5194 5194
 	*/
5195
-	public function countAllAircraftTypesByCountry($country,$filters = array())
5195
+	public function countAllAircraftTypesByCountry($country, $filters = array())
5196 5196
 	{
5197
-		$filter_query = $this->getFilter($filters,true,true);
5198
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5199
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5197
+		$filter_query = $this->getFilter($filters, true, true);
5198
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5199
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5200 5200
                     FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
5201 5201
                     GROUP BY spotter_output.aircraft_name 
5202 5202
 			ORDER BY aircraft_icao_count DESC";
@@ -5208,7 +5208,7 @@  discard block
 block discarded – undo
5208 5208
 		$aircraft_array = array();
5209 5209
 		$temp_array = array();
5210 5210
         
5211
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5211
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5212 5212
 		{
5213 5213
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5214 5214
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5227,12 +5227,12 @@  discard block
 block discarded – undo
5227 5227
 	* @return Array the aircraft list
5228 5228
 	*
5229 5229
 	*/
5230
-	public function countAllAircraftRegistrationByCountry($country,$filters = array())
5230
+	public function countAllAircraftRegistrationByCountry($country, $filters = array())
5231 5231
 	{
5232
-		$filter_query = $this->getFilter($filters,true,true);
5232
+		$filter_query = $this->getFilter($filters, true, true);
5233 5233
 		$Image = new Image($this->db);
5234
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5235
-		$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 
5234
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5235
+		$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 
5236 5236
                     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)    
5237 5237
                     GROUP BY spotter_output.registration 
5238 5238
 					ORDER BY registration_count DESC";
@@ -5244,14 +5244,14 @@  discard block
 block discarded – undo
5244 5244
 		$aircraft_array = array();
5245 5245
 		$temp_array = array();
5246 5246
         
5247
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5247
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5248 5248
 		{
5249 5249
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5250 5250
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5251 5251
 			$temp_array['registration'] = $row['registration'];
5252 5252
 			$temp_array['airline_name'] = $row['airline_name'];
5253 5253
 			$temp_array['image_thumbnail'] = "";
5254
-			if($row['registration'] != "")
5254
+			if ($row['registration'] != "")
5255 5255
 			{
5256 5256
 				$image_array = $Image->getSpotterImage($row['registration']);
5257 5257
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5271,11 +5271,11 @@  discard block
 block discarded – undo
5271 5271
 	* @return Array the aircraft manufacturer list
5272 5272
 	*
5273 5273
 	*/
5274
-	public function countAllAircraftManufacturerByCountry($country,$filters = array())
5274
+	public function countAllAircraftManufacturerByCountry($country, $filters = array())
5275 5275
 	{
5276
-		$filter_query = $this->getFilter($filters,true,true);
5277
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5278
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5276
+		$filter_query = $this->getFilter($filters, true, true);
5277
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5278
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5279 5279
                     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) 
5280 5280
                     GROUP BY spotter_output.aircraft_manufacturer 
5281 5281
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -5287,7 +5287,7 @@  discard block
 block discarded – undo
5287 5287
 		$aircraft_array = array();
5288 5288
 		$temp_array = array();
5289 5289
         
5290
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5290
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5291 5291
 		{
5292 5292
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5293 5293
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5308,8 +5308,8 @@  discard block
 block discarded – undo
5308 5308
 	*/
5309 5309
 	public function countAllAircraftManufacturers($filters = array())
5310 5310
 	{
5311
-		$filter_query = $this->getFilter($filters,true,true);
5312
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5311
+		$filter_query = $this->getFilter($filters, true, true);
5312
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5313 5313
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
5314 5314
                 $query .= " GROUP BY spotter_output.aircraft_manufacturer
5315 5315
 					ORDER BY aircraft_manufacturer_count DESC
@@ -5322,7 +5322,7 @@  discard block
 block discarded – undo
5322 5322
 		$manufacturer_array = array();
5323 5323
 		$temp_array = array();
5324 5324
         
5325
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5325
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5326 5326
 		{
5327 5327
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5328 5328
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5341,12 +5341,12 @@  discard block
 block discarded – undo
5341 5341
 	* @return Array the aircraft list
5342 5342
 	*
5343 5343
 	*/
5344
-	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5344
+	public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5345 5345
 	{
5346 5346
 		global $globalDBdriver;
5347 5347
 		$Image = new Image($this->db);
5348
-		$filter_query = $this->getFilter($filters,true,true);
5349
-		$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    
5348
+		$filter_query = $this->getFilter($filters, true, true);
5349
+		$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    
5350 5350
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
5351 5351
                 if ($olderthanmonths > 0) {
5352 5352
             		if ($globalDBdriver == 'mysql') {
@@ -5374,7 +5374,7 @@  discard block
 block discarded – undo
5374 5374
 		$aircraft_array = array();
5375 5375
 		$temp_array = array();
5376 5376
         
5377
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5377
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5378 5378
 		{
5379 5379
 			$temp_array['registration'] = $row['registration'];
5380 5380
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -5382,7 +5382,7 @@  discard block
 block discarded – undo
5382 5382
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5383 5383
 			$temp_array['airline_name'] = $row['airline_name'];
5384 5384
 			$temp_array['image_thumbnail'] = "";
5385
-			if($row['registration'] != "")
5385
+			if ($row['registration'] != "")
5386 5386
 			{
5387 5387
 				$image_array = $Image->getSpotterImage($row['registration']);
5388 5388
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5401,12 +5401,12 @@  discard block
 block discarded – undo
5401 5401
 	* @return Array the aircraft list
5402 5402
 	*
5403 5403
 	*/
5404
-	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5404
+	public function countAllAircraftRegistrationsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5405 5405
 	{
5406 5406
 		global $globalDBdriver;
5407
-		$filter_query = $this->getFilter($filters,true,true);
5407
+		$filter_query = $this->getFilter($filters, true, true);
5408 5408
 		$Image = new Image($this->db);
5409
-		$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    
5409
+		$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    
5410 5410
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
5411 5411
                 if ($olderthanmonths > 0) {
5412 5412
             		if ($globalDBdriver == 'mysql') {
@@ -5434,7 +5434,7 @@  discard block
 block discarded – undo
5434 5434
 		$aircraft_array = array();
5435 5435
 		$temp_array = array();
5436 5436
         
5437
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5437
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5438 5438
 		{
5439 5439
 			$temp_array['registration'] = $row['registration'];
5440 5440
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -5443,7 +5443,7 @@  discard block
 block discarded – undo
5443 5443
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5444 5444
 			$temp_array['airline_name'] = $row['airline_name'];
5445 5445
 			$temp_array['image_thumbnail'] = "";
5446
-			if($row['registration'] != "")
5446
+			if ($row['registration'] != "")
5447 5447
 			{
5448 5448
 				$image_array = $Image->getSpotterImage($row['registration']);
5449 5449
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5462,11 +5462,11 @@  discard block
 block discarded – undo
5462 5462
 	* @return Array the airport list
5463 5463
 	*
5464 5464
 	*/
5465
-	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5465
+	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5466 5466
 	{
5467 5467
 		global $globalDBdriver;
5468
-		$filter_query = $this->getFilter($filters,true,true);
5469
-		$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 
5468
+		$filter_query = $this->getFilter($filters, true, true);
5469
+		$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 
5470 5470
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA'";
5471 5471
                 if ($olderthanmonths > 0) {
5472 5472
             		if ($globalDBdriver == 'mysql') {
@@ -5495,7 +5495,7 @@  discard block
 block discarded – undo
5495 5495
 		$airport_array = array();
5496 5496
 		$temp_array = array();
5497 5497
         
5498
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5498
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5499 5499
 		{
5500 5500
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5501 5501
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5514,11 +5514,11 @@  discard block
 block discarded – undo
5514 5514
 	* @return Array the airport list
5515 5515
 	*
5516 5516
 	*/
5517
-	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5517
+	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5518 5518
 	{
5519 5519
 		global $globalDBdriver;
5520
-		$filter_query = $this->getFilter($filters,true,true);
5521
-		$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 
5520
+		$filter_query = $this->getFilter($filters, true, true);
5521
+		$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 
5522 5522
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' ";
5523 5523
                 if ($olderthanmonths > 0) {
5524 5524
             		if ($globalDBdriver == 'mysql') {
@@ -5547,7 +5547,7 @@  discard block
 block discarded – undo
5547 5547
 		$airport_array = array();
5548 5548
 		$temp_array = array();
5549 5549
         
5550
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5550
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5551 5551
 		{
5552 5552
 			$temp_array['airline_icao'] = $row['airline_icao'];
5553 5553
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -5567,11 +5567,11 @@  discard block
 block discarded – undo
5567 5567
 	* @return Array the airport list
5568 5568
 	*
5569 5569
 	*/
5570
-	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5570
+	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5571 5571
 	{
5572 5572
 		global $globalDBdriver;
5573
-		$filter_query = $this->getFilter($filters,true,true);
5574
-		$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
5573
+		$filter_query = $this->getFilter($filters, true, true);
5574
+		$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
5575 5575
 				FROM spotter_output, airport".$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";
5576 5576
                 if ($olderthanmonths > 0) {
5577 5577
             		if ($globalDBdriver == 'mysql') {
@@ -5599,7 +5599,7 @@  discard block
 block discarded – undo
5599 5599
 		$airport_array = array();
5600 5600
 		$temp_array = array();
5601 5601
         
5602
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5602
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5603 5603
 		{
5604 5604
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5605 5605
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5618,11 +5618,11 @@  discard block
 block discarded – undo
5618 5618
 	* @return Array the airport list
5619 5619
 	*
5620 5620
 	*/
5621
-	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5621
+	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5622 5622
 	{
5623 5623
 		global $globalDBdriver;
5624
-		$filter_query = $this->getFilter($filters,true,true);
5625
-		$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
5624
+		$filter_query = $this->getFilter($filters, true, true);
5625
+		$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
5626 5626
 				FROM spotter_output, airport".$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 ";
5627 5627
                 if ($olderthanmonths > 0) {
5628 5628
             		if ($globalDBdriver == 'mysql') {
@@ -5651,7 +5651,7 @@  discard block
 block discarded – undo
5651 5651
 		$airport_array = array();
5652 5652
 		$temp_array = array();
5653 5653
         
5654
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5654
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5655 5655
 		{
5656 5656
 			$temp_array['airline_icao'] = $row['airline_icao'];
5657 5657
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -5671,11 +5671,11 @@  discard block
 block discarded – undo
5671 5671
 	* @return Array the airport list
5672 5672
 	*
5673 5673
 	*/
5674
-	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
5674
+	public function countAllDepartureAirportsByAirline($airline_icao, $filters = array())
5675 5675
 	{
5676
-		$filter_query = $this->getFilter($filters,true,true);
5677
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5678
-		$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 
5676
+		$filter_query = $this->getFilter($filters, true, true);
5677
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5678
+		$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 
5679 5679
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao 
5680 5680
                     GROUP BY spotter_output.departure_airport_icao
5681 5681
 					ORDER BY airport_departure_icao_count DESC";
@@ -5687,7 +5687,7 @@  discard block
 block discarded – undo
5687 5687
 		$airport_array = array();
5688 5688
 		$temp_array = array();
5689 5689
         
5690
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5690
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5691 5691
 		{
5692 5692
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5693 5693
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5709,11 +5709,11 @@  discard block
 block discarded – undo
5709 5709
 	* @return Array the airport list
5710 5710
 	*
5711 5711
 	*/
5712
-	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
5712
+	public function countAllDepartureAirportCountriesByAirline($airline_icao, $filters = array())
5713 5713
 	{
5714
-		$filter_query = $this->getFilter($filters,true,true);
5715
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5716
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5714
+		$filter_query = $this->getFilter($filters, true, true);
5715
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5716
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5717 5717
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
5718 5718
                     GROUP BY spotter_output.departure_airport_country
5719 5719
 					ORDER BY airport_departure_country_count DESC";
@@ -5725,7 +5725,7 @@  discard block
 block discarded – undo
5725 5725
 		$airport_array = array();
5726 5726
 		$temp_array = array();
5727 5727
         
5728
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5728
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5729 5729
 		{
5730 5730
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5731 5731
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5744,11 +5744,11 @@  discard block
 block discarded – undo
5744 5744
 	* @return Array the airport list
5745 5745
 	*
5746 5746
 	*/
5747
-	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
5747
+	public function countAllDepartureAirportsByAircraft($aircraft_icao, $filters = array())
5748 5748
 	{
5749
-		$filter_query = $this->getFilter($filters,true,true);
5750
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5751
-		$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 
5749
+		$filter_query = $this->getFilter($filters, true, true);
5750
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5751
+		$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 
5752 5752
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao 
5753 5753
                     GROUP BY spotter_output.departure_airport_icao
5754 5754
 					ORDER BY airport_departure_icao_count DESC";
@@ -5760,7 +5760,7 @@  discard block
 block discarded – undo
5760 5760
 		$airport_array = array();
5761 5761
 		$temp_array = array();
5762 5762
         
5763
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5763
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5764 5764
 		{
5765 5765
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5766 5766
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5781,11 +5781,11 @@  discard block
 block discarded – undo
5781 5781
 	* @return Array the airport list
5782 5782
 	*
5783 5783
 	*/
5784
-	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
5784
+	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao, $filters = array())
5785 5785
 	{
5786
-		$filter_query = $this->getFilter($filters,true,true);
5787
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5788
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5786
+		$filter_query = $this->getFilter($filters, true, true);
5787
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5788
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5789 5789
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
5790 5790
                     GROUP BY spotter_output.departure_airport_country
5791 5791
 					ORDER BY airport_departure_country_count DESC";
@@ -5797,7 +5797,7 @@  discard block
 block discarded – undo
5797 5797
 		$airport_array = array();
5798 5798
 		$temp_array = array();
5799 5799
         
5800
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5800
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5801 5801
 		{
5802 5802
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5803 5803
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5815,11 +5815,11 @@  discard block
 block discarded – undo
5815 5815
 	* @return Array the airport list
5816 5816
 	*
5817 5817
 	*/
5818
-	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
5818
+	public function countAllDepartureAirportsByRegistration($registration, $filters = array())
5819 5819
 	{
5820
-		$filter_query = $this->getFilter($filters,true,true);
5821
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5822
-		$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 
5820
+		$filter_query = $this->getFilter($filters, true, true);
5821
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5822
+		$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 
5823 5823
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration 
5824 5824
                     GROUP BY spotter_output.departure_airport_icao
5825 5825
 					ORDER BY airport_departure_icao_count DESC";
@@ -5831,7 +5831,7 @@  discard block
 block discarded – undo
5831 5831
 		$airport_array = array();
5832 5832
 		$temp_array = array();
5833 5833
         
5834
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5834
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5835 5835
 		{
5836 5836
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5837 5837
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5852,11 +5852,11 @@  discard block
 block discarded – undo
5852 5852
 	* @return Array the airport list
5853 5853
 	*
5854 5854
 	*/
5855
-	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
5855
+	public function countAllDepartureAirportCountriesByRegistration($registration, $filters = array())
5856 5856
 	{
5857
-		$filter_query = $this->getFilter($filters,true,true);
5858
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5859
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5857
+		$filter_query = $this->getFilter($filters, true, true);
5858
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5859
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5860 5860
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration 
5861 5861
                     GROUP BY spotter_output.departure_airport_country
5862 5862
 					ORDER BY airport_departure_country_count DESC";
@@ -5868,7 +5868,7 @@  discard block
 block discarded – undo
5868 5868
 		$airport_array = array();
5869 5869
 		$temp_array = array();
5870 5870
         
5871
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5871
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5872 5872
 		{
5873 5873
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5874 5874
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5886,11 +5886,11 @@  discard block
 block discarded – undo
5886 5886
 	* @return Array the airport list
5887 5887
 	*
5888 5888
 	*/
5889
-	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
5889
+	public function countAllDepartureAirportsByAirport($airport_icao, $filters = array())
5890 5890
 	{
5891
-		$filter_query = $this->getFilter($filters,true,true);
5892
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5893
-		$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 
5891
+		$filter_query = $this->getFilter($filters, true, true);
5892
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5893
+		$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 
5894 5894
 			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 
5895 5895
                     GROUP BY spotter_output.departure_airport_icao
5896 5896
 					ORDER BY airport_departure_icao_count DESC";
@@ -5902,7 +5902,7 @@  discard block
 block discarded – undo
5902 5902
 		$airport_array = array();
5903 5903
 		$temp_array = array();
5904 5904
         
5905
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5905
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5906 5906
 		{
5907 5907
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5908 5908
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5923,11 +5923,11 @@  discard block
 block discarded – undo
5923 5923
 	* @return Array the airport list
5924 5924
 	*
5925 5925
 	*/
5926
-	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
5926
+	public function countAllDepartureAirportCountriesByAirport($airport_icao, $filters = array())
5927 5927
 	{
5928
-		$filter_query = $this->getFilter($filters,true,true);
5929
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5930
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5928
+		$filter_query = $this->getFilter($filters, true, true);
5929
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5930
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5931 5931
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao 
5932 5932
                     GROUP BY spotter_output.departure_airport_country
5933 5933
 					ORDER BY airport_departure_country_count DESC";
@@ -5939,7 +5939,7 @@  discard block
 block discarded – undo
5939 5939
 		$airport_array = array();
5940 5940
 		$temp_array = array();
5941 5941
         
5942
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5942
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5943 5943
 		{
5944 5944
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5945 5945
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5958,11 +5958,11 @@  discard block
 block discarded – undo
5958 5958
 	* @return Array the airport list
5959 5959
 	*
5960 5960
 	*/
5961
-	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
5961
+	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer, $filters = array())
5962 5962
 	{
5963
-		$filter_query = $this->getFilter($filters,true,true);
5964
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5965
-		$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 
5963
+		$filter_query = $this->getFilter($filters, true, true);
5964
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5965
+		$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 
5966 5966
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
5967 5967
                     GROUP BY spotter_output.departure_airport_icao
5968 5968
 					ORDER BY airport_departure_icao_count DESC";
@@ -5974,7 +5974,7 @@  discard block
 block discarded – undo
5974 5974
 		$airport_array = array();
5975 5975
 		$temp_array = array();
5976 5976
         
5977
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5977
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5978 5978
 		{
5979 5979
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5980 5980
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5995,11 +5995,11 @@  discard block
 block discarded – undo
5995 5995
 	* @return Array the airport list
5996 5996
 	*
5997 5997
 	*/
5998
-	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
5998
+	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
5999 5999
 	{
6000
-		$filter_query = $this->getFilter($filters,true,true);
6001
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6002
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6000
+		$filter_query = $this->getFilter($filters, true, true);
6001
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6002
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6003 6003
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6004 6004
                     GROUP BY spotter_output.departure_airport_country
6005 6005
 					ORDER BY airport_departure_country_count DESC";
@@ -6011,7 +6011,7 @@  discard block
 block discarded – undo
6011 6011
 		$airport_array = array();
6012 6012
 		$temp_array = array();
6013 6013
         
6014
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6014
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6015 6015
 		{
6016 6016
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6017 6017
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6029,11 +6029,11 @@  discard block
 block discarded – undo
6029 6029
 	* @return Array the airport list
6030 6030
 	*
6031 6031
 	*/
6032
-	public function countAllDepartureAirportsByDate($date,$filters = array())
6032
+	public function countAllDepartureAirportsByDate($date, $filters = array())
6033 6033
 	{
6034 6034
 		global $globalTimezone, $globalDBdriver;
6035
-		$filter_query = $this->getFilter($filters,true,true);
6036
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6035
+		$filter_query = $this->getFilter($filters, true, true);
6036
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6037 6037
 		if ($globalTimezone != '') {
6038 6038
 			date_default_timezone_set($globalTimezone);
6039 6039
 			$datetime = new DateTime($date);
@@ -6041,12 +6041,12 @@  discard block
 block discarded – undo
6041 6041
 		} else $offset = '+00:00';
6042 6042
 
6043 6043
 		if ($globalDBdriver == 'mysql') {
6044
-			$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 
6044
+			$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 
6045 6045
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
6046 6046
 					GROUP BY spotter_output.departure_airport_icao
6047 6047
 					ORDER BY airport_departure_icao_count DESC";
6048 6048
 		} else {
6049
-			$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 
6049
+			$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 
6050 6050
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
6051 6051
 					GROUP BY spotter_output.departure_airport_icao
6052 6052
 					ORDER BY airport_departure_icao_count DESC";
@@ -6058,7 +6058,7 @@  discard block
 block discarded – undo
6058 6058
 		$airport_array = array();
6059 6059
 		$temp_array = array();
6060 6060
         
6061
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6061
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6062 6062
 		{
6063 6063
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6064 6064
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6079,11 +6079,11 @@  discard block
 block discarded – undo
6079 6079
 	* @return Array the airport list
6080 6080
 	*
6081 6081
 	*/
6082
-	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
6082
+	public function countAllDepartureAirportCountriesByDate($date, $filters = array())
6083 6083
 	{
6084 6084
 		global $globalTimezone, $globalDBdriver;
6085
-		$filter_query = $this->getFilter($filters,true,true);
6086
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6085
+		$filter_query = $this->getFilter($filters, true, true);
6086
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6087 6087
 		if ($globalTimezone != '') {
6088 6088
 			date_default_timezone_set($globalTimezone);
6089 6089
 			$datetime = new DateTime($date);
@@ -6091,12 +6091,12 @@  discard block
 block discarded – undo
6091 6091
 		} else $offset = '+00:00';
6092 6092
 
6093 6093
 		if ($globalDBdriver == 'mysql') {
6094
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6094
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6095 6095
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
6096 6096
 					GROUP BY spotter_output.departure_airport_country
6097 6097
 					ORDER BY airport_departure_country_count DESC";
6098 6098
 		} else {
6099
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6099
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6100 6100
 					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 
6101 6101
 					GROUP BY spotter_output.departure_airport_country
6102 6102
 					ORDER BY airport_departure_country_count DESC";
@@ -6108,7 +6108,7 @@  discard block
 block discarded – undo
6108 6108
 		$airport_array = array();
6109 6109
 		$temp_array = array();
6110 6110
         
6111
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6111
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6112 6112
 		{
6113 6113
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6114 6114
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6126,11 +6126,11 @@  discard block
 block discarded – undo
6126 6126
 	* @return Array the airport list
6127 6127
 	*
6128 6128
 	*/
6129
-	public function countAllDepartureAirportsByIdent($ident,$filters = array())
6129
+	public function countAllDepartureAirportsByIdent($ident, $filters = array())
6130 6130
 	{
6131
-		$filter_query = $this->getFilter($filters,true,true);
6132
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6133
-		$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 
6131
+		$filter_query = $this->getFilter($filters, true, true);
6132
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6133
+		$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 
6134 6134
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.ident = :ident 
6135 6135
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6136 6136
 		    ORDER BY airport_departure_icao_count DESC";
@@ -6142,7 +6142,7 @@  discard block
 block discarded – undo
6142 6142
 		$airport_array = array();
6143 6143
 		$temp_array = array();
6144 6144
         
6145
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6145
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6146 6146
 		{
6147 6147
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6148 6148
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6164,11 +6164,11 @@  discard block
 block discarded – undo
6164 6164
 	* @return Array the airport list
6165 6165
 	*
6166 6166
 	*/
6167
-	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
6167
+	public function countAllDepartureAirportCountriesByIdent($ident, $filters = array())
6168 6168
 	{
6169
-		$filter_query = $this->getFilter($filters,true,true);
6170
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6171
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6169
+		$filter_query = $this->getFilter($filters, true, true);
6170
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6171
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6172 6172
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident 
6173 6173
                     GROUP BY spotter_output.departure_airport_country
6174 6174
 					ORDER BY airport_departure_country_count DESC";
@@ -6180,7 +6180,7 @@  discard block
 block discarded – undo
6180 6180
 		$airport_array = array();
6181 6181
 		$temp_array = array();
6182 6182
         
6183
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6183
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6184 6184
 		{
6185 6185
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6186 6186
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6199,12 +6199,12 @@  discard block
 block discarded – undo
6199 6199
 	* @return Array the airport list
6200 6200
 	*
6201 6201
 	*/
6202
-	public function countAllDepartureAirportsByCountry($country,$filters = array())
6202
+	public function countAllDepartureAirportsByCountry($country, $filters = array())
6203 6203
 	{
6204
-		$filter_query = $this->getFilter($filters,true,true);
6205
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6204
+		$filter_query = $this->getFilter($filters, true, true);
6205
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6206 6206
 
6207
-		$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 
6207
+		$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 
6208 6208
 			FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
6209 6209
                     GROUP BY spotter_output.departure_airport_icao
6210 6210
 					ORDER BY airport_departure_icao_count DESC";
@@ -6216,7 +6216,7 @@  discard block
 block discarded – undo
6216 6216
 		$airport_array = array();
6217 6217
 		$temp_array = array();
6218 6218
         
6219
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6219
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6220 6220
 		{
6221 6221
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6222 6222
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6237,11 +6237,11 @@  discard block
 block discarded – undo
6237 6237
 	* @return Array the airport list
6238 6238
 	*
6239 6239
 	*/
6240
-	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
6240
+	public function countAllDepartureAirportCountriesByCountry($country, $filters = array())
6241 6241
 	{
6242
-		$filter_query = $this->getFilter($filters,true,true);
6243
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6244
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6242
+		$filter_query = $this->getFilter($filters, true, true);
6243
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6244
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6245 6245
 			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 
6246 6246
                     GROUP BY spotter_output.departure_airport_country
6247 6247
 					ORDER BY airport_departure_country_count DESC";
@@ -6253,7 +6253,7 @@  discard block
 block discarded – undo
6253 6253
 		$airport_array = array();
6254 6254
 		$temp_array = array();
6255 6255
         
6256
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6256
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6257 6257
 		{
6258 6258
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6259 6259
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6271,11 +6271,11 @@  discard block
 block discarded – undo
6271 6271
 	* @return Array the airport list
6272 6272
 	*
6273 6273
 	*/
6274
-	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
6274
+	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6275 6275
 	{
6276 6276
 		global $globalDBdriver;
6277
-		$filter_query = $this->getFilter($filters,true,true);
6278
-		$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 
6277
+		$filter_query = $this->getFilter($filters, true, true);
6278
+		$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 
6279 6279
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
6280 6280
                 if ($olderthanmonths > 0) {
6281 6281
             		if ($globalDBdriver == 'mysql') {
@@ -6310,7 +6310,7 @@  discard block
 block discarded – undo
6310 6310
 		$airport_array = array();
6311 6311
 		$temp_array = array();
6312 6312
         
6313
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6313
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6314 6314
 		{
6315 6315
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6316 6316
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6333,11 +6333,11 @@  discard block
 block discarded – undo
6333 6333
 	* @return Array the airport list
6334 6334
 	*
6335 6335
 	*/
6336
-	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
6336
+	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6337 6337
 	{
6338 6338
 		global $globalDBdriver;
6339
-		$filter_query = $this->getFilter($filters,true,true);
6340
-		$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 
6339
+		$filter_query = $this->getFilter($filters, true, true);
6340
+		$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 
6341 6341
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' ";
6342 6342
                 if ($olderthanmonths > 0) {
6343 6343
             		if ($globalDBdriver == 'mysql') {
@@ -6372,7 +6372,7 @@  discard block
 block discarded – undo
6372 6372
 		$airport_array = array();
6373 6373
 		$temp_array = array();
6374 6374
         
6375
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6375
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6376 6376
 		{
6377 6377
 			$temp_array['airline_icao'] = $row['airline_icao'];
6378 6378
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
@@ -6397,11 +6397,11 @@  discard block
 block discarded – undo
6397 6397
 	* @return Array the airport list
6398 6398
 	*
6399 6399
 	*/
6400
-	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
6400
+	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6401 6401
 	{
6402 6402
 		global $globalDBdriver;
6403
-		$filter_query = $this->getFilter($filters,true,true);
6404
-		$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 
6403
+		$filter_query = $this->getFilter($filters, true, true);
6404
+		$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 
6405 6405
 			FROM spotter_output, airport".$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";
6406 6406
                 if ($olderthanmonths > 0) {
6407 6407
             		if ($globalDBdriver == 'mysql') {
@@ -6435,7 +6435,7 @@  discard block
 block discarded – undo
6435 6435
 		$airport_array = array();
6436 6436
 		$temp_array = array();
6437 6437
         
6438
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6438
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6439 6439
 		{
6440 6440
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6441 6441
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6458,11 +6458,11 @@  discard block
 block discarded – undo
6458 6458
 	* @return Array the airport list
6459 6459
 	*
6460 6460
 	*/
6461
-	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
6461
+	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6462 6462
 	{
6463 6463
 		global $globalDBdriver;
6464
-		$filter_query = $this->getFilter($filters,true,true);
6465
-		$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 
6464
+		$filter_query = $this->getFilter($filters, true, true);
6465
+		$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 
6466 6466
 			FROM spotter_output, airport".$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 ";
6467 6467
                 if ($olderthanmonths > 0) {
6468 6468
             		if ($globalDBdriver == 'mysql') {
@@ -6497,7 +6497,7 @@  discard block
 block discarded – undo
6497 6497
 		$airport_array = array();
6498 6498
 		$temp_array = array();
6499 6499
         
6500
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6500
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6501 6501
 		{
6502 6502
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6503 6503
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6523,9 +6523,9 @@  discard block
 block discarded – undo
6523 6523
 	*/
6524 6524
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
6525 6525
 	{
6526
-		$filter_query = $this->getFilter($filters,true,true);
6527
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6528
-		$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 
6526
+		$filter_query = $this->getFilter($filters, true, true);
6527
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6528
+		$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 
6529 6529
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao 
6530 6530
                     GROUP BY spotter_output.arrival_airport_icao
6531 6531
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6536,7 +6536,7 @@  discard block
 block discarded – undo
6536 6536
 		$airport_array = array();
6537 6537
 		$temp_array = array();
6538 6538
         
6539
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6539
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6540 6540
 		{
6541 6541
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6542 6542
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6557,12 +6557,12 @@  discard block
 block discarded – undo
6557 6557
 	* @return Array the airport list
6558 6558
 	*
6559 6559
 	*/
6560
-	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
6560
+	public function countAllArrivalAirportCountriesByAirline($airline_icao, $filters = array())
6561 6561
 	{
6562
-		$filter_query = $this->getFilter($filters,true,true);
6563
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6562
+		$filter_query = $this->getFilter($filters, true, true);
6563
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6564 6564
 					
6565
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6565
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6566 6566
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
6567 6567
                     GROUP BY spotter_output.arrival_airport_country
6568 6568
 					ORDER BY airport_arrival_country_count DESC";
@@ -6574,7 +6574,7 @@  discard block
 block discarded – undo
6574 6574
 		$airport_array = array();
6575 6575
 		$temp_array = array();
6576 6576
         
6577
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6577
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6578 6578
 		{
6579 6579
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6580 6580
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6592,11 +6592,11 @@  discard block
 block discarded – undo
6592 6592
 	* @return Array the airport list
6593 6593
 	*
6594 6594
 	*/
6595
-	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
6595
+	public function countAllArrivalAirportsByAircraft($aircraft_icao, $filters = array())
6596 6596
 	{
6597
-		$filter_query = $this->getFilter($filters,true,true);
6598
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6599
-		$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 
6597
+		$filter_query = $this->getFilter($filters, true, true);
6598
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6599
+		$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 
6600 6600
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao 
6601 6601
                     GROUP BY spotter_output.arrival_airport_icao
6602 6602
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6608,7 +6608,7 @@  discard block
 block discarded – undo
6608 6608
 		$airport_array = array();
6609 6609
 		$temp_array = array();
6610 6610
         
6611
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6611
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6612 6612
 		{
6613 6613
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6614 6614
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6630,11 +6630,11 @@  discard block
 block discarded – undo
6630 6630
 	* @return Array the airport list
6631 6631
 	*
6632 6632
 	*/
6633
-	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
6633
+	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao, $filters = array())
6634 6634
 	{
6635
-		$filter_query = $this->getFilter($filters,true,true);
6636
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6637
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6635
+		$filter_query = $this->getFilter($filters, true, true);
6636
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6637
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6638 6638
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
6639 6639
                     GROUP BY spotter_output.arrival_airport_country
6640 6640
 					ORDER BY airport_arrival_country_count DESC";
@@ -6646,7 +6646,7 @@  discard block
 block discarded – undo
6646 6646
 		$airport_array = array();
6647 6647
 		$temp_array = array();
6648 6648
         
6649
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6649
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6650 6650
 		{
6651 6651
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6652 6652
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6664,12 +6664,12 @@  discard block
 block discarded – undo
6664 6664
 	* @return Array the airport list
6665 6665
 	*
6666 6666
 	*/
6667
-	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
6667
+	public function countAllArrivalAirportsByRegistration($registration, $filters = array())
6668 6668
 	{
6669
-		$filter_query = $this->getFilter($filters,true,true);
6670
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
6669
+		$filter_query = $this->getFilter($filters, true, true);
6670
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
6671 6671
 
6672
-		$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 
6672
+		$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 
6673 6673
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.registration = :registration 
6674 6674
                     GROUP BY spotter_output.arrival_airport_icao
6675 6675
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6681,7 +6681,7 @@  discard block
 block discarded – undo
6681 6681
 		$airport_array = array();
6682 6682
 		$temp_array = array();
6683 6683
         
6684
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6684
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6685 6685
 		{
6686 6686
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6687 6687
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6702,11 +6702,11 @@  discard block
 block discarded – undo
6702 6702
 	* @return Array the airport list
6703 6703
 	*
6704 6704
 	*/
6705
-	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
6705
+	public function countAllArrivalAirportCountriesByRegistration($registration, $filters = array())
6706 6706
 	{
6707
-		$filter_query = $this->getFilter($filters,true,true);
6708
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
6709
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6707
+		$filter_query = $this->getFilter($filters, true, true);
6708
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
6709
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6710 6710
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration 
6711 6711
                     GROUP BY spotter_output.arrival_airport_country
6712 6712
 					ORDER BY airport_arrival_country_count DESC";
@@ -6718,7 +6718,7 @@  discard block
 block discarded – undo
6718 6718
 		$airport_array = array();
6719 6719
 		$temp_array = array();
6720 6720
         
6721
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6721
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6722 6722
 		{
6723 6723
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6724 6724
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6737,11 +6737,11 @@  discard block
 block discarded – undo
6737 6737
 	* @return Array the airport list
6738 6738
 	*
6739 6739
 	*/
6740
-	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
6740
+	public function countAllArrivalAirportsByAirport($airport_icao, $filters = array())
6741 6741
 	{
6742
-		$filter_query = $this->getFilter($filters,true,true);
6743
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6744
-		$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 
6742
+		$filter_query = $this->getFilter($filters, true, true);
6743
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6744
+		$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 
6745 6745
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.departure_airport_icao = :airport_icao 
6746 6746
                     GROUP BY spotter_output.arrival_airport_icao
6747 6747
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6753,7 +6753,7 @@  discard block
 block discarded – undo
6753 6753
 		$airport_array = array();
6754 6754
 		$temp_array = array();
6755 6755
         
6756
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6756
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6757 6757
 		{
6758 6758
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6759 6759
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6774,11 +6774,11 @@  discard block
 block discarded – undo
6774 6774
 	* @return Array the airport list
6775 6775
 	*
6776 6776
 	*/
6777
-	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
6777
+	public function countAllArrivalAirportCountriesByAirport($airport_icao, $filters = array())
6778 6778
 	{
6779
-		$filter_query = $this->getFilter($filters,true,true);
6780
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6781
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6779
+		$filter_query = $this->getFilter($filters, true, true);
6780
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6781
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6782 6782
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao 
6783 6783
                     GROUP BY spotter_output.arrival_airport_country
6784 6784
 					ORDER BY airport_arrival_country_count DESC";
@@ -6790,7 +6790,7 @@  discard block
 block discarded – undo
6790 6790
 		$airport_array = array();
6791 6791
 		$temp_array = array();
6792 6792
         
6793
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6793
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6794 6794
 		{
6795 6795
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6796 6796
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6808,11 +6808,11 @@  discard block
 block discarded – undo
6808 6808
 	* @return Array the airport list
6809 6809
 	*
6810 6810
 	*/
6811
-	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
6811
+	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer, $filters = array())
6812 6812
 	{
6813
-		$filter_query = $this->getFilter($filters,true,true);
6814
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6815
-		$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 
6813
+		$filter_query = $this->getFilter($filters, true, true);
6814
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6815
+		$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 
6816 6816
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6817 6817
                     GROUP BY spotter_output.arrival_airport_icao
6818 6818
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6824,7 +6824,7 @@  discard block
 block discarded – undo
6824 6824
 		$airport_array = array();
6825 6825
 		$temp_array = array();
6826 6826
         
6827
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6827
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6828 6828
 		{
6829 6829
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6830 6830
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6846,11 +6846,11 @@  discard block
 block discarded – undo
6846 6846
 	* @return Array the airport list
6847 6847
 	*
6848 6848
 	*/
6849
-	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
6849
+	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
6850 6850
 	{
6851
-		$filter_query = $this->getFilter($filters,true,true);
6852
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6853
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6851
+		$filter_query = $this->getFilter($filters, true, true);
6852
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6853
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6854 6854
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6855 6855
                     GROUP BY spotter_output.arrival_airport_country
6856 6856
 					ORDER BY airport_arrival_country_count DESC";
@@ -6862,7 +6862,7 @@  discard block
 block discarded – undo
6862 6862
 		$airport_array = array();
6863 6863
 		$temp_array = array();
6864 6864
         
6865
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6865
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6866 6866
 		{
6867 6867
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6868 6868
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6881,11 +6881,11 @@  discard block
 block discarded – undo
6881 6881
 	* @return Array the airport list
6882 6882
 	*
6883 6883
 	*/
6884
-	public function countAllArrivalAirportsByDate($date,$filters = array())
6884
+	public function countAllArrivalAirportsByDate($date, $filters = array())
6885 6885
 	{
6886 6886
 		global $globalTimezone, $globalDBdriver;
6887
-		$filter_query = $this->getFilter($filters,true,true);
6888
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6887
+		$filter_query = $this->getFilter($filters, true, true);
6888
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6889 6889
 		if ($globalTimezone != '') {
6890 6890
 			date_default_timezone_set($globalTimezone);
6891 6891
 			$datetime = new DateTime($date);
@@ -6893,12 +6893,12 @@  discard block
 block discarded – undo
6893 6893
 		} else $offset = '+00:00';
6894 6894
 
6895 6895
 		if ($globalDBdriver == 'mysql') {
6896
-			$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 
6896
+			$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 
6897 6897
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
6898 6898
 					GROUP BY spotter_output.arrival_airport_icao
6899 6899
 					ORDER BY airport_arrival_icao_count DESC";
6900 6900
 		} else {
6901
-			$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 
6901
+			$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 
6902 6902
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
6903 6903
 					GROUP BY spotter_output.arrival_airport_icao
6904 6904
 					ORDER BY airport_arrival_icao_count DESC";
@@ -6910,7 +6910,7 @@  discard block
 block discarded – undo
6910 6910
 		$airport_array = array();
6911 6911
 		$temp_array = array();
6912 6912
         
6913
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6913
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6914 6914
 		{
6915 6915
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6916 6916
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6934,8 +6934,8 @@  discard block
 block discarded – undo
6934 6934
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
6935 6935
 	{
6936 6936
 		global $globalTimezone, $globalDBdriver;
6937
-		$filter_query = $this->getFilter($filters,true,true);
6938
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6937
+		$filter_query = $this->getFilter($filters, true, true);
6938
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6939 6939
 		if ($globalTimezone != '') {
6940 6940
 			date_default_timezone_set($globalTimezone);
6941 6941
 			$datetime = new DateTime($date);
@@ -6943,12 +6943,12 @@  discard block
 block discarded – undo
6943 6943
 		} else $offset = '+00:00';
6944 6944
 
6945 6945
 		if ($globalDBdriver == 'mysql') {
6946
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6946
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6947 6947
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
6948 6948
 					GROUP BY spotter_output.arrival_airport_country
6949 6949
 					ORDER BY airport_arrival_country_count DESC";
6950 6950
 		} else {
6951
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6951
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6952 6952
 					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 
6953 6953
 					GROUP BY spotter_output.arrival_airport_country
6954 6954
 					ORDER BY airport_arrival_country_count DESC";
@@ -6960,7 +6960,7 @@  discard block
 block discarded – undo
6960 6960
 		$airport_array = array();
6961 6961
 		$temp_array = array();
6962 6962
         
6963
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6963
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6964 6964
 		{
6965 6965
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6966 6966
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6978,11 +6978,11 @@  discard block
 block discarded – undo
6978 6978
 	* @return Array the airport list
6979 6979
 	*
6980 6980
 	*/
6981
-	public function countAllArrivalAirportsByIdent($ident,$filters = array())
6981
+	public function countAllArrivalAirportsByIdent($ident, $filters = array())
6982 6982
 	{
6983
-		$filter_query = $this->getFilter($filters,true,true);
6984
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6985
-		$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 
6983
+		$filter_query = $this->getFilter($filters, true, true);
6984
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6985
+		$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 
6986 6986
 		    FROM spotter_output".$filter_query." WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.ident = :ident  
6987 6987
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6988 6988
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -6994,7 +6994,7 @@  discard block
 block discarded – undo
6994 6994
 		$airport_array = array();
6995 6995
 		$temp_array = array();
6996 6996
         
6997
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6997
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6998 6998
 		{
6999 6999
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7000 7000
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7017,9 +7017,9 @@  discard block
 block discarded – undo
7017 7017
 	*/
7018 7018
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
7019 7019
 	{
7020
-		$filter_query = $this->getFilter($filters,true,true);
7021
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7022
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7020
+		$filter_query = $this->getFilter($filters, true, true);
7021
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7022
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7023 7023
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident 
7024 7024
                     GROUP BY spotter_output.arrival_airport_country
7025 7025
 					ORDER BY airport_arrival_country_count DESC";
@@ -7031,7 +7031,7 @@  discard block
 block discarded – undo
7031 7031
 		$airport_array = array();
7032 7032
 		$temp_array = array();
7033 7033
         
7034
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7034
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7035 7035
 		{
7036 7036
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7037 7037
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7050,11 +7050,11 @@  discard block
 block discarded – undo
7050 7050
 	* @return Array the airport list
7051 7051
 	*
7052 7052
 	*/
7053
-	public function countAllArrivalAirportsByCountry($country,$filters = array())
7053
+	public function countAllArrivalAirportsByCountry($country, $filters = array())
7054 7054
 	{
7055
-		$filter_query = $this->getFilter($filters,true,true);
7056
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7057
-		$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 
7055
+		$filter_query = $this->getFilter($filters, true, true);
7056
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7057
+		$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 
7058 7058
 			FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
7059 7059
                     GROUP BY spotter_output.arrival_airport_icao
7060 7060
 					ORDER BY airport_arrival_icao_count DESC";
@@ -7066,7 +7066,7 @@  discard block
 block discarded – undo
7066 7066
 		$airport_array = array();
7067 7067
 		$temp_array = array();
7068 7068
         
7069
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7069
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7070 7070
 		{
7071 7071
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7072 7072
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7087,11 +7087,11 @@  discard block
 block discarded – undo
7087 7087
 	* @return Array the airport list
7088 7088
 	*
7089 7089
 	*/
7090
-	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
7090
+	public function countAllArrivalAirportCountriesByCountry($country, $filters = array())
7091 7091
 	{
7092
-		$filter_query = $this->getFilter($filters,true,true);
7093
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7094
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7092
+		$filter_query = $this->getFilter($filters, true, true);
7093
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7094
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7095 7095
 			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 
7096 7096
                     GROUP BY spotter_output.arrival_airport_country
7097 7097
 					ORDER BY airport_arrival_country_count DESC";
@@ -7103,7 +7103,7 @@  discard block
 block discarded – undo
7103 7103
 		$airport_array = array();
7104 7104
 		$temp_array = array();
7105 7105
         
7106
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7106
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7107 7107
 		{
7108 7108
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7109 7109
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7124,7 +7124,7 @@  discard block
 block discarded – undo
7124 7124
 	*/
7125 7125
 	public function countAllDepartureCountries($filters = array())
7126 7126
 	{
7127
-		$filter_query = $this->getFilter($filters,true,true);
7127
+		$filter_query = $this->getFilter($filters, true, true);
7128 7128
 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7129 7129
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA'";
7130 7130
 		$query .= " GROUP BY spotter_output.departure_airport_country
@@ -7138,7 +7138,7 @@  discard block
 block discarded – undo
7138 7138
 		$airport_array = array();
7139 7139
 		$temp_array = array();
7140 7140
         
7141
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7141
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7142 7142
 		{
7143 7143
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
7144 7144
 			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
@@ -7156,9 +7156,9 @@  discard block
 block discarded – undo
7156 7156
 	* @return Array the airport arrival list
7157 7157
 	*
7158 7158
 	*/
7159
-	public function countAllArrivalCountries($limit = true,$filters = array())
7159
+	public function countAllArrivalCountries($limit = true, $filters = array())
7160 7160
 	{
7161
-		$filter_query = $this->getFilter($filters,true,true);
7161
+		$filter_query = $this->getFilter($filters, true, true);
7162 7162
 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7163 7163
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
7164 7164
 		$query .= " GROUP BY spotter_output.arrival_airport_country
@@ -7172,7 +7172,7 @@  discard block
 block discarded – undo
7172 7172
 		$airport_array = array();
7173 7173
 		$temp_array = array();
7174 7174
         
7175
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7175
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7176 7176
 		{
7177 7177
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
7178 7178
 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
@@ -7195,8 +7195,8 @@  discard block
 block discarded – undo
7195 7195
 	*/
7196 7196
 	public function countAllRoutes($filters = array())
7197 7197
 	{
7198
-		$filter_query = $this->getFilter($filters,true,true);
7199
-		$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
7198
+		$filter_query = $this->getFilter($filters, true, true);
7199
+		$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
7200 7200
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> 'NA'
7201 7201
                     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
7202 7202
                     ORDER BY route_count DESC
@@ -7209,7 +7209,7 @@  discard block
 block discarded – undo
7209 7209
 		$routes_array = array();
7210 7210
 		$temp_array = array();
7211 7211
         
7212
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7212
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7213 7213
 		{
7214 7214
 			$temp_array['route_count'] = $row['route_count'];
7215 7215
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7236,11 +7236,11 @@  discard block
 block discarded – undo
7236 7236
 	* @return Array the route list
7237 7237
 	*
7238 7238
 	*/
7239
-	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
7239
+	public function countAllRoutesByAircraft($aircraft_icao, $filters = array())
7240 7240
 	{
7241
-		$filter_query = $this->getFilter($filters,true,true);
7242
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7243
-		$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
7241
+		$filter_query = $this->getFilter($filters, true, true);
7242
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7243
+		$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
7244 7244
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
7245 7245
                     GROUP BY route
7246 7246
                     ORDER BY route_count DESC";
@@ -7251,7 +7251,7 @@  discard block
 block discarded – undo
7251 7251
 		$routes_array = array();
7252 7252
 		$temp_array = array();
7253 7253
         
7254
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7254
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7255 7255
 		{
7256 7256
 			$temp_array['route_count'] = $row['route_count'];
7257 7257
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7278,9 +7278,9 @@  discard block
 block discarded – undo
7278 7278
 	*/
7279 7279
 	public function countAllRoutesByRegistration($registration, $filters = array())
7280 7280
 	{
7281
-		$filter_query = $this->getFilter($filters,true,true);
7281
+		$filter_query = $this->getFilter($filters, true, true);
7282 7282
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7283
-		$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
7283
+		$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
7284 7284
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration 
7285 7285
                     GROUP BY route
7286 7286
                     ORDER BY route_count DESC";
@@ -7292,7 +7292,7 @@  discard block
 block discarded – undo
7292 7292
 		$routes_array = array();
7293 7293
 		$temp_array = array();
7294 7294
         
7295
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7295
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7296 7296
 		{
7297 7297
 			$temp_array['route_count'] = $row['route_count'];
7298 7298
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7320,9 +7320,9 @@  discard block
 block discarded – undo
7320 7320
 	*/
7321 7321
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
7322 7322
 	{
7323
-		$filter_query = $this->getFilter($filters,true,true);
7324
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7325
-		$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
7323
+		$filter_query = $this->getFilter($filters, true, true);
7324
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7325
+		$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
7326 7326
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao 
7327 7327
                     GROUP BY route
7328 7328
                     ORDER BY route_count DESC";
@@ -7334,7 +7334,7 @@  discard block
 block discarded – undo
7334 7334
 		$routes_array = array();
7335 7335
 		$temp_array = array();
7336 7336
         
7337
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7337
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7338 7338
 		{
7339 7339
 			$temp_array['route_count'] = $row['route_count'];
7340 7340
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7362,9 +7362,9 @@  discard block
 block discarded – undo
7362 7362
 	*/
7363 7363
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
7364 7364
 	{
7365
-		$filter_query = $this->getFilter($filters,true,true);
7366
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7367
-		$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
7365
+		$filter_query = $this->getFilter($filters, true, true);
7366
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7367
+		$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
7368 7368
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
7369 7369
                     GROUP BY route
7370 7370
                     ORDER BY route_count DESC";
@@ -7375,7 +7375,7 @@  discard block
 block discarded – undo
7375 7375
 		$routes_array = array();
7376 7376
 		$temp_array = array();
7377 7377
         
7378
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7378
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7379 7379
 		{
7380 7380
 			$temp_array['route_count'] = $row['route_count'];
7381 7381
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7403,9 +7403,9 @@  discard block
 block discarded – undo
7403 7403
 	*/
7404 7404
 	public function countAllRoutesByCountry($country, $filters = array())
7405 7405
 	{
7406
-		$filter_query = $this->getFilter($filters,true,true);
7407
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7408
-		$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
7406
+		$filter_query = $this->getFilter($filters, true, true);
7407
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7408
+		$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
7409 7409
 			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 
7410 7410
                     GROUP BY route
7411 7411
                     ORDER BY route_count DESC";
@@ -7416,7 +7416,7 @@  discard block
 block discarded – undo
7416 7416
 		$routes_array = array();
7417 7417
 		$temp_array = array();
7418 7418
         
7419
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7419
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7420 7420
 		{
7421 7421
 			$temp_array['route_count'] = $row['route_count'];
7422 7422
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7444,8 +7444,8 @@  discard block
 block discarded – undo
7444 7444
 	public function countAllRoutesByDate($date, $filters = array())
7445 7445
 	{
7446 7446
 		global $globalTimezone, $globalDBdriver;
7447
-		$filter_query = $this->getFilter($filters,true,true);
7448
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7447
+		$filter_query = $this->getFilter($filters, true, true);
7448
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7449 7449
 		if ($globalTimezone != '') {
7450 7450
 			date_default_timezone_set($globalTimezone);
7451 7451
 			$datetime = new DateTime($date);
@@ -7453,12 +7453,12 @@  discard block
 block discarded – undo
7453 7453
 		} else $offset = '+00:00';
7454 7454
 		
7455 7455
 		if ($globalDBdriver == 'mysql') {
7456
-			$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
7456
+			$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
7457 7457
 					FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
7458 7458
 					GROUP BY route
7459 7459
 					ORDER BY route_count DESC";
7460 7460
 		} else {
7461
-			$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
7461
+			$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
7462 7462
 					FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
7463 7463
 					GROUP BY route
7464 7464
 					ORDER BY route_count DESC";
@@ -7470,7 +7470,7 @@  discard block
 block discarded – undo
7470 7470
 		$routes_array = array();
7471 7471
 		$temp_array = array();
7472 7472
         
7473
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7473
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7474 7474
 		{
7475 7475
 			$temp_array['route_count'] = $row['route_count'];
7476 7476
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7497,9 +7497,9 @@  discard block
 block discarded – undo
7497 7497
 	*/
7498 7498
 	public function countAllRoutesByIdent($ident, $filters = array())
7499 7499
 	{
7500
-		$filter_query = $this->getFilter($filters,true,true);
7501
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7502
-		$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
7500
+		$filter_query = $this->getFilter($filters, true, true);
7501
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7502
+		$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
7503 7503
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident   
7504 7504
                     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
7505 7505
                     ORDER BY route_count DESC";
@@ -7511,7 +7511,7 @@  discard block
 block discarded – undo
7511 7511
 		$routes_array = array();
7512 7512
 		$temp_array = array();
7513 7513
         
7514
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7514
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7515 7515
 		{
7516 7516
 			$temp_array['route_count'] = $row['route_count'];
7517 7517
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7538,9 +7538,9 @@  discard block
 block discarded – undo
7538 7538
 	*/
7539 7539
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
7540 7540
 	{
7541
-		$filter_query = $this->getFilter($filters,true,true);
7542
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7543
-		$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
7541
+		$filter_query = $this->getFilter($filters, true, true);
7542
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7543
+		$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
7544 7544
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
7545 7545
                     GROUP BY route
7546 7546
                     ORDER BY route_count DESC";
@@ -7552,7 +7552,7 @@  discard block
 block discarded – undo
7552 7552
 		$routes_array = array();
7553 7553
 		$temp_array = array();
7554 7554
         
7555
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7555
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7556 7556
 		{
7557 7557
 			$temp_array['route_count'] = $row['route_count'];
7558 7558
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7580,8 +7580,8 @@  discard block
 block discarded – undo
7580 7580
 	*/
7581 7581
 	public function countAllRoutesWithWaypoints($filters = array())
7582 7582
 	{
7583
-		$filter_query = $this->getFilter($filters,true,true);
7584
-		$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
7583
+		$filter_query = $this->getFilter($filters, true, true);
7584
+		$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
7585 7585
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> '' 
7586 7586
                     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
7587 7587
                     ORDER BY route_count DESC
@@ -7594,7 +7594,7 @@  discard block
 block discarded – undo
7594 7594
 		$routes_array = array();
7595 7595
 		$temp_array = array();
7596 7596
         
7597
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7597
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7598 7598
 		{
7599 7599
 			$temp_array['spotter_id'] = $row['spotter_id'];
7600 7600
 			$temp_array['route_count'] = $row['route_count'];
@@ -7619,11 +7619,11 @@  discard block
 block discarded – undo
7619 7619
 	* @return Array the callsign list
7620 7620
 	*
7621 7621
 	*/
7622
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
7622
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
7623 7623
 	{
7624 7624
 		global $globalDBdriver;
7625
-		$filter_query = $this->getFilter($filters,true,true);
7626
-		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7625
+		$filter_query = $this->getFilter($filters, true, true);
7626
+		$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7627 7627
                     FROM spotter_output".$filter_query." spotter_output.ident <> '' ";
7628 7628
 		 if ($olderthanmonths > 0) {
7629 7629
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -7642,7 +7642,7 @@  discard block
 block discarded – undo
7642 7642
 		$callsign_array = array();
7643 7643
 		$temp_array = array();
7644 7644
         
7645
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7645
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7646 7646
 		{
7647 7647
 			$temp_array['callsign_icao'] = $row['ident'];
7648 7648
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -7664,8 +7664,8 @@  discard block
 block discarded – undo
7664 7664
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
7665 7665
 	{
7666 7666
 		global $globalDBdriver;
7667
-		$filter_query = $this->getFilter($filters,true,true);
7668
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7667
+		$filter_query = $this->getFilter($filters, true, true);
7668
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7669 7669
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
7670 7670
 		 if ($olderthanmonths > 0) {
7671 7671
 			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
@@ -7684,7 +7684,7 @@  discard block
 block discarded – undo
7684 7684
 		$callsign_array = array();
7685 7685
 		$temp_array = array();
7686 7686
         
7687
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7687
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7688 7688
 		{
7689 7689
 			$temp_array['callsign_icao'] = $row['ident'];
7690 7690
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -7738,7 +7738,7 @@  discard block
 block discarded – undo
7738 7738
 		$date_array = array();
7739 7739
 		$temp_array = array();
7740 7740
         
7741
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7741
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7742 7742
 		{
7743 7743
 			$temp_array['date_name'] = $row['date_name'];
7744 7744
 			$temp_array['date_count'] = $row['date_count'];
@@ -7763,15 +7763,15 @@  discard block
 block discarded – undo
7763 7763
 			$datetime = new DateTime();
7764 7764
 			$offset = $datetime->format('P');
7765 7765
 		} else $offset = '+00:00';
7766
-		$filter_query = $this->getFilter($filters,true,true);
7766
+		$filter_query = $this->getFilter($filters, true, true);
7767 7767
 		if ($globalDBdriver == 'mysql') {
7768
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7768
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7769 7769
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
7770 7770
 								GROUP BY spotter_output.airline_icao, date_name 
7771 7771
 								ORDER BY date_count DESC
7772 7772
 								LIMIT 10 OFFSET 0";
7773 7773
 		} else {
7774
-			$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
7774
+			$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
7775 7775
 								FROM spotter_output 
7776 7776
 								WHERE spotter_output.airline_icao <> '' 
7777 7777
 								GROUP BY spotter_output.airline_icao, date_name 
@@ -7786,7 +7786,7 @@  discard block
 block discarded – undo
7786 7786
 		$date_array = array();
7787 7787
 		$temp_array = array();
7788 7788
         
7789
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7789
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7790 7790
 		{
7791 7791
 			$temp_array['date_name'] = $row['date_name'];
7792 7792
 			$temp_array['date_count'] = $row['date_count'];
@@ -7812,7 +7812,7 @@  discard block
 block discarded – undo
7812 7812
 			$datetime = new DateTime();
7813 7813
 			$offset = $datetime->format('P');
7814 7814
 		} else $offset = '+00:00';
7815
-		$filter_query = $this->getFilter($filters,true,true);
7815
+		$filter_query = $this->getFilter($filters, true, true);
7816 7816
 		if ($globalDBdriver == 'mysql') {
7817 7817
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7818 7818
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -7833,7 +7833,7 @@  discard block
 block discarded – undo
7833 7833
 		$date_array = array();
7834 7834
 		$temp_array = array();
7835 7835
         
7836
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7836
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7837 7837
 		{
7838 7838
 			$temp_array['date_name'] = $row['date_name'];
7839 7839
 			$temp_array['date_count'] = $row['date_count'];
@@ -7858,7 +7858,7 @@  discard block
 block discarded – undo
7858 7858
 			$datetime = new DateTime();
7859 7859
 			$offset = $datetime->format('P');
7860 7860
 		} else $offset = '+00:00';
7861
-		$filter_query = $this->getFilter($filters,true,true);
7861
+		$filter_query = $this->getFilter($filters, true, true);
7862 7862
 		if ($globalDBdriver == 'mysql') {
7863 7863
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7864 7864
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -7879,7 +7879,7 @@  discard block
 block discarded – undo
7879 7879
 		$date_array = array();
7880 7880
 		$temp_array = array();
7881 7881
         
7882
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7882
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7883 7883
 		{
7884 7884
 			$temp_array['date_name'] = $row['date_name'];
7885 7885
 			$temp_array['date_count'] = $row['date_count'];
@@ -7900,7 +7900,7 @@  discard block
 block discarded – undo
7900 7900
 	public function countAllDatesLastMonthByAirlines($filters = array())
7901 7901
 	{
7902 7902
 		global $globalTimezone, $globalDBdriver;
7903
-		$filter_query = $this->getFilter($filters,true,true);
7903
+		$filter_query = $this->getFilter($filters, true, true);
7904 7904
 		if ($globalTimezone != '') {
7905 7905
 			date_default_timezone_set($globalTimezone);
7906 7906
 			$datetime = new DateTime();
@@ -7908,13 +7908,13 @@  discard block
 block discarded – undo
7908 7908
 		} else $offset = '+00:00';
7909 7909
 		
7910 7910
 		if ($globalDBdriver == 'mysql') {
7911
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7911
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7912 7912
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
7913 7913
 								GROUP BY spotter_output.airline_icao, date_name 
7914 7914
 								ORDER BY spotter_output.date ASC";
7915 7915
 			$query_data = array(':offset' => $offset);
7916 7916
 		} else {
7917
-			$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
7917
+			$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
7918 7918
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
7919 7919
 								GROUP BY spotter_output.airline_icao, date_name 
7920 7920
 								ORDER BY date_name ASC";
@@ -7927,7 +7927,7 @@  discard block
 block discarded – undo
7927 7927
 		$date_array = array();
7928 7928
 		$temp_array = array();
7929 7929
         
7930
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7930
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7931 7931
 		{
7932 7932
 			$temp_array['date_name'] = $row['date_name'];
7933 7933
 			$temp_array['date_count'] = $row['date_count'];
@@ -7974,7 +7974,7 @@  discard block
 block discarded – undo
7974 7974
 		$date_array = array();
7975 7975
 		$temp_array = array();
7976 7976
         
7977
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7977
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7978 7978
 		{
7979 7979
 			$temp_array['month_name'] = $row['month_name'];
7980 7980
 			$temp_array['year_name'] = $row['year_name'];
@@ -7995,7 +7995,7 @@  discard block
 block discarded – undo
7995 7995
 	public function countAllMonthsByAirlines($filters = array())
7996 7996
 	{
7997 7997
 		global $globalTimezone, $globalDBdriver;
7998
-		$filter_query = $this->getFilter($filters,true,true);
7998
+		$filter_query = $this->getFilter($filters, true, true);
7999 7999
 		if ($globalTimezone != '') {
8000 8000
 			date_default_timezone_set($globalTimezone);
8001 8001
 			$datetime = new DateTime();
@@ -8003,12 +8003,12 @@  discard block
 block discarded – undo
8003 8003
 		} else $offset = '+00:00';
8004 8004
 
8005 8005
 		if ($globalDBdriver == 'mysql') {
8006
-			$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
8006
+			$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
8007 8007
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
8008 8008
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
8009 8009
 								ORDER BY date_count DESC";
8010 8010
 		} else {
8011
-			$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
8011
+			$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
8012 8012
 								FROM spotter_output 
8013 8013
 								WHERE spotter_output.airline_icao <> '' 
8014 8014
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
@@ -8022,7 +8022,7 @@  discard block
 block discarded – undo
8022 8022
 		$date_array = array();
8023 8023
 		$temp_array = array();
8024 8024
         
8025
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8025
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8026 8026
 		{
8027 8027
 			$temp_array['month_name'] = $row['month_name'];
8028 8028
 			$temp_array['year_name'] = $row['year_name'];
@@ -8049,14 +8049,14 @@  discard block
 block discarded – undo
8049 8049
 			$datetime = new DateTime();
8050 8050
 			$offset = $datetime->format('P');
8051 8051
 		} else $offset = '+00:00';
8052
-		$filter_query = $this->getFilter($filters,true,true);
8052
+		$filter_query = $this->getFilter($filters, true, true);
8053 8053
 		if ($globalDBdriver == 'mysql') {
8054
-			$query  = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8054
+			$query = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8055 8055
 								FROM spotter_output s".$filter_query." s.airline_type = 'military'
8056 8056
 								GROUP BY year_name, month_name 
8057 8057
 								ORDER BY date_count DESC";
8058 8058
 		} else {
8059
-			$query  = "SELECT EXTRACT(YEAR FROM s.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM s.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8059
+			$query = "SELECT EXTRACT(YEAR FROM s.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM s.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8060 8060
 								FROM spotter_output s".$filter_query." s.airline_type = 'military'
8061 8061
 								GROUP BY year_name, month_name 
8062 8062
 								ORDER BY date_count DESC";
@@ -8068,7 +8068,7 @@  discard block
 block discarded – undo
8068 8068
 		$date_array = array();
8069 8069
 		$temp_array = array();
8070 8070
         
8071
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8071
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8072 8072
 		{
8073 8073
 			$temp_array['month_name'] = $row['month_name'];
8074 8074
 			$temp_array['year_name'] = $row['year_name'];
@@ -8094,15 +8094,15 @@  discard block
 block discarded – undo
8094 8094
 			$datetime = new DateTime();
8095 8095
 			$offset = $datetime->format('P');
8096 8096
 		} else $offset = '+00:00';
8097
-		$filter_query = $this->getFilter($filters,true,true);
8097
+		$filter_query = $this->getFilter($filters, true, true);
8098 8098
 
8099 8099
 		if ($globalDBdriver == 'mysql') {
8100
-			$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
8100
+			$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
8101 8101
 								FROM spotter_output".$filter_query." owner_name <> ''
8102 8102
 								GROUP BY year_name, month_name
8103 8103
 								ORDER BY date_count DESC";
8104 8104
 		} else {
8105
-			$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
8105
+			$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
8106 8106
 								FROM spotter_output".$filter_query." owner_name <> ''
8107 8107
 								GROUP BY year_name, month_name
8108 8108
 								ORDER BY date_count DESC";
@@ -8114,7 +8114,7 @@  discard block
 block discarded – undo
8114 8114
 		$date_array = array();
8115 8115
 		$temp_array = array();
8116 8116
         
8117
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8117
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8118 8118
 		{
8119 8119
 			$temp_array['month_name'] = $row['month_name'];
8120 8120
 			$temp_array['year_name'] = $row['year_name'];
@@ -8135,7 +8135,7 @@  discard block
 block discarded – undo
8135 8135
 	public function countAllMonthsOwnersByAirlines($filters = array())
8136 8136
 	{
8137 8137
 		global $globalTimezone, $globalDBdriver;
8138
-		$filter_query = $this->getFilter($filters,true,true);
8138
+		$filter_query = $this->getFilter($filters, true, true);
8139 8139
 		if ($globalTimezone != '') {
8140 8140
 			date_default_timezone_set($globalTimezone);
8141 8141
 			$datetime = new DateTime();
@@ -8143,12 +8143,12 @@  discard block
 block discarded – undo
8143 8143
 		} else $offset = '+00:00';
8144 8144
 
8145 8145
 		if ($globalDBdriver == 'mysql') {
8146
-			$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
8146
+			$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
8147 8147
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
8148 8148
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8149 8149
 								ORDER BY date_count DESC";
8150 8150
 		} else {
8151
-			$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
8151
+			$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
8152 8152
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
8153 8153
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8154 8154
 								ORDER BY date_count DESC";
@@ -8160,7 +8160,7 @@  discard block
 block discarded – undo
8160 8160
 		$date_array = array();
8161 8161
 		$temp_array = array();
8162 8162
         
8163
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8163
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8164 8164
 		{
8165 8165
 			$temp_array['month_name'] = $row['month_name'];
8166 8166
 			$temp_array['year_name'] = $row['year_name'];
@@ -8187,15 +8187,15 @@  discard block
 block discarded – undo
8187 8187
 			$datetime = new DateTime();
8188 8188
 			$offset = $datetime->format('P');
8189 8189
 		} else $offset = '+00:00';
8190
-		$filter_query = $this->getFilter($filters,true,true);
8190
+		$filter_query = $this->getFilter($filters, true, true);
8191 8191
 
8192 8192
 		if ($globalDBdriver == 'mysql') {
8193
-			$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
8193
+			$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
8194 8194
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
8195 8195
 								GROUP BY year_name, month_name
8196 8196
 								ORDER BY date_count DESC";
8197 8197
 		} else {
8198
-			$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
8198
+			$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
8199 8199
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
8200 8200
 								GROUP BY year_name, month_name
8201 8201
 								ORDER BY date_count DESC";
@@ -8207,7 +8207,7 @@  discard block
 block discarded – undo
8207 8207
 		$date_array = array();
8208 8208
 		$temp_array = array();
8209 8209
         
8210
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8210
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8211 8211
 		{
8212 8212
 			$temp_array['month_name'] = $row['month_name'];
8213 8213
 			$temp_array['year_name'] = $row['year_name'];
@@ -8228,7 +8228,7 @@  discard block
 block discarded – undo
8228 8228
 	public function countAllMonthsPilotsByAirlines($filters = array())
8229 8229
 	{
8230 8230
 		global $globalTimezone, $globalDBdriver;
8231
-		$filter_query = $this->getFilter($filters,true,true);
8231
+		$filter_query = $this->getFilter($filters, true, true);
8232 8232
 		if ($globalTimezone != '') {
8233 8233
 			date_default_timezone_set($globalTimezone);
8234 8234
 			$datetime = new DateTime();
@@ -8236,12 +8236,12 @@  discard block
 block discarded – undo
8236 8236
 		} else $offset = '+00:00';
8237 8237
 
8238 8238
 		if ($globalDBdriver == 'mysql') {
8239
-			$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
8239
+			$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
8240 8240
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
8241 8241
 								GROUP BY spotter_output.airline_icao,year_name, month_name
8242 8242
 								ORDER BY date_count DESC";
8243 8243
 		} else {
8244
-			$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
8244
+			$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
8245 8245
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
8246 8246
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8247 8247
 								ORDER BY date_count DESC";
@@ -8253,7 +8253,7 @@  discard block
 block discarded – undo
8253 8253
 		$date_array = array();
8254 8254
 		$temp_array = array();
8255 8255
         
8256
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8256
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8257 8257
 		{
8258 8258
 			$temp_array['month_name'] = $row['month_name'];
8259 8259
 			$temp_array['year_name'] = $row['year_name'];
@@ -8275,7 +8275,7 @@  discard block
 block discarded – undo
8275 8275
 	public function countAllMonthsAirlines($filters = array())
8276 8276
 	{
8277 8277
 		global $globalTimezone, $globalDBdriver;
8278
-		$filter_query = $this->getFilter($filters,true,true);
8278
+		$filter_query = $this->getFilter($filters, true, true);
8279 8279
 		if ($globalTimezone != '') {
8280 8280
 			date_default_timezone_set($globalTimezone);
8281 8281
 			$datetime = new DateTime();
@@ -8283,12 +8283,12 @@  discard block
 block discarded – undo
8283 8283
 		} else $offset = '+00:00';
8284 8284
 
8285 8285
 		if ($globalDBdriver == 'mysql') {
8286
-			$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
8286
+			$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
8287 8287
 								FROM spotter_output".$filter_query." airline_icao <> '' 
8288 8288
 								GROUP BY year_name, month_name
8289 8289
 								ORDER BY date_count DESC";
8290 8290
 		} else {
8291
-			$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
8291
+			$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
8292 8292
 								FROM spotter_output".$filter_query." airline_icao <> '' 
8293 8293
 								GROUP BY year_name, month_name
8294 8294
 								ORDER BY date_count DESC";
@@ -8300,7 +8300,7 @@  discard block
 block discarded – undo
8300 8300
 		$date_array = array();
8301 8301
 		$temp_array = array();
8302 8302
         
8303
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8303
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8304 8304
 		{
8305 8305
 			$temp_array['month_name'] = $row['month_name'];
8306 8306
 			$temp_array['year_name'] = $row['year_name'];
@@ -8326,15 +8326,15 @@  discard block
 block discarded – undo
8326 8326
 			$datetime = new DateTime();
8327 8327
 			$offset = $datetime->format('P');
8328 8328
 		} else $offset = '+00:00';
8329
-		$filter_query = $this->getFilter($filters,true,true);
8329
+		$filter_query = $this->getFilter($filters, true, true);
8330 8330
 
8331 8331
 		if ($globalDBdriver == 'mysql') {
8332
-			$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
8332
+			$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
8333 8333
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
8334 8334
 								GROUP BY year_name, month_name
8335 8335
 								ORDER BY date_count DESC";
8336 8336
 		} else {
8337
-			$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
8337
+			$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
8338 8338
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
8339 8339
 								GROUP BY year_name, month_name
8340 8340
 								ORDER BY date_count DESC";
@@ -8346,7 +8346,7 @@  discard block
 block discarded – undo
8346 8346
 		$date_array = array();
8347 8347
 		$temp_array = array();
8348 8348
         
8349
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8349
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8350 8350
 		{
8351 8351
 			$temp_array['month_name'] = $row['month_name'];
8352 8352
 			$temp_array['year_name'] = $row['year_name'];
@@ -8368,7 +8368,7 @@  discard block
 block discarded – undo
8368 8368
 	public function countAllMonthsAircraftsByAirlines($filters = array())
8369 8369
 	{
8370 8370
 		global $globalTimezone, $globalDBdriver;
8371
-		$filter_query = $this->getFilter($filters,true,true);
8371
+		$filter_query = $this->getFilter($filters, true, true);
8372 8372
 		if ($globalTimezone != '') {
8373 8373
 			date_default_timezone_set($globalTimezone);
8374 8374
 			$datetime = new DateTime();
@@ -8376,12 +8376,12 @@  discard block
 block discarded – undo
8376 8376
 		} else $offset = '+00:00';
8377 8377
 
8378 8378
 		if ($globalDBdriver == 'mysql') {
8379
-			$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
8379
+			$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
8380 8380
 								FROM spotter_output".$filter_query." aircraft_icao <> ''  AND spotter_output.airline_icao <> '' 
8381 8381
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8382 8382
 								ORDER BY date_count DESC";
8383 8383
 		} else {
8384
-			$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
8384
+			$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
8385 8385
 								FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' 
8386 8386
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8387 8387
 								ORDER BY date_count DESC";
@@ -8393,7 +8393,7 @@  discard block
 block discarded – undo
8393 8393
 		$date_array = array();
8394 8394
 		$temp_array = array();
8395 8395
         
8396
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8396
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8397 8397
 		{
8398 8398
 			$temp_array['month_name'] = $row['month_name'];
8399 8399
 			$temp_array['year_name'] = $row['year_name'];
@@ -8420,15 +8420,15 @@  discard block
 block discarded – undo
8420 8420
 			$datetime = new DateTime();
8421 8421
 			$offset = $datetime->format('P');
8422 8422
 		} else $offset = '+00:00';
8423
-		$filter_query = $this->getFilter($filters,true,true);
8423
+		$filter_query = $this->getFilter($filters, true, true);
8424 8424
 
8425 8425
 		if ($globalDBdriver == 'mysql') {
8426
-			$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
8426
+			$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
8427 8427
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
8428 8428
 								GROUP BY year_name, month_name
8429 8429
 								ORDER BY date_count DESC";
8430 8430
 		} else {
8431
-			$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
8431
+			$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
8432 8432
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
8433 8433
 								GROUP BY year_name, month_name
8434 8434
 								ORDER BY date_count DESC";
@@ -8440,7 +8440,7 @@  discard block
 block discarded – undo
8440 8440
 		$date_array = array();
8441 8441
 		$temp_array = array();
8442 8442
         
8443
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8443
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8444 8444
 		{
8445 8445
 			$temp_array['month_name'] = $row['month_name'];
8446 8446
 			$temp_array['year_name'] = $row['year_name'];
@@ -8462,7 +8462,7 @@  discard block
 block discarded – undo
8462 8462
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
8463 8463
 	{
8464 8464
 		global $globalTimezone, $globalDBdriver;
8465
-		$filter_query = $this->getFilter($filters,true,true);
8465
+		$filter_query = $this->getFilter($filters, true, true);
8466 8466
 		if ($globalTimezone != '') {
8467 8467
 			date_default_timezone_set($globalTimezone);
8468 8468
 			$datetime = new DateTime();
@@ -8470,12 +8470,12 @@  discard block
 block discarded – undo
8470 8470
 		} else $offset = '+00:00';
8471 8471
 
8472 8472
 		if ($globalDBdriver == 'mysql') {
8473
-			$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
8473
+			$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
8474 8474
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
8475 8475
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8476 8476
 								ORDER BY date_count DESC";
8477 8477
 		} else {
8478
-			$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
8478
+			$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
8479 8479
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
8480 8480
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8481 8481
 								ORDER BY date_count DESC";
@@ -8487,7 +8487,7 @@  discard block
 block discarded – undo
8487 8487
 		$date_array = array();
8488 8488
 		$temp_array = array();
8489 8489
         
8490
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8490
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8491 8491
 		{
8492 8492
 			$temp_array['month_name'] = $row['month_name'];
8493 8493
 			$temp_array['year_name'] = $row['year_name'];
@@ -8515,7 +8515,7 @@  discard block
 block discarded – undo
8515 8515
 			$datetime = new DateTime();
8516 8516
 			$offset = $datetime->format('P');
8517 8517
 		} else $offset = '+00:00';
8518
-		$filter_query = $this->getFilter($filters,true,true);
8518
+		$filter_query = $this->getFilter($filters, true, true);
8519 8519
 		if ($globalDBdriver == 'mysql') {
8520 8520
 			$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
8521 8521
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -8536,7 +8536,7 @@  discard block
 block discarded – undo
8536 8536
 		$date_array = array();
8537 8537
 		$temp_array = array();
8538 8538
         
8539
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8539
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8540 8540
 		{
8541 8541
 			$temp_array['year_name'] = $row['year_name'];
8542 8542
 			$temp_array['month_name'] = $row['month_name'];
@@ -8556,7 +8556,7 @@  discard block
 block discarded – undo
8556 8556
 	* @return Array the hour list
8557 8557
 	*
8558 8558
 	*/
8559
-	public function countAllHours($orderby,$filters = array())
8559
+	public function countAllHours($orderby, $filters = array())
8560 8560
 	{
8561 8561
 		global $globalTimezone, $globalDBdriver;
8562 8562
 		if ($globalTimezone != '') {
@@ -8604,7 +8604,7 @@  discard block
 block discarded – undo
8604 8604
 		$hour_array = array();
8605 8605
 		$temp_array = array();
8606 8606
         
8607
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8607
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8608 8608
 		{
8609 8609
 			$temp_array['hour_name'] = $row['hour_name'];
8610 8610
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8624,7 +8624,7 @@  discard block
 block discarded – undo
8624 8624
 	public function countAllHoursByAirlines($orderby, $filters = array())
8625 8625
 	{
8626 8626
 		global $globalTimezone, $globalDBdriver;
8627
-		$filter_query = $this->getFilter($filters,true,true);
8627
+		$filter_query = $this->getFilter($filters, true, true);
8628 8628
 		if ($globalTimezone != '') {
8629 8629
 			date_default_timezone_set($globalTimezone);
8630 8630
 			$datetime = new DateTime();
@@ -8642,7 +8642,7 @@  discard block
 block discarded – undo
8642 8642
 		}
8643 8643
 		
8644 8644
 		if ($globalDBdriver == 'mysql') {
8645
-			$query  = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8645
+			$query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8646 8646
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
8647 8647
 								GROUP BY spotter_output.airline_icao, hour_name 
8648 8648
 								".$orderby_sql;
@@ -8655,7 +8655,7 @@  discard block
 block discarded – undo
8655 8655
   */    
8656 8656
 		$query_data = array(':offset' => $offset);
8657 8657
 		} else {
8658
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8658
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8659 8659
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
8660 8660
 								GROUP BY spotter_output.airline_icao, hour_name 
8661 8661
 								".$orderby_sql;
@@ -8668,7 +8668,7 @@  discard block
 block discarded – undo
8668 8668
 		$hour_array = array();
8669 8669
 		$temp_array = array();
8670 8670
         
8671
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8671
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8672 8672
 		{
8673 8673
 			$temp_array['hour_name'] = $row['hour_name'];
8674 8674
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8691,34 +8691,34 @@  discard block
 block discarded – undo
8691 8691
 	public function countAllHoursByAirline($airline_icao, $filters = array())
8692 8692
 	{
8693 8693
 		global $globalTimezone, $globalDBdriver;
8694
-		$filter_query = $this->getFilter($filters,true,true);
8694
+		$filter_query = $this->getFilter($filters, true, true);
8695 8695
 		if ($globalTimezone != '') {
8696 8696
 			date_default_timezone_set($globalTimezone);
8697 8697
 			$datetime = new DateTime();
8698 8698
 			$offset = $datetime->format('P');
8699 8699
 		} else $offset = '+00:00';
8700 8700
 
8701
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8701
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
8702 8702
 
8703 8703
 		if ($globalDBdriver == 'mysql') {
8704
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8704
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8705 8705
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
8706 8706
 								GROUP BY hour_name 
8707 8707
 								ORDER BY hour_name ASC";
8708 8708
 		} else {
8709
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8709
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8710 8710
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
8711 8711
 								GROUP BY hour_name 
8712 8712
 								ORDER BY hour_name ASC";
8713 8713
 		}
8714 8714
 		
8715 8715
 		$sth = $this->db->prepare($query);
8716
-		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset));
8716
+		$sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset));
8717 8717
       
8718 8718
 		$hour_array = array();
8719 8719
 		$temp_array = array();
8720 8720
         
8721
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8721
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8722 8722
 		{
8723 8723
 			$temp_array['hour_name'] = $row['hour_name'];
8724 8724
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8741,8 +8741,8 @@  discard block
 block discarded – undo
8741 8741
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
8742 8742
 	{
8743 8743
 		global $globalTimezone, $globalDBdriver;
8744
-		$filter_query = $this->getFilter($filters,true,true);
8745
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8744
+		$filter_query = $this->getFilter($filters, true, true);
8745
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8746 8746
 		if ($globalTimezone != '') {
8747 8747
 			date_default_timezone_set($globalTimezone);
8748 8748
 			$datetime = new DateTime();
@@ -8750,24 +8750,24 @@  discard block
 block discarded – undo
8750 8750
 		} else $offset = '+00:00';
8751 8751
 
8752 8752
 		if ($globalDBdriver == 'mysql') {
8753
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8753
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8754 8754
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
8755 8755
 								GROUP BY hour_name 
8756 8756
 								ORDER BY hour_name ASC";
8757 8757
 		} else {
8758
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8758
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8759 8759
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
8760 8760
 								GROUP BY hour_name 
8761 8761
 								ORDER BY hour_name ASC";
8762 8762
 		}
8763 8763
 		
8764 8764
 		$sth = $this->db->prepare($query);
8765
-		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset));
8765
+		$sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset));
8766 8766
       
8767 8767
 		$hour_array = array();
8768 8768
 		$temp_array = array();
8769 8769
         
8770
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8770
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8771 8771
 		{
8772 8772
 			$temp_array['hour_name'] = $row['hour_name'];
8773 8773
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8788,8 +8788,8 @@  discard block
 block discarded – undo
8788 8788
 	public function countAllHoursByRegistration($registration, $filters = array())
8789 8789
 	{
8790 8790
 		global $globalTimezone, $globalDBdriver;
8791
-		$filter_query = $this->getFilter($filters,true,true);
8792
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8791
+		$filter_query = $this->getFilter($filters, true, true);
8792
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8793 8793
 		if ($globalTimezone != '') {
8794 8794
 			date_default_timezone_set($globalTimezone);
8795 8795
 			$datetime = new DateTime();
@@ -8797,24 +8797,24 @@  discard block
 block discarded – undo
8797 8797
 		} else $offset = '+00:00';
8798 8798
 
8799 8799
 		if ($globalDBdriver == 'mysql') {
8800
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8800
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8801 8801
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
8802 8802
 								GROUP BY hour_name 
8803 8803
 								ORDER BY hour_name ASC";
8804 8804
 		} else {
8805
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8805
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8806 8806
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
8807 8807
 								GROUP BY hour_name 
8808 8808
 								ORDER BY hour_name ASC";
8809 8809
 		}
8810 8810
 		
8811 8811
 		$sth = $this->db->prepare($query);
8812
-		$sth->execute(array(':registration' => $registration,':offset' => $offset));
8812
+		$sth->execute(array(':registration' => $registration, ':offset' => $offset));
8813 8813
       
8814 8814
 		$hour_array = array();
8815 8815
 		$temp_array = array();
8816 8816
         
8817
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8817
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8818 8818
 		{
8819 8819
 			$temp_array['hour_name'] = $row['hour_name'];
8820 8820
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8835,8 +8835,8 @@  discard block
 block discarded – undo
8835 8835
 	public function countAllHoursByAirport($airport_icao, $filters = array())
8836 8836
 	{
8837 8837
 		global $globalTimezone, $globalDBdriver;
8838
-		$filter_query = $this->getFilter($filters,true,true);
8839
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8838
+		$filter_query = $this->getFilter($filters, true, true);
8839
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8840 8840
 		if ($globalTimezone != '') {
8841 8841
 			date_default_timezone_set($globalTimezone);
8842 8842
 			$datetime = new DateTime();
@@ -8844,24 +8844,24 @@  discard block
 block discarded – undo
8844 8844
 		} else $offset = '+00:00';
8845 8845
 
8846 8846
 		if ($globalDBdriver == 'mysql') {
8847
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8847
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8848 8848
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8849 8849
 								GROUP BY hour_name 
8850 8850
 								ORDER BY hour_name ASC";
8851 8851
 		} else {
8852
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8852
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8853 8853
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8854 8854
 								GROUP BY hour_name 
8855 8855
 								ORDER BY hour_name ASC";
8856 8856
 		}
8857 8857
 		
8858 8858
 		$sth = $this->db->prepare($query);
8859
-		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset));
8859
+		$sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset));
8860 8860
       
8861 8861
 		$hour_array = array();
8862 8862
 		$temp_array = array();
8863 8863
         
8864
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8864
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8865 8865
 		{
8866 8866
 			$temp_array['hour_name'] = $row['hour_name'];
8867 8867
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8880,11 +8880,11 @@  discard block
 block discarded – undo
8880 8880
 	* @return Array the hour list
8881 8881
 	*
8882 8882
 	*/
8883
-	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
8883
+	public function countAllHoursByManufacturer($aircraft_manufacturer, $filters = array())
8884 8884
 	{
8885 8885
 		global $globalTimezone, $globalDBdriver;
8886
-		$filter_query = $this->getFilter($filters,true,true);
8887
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8886
+		$filter_query = $this->getFilter($filters, true, true);
8887
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8888 8888
 		if ($globalTimezone != '') {
8889 8889
 			date_default_timezone_set($globalTimezone);
8890 8890
 			$datetime = new DateTime();
@@ -8892,24 +8892,24 @@  discard block
 block discarded – undo
8892 8892
 		} else $offset = '+00:00';
8893 8893
 
8894 8894
 		if ($globalDBdriver == 'mysql') {
8895
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8895
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8896 8896
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
8897 8897
 								GROUP BY hour_name 
8898 8898
 								ORDER BY hour_name ASC";
8899 8899
 		} else {
8900
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8900
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8901 8901
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
8902 8902
 								GROUP BY hour_name 
8903 8903
 								ORDER BY hour_name ASC";
8904 8904
 		}
8905 8905
 		
8906 8906
 		$sth = $this->db->prepare($query);
8907
-		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset));
8907
+		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset));
8908 8908
       
8909 8909
 		$hour_array = array();
8910 8910
 		$temp_array = array();
8911 8911
         
8912
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8912
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8913 8913
 		{
8914 8914
 			$temp_array['hour_name'] = $row['hour_name'];
8915 8915
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8931,8 +8931,8 @@  discard block
 block discarded – undo
8931 8931
 	public function countAllHoursByDate($date, $filters = array())
8932 8932
 	{
8933 8933
 		global $globalTimezone, $globalDBdriver;
8934
-		$filter_query = $this->getFilter($filters,true,true);
8935
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8934
+		$filter_query = $this->getFilter($filters, true, true);
8935
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8936 8936
 		if ($globalTimezone != '') {
8937 8937
 			date_default_timezone_set($globalTimezone);
8938 8938
 			$datetime = new DateTime($date);
@@ -8940,12 +8940,12 @@  discard block
 block discarded – undo
8940 8940
 		} else $offset = '+00:00';
8941 8941
 
8942 8942
 		if ($globalDBdriver == 'mysql') {
8943
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8943
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8944 8944
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
8945 8945
 								GROUP BY hour_name 
8946 8946
 								ORDER BY hour_name ASC";
8947 8947
 		} else {
8948
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8948
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8949 8949
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
8950 8950
 								GROUP BY hour_name 
8951 8951
 								ORDER BY hour_name ASC";
@@ -8957,7 +8957,7 @@  discard block
 block discarded – undo
8957 8957
 		$hour_array = array();
8958 8958
 		$temp_array = array();
8959 8959
         
8960
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8960
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8961 8961
 		{
8962 8962
 			$temp_array['hour_name'] = $row['hour_name'];
8963 8963
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8979,8 +8979,8 @@  discard block
 block discarded – undo
8979 8979
 	public function countAllHoursByIdent($ident, $filters = array())
8980 8980
 	{
8981 8981
 		global $globalTimezone, $globalDBdriver;
8982
-		$filter_query = $this->getFilter($filters,true,true);
8983
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8982
+		$filter_query = $this->getFilter($filters, true, true);
8983
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8984 8984
 		if ($globalTimezone != '') {
8985 8985
 			date_default_timezone_set($globalTimezone);
8986 8986
 			$datetime = new DateTime();
@@ -8988,12 +8988,12 @@  discard block
 block discarded – undo
8988 8988
 		} else $offset = '+00:00';
8989 8989
 
8990 8990
 		if ($globalDBdriver == 'mysql') {
8991
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8991
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8992 8992
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
8993 8993
 								GROUP BY hour_name 
8994 8994
 								ORDER BY hour_name ASC";
8995 8995
 		} else {
8996
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8996
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8997 8997
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
8998 8998
 								GROUP BY hour_name 
8999 8999
 								ORDER BY hour_name ASC";
@@ -9001,12 +9001,12 @@  discard block
 block discarded – undo
9001 9001
       
9002 9002
 		
9003 9003
 		$sth = $this->db->prepare($query);
9004
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
9004
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
9005 9005
       
9006 9006
 		$hour_array = array();
9007 9007
 		$temp_array = array();
9008 9008
         
9009
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9009
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9010 9010
 		{
9011 9011
 			$temp_array['hour_name'] = $row['hour_name'];
9012 9012
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9025,12 +9025,12 @@  discard block
 block discarded – undo
9025 9025
 	* @return Array the hour list
9026 9026
 	*
9027 9027
 	*/
9028
-	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
9028
+	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
9029 9029
 	{
9030 9030
 		global $globalTimezone, $globalDBdriver;
9031
-		$filter_query = $this->getFilter($filters,true,true);
9032
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
9033
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
9031
+		$filter_query = $this->getFilter($filters, true, true);
9032
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
9033
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
9034 9034
 		if ($globalTimezone != '') {
9035 9035
 			date_default_timezone_set($globalTimezone);
9036 9036
 			$datetime = new DateTime();
@@ -9038,24 +9038,24 @@  discard block
 block discarded – undo
9038 9038
 		} else $offset = '+00:00';
9039 9039
 
9040 9040
 		if ($globalDBdriver == 'mysql') {
9041
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9041
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9042 9042
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
9043 9043
 								GROUP BY hour_name 
9044 9044
 								ORDER BY hour_name ASC";
9045 9045
 		} else {
9046
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9046
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9047 9047
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
9048 9048
 								GROUP BY hour_name 
9049 9049
 								ORDER BY hour_name ASC";
9050 9050
 		}
9051 9051
 		
9052 9052
 		$sth = $this->db->prepare($query);
9053
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset));
9053
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset));
9054 9054
       
9055 9055
 		$hour_array = array();
9056 9056
 		$temp_array = array();
9057 9057
         
9058
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9058
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9059 9059
 		{
9060 9060
 			$temp_array['hour_name'] = $row['hour_name'];
9061 9061
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9076,8 +9076,8 @@  discard block
 block discarded – undo
9076 9076
 	public function countAllHoursByCountry($country, $filters = array())
9077 9077
 	{
9078 9078
 		global $globalTimezone, $globalDBdriver;
9079
-		$filter_query = $this->getFilter($filters,true,true);
9080
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
9079
+		$filter_query = $this->getFilter($filters, true, true);
9080
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
9081 9081
 		if ($globalTimezone != '') {
9082 9082
 			date_default_timezone_set($globalTimezone);
9083 9083
 			$datetime = new DateTime();
@@ -9085,24 +9085,24 @@  discard block
 block discarded – undo
9085 9085
 		} else $offset = '+00:00';
9086 9086
 
9087 9087
 		if ($globalDBdriver == 'mysql') {
9088
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9088
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9089 9089
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
9090 9090
 								GROUP BY hour_name 
9091 9091
 								ORDER BY hour_name ASC";
9092 9092
 		} else {
9093
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9093
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9094 9094
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
9095 9095
 								GROUP BY hour_name 
9096 9096
 								ORDER BY hour_name ASC";
9097 9097
 		}
9098 9098
 		
9099 9099
 		$sth = $this->db->prepare($query);
9100
-		$sth->execute(array(':country' => $country,':offset' => $offset));
9100
+		$sth->execute(array(':country' => $country, ':offset' => $offset));
9101 9101
       
9102 9102
 		$hour_array = array();
9103 9103
 		$temp_array = array();
9104 9104
         
9105
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9105
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9106 9106
 		{
9107 9107
 			$temp_array['hour_name'] = $row['hour_name'];
9108 9108
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9124,8 +9124,8 @@  discard block
 block discarded – undo
9124 9124
 	*/
9125 9125
 	public function countOverallAircrafts($filters = array())
9126 9126
 	{
9127
-		$filter_query = $this->getFilter($filters,true,true);
9128
-		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
9127
+		$filter_query = $this->getFilter($filters, true, true);
9128
+		$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
9129 9129
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9130 9130
 		$sth = $this->db->prepare($query);
9131 9131
 		$sth->execute();
@@ -9140,8 +9140,8 @@  discard block
 block discarded – undo
9140 9140
 	*/
9141 9141
 	public function countOverallArrival($filters = array())
9142 9142
 	{
9143
-		$filter_query = $this->getFilter($filters,true,true);
9144
-		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
9143
+		$filter_query = $this->getFilter($filters, true, true);
9144
+		$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
9145 9145
                     FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''";
9146 9146
 		
9147 9147
 		$sth = $this->db->prepare($query);
@@ -9157,8 +9157,8 @@  discard block
 block discarded – undo
9157 9157
 	*/
9158 9158
 	public function countOverallPilots($filters = array())
9159 9159
 	{
9160
-		$filter_query = $this->getFilter($filters,true,true);
9161
-		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
9160
+		$filter_query = $this->getFilter($filters, true, true);
9161
+		$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
9162 9162
                     FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''";
9163 9163
 		$sth = $this->db->prepare($query);
9164 9164
 		$sth->execute();
@@ -9173,8 +9173,8 @@  discard block
 block discarded – undo
9173 9173
 	*/
9174 9174
 	public function countOverallOwners($filters = array())
9175 9175
 	{
9176
-		$filter_query = $this->getFilter($filters,true,true);
9177
-		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
9176
+		$filter_query = $this->getFilter($filters, true, true);
9177
+		$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
9178 9178
                     FROM spotter_output".$filter_query." spotter_output.owner_name <> ''";
9179 9179
 		$sth = $this->db->prepare($query);
9180 9180
 		$sth->execute();
@@ -9207,8 +9207,8 @@  discard block
 block discarded – undo
9207 9207
 	*/
9208 9208
 	public function countOverallMilitaryFlights($filters = array())
9209 9209
 	{
9210
-		$filter_query = $this->getFilter($filters,true,true);
9211
-		$query  = "SELECT COUNT(s.spotter_id) AS flight_count  
9210
+		$filter_query = $this->getFilter($filters, true, true);
9211
+		$query = "SELECT COUNT(s.spotter_id) AS flight_count  
9212 9212
                     FROM spotter_output s, airlines a".$filter_query." s.airline_icao = a.icao AND a.type = 'military'";
9213 9213
       
9214 9214
 		$sth = $this->db->prepare($query);
@@ -9245,7 +9245,7 @@  discard block
 block discarded – undo
9245 9245
 	public function countAllHoursFromToday($filters = array())
9246 9246
 	{
9247 9247
 		global $globalTimezone, $globalDBdriver;
9248
-		$filter_query = $this->getFilter($filters,true,true);
9248
+		$filter_query = $this->getFilter($filters, true, true);
9249 9249
 		if ($globalTimezone != '') {
9250 9250
 			date_default_timezone_set($globalTimezone);
9251 9251
 			$datetime = new DateTime();
@@ -9253,12 +9253,12 @@  discard block
 block discarded – undo
9253 9253
 		} else $offset = '+00:00';
9254 9254
 
9255 9255
 		if ($globalDBdriver == 'mysql') {
9256
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9256
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9257 9257
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE()
9258 9258
 								GROUP BY hour_name 
9259 9259
 								ORDER BY hour_name ASC";
9260 9260
 		} else {
9261
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9261
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9262 9262
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
9263 9263
 								GROUP BY hour_name 
9264 9264
 								ORDER BY hour_name ASC";
@@ -9270,7 +9270,7 @@  discard block
 block discarded – undo
9270 9270
 		$hour_array = array();
9271 9271
 		$temp_array = array();
9272 9272
         
9273
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9273
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9274 9274
 		{
9275 9275
 			$temp_array['hour_name'] = $row['hour_name'];
9276 9276
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9289,14 +9289,14 @@  discard block
 block discarded – undo
9289 9289
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
9290 9290
 	{
9291 9291
 		global $global_query, $globalDBdriver, $globalTimezone;
9292
-		$filter_query = $this->getFilter($filters,true,true);
9292
+		$filter_query = $this->getFilter($filters, true, true);
9293 9293
 		date_default_timezone_set('UTC');
9294 9294
 		$limit_query = '';
9295 9295
 		if ($limit != "")
9296 9296
 		{
9297 9297
 			$limit_array = explode(",", $limit);
9298
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
9299
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
9298
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
9299
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
9300 9300
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
9301 9301
 			{
9302 9302
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -9349,7 +9349,7 @@  discard block
 block discarded – undo
9349 9349
 			    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')
9350 9350
 			    HAVING count(spotter_output.ident) > 5$orderby_query";
9351 9351
 			//echo $query;
9352
-			$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone));
9352
+			$spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone));
9353 9353
 			/*
9354 9354
 			$sth = $this->db->prepare($query);
9355 9355
 			$sth->execute(array(':timezone' => $globalTimezone));
@@ -9368,9 +9368,9 @@  discard block
 block discarded – undo
9368 9368
 	*/
9369 9369
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
9370 9370
 	{
9371
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
9371
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
9372 9372
 
9373
-		$query  = "SELECT spotter_output.spotter_id
9373
+		$query = "SELECT spotter_output.spotter_id
9374 9374
 								FROM spotter_output 
9375 9375
 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'";
9376 9376
         
@@ -9378,7 +9378,7 @@  discard block
 block discarded – undo
9378 9378
 		$sth = $this->db->prepare($query);
9379 9379
 		$sth->execute();
9380 9380
 
9381
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9381
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9382 9382
 		{
9383 9383
 			return $row['spotter_id'];
9384 9384
 		}
@@ -9403,23 +9403,23 @@  discard block
 block discarded – undo
9403 9403
 		}
9404 9404
 		
9405 9405
 		$current_date = date("Y-m-d H:i:s");
9406
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
9406
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
9407 9407
 		
9408 9408
 		$diff = abs(strtotime($current_date) - strtotime($date));
9409 9409
 
9410
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
9410
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
9411 9411
 		$years = $time_array['years'];
9412 9412
 		
9413
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
9413
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
9414 9414
 		$months = $time_array['months'];
9415 9415
 		
9416
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
9416
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
9417 9417
 		$days = $time_array['days'];
9418
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
9418
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
9419 9419
 		$hours = $time_array['hours'];
9420
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
9420
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
9421 9421
 		$minutes = $time_array['minutes'];
9422
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
9422
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
9423 9423
 		
9424 9424
 		return $time_array;	
9425 9425
 	}	
@@ -9445,63 +9445,63 @@  discard block
 block discarded – undo
9445 9445
 			$temp_array['direction_degree'] = $direction;
9446 9446
 			$temp_array['direction_shortname'] = "N";
9447 9447
 			$temp_array['direction_fullname'] = "North";
9448
-		} elseif ($direction >= 22.5 && $direction < 45){
9448
+		} elseif ($direction >= 22.5 && $direction < 45) {
9449 9449
 			$temp_array['direction_degree'] = $direction;
9450 9450
 			$temp_array['direction_shortname'] = "NNE";
9451 9451
 			$temp_array['direction_fullname'] = "North-Northeast";
9452
-		} elseif ($direction >= 45 && $direction < 67.5){
9452
+		} elseif ($direction >= 45 && $direction < 67.5) {
9453 9453
 			$temp_array['direction_degree'] = $direction;
9454 9454
 			$temp_array['direction_shortname'] = "NE";
9455 9455
 			$temp_array['direction_fullname'] = "Northeast";
9456
-		} elseif ($direction >= 67.5 && $direction < 90){
9456
+		} elseif ($direction >= 67.5 && $direction < 90) {
9457 9457
 			$temp_array['direction_degree'] = $direction;
9458 9458
 			$temp_array['direction_shortname'] = "ENE";
9459 9459
 			$temp_array['direction_fullname'] = "East-Northeast";
9460
-		} elseif ($direction >= 90 && $direction < 112.5){
9460
+		} elseif ($direction >= 90 && $direction < 112.5) {
9461 9461
 			$temp_array['direction_degree'] = $direction;
9462 9462
 			$temp_array['direction_shortname'] = "E";
9463 9463
 			$temp_array['direction_fullname'] = "East";
9464
-		} elseif ($direction >= 112.5 && $direction < 135){
9464
+		} elseif ($direction >= 112.5 && $direction < 135) {
9465 9465
 			$temp_array['direction_degree'] = $direction;
9466 9466
 			$temp_array['direction_shortname'] = "ESE";
9467 9467
 			$temp_array['direction_fullname'] = "East-Southeast";
9468
-		} elseif ($direction >= 135 && $direction < 157.5){
9468
+		} elseif ($direction >= 135 && $direction < 157.5) {
9469 9469
 			$temp_array['direction_degree'] = $direction;
9470 9470
 			$temp_array['direction_shortname'] = "SE";
9471 9471
 			$temp_array['direction_fullname'] = "Southeast";
9472
-		} elseif ($direction >= 157.5 && $direction < 180){
9472
+		} elseif ($direction >= 157.5 && $direction < 180) {
9473 9473
 			$temp_array['direction_degree'] = $direction;
9474 9474
 			$temp_array['direction_shortname'] = "SSE";
9475 9475
 			$temp_array['direction_fullname'] = "South-Southeast";
9476
-		} elseif ($direction >= 180 && $direction < 202.5){
9476
+		} elseif ($direction >= 180 && $direction < 202.5) {
9477 9477
 			$temp_array['direction_degree'] = $direction;
9478 9478
 			$temp_array['direction_shortname'] = "S";
9479 9479
 			$temp_array['direction_fullname'] = "South";
9480
-		} elseif ($direction >= 202.5 && $direction < 225){
9480
+		} elseif ($direction >= 202.5 && $direction < 225) {
9481 9481
 			$temp_array['direction_degree'] = $direction;
9482 9482
 			$temp_array['direction_shortname'] = "SSW";
9483 9483
 			$temp_array['direction_fullname'] = "South-Southwest";
9484
-		} elseif ($direction >= 225 && $direction < 247.5){
9484
+		} elseif ($direction >= 225 && $direction < 247.5) {
9485 9485
 			$temp_array['direction_degree'] = $direction;
9486 9486
 			$temp_array['direction_shortname'] = "SW";
9487 9487
 			$temp_array['direction_fullname'] = "Southwest";
9488
-		} elseif ($direction >= 247.5 && $direction < 270){
9488
+		} elseif ($direction >= 247.5 && $direction < 270) {
9489 9489
 			$temp_array['direction_degree'] = $direction;
9490 9490
 			$temp_array['direction_shortname'] = "WSW";
9491 9491
 			$temp_array['direction_fullname'] = "West-Southwest";
9492
-		} elseif ($direction >= 270 && $direction < 292.5){
9492
+		} elseif ($direction >= 270 && $direction < 292.5) {
9493 9493
 			$temp_array['direction_degree'] = $direction;
9494 9494
 			$temp_array['direction_shortname'] = "W";
9495 9495
 			$temp_array['direction_fullname'] = "West";
9496
-		} elseif ($direction >= 292.5 && $direction < 315){
9496
+		} elseif ($direction >= 292.5 && $direction < 315) {
9497 9497
 			$temp_array['direction_degree'] = $direction;
9498 9498
 			$temp_array['direction_shortname'] = "WNW";
9499 9499
 			$temp_array['direction_fullname'] = "West-Northwest";
9500
-		} elseif ($direction >= 315 && $direction < 337.5){
9500
+		} elseif ($direction >= 315 && $direction < 337.5) {
9501 9501
 			$temp_array['direction_degree'] = $direction;
9502 9502
 			$temp_array['direction_shortname'] = "NW";
9503 9503
 			$temp_array['direction_fullname'] = "Northwest";
9504
-		} elseif ($direction >= 337.5 && $direction < 360){
9504
+		} elseif ($direction >= 337.5 && $direction < 360) {
9505 9505
 			$temp_array['direction_degree'] = $direction;
9506 9506
 			$temp_array['direction_shortname'] = "NNW";
9507 9507
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -9554,9 +9554,9 @@  discard block
 block discarded – undo
9554 9554
 	*/
9555 9555
 	public function getAircraftRegistrationBymodeS($aircraft_modes)
9556 9556
 	{
9557
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
9557
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
9558 9558
 	
9559
-		$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9559
+		$query = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9560 9560
 		
9561 9561
 		$sth = $this->db->prepare($query);
9562 9562
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -9579,9 +9579,9 @@  discard block
 block discarded – undo
9579 9579
 	*/
9580 9580
 	public function getAircraftTypeBymodeS($aircraft_modes)
9581 9581
 	{
9582
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
9582
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
9583 9583
 	
9584
-		$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9584
+		$query = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9585 9585
 		
9586 9586
 		$sth = $this->db->prepare($query);
9587 9587
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -9602,11 +9602,11 @@  discard block
 block discarded – undo
9602 9602
 	* @param Float $longitude longitute of the flight
9603 9603
 	* @return String the countrie
9604 9604
 	*/
9605
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
9605
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
9606 9606
 	{
9607 9607
 		global $globalDBdriver, $globalDebug;
9608
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9609
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9608
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
9609
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
9610 9610
 	
9611 9611
 		$Connection = new Connection($this->db);
9612 9612
 		if (!$Connection->tableExists('countries')) return '';
@@ -9646,19 +9646,19 @@  discard block
 block discarded – undo
9646 9646
 	*/
9647 9647
 	public function convertAircraftRegistration($registration)
9648 9648
 	{
9649
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
9649
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
9650 9650
 		$registration_prefix = '';
9651 9651
 		$registration_1 = substr($registration, 0, 1);
9652 9652
 		$registration_2 = substr($registration, 0, 2);
9653 9653
 
9654 9654
 		//first get the prefix based on two characters
9655
-		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
9655
+		$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
9656 9656
       
9657 9657
 		
9658 9658
 		$sth = $this->db->prepare($query);
9659 9659
 		$sth->execute(array(':registration_2' => $registration_2));
9660 9660
         
9661
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9661
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9662 9662
 		{
9663 9663
 			$registration_prefix = $row['registration_prefix'];
9664 9664
 		}
@@ -9666,11 +9666,11 @@  discard block
 block discarded – undo
9666 9666
 		//if we didn't find a two chracter prefix lets just search the one with one character
9667 9667
 		if ($registration_prefix == '')
9668 9668
 		{
9669
-			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
9669
+			$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
9670 9670
 			$sth = $this->db->prepare($query);
9671 9671
 			$sth->execute(array(':registration_1' => $registration_1));
9672 9672
 	        
9673
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9673
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9674 9674
 			{
9675 9675
 				$registration_prefix = $row['registration_prefix'];
9676 9676
 			}
@@ -9684,7 +9684,7 @@  discard block
 block discarded – undo
9684 9684
 			} else {
9685 9685
 				$registration = preg_replace("/^(.{1})/", "$1-", $registration);
9686 9686
 			}
9687
-		} else if(strlen($registration_prefix) == 2){
9687
+		} else if (strlen($registration_prefix) == 2) {
9688 9688
 			if (0 === strpos($registration, 'N')) {
9689 9689
 				$registration = preg_replace("/^(.{2})/", "$1", $registration);
9690 9690
 			} else {
@@ -9703,17 +9703,17 @@  discard block
 block discarded – undo
9703 9703
 	*/
9704 9704
 	public function countryFromAircraftRegistration($registration)
9705 9705
 	{
9706
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
9706
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
9707 9707
 		
9708 9708
 		$registration_prefix = '';
9709
-		$registration_test = explode('-',$registration);
9709
+		$registration_test = explode('-', $registration);
9710 9710
 		$country = '';
9711 9711
 		if ($registration_test[0] != $registration) {
9712 9712
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9713 9713
 	      
9714 9714
 			$sth = $this->db->prepare($query);
9715 9715
 			$sth->execute(array(':registration_1' => $registration_test[0]));
9716
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9716
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9717 9717
 			{
9718 9718
 				//$registration_prefix = $row['registration_prefix'];
9719 9719
 				$country = $row['country'];
@@ -9724,13 +9724,13 @@  discard block
 block discarded – undo
9724 9724
 
9725 9725
 			$country = '';
9726 9726
 			//first get the prefix based on two characters
9727
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
9727
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
9728 9728
       
9729 9729
 			
9730 9730
 			$sth = $this->db->prepare($query);
9731 9731
 			$sth->execute(array(':registration_2' => $registration_2));
9732 9732
         
9733
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9733
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9734 9734
 			{
9735 9735
 				$registration_prefix = $row['registration_prefix'];
9736 9736
 				$country = $row['country'];
@@ -9739,12 +9739,12 @@  discard block
 block discarded – undo
9739 9739
 			//if we didn't find a two chracter prefix lets just search the one with one character
9740 9740
 			if ($registration_prefix == "")
9741 9741
 			{
9742
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9742
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9743 9743
 	      
9744 9744
 				$sth = $this->db->prepare($query);
9745 9745
 				$sth->execute(array(':registration_1' => $registration_1));
9746 9746
 	        
9747
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
9747
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9748 9748
 				{
9749 9749
 					//$registration_prefix = $row['registration_prefix'];
9750 9750
 					$country = $row['country'];
@@ -9761,9 +9761,9 @@  discard block
 block discarded – undo
9761 9761
 	* @param String $flightaware_id flightaware_id from spotter_output table
9762 9762
 	* @param String $highlight New highlight value
9763 9763
 	*/
9764
-	public function setHighlightFlight($flightaware_id,$highlight) {
9764
+	public function setHighlightFlight($flightaware_id, $highlight) {
9765 9765
 		
9766
-		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
9766
+		$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
9767 9767
 		$sth = $this->db->prepare($query);
9768 9768
 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight));
9769 9769
 	}
@@ -9792,7 +9792,7 @@  discard block
 block discarded – undo
9792 9792
 		
9793 9793
 		$bitly_data = json_decode($bitly_data);
9794 9794
 		$bitly_url = '';
9795
-		if ($bitly_data->status_txt = "OK"){
9795
+		if ($bitly_data->status_txt = "OK") {
9796 9796
 			$bitly_url = $bitly_data->data->url;
9797 9797
 		}
9798 9798
 
@@ -9802,7 +9802,7 @@  discard block
 block discarded – undo
9802 9802
 
9803 9803
 	public function getOrderBy()
9804 9804
 	{
9805
-		$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"));
9805
+		$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"));
9806 9806
 		
9807 9807
 		return $orderby;
9808 9808
 		
@@ -9936,14 +9936,14 @@  discard block
 block discarded – undo
9936 9936
 		}
9937 9937
 		$sth = $this->db->prepare($query);
9938 9938
 		$sth->execute();
9939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9940 9940
 		{
9941 9941
 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']);
9942 9942
 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']);
9943 9943
 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) {
9944
-				$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";
9944
+				$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";
9945 9945
 				$sthu = $this->db->prepare($update_query);
9946
-				$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']));
9946
+				$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']));
9947 9947
 			}
9948 9948
 		}
9949 9949
 		
@@ -9956,7 +9956,7 @@  discard block
 block discarded – undo
9956 9956
 		}
9957 9957
 		$sth = $this->db->prepare($query);
9958 9958
 		$sth->execute();
9959
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9959
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9960 9960
 		{
9961 9961
 			if (is_numeric(substr($row['ident'], -1, 1)))
9962 9962
 			{
@@ -9965,11 +9965,11 @@  discard block
 block discarded – undo
9965 9965
 				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
9966 9966
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
9967 9967
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
9968
-				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
9968
+				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
9969 9969
 				if (isset($airline_array[0]['name'])) {
9970
-					$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";
9970
+					$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";
9971 9971
 					$sthu = $this->db->prepare($update_query);
9972
-					$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']));
9972
+					$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']));
9973 9973
 				}
9974 9974
 			}
9975 9975
 		}
@@ -9989,18 +9989,18 @@  discard block
 block discarded – undo
9989 9989
 		}
9990 9990
 		$sth = $this->db->prepare($query);
9991 9991
 		$sth->execute();
9992
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9992
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9993 9993
 		{
9994 9994
 			if ($row['aircraft_icao'] != '') {
9995 9995
 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']);
9996
-				if ($row['registration'] != ""){
9996
+				if ($row['registration'] != "") {
9997 9997
 					$image_array = $Image->getSpotterImage($row['registration']);
9998 9998
 					if (count($image_array) == 0) {
9999 9999
 						$Image->addSpotterImage($row['registration']);
10000 10000
 					}
10001 10001
 				}
10002 10002
 				if (count($aircraft_name) > 0) {
10003
-					$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";
10003
+					$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";
10004 10004
 					$sthu = $this->db->prepare($update_query);
10005 10005
 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id']));
10006 10006
 				}
@@ -10015,10 +10015,10 @@  discard block
 block discarded – undo
10015 10015
 		$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";
10016 10016
 		$sth = $this->db->prepare($query);
10017 10017
 		$sth->execute();
10018
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10018
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10019 10019
 		{
10020 10020
 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') {
10021
-				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist);
10021
+				$closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist);
10022 10022
 				$airport_icao = '';
10023 10023
 				 if (isset($closestAirports[0])) {
10024 10024
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
@@ -10032,7 +10032,7 @@  discard block
 block discarded – undo
10032 10032
 								break;
10033 10033
 							}
10034 10034
 						}
10035
-					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
10035
+					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) {
10036 10036
 						$airport_icao = $closestAirports[0]['icao'];
10037 10037
 						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";
10038 10038
 					} else {
@@ -10043,28 +10043,28 @@  discard block
 block discarded – undo
10043 10043
 				}
10044 10044
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
10045 10045
 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
10046
-					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10046
+					$update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10047 10047
 					$sthu = $this->db->prepare($update_query);
10048
-					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
10048
+					$sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id']));
10049 10049
 				}
10050 10050
 			}
10051 10051
 		}
10052 10052
 	}
10053 10053
 	
10054
-	public function closestAirports($origLat,$origLon,$dist = 10) {
10054
+	public function closestAirports($origLat, $origLon, $dist = 10) {
10055 10055
 		global $globalDBdriver;
10056
-		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
10056
+		$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
10057 10057
 /*
10058 10058
 		$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 
10059 10059
                       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)) 
10060 10060
                       having distance < $dist ORDER BY distance limit 100;";
10061 10061
 */
10062 10062
 		if ($globalDBdriver == 'mysql') {
10063
-			$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 
10063
+			$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 
10064 10064
 	                      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)) 
10065 10065
 	                      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;";
10066 10066
                 } else {
10067
-			$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 
10067
+			$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 
10068 10068
 	                      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)) 
10069 10069
 	                      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;";
10070 10070
     		}
Please login to merge, or discard this patch.