Completed
Push — master ( 0da4d1...d670f0 )
by Yannick
15:46
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.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  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
 ?>
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script>
188 188
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
189 189
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
190
-<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>
190
+<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>
191 191
 <?php
192 192
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
193 193
 ?>
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script>
242 242
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
243 243
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
244
-<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>
244
+<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>
245 245
 <?php
246 246
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
247 247
 ?>
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 ?>
405 405
       <div class="search">
406 406
       <form action="<?php print $globalURL; ?>/search" method="get">
407
-		<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>
407
+		<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>
408 408
 	</form>
409 409
 	</div>
410 410
   	<div class="social">
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
 	print '</div>';
423 423
 }
424 424
 
425
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
425
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
426 426
 ?>
427 427
     <div class="top-header clear" role="main">
428 428
     <div id="archive-map"></div>
429 429
     </div>
430 430
 <?php
431 431
 }
432
-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))
432
+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))
433 433
 {
434 434
     ?>
435 435
     <div class="top-header clear" role="main">
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
         var zoom = 13;
443 443
 //create the map
444 444
 <?php
445
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
445
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
446 446
 ?>
447 447
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
448 448
 <?php
449
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
449
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
450 450
 ?>
451 451
   map = L.map('map', { zoomControl:true });
452 452
 <?php
453
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
453
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
454 454
 ?>
455 455
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
456 456
     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);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
     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);
459 459
     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);
460 460
 <?php
461
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
461
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
462 462
 ?>
463 463
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
464 464
 <?php
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 ?>
146 146
 <?php 
147
-    if (isset($_POST['archive'])) {
147
+	if (isset($_POST['archive'])) {
148 148
 ?>
149 149
 <?php
150 150
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 //	}
162 162
 ?>
163 163
 <?php    
164
-    } else {
164
+	} else {
165 165
 ?>
166 166
 <?php
167 167
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -173,17 +173,17 @@  discard block
 block discarded – undo
173 173
 */
174 174
 ?>
175 175
 <?php 
176
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
176
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
177 177
 ?>
178 178
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>"></script>
179 179
 <?php
180
-	    }
180
+		}
181 181
 ?>
182 182
 <?php
183 183
 //	}
184 184
 ?>
185 185
 <?php
186
-    }
186
+	}
187 187
 }
188 188
 ?>
189 189
 <?php
@@ -343,23 +343,23 @@  discard block
 block discarded – undo
343 343
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
344 344
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
345 345
             <?php
346
-        	if ($globalACARS) {
347
-        	    if (isset($globalDemo) && $globalDemo) {
348
-    	    ?>
346
+			if ($globalACARS) {
347
+				if (isset($globalDemo) && $globalDemo) {
348
+			?>
349 349
             <li><hr /></li>
350 350
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
351 351
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
352 352
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
353 353
             <?php
354
-        	    } else {
355
-    	    ?>
354
+				} else {
355
+			?>
356 356
             <li><hr /></li>
357 357
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
358 358
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
359 359
             <?php
360
-        	    }
361
-        	}
362
-    	    ?>
360
+				}
361
+			}
362
+			?>
363 363
             <li><hr /></li>
364 364
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
365 365
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
   	    <form>
402 402
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
403 403
   		    <?php
404
-  		        $Language = new Language();
405
-  		        $alllang = $Language->getLanguages();
406
-  		        foreach ($alllang as $key => $lang) {
407
-  		            print '<option value="'.$key.'"';
408
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
409
-  		            print '>'.$lang[0].'</option>';
410
-  		        }
411
-  		    ?>
404
+  				$Language = new Language();
405
+  				$alllang = $Language->getLanguages();
406
+  				foreach ($alllang as $key => $lang) {
407
+  					print '<option value="'.$key.'"';
408
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
409
+  					print '>'.$lang[0].'</option>';
410
+  				}
411
+  			?>
412 412
   		</select>
413 413
   	    </form>
414 414
   	</div>
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 }
445 445
 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))
446 446
 {
447
-    ?>
447
+	?>
448 448
     <div class="top-header clear" role="main">
449 449
         <div id="map"></div>
450 450
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
         var zoom = 13;
456 456
 //create the map
457 457
 <?php
458
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
458
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
459 459
 ?>
460 460
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
461 461
 <?php
462
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
462
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
463 463
 ?>
464 464
   map = L.map('map', { zoomControl:true });
465 465
 <?php
466
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
466
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
467 467
 ?>
468 468
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
469 469
     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);
@@ -471,22 +471,22 @@  discard block
 block discarded – undo
471 471
     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);
472 472
     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);
473 473
 <?php
474
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
474
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
475 475
 ?>
476 476
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
477 477
 <?php
478
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
478
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
479 479
 ?>
480 480
   map = L.map('map', { zoomControl:true });
481 481
 <?php
482
-    }
482
+	}
483 483
 ?>
484 484
   //initialize the layer group for the aircrft markers
485 485
   var layer_data = L.layerGroup();
486 486
 
487 487
   //a few title layers
488 488
 <?php
489
-    if ($globalMapProvider == 'Mapbox') {
489
+	if ($globalMapProvider == 'Mapbox') {
490 490
 ?>
491 491
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
492 492
     maxZoom: 18,
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     token : '<?php print $globalMapboxToken; ?>'
498 498
   }).addTo(map);
499 499
 <?php
500
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
500
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
501 501
 ?>
502 502
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
503 503
     maxZoom: 18,
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
506 506
   }).addTo(map);
507 507
 <?php
508
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
508
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
509 509
 ?>
510 510
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
511 511
     maxZoom: 18,
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
515 515
   }).addTo(map);
516 516
 <?php
517
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
517
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
518 518
 ?>
519 519
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
520 520
     maxZoom: 18,
@@ -523,27 +523,27 @@  discard block
 block discarded – undo
523 523
       '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"'
524 524
   }).addTo(map);
525 525
 <?php
526
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
526
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
527 527
 ?>
528 528
     var googleLayer = new L.Google('ROADMAP');
529 529
     map.addLayer(googleLayer);
530 530
 <?php
531
-    } elseif ($globalMapProvider == 'Google-Satellite') {
531
+	} elseif ($globalMapProvider == 'Google-Satellite') {
532 532
 ?>
533 533
     var googleLayer = new L.Google('SATELLITE');
534 534
     map.addLayer(googleLayer);
535 535
 <?php
536
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
536
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
537 537
 ?>
538 538
     var googleLayer = new L.Google('HYBRID');
539 539
     map.addLayer(googleLayer);
540 540
 <?php
541
-    } elseif ($globalMapProvider == 'Google-Terrain') {
541
+	} elseif ($globalMapProvider == 'Google-Terrain') {
542 542
 ?>
543 543
     var googleLayer = new L.Google('Terrain');
544 544
     map.addLayer(googleLayer);
545 545
 <?php
546
-    }
546
+	}
547 547
 ?>
548 548
         </script>
549 549
     </div>
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.
index.php 3 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 require_once('require/class.Satellite.php');
6 6
 
7
-$trackident = filter_input(INPUT_GET,'trackid',FILTER_SANITIZE_STRING);
7
+$trackident = filter_input(INPUT_GET, 'trackid', FILTER_SANITIZE_STRING);
8 8
 if ($trackident != '') {
9 9
 	require_once('require/class.SpotterLive.php');
10 10
 	$SpotterLive = new SpotterLive();
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		$spotterid = $Spotter->getSpotterIDBasedOnFlightAwareID($trackident);
15 15
 		header('Location: '.$globalURL.'/flightid/'.$spotterid);
16 16
 	} else {
17
-		setcookie('MapTrack',$resulttrackident[0]['flightaware_id']);
17
+		setcookie('MapTrack', $resulttrackident[0]['flightaware_id']);
18 18
 	}
19 19
 } else {
20 20
 	unset($_COOKIE['MapTrack']);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		        <div class="form-group">
119 119
 			    <label>From (UTC):</label>
120 120
 		            <div class='input-group date' id='datetimepicker1'>
121
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) print date("d/m/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
121
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) print date("d/m/Y h:i a", $_COOKIE['archive_begin']); ?>" required />
122 122
 		                <span class="input-group-addon">
123 123
             			    <span class="glyphicon glyphicon-calendar"></span>
124 124
 		                </span>
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		        <div class="form-group">
128 128
 			    <label>To (UTC):</label>
129 129
 		            <div class='input-group date' id='datetimepicker2'>
130
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) print date("d/m/Y h:i a",$_COOKIE['archive_end']); ?>" />
130
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) print date("d/m/Y h:i a", $_COOKIE['archive_end']); ?>" />
131 131
             			<span class="input-group-addon">
132 132
 		                    <span class="glyphicon glyphicon-calendar"></span>
133 133
             			</span>
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 		    <li><?php echo _("Type of Terrain:"); ?>
249 249
 			<select  class="selectpicker" onchange="terrainType(this);">
250 250
 			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
251
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
252
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
251
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected'; ?>>ellipsoid</option>
252
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected'; ?>>vr terrain</option>
253 253
 			</select>
254 254
 		    </li>
255 255
 <?php
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
 			<select class="selectpicker" multiple onchange="airlines(this);">
347 347
 			    <?php
348 348
 				$Spotter = new Spotter();
349
-				foreach($Spotter->getAllAirlineNames() as $airline) {
349
+				foreach ($Spotter->getAllAirlineNames() as $airline) {
350 350
 					$airline_name = $airline['airline_name'];
351
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
352
-					if (isset($_COOKIE['Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['Airlines']))) {
351
+					if (strlen($airline_name) > 30) $airline_name = substr($airline_name, 0, 30).'...';
352
+					if (isset($_COOKIE['Airlines']) && in_array($airline['airline_icao'], explode(',', $_COOKIE['Airlines']))) {
353 353
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
354 354
 					} else {
355 355
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 			<select class="selectpicker" multiple onchange="sources(this);">
366 366
 			    <?php
367 367
 				$Spotter = new Spotter();
368
-				foreach($Spotter->getAllSourceName('aprs') as $source) {
369
-					if (isset($_COOKIE['Sources']) && in_array($source['source_name'],explode(',',$_COOKIE['Sources']))) {
368
+				foreach ($Spotter->getAllSourceName('aprs') as $source) {
369
+					if (isset($_COOKIE['Sources']) && in_array($source['source_name'], explode(',', $_COOKIE['Sources']))) {
370 370
 						echo '<option value="'.$source['source_name'].'" selected>'.$source['source_name'].'</option>';
371 371
 					} else {
372 372
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
452 452
 					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
453 453
 					
454
-					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
454
+					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'], explode(',', $_COOKIE['sattypes']))) {
455 455
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
456 456
 					} else {
457 457
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 <div id="showdetails" class="showdetails"></div>
35 35
 <div id="infobox" class="infobox"></div>
36 36
 <?php
37
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
37
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
38 38
 
39 39
 ?>
40 40
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
41 41
 <?php
42
-    }
42
+	}
43 43
 ?>
44 44
 <div id="dialog" title="<?php echo _("Session has timed-out"); ?>">
45 45
   <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p>
@@ -53,31 +53,31 @@  discard block
 block discarded – undo
53 53
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
54 54
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
55 55
 <?php
56
-    if (isset($globalArchive) && $globalArchive == TRUE && (isset($globalBeta) && $globalBeta == TRUE)) {
56
+	if (isset($globalArchive) && $globalArchive == TRUE && (isset($globalBeta) && $globalBeta == TRUE)) {
57 57
 ?>
58 58
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
59 59
 <?php
60
-    }
60
+	}
61 61
 ?>
62 62
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
63 63
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
64 64
 <?php
65
-    if (isset($globalMap3D) && $globalMap3D) {
65
+	if (isset($globalMap3D) && $globalMap3D) {
66 66
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
67 67
 ?>
68 68
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
69 69
 <?php
70
-        } else {
71
-    	    if (isset($globalMapSatellites) && $globalMapSatellites) {
70
+		} else {
71
+			if (isset($globalMapSatellites) && $globalMapSatellites) {
72 72
 ?>
73 73
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
74 74
 <?php
75
-	    }
75
+		}
76 76
 ?>
77 77
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
78 78
 <?php
79 79
 	}
80
-    }
80
+	}
81 81
 ?>
82 82
     </ul>
83 83
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 ?>
110 110
         </div>
111 111
 <?php
112
-    if (isset($globalArchive) && $globalArchive == TRUE) {
112
+	if (isset($globalArchive) && $globalArchive == TRUE) {
113 113
 ?>
114 114
         <div class="sidebar-pane" id="archive">
115 115
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	    </form>
166 166
 	</div>
167 167
 <?php
168
-    }
168
+	}
169 169
 ?>
170 170
         <div class="sidebar-pane" id="settings">
171 171
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -176,56 +176,56 @@  discard block
 block discarded – undo
176 176
 			    <?php
177 177
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
178 178
 				else $MapType = $_COOKIE['MapType'];
179
-			    ?>
179
+				?>
180 180
 			    <?php
181 181
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
182
-			    ?>
182
+				?>
183 183
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
184 184
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
185 185
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
186 186
 			    <?php
187 187
 				}
188
-			    ?>
188
+				?>
189 189
 			    <?php
190
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
191
-			    ?>
190
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
191
+				?>
192 192
 			    <?php
193
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
194
-			    ?>
193
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
194
+				?>
195 195
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
196 196
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
197 197
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
198 198
 			    <?php
199
-				    }
200
-			    ?>
199
+					}
200
+				?>
201 201
 			    <?php
202
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
203
-			    ?>
202
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
203
+				?>
204 204
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
205 205
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
206 206
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
207 207
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
208 208
 			    <?php
209
-				    }
210
-			    ?>
209
+					}
210
+				?>
211 211
 			    <?php
212
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
213
-			    ?>
212
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
213
+				?>
214 214
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
215 215
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
216 216
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
217 217
 			    <?php
218
-				    }
219
-			    ?>
218
+					}
219
+				?>
220 220
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
221 221
 			    <?php
222 222
 				}
223
-			    ?>
223
+				?>
224 224
 			    <?php
225
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
225
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
226 226
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
227 227
 					else $MapBoxId = $_COOKIE['MapTypeId'];
228
-			    ?>
228
+				?>
229 229
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
230 230
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
231 231
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
240 240
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
241 241
 			    <?php
242
-				    }
243
-			    ?>
242
+					}
243
+				?>
244 244
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
245 245
 			</select>
246 246
 		    </li>
247 247
 <?php
248
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
248
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
249 249
 ?>
250 250
 		    <li><?php echo _("Type of Terrain:"); ?>
251 251
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
 			</select>
256 256
 		    </li>
257 257
 <?php
258
-    }
258
+	}
259 259
 ?>
260 260
 <?php
261
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
261
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
262 262
 ?>
263 263
 		    
264 264
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -266,54 +266,54 @@  discard block
 block discarded – undo
266 266
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
267 267
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
268 268
 <?php
269
-    }
269
+	}
270 270
 ?>
271 271
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
272 272
 <?php
273
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
273
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
274 274
 ?>
275 275
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
276 276
 <?php
277
-    }
277
+	}
278 278
 ?>
279 279
 
280 280
 		    <?php
281 281
 			if (function_exists('array_column')) {
282
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
283
-		    ?>
282
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
283
+			?>
284 284
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
285 285
 		    <?php
286
-			    }
286
+				}
287 287
 			} elseif (isset($globalSources)) {
288
-			    $dispolar = false;
289
-			    foreach ($globalSources as $testsource) {
290
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
291
-			    }
292
-			    if ($dispolar) {
293
-		    ?>
288
+				$dispolar = false;
289
+				foreach ($globalSources as $testsource) {
290
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
291
+				}
292
+				if ($dispolar) {
293
+			?>
294 294
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
295 295
 		    <?php
296
-			    }
297
-		        }
298
-		    ?>
296
+				}
297
+				}
298
+			?>
299 299
 <?php
300
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
300
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
301 301
 ?>
302 302
 
303 303
 		    <?php
304
-		        if (extension_loaded('gd') && function_exists('gd_info')) {
305
-		    ?>
304
+				if (extension_loaded('gd') && function_exists('gd_info')) {
305
+			?>
306 306
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
307 307
 		    <?php 
308 308
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
309
-		    ?>
309
+			?>
310 310
 		    <li><?php echo _("Aircraft icon color:"); ?>
311 311
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
312 312
 		    </li>
313 313
 		    <?php
314
-			    }
315
-		        }
316
-		    ?>
314
+				}
315
+				}
316
+			?>
317 317
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
318 318
 			<div class="range">
319 319
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -321,20 +321,20 @@  discard block
 block discarded – undo
321 321
 			</div>
322 322
 		    </li>
323 323
 <?php
324
-    }
324
+	}
325 325
 ?>
326 326
 		    <?php
327 327
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
328
-		    ?>
328
+			?>
329 329
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
330 330
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
331 331
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
332 332
 		    <?php
333 333
 			}
334
-		    ?>
334
+			?>
335 335
 		    <?php
336 336
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
337
-		    ?>
337
+			?>
338 338
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
339 339
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
340 340
 			<?php } ?>
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 			<?php } ?>
344 344
 		    <?php
345 345
 			}
346
-		    ?>
346
+			?>
347 347
 		    <li><?php echo _("Display airlines:"); ?>
348 348
 			<select class="selectpicker" multiple onchange="airlines(this);">
349 349
 			    <?php
@@ -357,12 +357,12 @@  discard block
 block discarded – undo
357 357
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
358 358
 					}
359 359
 				}
360
-			    ?>
360
+				?>
361 361
 			</select>
362 362
 		    </li>
363 363
 		    <?php
364 364
 			if (isset($globalAPRS) && $globalAPRS) {
365
-		    ?>
365
+			?>
366 366
 		    <li><?php echo _("Display APRS sources name:"); ?>
367 367
 			<select class="selectpicker" multiple onchange="sources(this);">
368 368
 			    <?php
@@ -374,15 +374,15 @@  discard block
 block discarded – undo
374 374
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
375 375
 					}
376 376
 				}
377
-			    ?>
377
+				?>
378 378
 			</select>
379 379
 		    </li>
380 380
 		    <?php
381 381
 			}
382
-		    ?>
382
+			?>
383 383
 		    <?php
384 384
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
385
-		    ?>
385
+			?>
386 386
 		    <li><?php echo _("Display airlines of type:"); ?>
387 387
 			<select class="selectpicker" onchange="airlinestype(this);">
388 388
 			    <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 		    </li>
394 394
 		    <?php
395 395
 			}
396
-		    ?>
396
+			?>
397 397
 		    <li><?php echo _("Distance unit:"); ?>
398 398
 			<select class="selectpicker" onchange="unitdistance(this);">
399 399
 			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	    <p><?php echo _("Any change in settings reload page"); ?></p>
420 420
     	</div>
421 421
 <?php
422
-    if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
422
+	if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
423 423
 ?>
424 424
         <div class="sidebar-pane" id="satellites">
425 425
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -459,14 +459,14 @@  discard block
 block discarded – undo
459 459
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
460 460
 					}
461 461
 				}
462
-			    ?>
462
+				?>
463 463
 			</select>
464 464
 		    </li>
465 465
 		</ul>
466 466
 	    </form>
467 467
 	</div>
468 468
 <?php
469
-    }
469
+	}
470 470
 ?>
471 471
     </div>
472 472
 </div>
Please login to merge, or discard this patch.
Braces   +347 added lines, -94 removed lines patch added patch discarded remove patch
@@ -108,11 +108,26 @@  discard block
 block discarded – undo
108 108
 				<li><div class="checkbox"><label><input type="checkbox" name="notam" value="1" onclick="showNotam();" /><?php echo _("NOTAM"); ?></label></div></li>
109 109
 				<li><?php echo _("NOTAM scope:"); ?>
110 110
 					<select class="selectpicker" onchange="notamscope(this);">
111
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
112
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
113
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
114
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
115
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
111
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
112
+	print ' selected';
113
+}
114
+?>>All</option>
115
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
116
+	print ' selected';
117
+}
118
+?>>Airport/Enroute warning</option>
119
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
120
+	print ' selected';
121
+}
122
+?>>Airport warning</option>
123
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
124
+	print ' selected';
125
+}
126
+?>>Navigation warning</option>
127
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
128
+	print ' selected';
129
+}
130
+?>>Enroute warning</option>
116 131
 					</select
117 132
 				</li>
118 133
 <?php
@@ -133,7 +148,10 @@  discard block
 block discarded – undo
133 148
 		        <div class="form-group">
134 149
 			    <label>From (UTC):</label>
135 150
 		            <div class='input-group date' id='datetimepicker1'>
136
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) print date("d/m/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
151
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) {
152
+	print date("d/m/Y h:i a",$_COOKIE['archive_begin']);
153
+}
154
+?>" required />
137 155
 		                <span class="input-group-addon">
138 156
             			    <span class="glyphicon glyphicon-calendar"></span>
139 157
 		                </span>
@@ -142,7 +160,10 @@  discard block
 block discarded – undo
142 160
 		        <div class="form-group">
143 161
 			    <label>To (UTC):</label>
144 162
 		            <div class='input-group date' id='datetimepicker2'>
145
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) print date("d/m/Y h:i a",$_COOKIE['archive_end']); ?>" />
163
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) {
164
+	print date("d/m/Y h:i a",$_COOKIE['archive_end']);
165
+}
166
+?>" />
146 167
             			<span class="input-group-addon">
147 168
 		                    <span class="glyphicon glyphicon-calendar"></span>
148 169
             			</span>
@@ -165,8 +186,18 @@  discard block
 block discarded – undo
165 186
 
166 187
 		    <li><?php echo _("Playback speed:"); ?>
167 188
 			<div class="range">
168
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
169
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
189
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_COOKIE['archive_speed'])) {
190
+	print $_COOKIE['archive_speed'];
191
+} else {
192
+	print '1';
193
+}
194
+?>">
195
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
196
+	print $_COOKIE['archive_speed'];
197
+} else {
198
+	print '1';
199
+}
200
+?></output>
170 201
 			</div>
171 202
 		    </li>
172 203
 
@@ -187,15 +218,27 @@  discard block
 block discarded – undo
187 218
 		    <li><?php echo _("Type of Map:"); ?>
188 219
 			<select  class="selectpicker" onchange="mapType(this);">
189 220
 			    <?php
190
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
191
-				else $MapType = $_COOKIE['MapType'];
221
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
222
+					$MapType = $globalMapProvider;
223
+				} else {
224
+					$MapType = $_COOKIE['MapType'];
225
+				}
192 226
 			    ?>
193 227
 			    <?php
194 228
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
195 229
 			    ?>
196
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
197
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
198
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
230
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
231
+	print ' selected';
232
+}
233
+?>>Bing-Aerial</option>
234
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
235
+	print ' selected';
236
+}
237
+?>>Bing-Hybrid</option>
238
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
239
+	print ' selected';
240
+}
241
+?>>Bing-Road</option>
199 242
 			    <?php
200 243
 				}
201 244
 			    ?>
@@ -205,56 +248,131 @@  discard block
 block discarded – undo
205 248
 			    <?php
206 249
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
207 250
 			    ?>
208
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
209
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
210
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
251
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
252
+	print ' selected';
253
+}
254
+?>>Here-Aerial</option>
255
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
256
+	print ' selected';
257
+}
258
+?>>Here-Hybrid</option>
259
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
260
+	print ' selected';
261
+}
262
+?>>Here-Road</option>
211 263
 			    <?php
212 264
 				    }
213 265
 			    ?>
214 266
 			    <?php
215 267
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
216 268
 			    ?>
217
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
218
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
219
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
220
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
269
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
270
+	print ' selected';
271
+}
272
+?>>Google Roadmap</option>
273
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
274
+	print ' selected';
275
+}
276
+?>>Google Satellite</option>
277
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
278
+	print ' selected';
279
+}
280
+?>>Google Hybrid</option>
281
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
282
+	print ' selected';
283
+}
284
+?>>Google Terrain</option>
221 285
 			    <?php
222 286
 				    }
223 287
 			    ?>
224 288
 			    <?php
225 289
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
226 290
 			    ?>
227
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
228
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
229
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
291
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
292
+	print ' selected';
293
+}
294
+?>>MapQuest-OSM</option>
295
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
296
+	print ' selected';
297
+}
298
+?>>MapQuest-Aerial</option>
299
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
300
+	print ' selected';
301
+}
302
+?>>MapQuest-Hybrid</option>
230 303
 			    <?php
231 304
 				    }
232 305
 			    ?>
233
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
306
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
307
+	print ' selected';
308
+}
309
+?>>Yandex</option>
234 310
 			    <?php
235 311
 				}
236 312
 			    ?>
237 313
 			    <?php
238 314
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
239
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
240
-					else $MapBoxId = $_COOKIE['MapTypeId'];
315
+					if (!isset($_COOKIE['MapTypeId'])) {
316
+						$MapBoxId = 'default';
317
+					} else {
318
+						$MapBoxId = $_COOKIE['MapTypeId'];
319
+					}
241 320
 			    ?>
242
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
243
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
244
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
245
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
246
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
247
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
248
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
249
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
250
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
251
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
252
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
253
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
321
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
322
+	print ' selected';
323
+}
324
+?>>Mapbox default</option>
325
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
326
+	print ' selected';
327
+}
328
+?>>Mapbox streets</option>
329
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
330
+	print ' selected';
331
+}
332
+?>>Mapbox light</option>
333
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
334
+	print ' selected';
335
+}
336
+?>>Mapbox dark</option>
337
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
338
+	print ' selected';
339
+}
340
+?>>Mapbox satellite</option>
341
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
342
+	print ' selected';
343
+}
344
+?>>Mapbox streets-satellite</option>
345
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
346
+	print ' selected';
347
+}
348
+?>>Mapbox streets-basic</option>
349
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
350
+	print ' selected';
351
+}
352
+?>>Mapbox comic</option>
353
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
354
+	print ' selected';
355
+}
356
+?>>Mapbox outdoors</option>
357
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
358
+	print ' selected';
359
+}
360
+?>>Mapbox pencil</option>
361
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
362
+	print ' selected';
363
+}
364
+?>>Mapbox pirates</option>
365
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
366
+	print ' selected';
367
+}
368
+?>>Mapbox emerald</option>
254 369
 			    <?php
255 370
 				    }
256 371
 			    ?>
257
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
372
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
373
+	print ' selected';
374
+}
375
+?>>OpenStreetMap</option>
258 376
 			</select>
259 377
 		    </li>
260 378
 <?php
@@ -262,9 +380,18 @@  discard block
 block discarded – undo
262 380
 ?>
263 381
 		    <li><?php echo _("Type of Terrain:"); ?>
264 382
 			<select  class="selectpicker" onchange="terrainType(this);">
265
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
266
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
267
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
383
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
384
+	print ' selected';
385
+}
386
+?>>stk terrain</option>
387
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
388
+	print ' selected';
389
+}
390
+?>>ellipsoid</option>
391
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
392
+	print ' selected';
393
+}
394
+?>>vr terrain</option>
268 395
 			</select>
269 396
 		    </li>
270 397
 <?php
@@ -274,18 +401,36 @@  discard block
 block discarded – undo
274 401
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
275 402
 ?>
276 403
 		    
277
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
278
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
279
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
280
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
404
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
405
+	print 'checked';
406
+}
407
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
408
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) {
409
+	print 'checked';
410
+}
411
+?> ><?php echo _("Display flight path"); ?></label></div></li>
412
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) {
413
+	print 'checked';
414
+}
415
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
416
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
417
+	print 'checked';
418
+}
419
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
281 420
 <?php
282 421
     }
283 422
 ?>
284
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
423
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') {
424
+	print 'checked';
425
+}
426
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
285 427
 <?php
286 428
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
287 429
 ?>
288
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
430
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
431
+	print 'checked';
432
+}
433
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
289 434
 <?php
290 435
     }
291 436
 ?>
@@ -294,17 +439,25 @@  discard block
 block discarded – undo
294 439
 			if (function_exists('array_column')) {
295 440
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
296 441
 		    ?>
297
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
442
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
443
+	print 'checked';
444
+}
445
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
298 446
 		    <?php
299 447
 			    }
300 448
 			} elseif (isset($globalSources)) {
301 449
 			    $dispolar = false;
302 450
 			    foreach ($globalSources as $testsource) {
303
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
451
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
452
+			        	$dispolar = true;
453
+			        }
304 454
 			    }
305 455
 			    if ($dispolar) {
306 456
 		    ?>
307
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
457
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
458
+	print 'checked';
459
+}
460
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
308 461
 		    <?php
309 462
 			    }
310 463
 		        }
@@ -316,12 +469,22 @@  discard block
 block discarded – undo
316 469
 		    <?php
317 470
 		        if (extension_loaded('gd') && function_exists('gd_info')) {
318 471
 		    ?>
319
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
472
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
473
+	print 'checked';
474
+}
475
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
320 476
 		    <?php 
321 477
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
322 478
 		    ?>
323 479
 		    <li><?php echo _("Aircraft icon color:"); ?>
324
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
480
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
481
+	print $_COOKIE['IconColor'];
482
+} elseif (isset($globalAircraftIconColor)) {
483
+	print $globalAircraftIconColor;
484
+} else {
485
+	print '1a3151';
486
+}
487
+?>">
325 488
 		    </li>
326 489
 		    <?php
327 490
 			    }
@@ -329,8 +492,22 @@  discard block
 block discarded – undo
329 492
 		    ?>
330 493
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
331 494
 			<div class="range">
332
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
333
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
495
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
496
+	print $_COOKIE['AirportZoom'];
497
+} elseif (isset($globalAirportZoom)) {
498
+	print $globalAirportZoom;
499
+} else {
500
+	print '7';
501
+}
502
+?>">
503
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
504
+	print $_COOKIE['AirportZoom'];
505
+} elseif (isset($globalAirportZoom)) {
506
+	print $globalAirportZoom;
507
+} else {
508
+	print '7';
509
+}
510
+?></output>
334 511
 			</div>
335 512
 		    </li>
336 513
 <?php
@@ -339,9 +516,18 @@  discard block
 block discarded – undo
339 516
 		    <?php
340 517
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
341 518
 		    ?>
342
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
343
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
344
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
519
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
520
+	print 'checked';
521
+}
522
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
523
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
524
+	print 'checked';
525
+}
526
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
527
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
528
+	print 'checked';
529
+}
530
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
345 531
 		    <?php
346 532
 			}
347 533
 		    ?>
@@ -349,10 +535,16 @@  discard block
 block discarded – undo
349 535
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
350 536
 		    ?>
351 537
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
352
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
538
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
539
+	print 'checked';
540
+}
541
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
353 542
 			<?php } ?>
354 543
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
355
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
544
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
545
+	print 'checked';
546
+}
547
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
356 548
 			<?php } ?>
357 549
 		    <?php
358 550
 			}
@@ -363,7 +555,9 @@  discard block
 block discarded – undo
363 555
 				$Spotter = new Spotter();
364 556
 				foreach($Spotter->getAllAirlineNames() as $airline) {
365 557
 					$airline_name = $airline['airline_name'];
366
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
558
+					if (strlen($airline_name) > 30) {
559
+						$airline_name = substr($airline_name,0,30).'...';
560
+					}
367 561
 					if (isset($_COOKIE['Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['Airlines']))) {
368 562
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
369 563
 					} else {
@@ -398,10 +592,22 @@  discard block
 block discarded – undo
398 592
 		    ?>
399 593
 		    <li><?php echo _("Display airlines of type:"); ?>
400 594
 			<select class="selectpicker" onchange="airlinestype(this);">
401
-			    <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
402
-			    <option value="passenger"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
403
-			    <option value="cargo"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
404
-			    <option value="military"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
595
+			    <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') {
596
+	echo ' selected';
597
+}
598
+?>><?php echo _("All"); ?></option>
599
+			    <option value="passenger"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'passenger') {
600
+	echo ' selected';
601
+}
602
+?>><?php echo _("Passenger"); ?></option>
603
+			    <option value="cargo"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'cargo') {
604
+	echo ' selected';
605
+}
606
+?>><?php echo _("Cargo"); ?></option>
607
+			    <option value="military"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'military') {
608
+	echo ' selected';
609
+}
610
+?>><?php echo _("Military"); ?></option>
405 611
 			</select>
406 612
 		    </li>
407 613
 		    <?php
@@ -409,22 +615,46 @@  discard block
 block discarded – undo
409 615
 		    ?>
410 616
 		    <li><?php echo _("Distance unit:"); ?>
411 617
 			<select class="selectpicker" onchange="unitdistance(this);">
412
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
413
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
414
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
618
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
619
+	echo ' selected';
620
+}
621
+?>>km</option>
622
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
623
+	echo ' selected';
624
+}
625
+?>>nm</option>
626
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
627
+	echo ' selected';
628
+}
629
+?>>mi</option>
415 630
 		        </select>
416 631
 		    </li>
417 632
 		    <li><?php echo _("Altitude unit:"); ?>
418 633
 			<select class="selectpicker" onchange="unitaltitude(this);">
419
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
420
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
634
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
635
+	echo ' selected';
636
+}
637
+?>>m</option>
638
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
639
+	echo ' selected';
640
+}
641
+?>>feet</option>
421 642
 		        </select>
422 643
 		    </li>
423 644
 		    <li><?php echo _("Speed unit:"); ?>
424 645
 			<select class="selectpicker" onchange="unitspeed(this);">
425
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
426
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
427
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
646
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
647
+	echo ' selected';
648
+}
649
+?>>km/h</option>
650
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
651
+	echo ' selected';
652
+}
653
+?>>mph</option>
654
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
655
+	echo ' selected';
656
+}
657
+?>>knots</option>
428 658
 		        </select>
429 659
 		    </li>
430 660
 		</ul>
@@ -438,7 +668,10 @@  discard block
 block discarded – undo
438 668
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
439 669
 	    <form>
440 670
 		<ul>
441
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
671
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
672
+	print 'checked';
673
+}
674
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
442 675
 		    <li><?php echo _("Type:"); ?>
443 676
 			<select class="selectpicker" multiple onchange="sattypes(this);">
444 677
 			    <?php
@@ -446,25 +679,45 @@  discard block
 block discarded – undo
446 679
 				$types = $Satellite->get_tle_types();
447 680
 				foreach ($types as $type) {
448 681
 					$type_name = $type['tle_type'];
449
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
450
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
451
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
452
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
453
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
454
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
455
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
456
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
457
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
458
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
459
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
460
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
461
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
462
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
463
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
464
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
465
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
466
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
467
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
682
+					if ($type_name == 'musson') {
683
+						$type_name = 'Russian LEO Navigation';
684
+					} else if ($type_name == 'nnss') {
685
+						$type_name = 'Navi Navigation Satellite System';
686
+					} else if ($type_name == 'sbas') {
687
+						$type_name = 'Satellite-Based Augmentation System';
688
+					} else if ($type_name == 'glo-ops') {
689
+						$type_name = 'Glonass Operational';
690
+					} else if ($type_name == 'gps-ops') {
691
+						$type_name = 'GPS Operational';
692
+					} else if ($type_name == 'argos') {
693
+						$type_name = 'ARGOS Data Collection System';
694
+					} else if ($type_name == 'tdrss') {
695
+						$type_name = 'Tracking and Data Relay Satellite System';
696
+					} else if ($type_name == 'sarsat') {
697
+						$type_name = 'Search & Rescue';
698
+					} else if ($type_name == 'dmc') {
699
+						$type_name = 'Disaster Monitoring';
700
+					} else if ($type_name == 'resource') {
701
+						$type_name = 'Earth Resources';
702
+					} else if ($type_name == 'stations') {
703
+						$type_name = 'Space Stations';
704
+					} else if ($type_name == 'geo') {
705
+						$type_name = 'Geostationary';
706
+					} else if ($type_name == 'amateur') {
707
+						$type_name = 'Amateur Radio';
708
+					} else if ($type_name == 'x-comm') {
709
+						$type_name = 'Experimental';
710
+					} else if ($type_name == 'other-comm') {
711
+						$type_name = 'Other Comm';
712
+					} else if ($type_name == 'science') {
713
+						$type_name = 'Space & Earth Science';
714
+					} else if ($type_name == 'military') {
715
+						$type_name = 'Miscellaneous Military';
716
+					} else if ($type_name == 'radar') {
717
+						$type_name = 'Radar Calibration';
718
+					} else if ($type_name == 'tle-new') {
719
+						$type_name = 'Last 30 days launches';
720
+					}
468 721
 					
469 722
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
470 723
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
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.
Spacing   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 		$this->db = $Connection->db();
14 14
         }
15 15
               
16
-	public function addLastStatsUpdate($type,$stats_date) {
16
+	public function addLastStatsUpdate($type, $stats_date) {
17 17
                 $query = "DELETE FROM config WHERE name = :type;
18 18
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
19
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
19
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
20 20
                  try {
21 21
                         $sth = $this->db->prepare($query);
22 22
                         $sth->execute($query_values);
23
-                } catch(PDOException $e) {
23
+                } catch (PDOException $e) {
24 24
                         return "error : ".$e->getMessage();
25 25
                 }
26 26
         }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
                  try {
31 31
                         $sth = $this->db->prepare($query);
32 32
                         $sth->execute(array(':type' => $type));
33
-                } catch(PDOException $e) {
33
+                } catch (PDOException $e) {
34 34
                         echo "error : ".$e->getMessage();
35 35
                 }
36 36
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -41,29 +41,29 @@  discard block
 block discarded – undo
41 41
                  try {
42 42
                         $sth = $this->db->prepare($query);
43 43
                         $sth->execute(array(':filter_name' => $filter_name));
44
-                } catch(PDOException $e) {
44
+                } catch (PDOException $e) {
45 45
                         echo "error : ".$e->getMessage();
46 46
                 }
47 47
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
48 48
                 return $all;
49 49
         }
50
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
50
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
51 51
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
52 52
                  try {
53 53
                         $sth = $this->db->prepare($query);
54
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
55
-                } catch(PDOException $e) {
54
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
55
+                } catch (PDOException $e) {
56 56
                         echo "error : ".$e->getMessage();
57 57
                 }
58 58
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
59 59
                 return $all;
60 60
         }
61
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
61
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
62 62
                 $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";
63 63
                  try {
64 64
                         $sth = $this->db->prepare($query);
65
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
66
-                } catch(PDOException $e) {
65
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
66
+                } catch (PDOException $e) {
67 67
                         echo "error : ".$e->getMessage();
68 68
                 }
69 69
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -77,29 +77,29 @@  discard block
 block discarded – undo
77 77
 		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";
78 78
                  try {
79 79
                         $sth = $this->db->prepare($query);
80
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
81
-                } catch(PDOException $e) {
80
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
81
+                } catch (PDOException $e) {
82 82
                         echo "error : ".$e->getMessage();
83 83
                 }
84 84
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
85 85
                 if (empty($all)) {
86 86
             	    $filters = array('airlines' => array($stats_airline));
87 87
             	    if ($filter_name != '') {
88
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
88
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
89 89
             	    }
90 90
             	    $Spotter = new Spotter($this->db);
91
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
91
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
92 92
                 }
93 93
                 return $all;
94 94
 	}
95
-	public function countAllAirlineCountries($limit = true,$filter_name = '') {
95
+	public function countAllAirlineCountries($limit = true, $filter_name = '') {
96 96
 		global $globalStatsFilters;
97 97
 		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";
98 98
 		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";
99 99
                  try {
100 100
                         $sth = $this->db->prepare($query);
101 101
                         $sth->execute(array(':filter_name' => $filter_name));
102
-                } catch(PDOException $e) {
102
+                } catch (PDOException $e) {
103 103
                         echo "error : ".$e->getMessage();
104 104
                 }
105 105
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -107,27 +107,27 @@  discard block
 block discarded – undo
107 107
             		$Spotter = new Spotter($this->db);
108 108
             		$filters = array();
109 109
             		if ($filter_name != '') {
110
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
110
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
111 111
 			}
112
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
112
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
113 113
                 }
114 114
                 return $all;
115 115
 	}
116
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
116
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') {
117 117
 		global $globalStatsFilters;
118 118
 		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";
119 119
 		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";
120 120
                  try {
121 121
                         $sth = $this->db->prepare($query);
122
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
123
-                } catch(PDOException $e) {
122
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
123
+                } catch (PDOException $e) {
124 124
                         echo "error : ".$e->getMessage();
125 125
                 }
126 126
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
127 127
                 if (empty($all)) {
128 128
             		$filters = array('airlines' => array($stats_airline));
129 129
             		if ($filter_name != '') {
130
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
130
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
131 131
 			}
132 132
             		$Spotter = new Spotter($this->db);
133 133
 			$all = $Spotter->countAllAircraftManufacturers($filters);
@@ -141,18 +141,18 @@  discard block
 block discarded – undo
141 141
 		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";
142 142
                  try {
143 143
                         $sth = $this->db->prepare($query);
144
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
145
-                } catch(PDOException $e) {
144
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
145
+                } catch (PDOException $e) {
146 146
                         echo "error : ".$e->getMessage();
147 147
                 }
148 148
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
149 149
                 if (empty($all)) {
150 150
 			$filters = array('airlines' => array($stats_airline));
151 151
 			if ($filter_name != '') {
152
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
152
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
153 153
 			}
154 154
 			$Spotter = new Spotter($this->db);
155
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
155
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
156 156
                 }
157 157
                 return $all;
158 158
 	}
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 		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";
163 163
                  try {
164 164
                         $sth = $this->db->prepare($query);
165
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
166
-                } catch(PDOException $e) {
165
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
166
+                } catch (PDOException $e) {
167 167
                         echo "error : ".$e->getMessage();
168 168
                 }
169 169
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
170 170
                 if (empty($all)) {
171 171
 			$filters = array('airlines' => array($stats_airline));
172 172
 			if ($filter_name != '') {
173
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
174 174
 			}
175 175
 			$Spotter = new Spotter($this->db);
176 176
 			$all = $Spotter->countAllDepartureCountries($filters);
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
                 return $all;
179 179
 	}
180 180
 
181
-	public function countAllAirlines($limit = true,$filter_name = '') {
181
+	public function countAllAirlines($limit = true, $filter_name = '') {
182 182
 		global $globalStatsFilters;
183 183
 		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";
184 184
 		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";
185 185
                  try {
186 186
                         $sth = $this->db->prepare($query);
187 187
                         $sth->execute(array(':filter_name' => $filter_name));
188
-                } catch(PDOException $e) {
188
+                } catch (PDOException $e) {
189 189
                         echo "error : ".$e->getMessage();
190 190
                 }
191 191
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -193,64 +193,64 @@  discard block
 block discarded – undo
193 193
 	                $Spotter = new Spotter($this->db);
194 194
             		$filters = array();
195 195
             		if ($filter_name != '') {
196
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
196
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
197 197
 			}
198 198
 
199
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
199
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
200 200
                 }
201 201
                 return $all;
202 202
 	}
203
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
203
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') {
204 204
 		global $globalStatsFilters;
205 205
 		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";
206 206
 		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";
207 207
                  try {
208 208
                         $sth = $this->db->prepare($query);
209
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
210
-                } catch(PDOException $e) {
209
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
210
+                } catch (PDOException $e) {
211 211
                         echo "error : ".$e->getMessage();
212 212
                 }
213 213
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
214 214
                 if (empty($all)) {
215 215
 			$filters = array('airlines' => array($stats_airline));
216 216
 			if ($filter_name != '') {
217
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
217
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
218 218
 			}
219 219
 	                $Spotter = new Spotter($this->db);
220
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
220
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
221 221
                 }
222 222
                 return $all;
223 223
 	}
224
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
224
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') {
225 225
 		global $globalStatsFilters;
226 226
 		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";
227 227
 		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";
228 228
 		 try {
229 229
 			$sth = $this->db->prepare($query);
230
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
231
-		} catch(PDOException $e) {
230
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
231
+		} catch (PDOException $e) {
232 232
 			echo "error : ".$e->getMessage();
233 233
 		}
234 234
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
235 235
 		if (empty($all)) {
236 236
 			$filters = array('airlines' => array($stats_airline));
237 237
 			if ($filter_name != '') {
238
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
238
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
239 239
 			}
240 240
 			$Spotter = new Spotter($this->db);
241
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
241
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
242 242
 		}
243 243
 		return $all;
244 244
 	}
245
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
245
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') {
246 246
 		$Connection = new Connection();
247 247
 		if ($Connection->tableExists('countries')) {
248 248
 			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";
249 249
 			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";
250 250
 			 try {
251 251
 				$sth = $this->db->prepare($query);
252
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
253
-			} catch(PDOException $e) {
252
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
253
+			} catch (PDOException $e) {
254 254
 				echo "error : ".$e->getMessage();
255 255
 			}
256 256
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -265,67 +265,67 @@  discard block
 block discarded – undo
265 265
 			return array();
266 266
 		}
267 267
 	}
268
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
268
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') {
269 269
 		global $globalStatsFilters;
270 270
 		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";
271 271
 		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";
272 272
                  try {
273 273
                         $sth = $this->db->prepare($query);
274
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
275
-                } catch(PDOException $e) {
274
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
275
+                } catch (PDOException $e) {
276 276
                         echo "error : ".$e->getMessage();
277 277
                 }
278 278
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
279 279
                 if (empty($all)) {
280 280
 			$filters = array('airlines' => array($stats_airline));
281 281
 			if ($filter_name != '') {
282
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
282
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
283 283
 			}
284 284
             		$Spotter = new Spotter($this->db);
285
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
285
+            		$all = $Spotter->countAllPilots($limit, 0, '', $filters);
286 286
                 }
287 287
                 return $all;
288 288
 	}
289
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
289
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') {
290 290
 		global $globalStatsFilters;
291 291
 		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";
292 292
 		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";
293 293
                  try {
294 294
                         $sth = $this->db->prepare($query);
295
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
296
-                } catch(PDOException $e) {
295
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
296
+                } catch (PDOException $e) {
297 297
                         echo "error : ".$e->getMessage();
298 298
                 }
299 299
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
300 300
                 if (empty($all)) {
301 301
 			$filters = array('airlines' => array($stats_airline));
302 302
 			if ($filter_name != '') {
303
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
303
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
304 304
 			}
305 305
             		$Spotter = new Spotter($this->db);
306
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
306
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
307 307
                 }
308 308
                 return $all;
309 309
 	}
310
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
310
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') {
311 311
 		global $globalStatsFilters;
312 312
 		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";
313 313
 		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";
314 314
                  try {
315 315
                         $sth = $this->db->prepare($query);
316
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
317
-                } catch(PDOException $e) {
316
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
317
+                } catch (PDOException $e) {
318 318
                         echo "error : ".$e->getMessage();
319 319
                 }
320 320
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
321 321
                 if (empty($all)) {
322 322
 			$filters = array('airlines' => array($stats_airline));
323 323
             		if ($filter_name != '') {
324
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
324
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
325 325
 			}
326 326
             		$Spotter = new Spotter($this->db);
327
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
328
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
327
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
328
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
329 329
         		$all = array();
330 330
         		foreach ($pall as $value) {
331 331
         			$icao = $value['airport_departure_icao'];
@@ -342,29 +342,29 @@  discard block
 block discarded – undo
342 342
         		foreach ($all as $key => $row) {
343 343
         			$count[$key] = $row['airport_departure_icao_count'];
344 344
         		}
345
-        		array_multisort($count,SORT_DESC,$all);
345
+        		array_multisort($count, SORT_DESC, $all);
346 346
                 }
347 347
                 return $all;
348 348
 	}
349
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
349
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') {
350 350
 		global $globalStatsFilters;
351 351
 		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";
352 352
 		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";
353 353
 		try {
354 354
 			$sth = $this->db->prepare($query);
355
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
356
-		} catch(PDOException $e) {
355
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
356
+		} catch (PDOException $e) {
357 357
 			echo "error : ".$e->getMessage();
358 358
 		}
359 359
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
360 360
 		if (empty($all)) {
361 361
 			$filters = array('airlines' => array($stats_airline));
362 362
 			if ($filter_name != '') {
363
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
363
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
364 364
 			}
365 365
 			$Spotter = new Spotter($this->db);
366
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
367
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
366
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
367
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
368 368
         		$all = array();
369 369
         		foreach ($pall as $value) {
370 370
         			$icao = $value['airport_arrival_icao'];
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
         		foreach ($all as $key => $row) {
382 382
         			$count[$key] = $row['airport_arrival_icao_count'];
383 383
         		}
384
-        		array_multisort($count,SORT_DESC,$all);
384
+        		array_multisort($count, SORT_DESC, $all);
385 385
                 }
386 386
  
387 387
                 return $all;
388 388
 	}
389
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
389
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
390 390
 		global $globalDBdriver, $globalStatsFilters;
391 391
 		if ($globalDBdriver == 'mysql') {
392 392
 			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";
@@ -395,18 +395,18 @@  discard block
 block discarded – undo
395 395
 			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";
396 396
 			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";
397 397
 		}
398
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
398
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
399 399
                  try {
400 400
                         $sth = $this->db->prepare($query);
401 401
                         $sth->execute($query_data);
402
-                } catch(PDOException $e) {
402
+                } catch (PDOException $e) {
403 403
                         echo "error : ".$e->getMessage();
404 404
                 }
405 405
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
406 406
                 if (empty($all)) {
407 407
 			$filters = array('airlines' => array($stats_airline));
408 408
 			if ($filter_name != '') {
409
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
409
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
410 410
 			}
411 411
             		$Spotter = new Spotter($this->db);
412 412
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -415,67 +415,67 @@  discard block
 block discarded – undo
415 415
                 return $all;
416 416
 	}
417 417
 	
418
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
418
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
419 419
 		global $globalStatsFilters;
420 420
 		$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";
421
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
421
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
422 422
                  try {
423 423
                         $sth = $this->db->prepare($query);
424 424
                         $sth->execute($query_data);
425
-                } catch(PDOException $e) {
425
+                } catch (PDOException $e) {
426 426
                         echo "error : ".$e->getMessage();
427 427
                 }
428 428
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
429 429
                 if (empty($all)) {
430 430
 			$filters = array('airlines' => array($stats_airline));
431 431
 			if ($filter_name != '') {
432
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
432
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
433 433
 			}
434 434
             		$Spotter = new Spotter($this->db);
435 435
             		$all = $Spotter->countAllDatesLastMonth($filters);
436 436
                 }
437 437
                 return $all;
438 438
 	}
439
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
439
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
440 440
 		global $globalDBdriver, $globalStatsFilters;
441 441
 		if ($globalDBdriver == 'mysql') {
442 442
 			$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";
443 443
 		} else {
444 444
 			$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";
445 445
 		}
446
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
446
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
447 447
                  try {
448 448
                         $sth = $this->db->prepare($query);
449 449
                         $sth->execute($query_data);
450
-                } catch(PDOException $e) {
450
+                } catch (PDOException $e) {
451 451
                         echo "error : ".$e->getMessage();
452 452
                 }
453 453
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
454 454
                 if (empty($all)) {
455 455
 			$filters = array('airlines' => array($stats_airline));
456 456
 			if ($filter_name != '') {
457
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
457
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
458 458
 			}
459 459
             		$Spotter = new Spotter($this->db);
460 460
             		$all = $Spotter->countAllDatesLast7Days($filters);
461 461
                 }
462 462
                 return $all;
463 463
 	}
464
-	public function countAllDates($stats_airline = '',$filter_name = '') {
464
+	public function countAllDates($stats_airline = '', $filter_name = '') {
465 465
 		global $globalStatsFilters;
466 466
 		$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";
467
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
467
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
468 468
                  try {
469 469
                         $sth = $this->db->prepare($query);
470 470
                         $sth->execute($query_data);
471
-                } catch(PDOException $e) {
471
+                } catch (PDOException $e) {
472 472
                         echo "error : ".$e->getMessage();
473 473
                 }
474 474
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
475 475
                 if (empty($all)) {
476 476
 			$filters = array('airlines' => array($stats_airline));
477 477
 			if ($filter_name != '') {
478
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
478
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
479 479
 			}
480 480
             		$Spotter = new Spotter($this->db);
481 481
             		$all = $Spotter->countAllDates($filters);
@@ -488,34 +488,34 @@  discard block
 block discarded – undo
488 488
                  try {
489 489
                         $sth = $this->db->prepare($query);
490 490
                         $sth->execute($query_data);
491
-                } catch(PDOException $e) {
491
+                } catch (PDOException $e) {
492 492
                         echo "error : ".$e->getMessage();
493 493
                 }
494 494
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
495 495
                 if (empty($all)) {
496 496
             		$filters = array();
497 497
             		if ($filter_name != '') {
498
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
498
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
499 499
 			}
500 500
             		$Spotter = new Spotter($this->db);
501 501
             		$all = $Spotter->countAllDatesByAirlines($filters);
502 502
                 }
503 503
                 return $all;
504 504
 	}
505
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
505
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
506 506
 		global $globalStatsFilters;
507 507
 	    	$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";
508 508
                  try {
509 509
                         $sth = $this->db->prepare($query);
510 510
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
511
-                } catch(PDOException $e) {
511
+                } catch (PDOException $e) {
512 512
                         echo "error : ".$e->getMessage();
513 513
                 }
514 514
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
515 515
                 if (empty($all)) {
516 516
 			$filters = array('airlines' => array($stats_airline));
517 517
 			if ($filter_name != '') {
518
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
518
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
519 519
 			}
520 520
             		$Spotter = new Spotter($this->db);
521 521
             		$all = $Spotter->countAllMonths($filters);
@@ -528,21 +528,21 @@  discard block
 block discarded – undo
528 528
                  try {
529 529
                         $sth = $this->db->prepare($query);
530 530
                         $sth->execute(array(':filter_name' => $filter_name));
531
-                } catch(PDOException $e) {
531
+                } catch (PDOException $e) {
532 532
                         echo "error : ".$e->getMessage();
533 533
                 }
534 534
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
535 535
                 if (empty($all)) {
536 536
             		$filters = array();
537 537
             		if ($filter_name != '') {
538
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
538
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
539 539
 			}
540 540
             		$Spotter = new Spotter($this->db);
541 541
             		$all = $Spotter->countAllMilitaryMonths($filters);
542 542
                 }
543 543
                 return $all;
544 544
 	}
545
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
545
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
546 546
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
547 547
 
548 548
 		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";
@@ -558,28 +558,28 @@  discard block
 block discarded – undo
558 558
                  try {
559 559
                         $sth = $this->db->prepare($query);
560 560
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
561
-                } catch(PDOException $e) {
561
+                } catch (PDOException $e) {
562 562
                         echo "error : ".$e->getMessage();
563 563
                 }
564 564
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
565 565
                 if (empty($all)) {
566 566
 			$filters = array('airlines' => array($stats_airline));
567 567
 			if ($filter_name != '') {
568
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
568
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
569 569
 			}
570 570
             		$Spotter = new Spotter($this->db);
571
-            		$all = $Spotter->countAllHours($orderby,$filters);
571
+            		$all = $Spotter->countAllHours($orderby, $filters);
572 572
                 }
573 573
                 return $all;
574 574
 	}
575 575
 	
576 576
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
577 577
 		global $globalStatsFilters;
578
-		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
578
+		$all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name);
579 579
 		if (empty($all)) {
580 580
 			$filters = array('airlines' => array($stats_airline));
581 581
 			if ($filter_name != '') {
582
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
582
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
583 583
 			}
584 584
 			$Spotter = new Spotter($this->db);
585 585
 			$all = $Spotter->countOverallFlights($filters);
@@ -587,37 +587,37 @@  discard block
 block discarded – undo
587 587
 		return $all;
588 588
 	}
589 589
 	public function countOverallMilitaryFlights($filter_name = '') {
590
-		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
590
+		$all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name);
591 591
 		if (empty($all)) {
592 592
 		        $filters = array();
593 593
             		if ($filter_name != '') {
594
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
594
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
595 595
 			}
596 596
 			$Spotter = new Spotter($this->db);
597 597
 			$all = $Spotter->countOverallMilitaryFlights($filters);
598 598
 		}
599 599
 		return $all;
600 600
 	}
601
-	public function countOverallArrival($stats_airline = '',$filter_name = '') {
601
+	public function countOverallArrival($stats_airline = '', $filter_name = '') {
602 602
 		global $globalStatsFilters;
603
-		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
603
+		$all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name);
604 604
 		if (empty($all)) {
605 605
 			$filters = array('airlines' => array($stats_airline));
606 606
 			if ($filter_name != '') {
607
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
607
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
608 608
 			}
609 609
 			$Spotter = new Spotter($this->db);
610 610
 			$all = $Spotter->countOverallArrival($filters);
611 611
 		}
612 612
 		return $all;
613 613
 	}
614
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
614
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '') {
615 615
 		global $globalStatsFilters;
616
-		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
616
+		$all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name);
617 617
 		if (empty($all)) {
618 618
 			$filters = array('airlines' => array($stats_airline));
619 619
 			if ($filter_name != '') {
620
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
620
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
621 621
 			}
622 622
 			$Spotter = new Spotter($this->db);
623 623
 			$all = $Spotter->countOverallAircrafts($filters);
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
                  try {
630 630
                         $sth = $this->db->prepare($query);
631 631
                         $sth->execute(array(':filter_name' => $filter_name));
632
-                } catch(PDOException $e) {
632
+                } catch (PDOException $e) {
633 633
                         echo "error : ".$e->getMessage();
634 634
                 }
635 635
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -638,14 +638,14 @@  discard block
 block discarded – undo
638 638
 		if (empty($all)) {
639 639
             		$filters = array();
640 640
             		if ($filter_name != '') {
641
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
641
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
642 642
 			}
643 643
 			$Spotter = new Spotter($this->db);
644 644
 			$all = $Spotter->countOverallAirlines($filters);
645 645
 		}
646 646
 		return $all;
647 647
 	}
648
-	public function countOverallOwners($stats_airline = '',$filter_name = '') {
648
+	public function countOverallOwners($stats_airline = '', $filter_name = '') {
649 649
 		global $globalStatsFilters;
650 650
 		/*
651 651
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
@@ -658,24 +658,24 @@  discard block
 block discarded – undo
658 658
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
659 659
                 $all = $result[0]['nb_owner'];
660 660
                 */
661
-		$all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name);
661
+		$all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name);
662 662
 		if (empty($all)) {
663 663
 			$filters = array('airlines' => array($stats_airline));
664 664
 			if ($filter_name != '') {
665
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
665
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
666 666
 			}
667 667
 			$Spotter = new Spotter($this->db);
668 668
 			$all = $Spotter->countOverallOwners($filters);
669 669
 		}
670 670
 		return $all;
671 671
 	}
672
-	public function countOverallPilots($stats_airline = '',$filter_name = '') {
672
+	public function countOverallPilots($stats_airline = '', $filter_name = '') {
673 673
 		global $globalStatsFilters;
674
-		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
674
+		$all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name);
675 675
 		if (empty($all)) {
676 676
 			$filters = array('airlines' => array($stats_airline));
677 677
 			if ($filter_name != '') {
678
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
678
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
679 679
 			}
680 680
 			$Spotter = new Spotter($this->db);
681 681
 			$all = $Spotter->countOverallPilots($filters);
@@ -683,42 +683,42 @@  discard block
 block discarded – undo
683 683
 		return $all;
684 684
 	}
685 685
 
686
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
686
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
687 687
 		$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";
688
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
688
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
689 689
                  try {
690 690
                         $sth = $this->db->prepare($query);
691 691
                         $sth->execute($query_values);
692
-                } catch(PDOException $e) {
692
+                } catch (PDOException $e) {
693 693
                         echo "error : ".$e->getMessage();
694 694
                 }
695 695
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
696 696
                 return $all;
697 697
 	}
698
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
698
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
699 699
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
700
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
700
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
701 701
                  try {
702 702
                         $sth = $this->db->prepare($query);
703 703
                         $sth->execute($query_values);
704
-                } catch(PDOException $e) {
704
+                } catch (PDOException $e) {
705 705
                         echo "error : ".$e->getMessage();
706 706
                 }
707 707
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
708 708
                 return $all;
709 709
         }
710
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
710
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') {
711 711
     		global $globalArchiveMonths, $globalDBdriver;
712 712
     		if ($globalDBdriver == 'mysql') {
713 713
 	                $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";
714 714
 	        } else {
715 715
             		$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";
716 716
                 }
717
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
717
+                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
718 718
                  try {
719 719
                         $sth = $this->db->prepare($query);
720 720
                         $sth->execute($query_values);
721
-                } catch(PDOException $e) {
721
+                } catch (PDOException $e) {
722 722
                         echo "error : ".$e->getMessage();
723 723
                 }
724 724
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
                  try {
736 736
                         $sth = $this->db->prepare($query);
737 737
                         $sth->execute($query_values);
738
-                } catch(PDOException $e) {
738
+                } catch (PDOException $e) {
739 739
                         echo "error : ".$e->getMessage();
740 740
                 }
741 741
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
                  try {
752 752
                         $sth = $this->db->prepare($query);
753 753
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
754
-                } catch(PDOException $e) {
754
+                } catch (PDOException $e) {
755 755
                         echo "error : ".$e->getMessage();
756 756
                 }
757 757
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
                  try {
768 768
                         $sth = $this->db->prepare($query);
769 769
                         $sth->execute(array(':filter_name' => $filter_name));
770
-                } catch(PDOException $e) {
770
+                } catch (PDOException $e) {
771 771
                         echo "error : ".$e->getMessage();
772 772
                 }
773 773
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
                  try {
784 784
                         $sth = $this->db->prepare($query);
785 785
                         $sth->execute(array(':filter_name' => $filter_name));
786
-                } catch(PDOException $e) {
786
+                } catch (PDOException $e) {
787 787
                         echo "error : ".$e->getMessage();
788 788
                 }
789 789
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -799,29 +799,29 @@  discard block
 block discarded – undo
799 799
                  try {
800 800
                         $sth = $this->db->prepare($query);
801 801
                         $sth->execute(array(':filter_name' => $filter_name));
802
-                } catch(PDOException $e) {
802
+                } catch (PDOException $e) {
803 803
                         echo "error : ".$e->getMessage();
804 804
                 }
805 805
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
806 806
                 return $all[0]['total'];
807 807
         }
808 808
 
809
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
809
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
810 810
 		global $globalDBdriver;
811 811
 		if ($globalDBdriver == 'mysql') {
812 812
 			$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";
813 813
                 } else {
814 814
 			$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);"; 
815 815
 		}
816
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
816
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
817 817
                  try {
818 818
                         $sth = $this->db->prepare($query);
819 819
                         $sth->execute($query_values);
820
-                } catch(PDOException $e) {
820
+                } catch (PDOException $e) {
821 821
                         return "error : ".$e->getMessage();
822 822
                 }
823 823
         }
824
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
824
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
825 825
 		global $globalDBdriver;
826 826
 		if ($globalDBdriver == 'mysql') {
827 827
 			$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";
@@ -829,219 +829,219 @@  discard block
 block discarded – undo
829 829
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
830 830
 			$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);"; 
831 831
                 }
832
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
832
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
833 833
                  try {
834 834
                         $sth = $this->db->prepare($query);
835 835
                         $sth->execute($query_values);
836
-                } catch(PDOException $e) {
836
+                } catch (PDOException $e) {
837 837
                         return "error : ".$e->getMessage();
838 838
                 }
839 839
         }
840
-	public function getStatsSource($date,$stats_type = '') {
840
+	public function getStatsSource($date, $stats_type = '') {
841 841
 		if ($stats_type == '') {
842 842
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
843 843
 			$query_values = array(':date' => $date);
844 844
 		} else {
845 845
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
846
-			$query_values = array(':date' => $date,':stats_type' => $stats_type);
846
+			$query_values = array(':date' => $date, ':stats_type' => $stats_type);
847 847
 		}
848 848
                  try {
849 849
                         $sth = $this->db->prepare($query);
850 850
                         $sth->execute($query_values);
851
-                } catch(PDOException $e) {
851
+                } catch (PDOException $e) {
852 852
                         echo "error : ".$e->getMessage();
853 853
                 }
854 854
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
855 855
                 return $all;
856 856
         }
857 857
 
858
-	public function addStatSource($data,$source_name,$stats_type,$date) {
858
+	public function addStatSource($data, $source_name, $stats_type, $date) {
859 859
 		global $globalDBdriver;
860 860
 		if ($globalDBdriver == 'mysql') {
861 861
 			$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";
862 862
 		} else {
863 863
 			$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);"; 
864 864
                 }
865
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
865
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
866 866
                  try {
867 867
                         $sth = $this->db->prepare($query);
868 868
                         $sth->execute($query_values);
869
-                } catch(PDOException $e) {
869
+                } catch (PDOException $e) {
870 870
                         return "error : ".$e->getMessage();
871 871
                 }
872 872
         }
873
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
873
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
874 874
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
875
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
875
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
876 876
                  try {
877 877
                         $sth = $this->db->prepare($query);
878 878
                         $sth->execute($query_values);
879
-                } catch(PDOException $e) {
879
+                } catch (PDOException $e) {
880 880
                         return "error : ".$e->getMessage();
881 881
                 }
882 882
         }
883
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') {
883
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '') {
884 884
 		global $globalDBdriver;
885 885
 		if ($globalDBdriver == 'mysql') {
886 886
 			$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";
887 887
 		} else {
888 888
 			$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);"; 
889 889
 		}
890
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
890
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
891 891
                  try {
892 892
                         $sth = $this->db->prepare($query);
893 893
                         $sth->execute($query_values);
894
-                } catch(PDOException $e) {
894
+                } catch (PDOException $e) {
895 895
                         return "error : ".$e->getMessage();
896 896
                 }
897 897
         }
898
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') {
898
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '') {
899 899
 		global $globalDBdriver;
900 900
 		if ($globalDBdriver == 'mysql') {
901 901
 			$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";
902 902
 		} else {
903 903
 			$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);"; 
904 904
 		}
905
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
905
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
906 906
                  try {
907 907
                         $sth = $this->db->prepare($query);
908 908
                         $sth->execute($query_values);
909
-                } catch(PDOException $e) {
909
+                } catch (PDOException $e) {
910 910
                         return "error : ".$e->getMessage();
911 911
                 }
912 912
         }
913
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') {
913
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '') {
914 914
 		global $globalDBdriver;
915 915
 		if ($globalDBdriver == 'mysql') {
916 916
 			$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";
917 917
 		} else {
918 918
 			$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);"; 
919 919
 		}
920
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
920
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
921 921
                  try {
922 922
                         $sth = $this->db->prepare($query);
923 923
                         $sth->execute($query_values);
924
-                } catch(PDOException $e) {
924
+                } catch (PDOException $e) {
925 925
                         return "error : ".$e->getMessage();
926 926
                 }
927 927
         }
928
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
928
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
929 929
 		global $globalDBdriver;
930 930
 		if ($globalDBdriver == 'mysql') {
931 931
 			$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";
932 932
 		} else {
933 933
 			$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);"; 
934 934
 		}
935
-                $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);
935
+                $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);
936 936
                  try {
937 937
                         $sth = $this->db->prepare($query);
938 938
                         $sth->execute($query_values);
939
-                } catch(PDOException $e) {
939
+                } catch (PDOException $e) {
940 940
                         return "error : ".$e->getMessage();
941 941
                 }
942 942
         }
943
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') {
943
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '') {
944 944
 		global $globalDBdriver;
945 945
 		if ($globalDBdriver == 'mysql') {
946 946
 			$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";
947 947
 		} else {
948 948
 			$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);"; 
949 949
 		}
950
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
950
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
951 951
                  try {
952 952
                         $sth = $this->db->prepare($query);
953 953
                         $sth->execute($query_values);
954
-                } catch(PDOException $e) {
954
+                } catch (PDOException $e) {
955 955
                         return "error : ".$e->getMessage();
956 956
                 }
957 957
         }
958
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') {
958
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '') {
959 959
 		global $globalDBdriver;
960 960
 		if ($globalDBdriver == 'mysql') {
961 961
 			$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";
962 962
 		} else {
963 963
 			$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);"; 
964 964
 		}
965
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
965
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
966 966
                  try {
967 967
                         $sth = $this->db->prepare($query);
968 968
                         $sth->execute($query_values);
969
-                } catch(PDOException $e) {
969
+                } catch (PDOException $e) {
970 970
                         return "error : ".$e->getMessage();
971 971
                 }
972 972
         }
973
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') {
973
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '') {
974 974
 		global $globalDBdriver;
975 975
 		if ($globalDBdriver == 'mysql') {
976 976
 			$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";
977 977
 		} else {
978 978
 			$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);"; 
979 979
 		}
980
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
980
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
981 981
                  try {
982 982
                         $sth = $this->db->prepare($query);
983 983
                         $sth->execute($query_values);
984
-                } catch(PDOException $e) {
984
+                } catch (PDOException $e) {
985 985
                         return "error : ".$e->getMessage();
986 986
                 }
987 987
         }
988
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
988
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
989 989
 		global $globalDBdriver;
990 990
 		if ($globalDBdriver == 'mysql') {
991 991
 			$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";
992 992
 		} else {
993 993
 			$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);"; 
994 994
 		}
995
-                $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);
995
+                $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);
996 996
                  try {
997 997
                         $sth = $this->db->prepare($query);
998 998
                         $sth->execute($query_values);
999
-                } catch(PDOException $e) {
999
+                } catch (PDOException $e) {
1000 1000
                         return "error : ".$e->getMessage();
1001 1001
                 }
1002 1002
         }
1003
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1003
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1004 1004
 		global $globalDBdriver;
1005 1005
 		if ($globalDBdriver == 'mysql') {
1006 1006
 			$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";
1007 1007
 		} else {
1008 1008
 			$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);"; 
1009 1009
 		}
1010
-                $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);
1010
+                $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);
1011 1011
                  try {
1012 1012
                         $sth = $this->db->prepare($query);
1013 1013
                         $sth->execute($query_values);
1014
-                } catch(PDOException $e) {
1014
+                } catch (PDOException $e) {
1015 1015
                         return "error : ".$e->getMessage();
1016 1016
                 }
1017 1017
         }
1018
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1018
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1019 1019
 		global $globalDBdriver;
1020 1020
 		if ($globalDBdriver == 'mysql') {
1021 1021
 			$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";
1022 1022
 		} else {
1023 1023
 			$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);"; 
1024 1024
 		}
1025
-                $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);
1025
+                $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);
1026 1026
                  try {
1027 1027
                         $sth = $this->db->prepare($query);
1028 1028
                         $sth->execute($query_values);
1029
-                } catch(PDOException $e) {
1029
+                } catch (PDOException $e) {
1030 1030
                         return "error : ".$e->getMessage();
1031 1031
                 }
1032 1032
         }
1033
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1033
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1034 1034
 		global $globalDBdriver;
1035 1035
 		if ($globalDBdriver == 'mysql') {
1036 1036
 			$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";
1037 1037
 		} else {
1038 1038
 			$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);"; 
1039 1039
 		}
1040
-                $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);
1040
+                $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);
1041 1041
                  try {
1042 1042
                         $sth = $this->db->prepare($query);
1043 1043
                         $sth->execute($query_values);
1044
-                } catch(PDOException $e) {
1044
+                } catch (PDOException $e) {
1045 1045
                         return "error : ".$e->getMessage();
1046 1046
                 }
1047 1047
         }
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
                  try {
1053 1053
                         $sth = $this->db->prepare($query);
1054 1054
                         $sth->execute($query_values);
1055
-                } catch(PDOException $e) {
1055
+                } catch (PDOException $e) {
1056 1056
                         return "error : ".$e->getMessage();
1057 1057
                 }
1058 1058
         }
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
                  try {
1063 1063
                         $sth = $this->db->prepare($query);
1064 1064
                         $sth->execute($query_values);
1065
-                } catch(PDOException $e) {
1065
+                } catch (PDOException $e) {
1066 1066
                         return "error : ".$e->getMessage();
1067 1067
                 }
1068 1068
         }
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
                  try {
1073 1073
                         $sth = $this->db->prepare($query);
1074 1074
                         $sth->execute($query_values);
1075
-                } catch(PDOException $e) {
1075
+                } catch (PDOException $e) {
1076 1076
                         return "error : ".$e->getMessage();
1077 1077
                 }
1078 1078
         }
@@ -1310,33 +1310,33 @@  discard block
 block discarded – undo
1310 1310
 				$last_update_day = $last_update[0]['value'];
1311 1311
 			} else $last_update_day = '2012-12-12 12:12:12';
1312 1312
 			$Spotter = new Spotter($this->db);
1313
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1313
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1314 1314
 			foreach ($alldata as $number) {
1315
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1315
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer']);
1316 1316
 			}
1317
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1317
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1318 1318
 			foreach ($alldata as $number) {
1319
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1319
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1320 1320
 			}
1321
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1321
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1322 1322
 			foreach ($alldata as $number) {
1323
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1323
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1324 1324
 			}
1325
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1325
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1326 1326
 			foreach ($alldata as $number) {
1327
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1327
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1328 1328
 			}
1329
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1329
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1330 1330
 			foreach ($alldata as $number) {
1331
-				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1331
+				$this->addStatOwner($number['owner_name'], $number['owner_count']);
1332 1332
 			}
1333
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1333
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1334 1334
 			foreach ($alldata as $number) {
1335
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']);
1335
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name']);
1336 1336
 			}
1337 1337
 			
1338
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1339
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1338
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1339
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1340 1340
 	        	$alldata = array();
1341 1341
 	        	
1342 1342
     			foreach ($pall as $value) {
@@ -1353,12 +1353,12 @@  discard block
 block discarded – undo
1353 1353
     			foreach ($alldata as $key => $row) {
1354 1354
     				$count[$key] = $row['airport_departure_icao_count'];
1355 1355
         		}
1356
-			array_multisort($count,SORT_DESC,$alldata);
1356
+			array_multisort($count, SORT_DESC, $alldata);
1357 1357
 			foreach ($alldata as $number) {
1358
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1358
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1359 1359
 			}
1360
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1361
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1360
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1361
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1362 1362
 	        	$alldata = array();
1363 1363
     			foreach ($pall as $value) {
1364 1364
 	        		$icao = $value['airport_arrival_icao'];
@@ -1374,15 +1374,15 @@  discard block
 block discarded – undo
1374 1374
         		foreach ($alldata as $key => $row) {
1375 1375
         			$count[$key] = $row['airport_arrival_icao_count'];
1376 1376
 	        	}
1377
-    			array_multisort($count,SORT_DESC,$alldata);
1377
+    			array_multisort($count, SORT_DESC, $alldata);
1378 1378
                         foreach ($alldata as $number) {
1379
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1379
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1380 1380
 			}
1381 1381
 			if ($Connection->tableExists('countries')) {
1382 1382
 				$SpotterArchive = new SpotterArchive();
1383
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1383
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1384 1384
 				foreach ($alldata as $number) {
1385
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1385
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1386 1386
 				}
1387 1387
 			}
1388 1388
 			
@@ -1395,31 +1395,31 @@  discard block
 block discarded – undo
1395 1395
 			$lastyear = false;
1396 1396
 			foreach ($alldata as $number) {
1397 1397
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1398
-				$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'])));
1398
+				$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'])));
1399 1399
 			}
1400 1400
 			$alldata = $Spotter->countAllMilitaryMonths();
1401 1401
 			foreach ($alldata as $number) {
1402
-				$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'])));
1402
+				$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'])));
1403 1403
 			}
1404 1404
 			$alldata = $Spotter->countAllMonthsOwners();
1405 1405
 			foreach ($alldata as $number) {
1406
-				$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'])));
1406
+				$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'])));
1407 1407
 			}
1408 1408
 			$alldata = $Spotter->countAllMonthsPilots();
1409 1409
 			foreach ($alldata as $number) {
1410
-				$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'])));
1410
+				$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'])));
1411 1411
 			}
1412 1412
 			$alldata = $Spotter->countAllMonthsAirlines();
1413 1413
 			foreach ($alldata as $number) {
1414
-				$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'])));
1414
+				$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'])));
1415 1415
 			}
1416 1416
 			$alldata = $Spotter->countAllMonthsAircrafts();
1417 1417
 			foreach ($alldata as $number) {
1418
-				$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'])));
1418
+				$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'])));
1419 1419
 			}
1420 1420
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1421 1421
 			foreach ($alldata as $number) {
1422
-				$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'])));
1422
+				$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'])));
1423 1423
 			}
1424 1424
 			echo 'Airports data...'."\n";
1425 1425
 			echo '...Departure'."\n";
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
     			}
1465 1465
     			$alldata = $pall;
1466 1466
 			foreach ($alldata as $number) {
1467
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1467
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1468 1468
 			}
1469 1469
 			echo '...Arrival'."\n";
1470 1470
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
     			}
1507 1507
     			$alldata = $pall;
1508 1508
 			foreach ($alldata as $number) {
1509
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1509
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1510 1510
 			}
1511 1511
 
1512 1512
 			echo 'Flights data...'."\n";
@@ -1514,27 +1514,27 @@  discard block
 block discarded – undo
1514 1514
 			echo '-> countAllDatesLastMonth...'."\n";
1515 1515
 			$alldata = $Spotter->countAllDatesLastMonth();
1516 1516
 			foreach ($alldata as $number) {
1517
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1517
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1518 1518
 			}
1519 1519
 			echo '-> countAllDates...'."\n";
1520 1520
 			$previousdata = $this->countAllDates();
1521 1521
 			$this->deleteStatFlight('date');
1522
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1522
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1523 1523
 			$values = array();
1524 1524
 			foreach ($alldata as $cnt) {
1525 1525
 				$values[] = $cnt['date_count'];
1526 1526
 			}
1527
-			array_multisort($values,SORT_DESC,$alldata);
1528
-			array_splice($alldata,11);
1527
+			array_multisort($values, SORT_DESC, $alldata);
1528
+			array_splice($alldata, 11);
1529 1529
 			foreach ($alldata as $number) {
1530
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1530
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1531 1531
 			}
1532 1532
 			
1533 1533
 			$this->deleteStatFlight('hour');
1534 1534
 			echo '-> countAllHours...'."\n";
1535 1535
 			$alldata = $Spotter->countAllHours('hour');
1536 1536
 			foreach ($alldata as $number) {
1537
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1537
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1538 1538
 			}
1539 1539
 
1540 1540
 
@@ -1542,29 +1542,29 @@  discard block
 block discarded – undo
1542 1542
 			// Count by airlines
1543 1543
 			echo '--- Stats by airlines ---'."\n";
1544 1544
 			$Spotter = new Spotter($this->db);
1545
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1545
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1546 1546
 			foreach ($alldata as $number) {
1547
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1547
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao']);
1548 1548
 			}
1549
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1549
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1550 1550
 			foreach ($alldata as $number) {
1551
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1551
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao']);
1552 1552
 			}
1553
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1553
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1554 1554
 			foreach ($alldata as $number) {
1555
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1555
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1556 1556
 			}
1557
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1557
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1558 1558
 			foreach ($alldata as $number) {
1559
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1559
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao']);
1560 1560
 			}
1561
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1561
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1562 1562
 			foreach ($alldata as $number) {
1563
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']);
1563
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao']);
1564 1564
 			}
1565 1565
 			
1566
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1567
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1566
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1567
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1568 1568
 	        	//$alldata = array();
1569 1569
     			foreach ($dall as $value) {
1570 1570
     				$icao = $value['airport_departure_icao'];
@@ -1583,10 +1583,10 @@  discard block
 block discarded – undo
1583 1583
     			}
1584 1584
     			$alldata = $pall;
1585 1585
 			foreach ($alldata as $number) {
1586
-				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']);
1586
+				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']);
1587 1587
 			}
1588
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1589
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1588
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1589
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1590 1590
 	        	//$alldata = array();
1591 1591
     			foreach ($dall as $value) {
1592 1592
     				$icao = $value['airport_arrival_icao'];
@@ -1605,30 +1605,30 @@  discard block
 block discarded – undo
1605 1605
     			}
1606 1606
     			$alldata = $pall;
1607 1607
                         foreach ($alldata as $number) {
1608
-				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']);
1608
+				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']);
1609 1609
 			}
1610 1610
 			$Spotter = new Spotter($this->db);
1611 1611
 			$alldata = $Spotter->countAllMonthsByAirlines();
1612 1612
 			$lastyear = false;
1613 1613
 			foreach ($alldata as $number) {
1614 1614
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1615
-				$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']);
1615
+				$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']);
1616 1616
 			}
1617 1617
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1618 1618
 			foreach ($alldata as $number) {
1619
-				$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']);
1619
+				$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']);
1620 1620
 			}
1621 1621
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1622 1622
 			foreach ($alldata as $number) {
1623
-				$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']);
1623
+				$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']);
1624 1624
 			}
1625 1625
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1626 1626
 			foreach ($alldata as $number) {
1627
-				$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']);
1627
+				$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']);
1628 1628
 			}
1629 1629
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1630 1630
 			foreach ($alldata as $number) {
1631
-				$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']);
1631
+				$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']);
1632 1632
 			}
1633 1633
 			echo '...Departure'."\n";
1634 1634
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1651,7 +1651,7 @@  discard block
 block discarded – undo
1651 1651
     			}
1652 1652
     			$alldata = $pall;
1653 1653
 			foreach ($alldata as $number) {
1654
-				$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']);
1654
+				$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']);
1655 1655
 			}
1656 1656
 			echo '...Arrival'."\n";
1657 1657
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1674,32 +1674,32 @@  discard block
 block discarded – undo
1674 1674
     			}
1675 1675
     			$alldata = $pall;
1676 1676
 			foreach ($alldata as $number) {
1677
-				$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']);
1677
+				$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']);
1678 1678
 			}
1679 1679
 
1680 1680
 			echo 'Flights data...'."\n";
1681 1681
 			echo '-> countAllDatesLastMonth...'."\n";
1682 1682
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1683 1683
 			foreach ($alldata as $number) {
1684
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1684
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1685 1685
 			}
1686 1686
 			echo '-> countAllDates...'."\n";
1687 1687
 			$previousdata = $this->countAllDatesByAirlines();
1688
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDatesByAirlines());
1688
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDatesByAirlines());
1689 1689
 			$values = array();
1690 1690
 			foreach ($alldata as $cnt) {
1691 1691
 				$values[] = $cnt['date_count'];
1692 1692
 			}
1693
-			array_multisort($values,SORT_DESC,$alldata);
1694
-			array_splice($alldata,11);
1693
+			array_multisort($values, SORT_DESC, $alldata);
1694
+			array_splice($alldata, 11);
1695 1695
 			foreach ($alldata as $number) {
1696
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1696
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1697 1697
 			}
1698 1698
 			
1699 1699
 			echo '-> countAllHours...'."\n";
1700 1700
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1701 1701
 			foreach ($alldata as $number) {
1702
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1702
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1703 1703
 			}
1704 1704
 			
1705 1705
 
@@ -1710,29 +1710,29 @@  discard block
 block discarded – undo
1710 1710
 				// Count by filter
1711 1711
 				echo '--- Stats by airlines ---'."\n";
1712 1712
 				$Spotter = new Spotter($this->db);
1713
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1713
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1714 1714
 				foreach ($alldata as $number) {
1715
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name);
1715
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name);
1716 1716
 				}
1717
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1717
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1718 1718
 				foreach ($alldata as $number) {
1719
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name);
1719
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name);
1720 1720
 				}
1721
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1721
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1722 1722
 				foreach ($alldata as $number) {
1723
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name);
1723
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name);
1724 1724
 				}
1725
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1725
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1726 1726
 				foreach ($alldata as $number) {
1727
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name);
1727
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name);
1728 1728
 				}
1729
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1729
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1730 1730
 				foreach ($alldata as $number) {
1731
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name);
1731
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name);
1732 1732
 				}
1733 1733
     			
1734
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1735
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1734
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1735
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1736 1736
 		        	//$alldata = array();
1737 1737
 	    			foreach ($dall as $value) {
1738 1738
 	    				$icao = $value['airport_departure_icao'];
@@ -1751,10 +1751,10 @@  discard block
 block discarded – undo
1751 1751
         			}
1752 1752
         			$alldata = $pall;
1753 1753
 				foreach ($alldata as $number) {
1754
-    					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);
1754
+    					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);
1755 1755
 				}
1756
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);
1757
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1756
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, $filter);
1757
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, $filter);
1758 1758
 	    			//$alldata = array();
1759 1759
 				foreach ($dall as $value) {
1760 1760
     					$icao = $value['airport_arrival_icao'];
@@ -1773,30 +1773,30 @@  discard block
 block discarded – undo
1773 1773
         			}
1774 1774
 				$alldata = $pall;
1775 1775
 				foreach ($alldata as $number) {
1776
-					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);
1776
+					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);
1777 1777
 				}
1778 1778
 				$Spotter = new Spotter($this->db);
1779 1779
 				$alldata = $Spotter->countAllMonths($filter);
1780 1780
 				$lastyear = false;
1781 1781
 				foreach ($alldata as $number) {
1782 1782
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1783
-					$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);
1783
+					$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);
1784 1784
 				}
1785 1785
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1786 1786
 				foreach ($alldata as $number) {
1787
-					$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);
1787
+					$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);
1788 1788
 				}
1789 1789
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1790 1790
 				foreach ($alldata as $number) {
1791
-					$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);
1791
+					$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);
1792 1792
 				}
1793 1793
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1794 1794
 				foreach ($alldata as $number) {
1795
-					$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);
1795
+					$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);
1796 1796
 				}
1797 1797
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1798 1798
 				foreach ($alldata as $number) {
1799
-					$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);
1799
+					$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);
1800 1800
 				}
1801 1801
 				echo '...Departure'."\n";
1802 1802
 				$pall = $Spotter->getLast7DaysAirportsDeparture($filter);
@@ -1819,7 +1819,7 @@  discard block
 block discarded – undo
1819 1819
     				}
1820 1820
 	    			$alldata = $pall;
1821 1821
 				foreach ($alldata as $number) {
1822
-					$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);
1822
+					$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);
1823 1823
 				}
1824 1824
 				echo '...Arrival'."\n";
1825 1825
 				$pall = $Spotter->getLast7DaysAirportsArrival($filter);
@@ -1842,32 +1842,32 @@  discard block
 block discarded – undo
1842 1842
     				}
1843 1843
     				$alldata = $pall;
1844 1844
 				foreach ($alldata as $number) {
1845
-					$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);
1845
+					$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);
1846 1846
 				}
1847 1847
     
1848 1848
 				echo 'Flights data...'."\n";
1849 1849
 				echo '-> countAllDatesLastMonth...'."\n";
1850 1850
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1851 1851
 				foreach ($alldata as $number) {
1852
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1852
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1853 1853
 				}
1854 1854
 				echo '-> countAllDates...'."\n";
1855 1855
 				$previousdata = $this->countAllDates($filter);
1856
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1856
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1857 1857
 				$values = array();
1858 1858
 				foreach ($alldata as $cnt) {
1859 1859
 					$values[] = $cnt['date_count'];
1860 1860
 				}
1861
-				array_multisort($values,SORT_DESC,$alldata);
1862
-				array_splice($alldata,11);
1861
+				array_multisort($values, SORT_DESC, $alldata);
1862
+				array_splice($alldata, 11);
1863 1863
 				foreach ($alldata as $number) {
1864
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1864
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1865 1865
 				}
1866 1866
 				
1867 1867
 				echo '-> countAllHours...'."\n";
1868
-				$alldata = $Spotter->countAllHours('hour',$filter);
1868
+				$alldata = $Spotter->countAllHours('hour', $filter);
1869 1869
 				foreach ($alldata as $number) {
1870
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
1870
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
1871 1871
 				}
1872 1872
 			}
1873 1873
 	
@@ -1878,16 +1878,16 @@  discard block
 block discarded – undo
1878 1878
 				// SUM all previous month to put as year
1879 1879
 				$previous_year = date('Y');
1880 1880
 				$previous_year--;
1881
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1882
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1883
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1884
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1881
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1882
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1883
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1884
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1885 1885
 				$allairlines = $this->getAllAirlineNames();
1886 1886
 				foreach ($allairlines as $data) {
1887
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1888
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1889
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1890
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1887
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1888
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1889
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1890
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1891 1891
 				}
1892 1892
 				
1893 1893
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 						try {
1897 1897
 							$sth = $this->db->prepare($query);
1898 1898
 							$sth->execute();
1899
-						} catch(PDOException $e) {
1899
+						} catch (PDOException $e) {
1900 1900
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1901 1901
 						}
1902 1902
 					}
@@ -1905,7 +1905,7 @@  discard block
 block discarded – undo
1905 1905
 					try {
1906 1906
 						$sth = $this->db->prepare($query);
1907 1907
 						$sth->execute();
1908
-					} catch(PDOException $e) {
1908
+					} catch (PDOException $e) {
1909 1909
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1910 1910
 					}
1911 1911
 				}
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
 					try {
1928 1928
 						$sth = $this->db->prepare($query);
1929 1929
 						$sth->execute();
1930
-					} catch(PDOException $e) {
1930
+					} catch (PDOException $e) {
1931 1931
 						return "error : ".$e->getMessage();
1932 1932
 					}
1933 1933
 				}
@@ -1941,13 +1941,13 @@  discard block
 block discarded – undo
1941 1941
 				try {
1942 1942
 					$sth = $this->db->prepare($query);
1943 1943
 					$sth->execute();
1944
-				} catch(PDOException $e) {
1944
+				} catch (PDOException $e) {
1945 1945
 					return "error : ".$e->getMessage();
1946 1946
 				}
1947 1947
 			}
1948 1948
 			echo 'Insert last stats update date...'."\n";
1949 1949
 			date_default_timezone_set('UTC');
1950
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1950
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
1951 1951
 		//}
1952 1952
 	}
1953 1953
 }
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.
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.