Completed
Push — master ( 637022...8149d9 )
by Yannick
55:10 queued 27:13
created
install/class.create_db.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@  discard block
 block discarded – undo
8 8
 	 * @param string $filename
9 9
 	 */
10 10
 	public static function import_file($filename) {
11
-		$filename = filter_var($filename,FILTER_SANITIZE_STRING);
11
+		$filename = filter_var($filename, FILTER_SANITIZE_STRING);
12 12
 		$Connection = new Connection();
13 13
 		if (!$Connection->connectionExists()) return 'error: DB connection failed';
14 14
 		//Connection::$db->beginTransaction();
15 15
 		$templine = '';
16
-		$handle = @fopen($filename,"r");
16
+		$handle = @fopen($filename, "r");
17 17
 		if ($handle) {
18 18
 			//$lines = file($filename);
19 19
 			//foreach ($lines as $line)
20
-			while (($line = fgets($handle,4096)) !== false)
20
+			while (($line = fgets($handle, 4096)) !== false)
21 21
 			{
22
-				if (substr($line,0,2) == '--' || $line == '') continue;
22
+				if (substr($line, 0, 2) == '--' || $line == '') continue;
23 23
 				$templine .= $line;
24
-				if (substr(trim($line), -1,1) == ';')
24
+				if (substr(trim($line), -1, 1) == ';')
25 25
 				{
26 26
 					try {
27 27
 						$sth = $Connection->db->prepare($templine);
28 28
 						$sth->execute();
29
-					} catch(PDOException $e) {
29
+					} catch (PDOException $e) {
30 30
 						return "error (import ".$filename.") : ".$e->getMessage()."\n";
31 31
 					}
32 32
 					$templine = '';
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
 		$error = '';
44 44
 		$dh = opendir($directory);
45 45
 		//foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
46
-		while(false !== ($filename = readdir($dh)))
46
+		while (false !== ($filename = readdir($dh)))
47 47
 		{
48
-			if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
48
+			if (preg_match('/\.sql$/', $filename)) $error .= create_db::import_file($directory.$filename);
49 49
 		}
50 50
 		return $error;
51 51
 	}
52 52
 
53
-	public static function create_database($root,$root_pass,$user,$pass,$db,$db_type,$host,$port = '') {
54
-		$root = filter_var($root,FILTER_SANITIZE_STRING);
55
-		$root_pass = filter_var($root_pass,FILTER_SANITIZE_STRING);
56
-		$user = filter_var($user,FILTER_SANITIZE_STRING);
57
-		$password = filter_var($pass,FILTER_SANITIZE_STRING);
58
-		$db = filter_var($db,FILTER_SANITIZE_STRING);
59
-		$db_type = filter_var($db_type,FILTER_SANITIZE_STRING);
60
-		$host = filter_var($host,FILTER_SANITIZE_STRING);
53
+	public static function create_database($root, $root_pass, $user, $pass, $db, $db_type, $host, $port = '') {
54
+		$root = filter_var($root, FILTER_SANITIZE_STRING);
55
+		$root_pass = filter_var($root_pass, FILTER_SANITIZE_STRING);
56
+		$user = filter_var($user, FILTER_SANITIZE_STRING);
57
+		$password = filter_var($pass, FILTER_SANITIZE_STRING);
58
+		$db = filter_var($db, FILTER_SANITIZE_STRING);
59
+		$db_type = filter_var($db_type, FILTER_SANITIZE_STRING);
60
+		$host = filter_var($host, FILTER_SANITIZE_STRING);
61 61
 		if ($db_type == 'mysql' && $port == '') $port = 3306;
62 62
 		elseif ($port == '') $port = 5432;
63 63
 		// Dirty hack
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 			$grantright = $_SERVER['SERVER_ADDR'];
66 66
 		} else $grantright = 'localhost';
67 67
 		try {
68
-			if ($host == 'localhost') $dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass);
69
-			else $dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass);
68
+			if ($host == 'localhost') $dbh = new PDO($db_type.':host=127.0.0.1', $root, $root_pass);
69
+			else $dbh = new PDO($db_type.':host='.$host.';port='.$port, $root, $root_pass);
70 70
 			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
71 71
 			if ($db_type == 'mysql') {
72 72
 				$dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 				$dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."';
77 77
 					GRANT ALL PRIVILEGES ON DATABASE ".$db." TO ".$user.";");
78 78
 			}
79
-		} catch(PDOException $e) {
79
+		} catch (PDOException $e) {
80 80
 			$dbh = null;
81 81
 			return "error : ".$e->getMessage();
82 82
 		}
Please login to merge, or discard this patch.
Braces   +25 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	public static function import_file($filename) {
11 11
 		$filename = filter_var($filename,FILTER_SANITIZE_STRING);
12 12
 		$Connection = new Connection();
13
-		if (!$Connection->connectionExists()) return 'error: DB connection failed';
13
+		if (!$Connection->connectionExists()) {
14
+			return 'error: DB connection failed';
15
+		}
14 16
 		//Connection::$db->beginTransaction();
15 17
 		$templine = '';
16 18
 		$handle = @fopen($filename,"r");
@@ -19,7 +21,9 @@  discard block
 block discarded – undo
19 21
 			//foreach ($lines as $line)
20 22
 			while (($line = fgets($handle,4096)) !== false)
21 23
 			{
22
-				if (substr($line,0,2) == '--' || $line == '') continue;
24
+				if (substr($line,0,2) == '--' || $line == '') {
25
+					continue;
26
+				}
23 27
 				$templine .= $line;
24 28
 				if (substr(trim($line), -1,1) == ';')
25 29
 				{
@@ -45,7 +49,9 @@  discard block
 block discarded – undo
45 49
 		//foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
46 50
 		while(false !== ($filename = readdir($dh)))
47 51
 		{
48
-			if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
52
+			if (preg_match('/\.sql$/',$filename)) {
53
+				$error .= create_db::import_file($directory.$filename);
54
+			}
49 55
 		}
50 56
 		return $error;
51 57
 	}
@@ -58,19 +64,29 @@  discard block
 block discarded – undo
58 64
 		$db = filter_var($db,FILTER_SANITIZE_STRING);
59 65
 		$db_type = filter_var($db_type,FILTER_SANITIZE_STRING);
60 66
 		$host = filter_var($host,FILTER_SANITIZE_STRING);
61
-		if ($db_type == 'mysql' && $port == '') $port = 3306;
62
-		elseif ($port == '') $port = 5432;
67
+		if ($db_type == 'mysql' && $port == '') {
68
+			$port = 3306;
69
+		} elseif ($port == '') {
70
+			$port = 5432;
71
+		}
63 72
 		// Dirty hack
64 73
 		if ($host != 'localhost' && $host != '127.0.0.1') {
65 74
 			$grantright = $_SERVER['SERVER_ADDR'];
66
-		} else $grantright = 'localhost';
75
+		} else {
76
+			$grantright = 'localhost';
77
+		}
67 78
 		try {
68
-			if ($host == 'localhost') $dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass);
69
-			else $dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass);
79
+			if ($host == 'localhost') {
80
+				$dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass);
81
+			} else {
82
+				$dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass);
83
+			}
70 84
 			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
71 85
 			if ($db_type == 'mysql') {
72 86
 				$dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
73
-				if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
87
+				if ($grantright == 'localhost') {
88
+					$dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
89
+				}
74 90
 			} else if ($db_type == 'pgsql') {
75 91
 				$dbh->exec("CREATE DATABASE ".$db.";");
76 92
 				$dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."';
Please login to merge, or discard this patch.
live-sat-geojson.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 		header('Content-disposition: attachment; filename="flightairmap-sat.json"');
14 14
 	}
15 15
 }
16
-$history = urldecode(filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING));
16
+$history = urldecode(filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING));
17 17
 header('Content-Type: text/javascript');
18 18
 
19 19
 $begintime = microtime(true);
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 
22 22
 $spotter_array = array();
23 23
 if (isset($_COOKIE['sattypes']) && $_COOKIE['sattypes'] != '') {
24
-	$sattypes = explode(',',$_COOKIE['sattypes']);
24
+	$sattypes = explode(',', $_COOKIE['sattypes']);
25 25
 	foreach ($sattypes as $sattype) {
26 26
 		//$spotter_array = array_merge($Satellite->position_all_type($sattype,$timeb-$globalLiveInterval,$timeb),$spotter_array);
27
-		$spotter_array = array_merge($Satellite->position_all_type($sattype),$spotter_array);
27
+		$spotter_array = array_merge($Satellite->position_all_type($sattype), $spotter_array);
28 28
 	}
29 29
 }
30 30
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 //$spotter_array = array_unique($spotter_array,SORT_REGULAR);
38 38
 //print_r($spotter_array);
39
-$sqltime = round(microtime(true)-$begintime,2);
39
+$sqltime = round(microtime(true) - $begintime, 2);
40 40
 
41 41
 $output = '{"type":"FeatureCollection","features":[';
42 42
 if (!empty($spotter_array) && is_array($spotter_array))
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	$last_name = '';
45 45
 	$coordinatearray = '';
46 46
 	$timearray = array();
47
-	foreach($spotter_array as $spotter_item)
47
+	foreach ($spotter_array as $spotter_item)
48 48
 	{
49 49
 		$output_data = '';
50 50
 		$output_data .= '{"type":"Feature","properties":{';
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 		}
62 62
 		$output_data .= '"altitude":0,';
63 63
 		$output_data .= '"sqt":'.$sqltime.',';
64
-		$nextlatlon = $Satellite->position($spotter_item['name'],time()+$globalMapRefresh+20);
64
+		$nextlatlon = $Satellite->position($spotter_item['name'], time() + $globalMapRefresh + 20);
65 65
 		$nextlat = $nextlatlon['latitude'];
66
-		if (abs($nextlat-$spotter_item['latitude']) > 90) {
66
+		if (abs($nextlat - $spotter_item['latitude']) > 90) {
67 67
 			if ($spotter_item['latitude'] < 0) $nexlat = -90;
68 68
 			else $nexlat = 90;
69 69
 		}
70 70
 		$nextlon = $nextlatlon['longitude'];
71
-		if (abs($nextlon-$spotter_item['longitude']) > 180) {
71
+		if (abs($nextlon - $spotter_item['longitude']) > 180) {
72 72
 			if ($spotter_item['longitude'] < 0) $nextlon = -180;
73 73
 			else $nextlon = 180;
74 74
 		}
@@ -79,27 +79,27 @@  discard block
 block discarded – undo
79 79
 		$output_data .= ']}},';
80 80
 		$output .= $output_data;
81 81
 		if ($history == $spotter_item['name']) {
82
-			$spotter_history_array = $Satellite->position($spotter_item['name'],time()-6000,time());
82
+			$spotter_history_array = $Satellite->position($spotter_item['name'], time() - 6000, time());
83 83
 			$spotter_history_array = array_reverse($spotter_history_array);
84 84
 			$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['name'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
85 85
 			foreach ($spotter_history_array as $key => $spotter_history) {
86
-				if ((isset($previous_lon) && abs($previous_lon-$spotter_history['longitude']) > 180) || (isset($previous_lat) && abs($previous_lat-$spotter_history['latitude']) > 90)) {
86
+				if ((isset($previous_lon) && abs($previous_lon - $spotter_history['longitude']) > 180) || (isset($previous_lat) && abs($previous_lat - $spotter_history['latitude']) > 90)) {
87 87
 					break;
88 88
 				}
89 89
 				$output_history .= '[';
90
-				$output_history .=  $spotter_history['longitude'].', ';
91
-				$output_history .=  $spotter_history['latitude'];
90
+				$output_history .= $spotter_history['longitude'].', ';
91
+				$output_history .= $spotter_history['latitude'];
92 92
 				$output_history .= '],';
93 93
 				$previous_lon = $spotter_history['longitude'];
94 94
 				$previous_lat = $spotter_history['latitude'];
95 95
 			}
96
-			$output_history = substr($output_history,0,-1);
96
+			$output_history = substr($output_history, 0, -1);
97 97
 			$output_history .= ']}},';
98 98
 			$output .= $output_history;
99 99
 		}
100 100
 	}
101 101
 }
102
-if (isset($output_data)) $output = substr($output,0,-1);
102
+if (isset($output_data)) $output = substr($output, 0, -1);
103 103
 $output .= ']}';
104 104
 print $output;
105 105
 ?>
Please login to merge, or discard this patch.
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,13 +64,19 @@  discard block
 block discarded – undo
64 64
 		$nextlatlon = $Satellite->position($spotter_item['name'],time()+$globalMapRefresh+20);
65 65
 		$nextlat = $nextlatlon['latitude'];
66 66
 		if (abs($nextlat-$spotter_item['latitude']) > 90) {
67
-			if ($spotter_item['latitude'] < 0) $nexlat = -90;
68
-			else $nexlat = 90;
67
+			if ($spotter_item['latitude'] < 0) {
68
+				$nexlat = -90;
69
+			} else {
70
+				$nexlat = 90;
71
+			}
69 72
 		}
70 73
 		$nextlon = $nextlatlon['longitude'];
71 74
 		if (abs($nextlon-$spotter_item['longitude']) > 180) {
72
-			if ($spotter_item['longitude'] < 0) $nextlon = -180;
73
-			else $nextlon = 180;
75
+			if ($spotter_item['longitude'] < 0) {
76
+				$nextlon = -180;
77
+			} else {
78
+				$nextlon = 180;
79
+			}
74 80
 		}
75 81
 		$output_data .= '"nextlatlon":['.$nextlat.','.$nextlon.']},';
76 82
 		//$output_data .= '"heading":"'.$Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$nextlatlon['latitude'],$nextlatlon['longitude']).'",';
@@ -99,7 +105,9 @@  discard block
 block discarded – undo
99 105
 		}
100 106
 	}
101 107
 }
102
-if (isset($output_data)) $output = substr($output,0,-1);
108
+if (isset($output_data)) {
109
+	$output = substr($output,0,-1);
110
+}
103 111
 $output .= ']}';
104 112
 print $output;
105 113
 ?>
Please login to merge, or discard this patch.
live-sat-czml.php 1 patch
Spacing   +19 added lines, -19 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'] == 'true') || !isset($_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');
@@ -115,23 +115,23 @@  discard block
 block discarded – undo
115 115
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubiesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
116 116
 				} elseif ($spotter_item['name'] == 'TERRA') {
117 117
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/terra.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
118
-				} elseif (strpos($spotter_item['name'],'O3B') !== false) {
118
+				} elseif (strpos($spotter_item['name'], 'O3B') !== false) {
119 119
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/o3b.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
120
-				} elseif (strpos($spotter_item['name'],'GLOBALSTAR') !== false) {
120
+				} elseif (strpos($spotter_item['name'], 'GLOBALSTAR') !== false) {
121 121
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/globalstar.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
122
-				} elseif (strpos($spotter_item['name'],'GPS') !== false) {
122
+				} elseif (strpos($spotter_item['name'], 'GPS') !== false) {
123 123
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/gps.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
124
-				} elseif (strpos($spotter_item['name'],'GENESIS') !== false) {
124
+				} elseif (strpos($spotter_item['name'], 'GENESIS') !== false) {
125 125
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/genesis.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
126
-				} elseif (strpos($spotter_item['name'],'OSCAR 7') !== false) {
126
+				} elseif (strpos($spotter_item['name'], 'OSCAR 7') !== false) {
127 127
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/oscar7.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
128
-				} elseif (strpos($spotter_item['name'],'FLOCK') !== false) {
128
+				} elseif (strpos($spotter_item['name'], 'FLOCK') !== false) {
129 129
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
130
-				} elseif (strpos($spotter_item['name'],'PLEIADES') !== false) {
130
+				} elseif (strpos($spotter_item['name'], 'PLEIADES') !== false) {
131 131
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/pleiades.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
132
-				} elseif (strpos($spotter_item['name'],'DUCHIFAT') !== false) {
132
+				} elseif (strpos($spotter_item['name'], 'DUCHIFAT') !== false) {
133 133
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/duchifat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
134
-				} elseif (strpos($spotter_item['name'],'FORMOSAT-2') !== false) {
134
+				} elseif (strpos($spotter_item['name'], 'FORMOSAT-2') !== false) {
135 135
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/formosat2.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
136 136
 				} elseif ($spotter_item['type'] == 'iridium') {
137 137
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/space/iridium.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },';
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
154 154
 			$output .= '"interpolationAlgorithm":"HERMITE","interpolationDegree":3,';
155 155
 			$output .= '"cartographicDegrees": [';
156
-			$output .= '"'.date("c",$spotter_item['timestamp']).'", ';
156
+			$output .= '"'.date("c", $spotter_item['timestamp']).'", ';
157 157
 			$output .= $spotter_item['longitude'].', ';
158 158
 			$output .= $spotter_item['latitude'].', ';
159 159
 			$output .= $spotter_item['altitude']*1000;
160 160
 			$orientation = '"orientation" : { ';
161 161
 			$orientation .= '"unitQuaternion": [';
162 162
 		} else {
163
-			$output .= ',"'.date("c",$spotter_item['timestamp']).'", ';
163
+			$output .= ',"'.date("c", $spotter_item['timestamp']).'", ';
164 164
 			$output .= $spotter_item['longitude'].', ';
165 165
 			$output .= $spotter_item['latitude'].', ';
166 166
 			$output .= $spotter_item['altitude']*1000;
Please login to merge, or discard this patch.
location-data.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $Source = new Source();
6 6
 
7 7
 if (isset($_GET['sourceid'])) {
8
-	$sourceid = filter_input(INPUT_GET,'sourceid',FILTER_SANITIZE_NUMBER_INT);
8
+	$sourceid = filter_input(INPUT_GET, 'sourceid', FILTER_SANITIZE_NUMBER_INT);
9 9
 	$source_data = $Source->getLocationInfoById($sourceid);
10 10
 	if (isset($source_data[0])) {
11 11
  ?>
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 print '</div>';
38 38
 
39 39
 if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
40
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
-print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],4).', '.round($spotter_item['longitude'],4).'</div>';
40
+if ($spotter_item['country'] != '') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
+print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 4).', '.round($spotter_item['longitude'], 4).'</div>';
42 42
 /*
43 43
 if ($spotter_item['atc_range'] > 0) {
44 44
     print '<div><span>'._("Range").'</span>';
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 }
48 48
 */
49 49
 if ($spotter_item['type'] == 'wx') {
50
-	$weather = json_decode($spotter_item['description'],true);
50
+	$weather = json_decode($spotter_item['description'], true);
51 51
 	//print_r($weather);
52 52
 	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
53 53
 	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
Please login to merge, or discard this patch.
Braces   +40 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,12 +17,19 @@  discard block
 block discarded – undo
17 17
 date_default_timezone_set('UTC');
18 18
 
19 19
 print '<div class="top">';
20
-if ($spotter_item['name'] != '') print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
21
-elseif ($spotter_item['location_id'] != 0) print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
22
-elseif ($spotter_item['type'] == 'lightning') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Lightning").'</div>';
23
-elseif ($spotter_item['type'] == 'wx') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Weather Station").'</div>';
24
-elseif ($spotter_item['type'] == 'fires') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Fire").'</div>';
25
-else print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
20
+if ($spotter_item['name'] != '') {
21
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
22
+} elseif ($spotter_item['location_id'] != 0) {
23
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
24
+} elseif ($spotter_item['type'] == 'lightning') {
25
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Lightning").'</div>';
26
+} elseif ($spotter_item['type'] == 'wx') {
27
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Weather Station").'</div>';
28
+} elseif ($spotter_item['type'] == 'fires') {
29
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Fire").'</div>';
30
+} else {
31
+	print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
32
+}
26 33
 print '</div>';
27 34
 
28 35
 print '</div></div>';
@@ -40,8 +47,12 @@  discard block
 block discarded – undo
40 47
 print $spotter_item['last_seen'].' UTC';
41 48
 print '</div>';
42 49
 
43
-if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
44
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
50
+if ($spotter_item['city'] != '') {
51
+	print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
52
+}
53
+if ($spotter_item['country'] !='') {
54
+	print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
55
+}
45 56
 print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],4).', '.round($spotter_item['longitude'],4).'</div>';
46 57
 /*
47 58
 if ($spotter_item['atc_range'] > 0) {
@@ -53,13 +64,27 @@  discard block
 block discarded – undo
53 64
 if ($spotter_item['type'] == 'wx') {
54 65
 	$weather = json_decode($spotter_item['description'],true);
55 66
 	//print_r($weather);
56
-	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
57
-	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
58
-	if (isset($weather['wind_gust'])) print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
59
-	if (isset($weather['humidity'])) print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
60
-	if (isset($weather['rain'])) print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
61
-	if (isset($weather['precipitation'])) print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
62
-	if (isset($weather['precipitation24h'])) print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
67
+	if (isset($weather['temp'])) {
68
+		print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
69
+	}
70
+	if (isset($weather['pressure'])) {
71
+		print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
72
+	}
73
+	if (isset($weather['wind_gust'])) {
74
+		print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
75
+	}
76
+	if (isset($weather['humidity'])) {
77
+		print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
78
+	}
79
+	if (isset($weather['rain'])) {
80
+		print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
81
+	}
82
+	if (isset($weather['precipitation'])) {
83
+		print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
84
+	}
85
+	if (isset($weather['precipitation24h'])) {
86
+		print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
87
+	}
63 88
 	$spotter_item['description'] = $weather['comment'];
64 89
 } elseif ($spotter_item['type'] == 'fires') {
65 90
 	//print_r(json_decode($spotter_item['description'],true));
Please login to merge, or discard this patch.
require/class.SpotterArchive.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, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Indentation   +528 added lines, -528 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
@@ -151,44 +151,44 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 
153 153
 
154
-        /**
155
-        * Gets all the spotter information based on a particular callsign
156
-        *
157
-        * @return Array the spotter information
158
-        *
159
-        */
160
-        public function getLastArchiveSpotterDataByIdent($ident)
161
-        {
154
+		/**
155
+		 * Gets all the spotter information based on a particular callsign
156
+		 *
157
+		 * @return Array the spotter information
158
+		 *
159
+		 */
160
+		public function getLastArchiveSpotterDataByIdent($ident)
161
+		{
162 162
 		$Spotter = new Spotter($this->db);
163
-                date_default_timezone_set('UTC');
163
+				date_default_timezone_set('UTC');
164 164
 
165
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
166
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
167
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
165
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
166
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
167
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
168 168
 
169
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
169
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170 170
 
171
-                return $spotter_array;
172
-        }
171
+				return $spotter_array;
172
+		}
173 173
 
174 174
 
175
-        /**
176
-        * Gets last the spotter information based on a particular id
177
-        *
178
-        * @return Array the spotter information
179
-        *
180
-        */
181
-        public function getLastArchiveSpotterDataById($id)
182
-        {
183
-    		$Spotter = new Spotter($this->db);
184
-                date_default_timezone_set('UTC');
185
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
186
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
187
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
188
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
175
+		/**
176
+		 * Gets last the spotter information based on a particular id
177
+		 *
178
+		 * @return Array the spotter information
179
+		 *
180
+		 */
181
+		public function getLastArchiveSpotterDataById($id)
182
+		{
183
+			$Spotter = new Spotter($this->db);
184
+				date_default_timezone_set('UTC');
185
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
186
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
187
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
188
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
189 189
 
190 190
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
191
-                  /*
191
+				  /*
192 192
                 try {
193 193
                         $Connection = new Connection();
194 194
                         $sth = Connection->$db->prepare($query);
@@ -198,122 +198,122 @@  discard block
 block discarded – undo
198 198
                 }
199 199
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
200 200
                 */
201
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
-
203
-                return $spotter_array;
204
-        }
205
-
206
-        /**
207
-        * Gets all the spotter information based on a particular id
208
-        *
209
-        * @return Array the spotter information
210
-        *
211
-        */
212
-        public function getAllArchiveSpotterDataById($id)
201
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
+
203
+				return $spotter_array;
204
+		}
205
+
206
+		/**
207
+		 * Gets all the spotter information based on a particular id
208
+		 *
209
+		 * @return Array the spotter information
210
+		 *
211
+		 */
212
+		public function getAllArchiveSpotterDataById($id)
213 213
 	{
214
-                date_default_timezone_set('UTC');
215
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
216
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
214
+				date_default_timezone_set('UTC');
215
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
216
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
217 217
 
218 218
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
219 219
 
220
-                try {
221
-                        $sth = $this->db->prepare($query);
222
-                        $sth->execute(array(':id' => $id));
223
-                } catch(PDOException $e) {
224
-                        echo $e->getMessage();
225
-                        die;
226
-                }
227
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
228
-
229
-                return $spotter_array;
230
-        }
231
-
232
-        /**
233
-        * Gets coordinate & time spotter information based on a particular id
234
-        *
235
-        * @return Array the spotter information
236
-        *
237
-        */
238
-        public function getCoordArchiveSpotterDataById($id)
239
-        {
240
-                date_default_timezone_set('UTC');
241
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
242
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
220
+				try {
221
+						$sth = $this->db->prepare($query);
222
+						$sth->execute(array(':id' => $id));
223
+				} catch(PDOException $e) {
224
+						echo $e->getMessage();
225
+						die;
226
+				}
227
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
228
+
229
+				return $spotter_array;
230
+		}
231
+
232
+		/**
233
+		 * Gets coordinate & time spotter information based on a particular id
234
+		 *
235
+		 * @return Array the spotter information
236
+		 *
237
+		 */
238
+		public function getCoordArchiveSpotterDataById($id)
239
+		{
240
+				date_default_timezone_set('UTC');
241
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
242
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
243 243
 
244 244
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
245 245
 
246
-                try {
247
-                        $sth = $this->db->prepare($query);
248
-                        $sth->execute(array(':id' => $id));
249
-                } catch(PDOException $e) {
250
-                        echo $e->getMessage();
251
-                        die;
252
-                }
253
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
246
+				try {
247
+						$sth = $this->db->prepare($query);
248
+						$sth->execute(array(':id' => $id));
249
+				} catch(PDOException $e) {
250
+						echo $e->getMessage();
251
+						die;
252
+				}
253
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
254 254
 
255
-                return $spotter_array;
256
-        }
255
+				return $spotter_array;
256
+		}
257 257
 
258 258
 
259
-        /**
260
-        * Gets altitude information based on a particular callsign
261
-        *
262
-        * @return Array the spotter information
263
-        *
264
-        */
265
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
266
-        {
259
+		/**
260
+		 * Gets altitude information based on a particular callsign
261
+		 *
262
+		 * @return Array the spotter information
263
+		 *
264
+		 */
265
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
266
+		{
267 267
 
268
-                date_default_timezone_set('UTC');
268
+				date_default_timezone_set('UTC');
269 269
 
270
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
271
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
270
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
271
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
272 272
 
273
-                try {
274
-                        $sth = $this->db->prepare($query);
275
-                        $sth->execute(array(':ident' => $ident));
276
-                } catch(PDOException $e) {
277
-                        echo $e->getMessage();
278
-                        die;
279
-                }
280
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
273
+				try {
274
+						$sth = $this->db->prepare($query);
275
+						$sth->execute(array(':ident' => $ident));
276
+				} catch(PDOException $e) {
277
+						echo $e->getMessage();
278
+						die;
279
+				}
280
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
281 281
 
282
-                return $spotter_array;
283
-        }
282
+				return $spotter_array;
283
+		}
284 284
 
285
-        /**
286
-        * Gets altitude information based on a particular id
287
-        *
288
-        * @return Array the spotter information
289
-        *
290
-        */
291
-        public function getAltitudeArchiveSpotterDataById($id)
292
-        {
285
+		/**
286
+		 * Gets altitude information based on a particular id
287
+		 *
288
+		 * @return Array the spotter information
289
+		 *
290
+		 */
291
+		public function getAltitudeArchiveSpotterDataById($id)
292
+		{
293 293
 
294
-                date_default_timezone_set('UTC');
294
+				date_default_timezone_set('UTC');
295 295
 
296
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
297
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
296
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
297
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
298 298
 
299
-                try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute(array(':id' => $id));
302
-                } catch(PDOException $e) {
303
-                        echo $e->getMessage();
304
-                        die;
305
-                }
306
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
299
+				try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute(array(':id' => $id));
302
+				} catch(PDOException $e) {
303
+						echo $e->getMessage();
304
+						die;
305
+				}
306
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
307 307
 
308
-                return $spotter_array;
309
-        }
308
+				return $spotter_array;
309
+		}
310 310
 
311
-        /**
312
-        * Gets altitude & speed information based on a particular id
313
-        *
314
-        * @return Array the spotter information
315
-        *
316
-        */
311
+		/**
312
+		 * Gets altitude & speed information based on a particular id
313
+		 *
314
+		 * @return Array the spotter information
315
+		 *
316
+		 */
317 317
 	public function getAltitudeSpeedArchiveSpotterDataById($id)
318 318
 	{
319 319
 		date_default_timezone_set('UTC');
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 		return $spotter_array;
331 331
 	}
332 332
 
333
-        /**
334
-        * Gets altitude information based on a particular callsign
335
-        *
336
-        * @return Array the spotter information
337
-        *
338
-        */
333
+		/**
334
+		 * Gets altitude information based on a particular callsign
335
+		 *
336
+		 * @return Array the spotter information
337
+		 *
338
+		 */
339 339
 	public function getLastAltitudeArchiveSpotterDataByIdent($ident)
340 340
 	{
341 341
 		date_default_timezone_set('UTC');
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
 
356 356
 
357 357
 
358
-       /**
359
-        * Gets all the archive spotter information
360
-        *
361
-        * @return Array the spotter information
362
-        *
363
-        */
358
+	   /**
359
+	    * Gets all the archive spotter information
360
+	    *
361
+	    * @return Array the spotter information
362
+	    *
363
+	    */
364 364
 	public function getSpotterArchiveData($ident,$flightaware_id,$date)
365 365
 	{
366 366
 		$Spotter = new Spotter($this->db);
@@ -388,34 +388,34 @@  discard block
 block discarded – undo
388 388
 	}
389 389
 
390 390
 	/**
391
-        * Gets Minimal Live Spotter data
392
-        *
393
-        * @return Array the spotter information
394
-        *
395
-        */
396
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
397
-        {
398
-                global $globalDBdriver, $globalLiveInterval;
399
-                date_default_timezone_set('UTC');
400
-
401
-                $filter_query = '';
402
-                if (isset($filter['source']) && !empty($filter['source'])) {
403
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
404
-                }
405
-                // Use spotter_output also ?
406
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
407
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
408
-                }
409
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
410
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
411
-                }
412
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
413
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
414
-                }
391
+	 * Gets Minimal Live Spotter data
392
+	 *
393
+	 * @return Array the spotter information
394
+	 *
395
+	 */
396
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
397
+		{
398
+				global $globalDBdriver, $globalLiveInterval;
399
+				date_default_timezone_set('UTC');
400
+
401
+				$filter_query = '';
402
+				if (isset($filter['source']) && !empty($filter['source'])) {
403
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
404
+				}
405
+				// Use spotter_output also ?
406
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
407
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
408
+				}
409
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
410
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
411
+				}
412
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
413
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
414
+				}
415 415
 
416
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
417
-                if ($globalDBdriver == 'mysql') {
418
-                        /*
416
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
417
+				if ($globalDBdriver == 'mysql') {
418
+						/*
419 419
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
420 420
                     		    FROM spotter_archive 
421 421
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -434,56 +434,56 @@  discard block
 block discarded – undo
434 434
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
435 435
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
436 436
                         	    '.$filter_query.' ORDER BY flightaware_id';
437
-                } else {
438
-                        //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
439
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
437
+				} else {
438
+						//$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
439
+						$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
440 440
                         	    FROM spotter_archive 
441 441
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
442 442
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
443 443
                         	    '.$filter_query.' ORDER BY flightaware_id';
444
-                }
445
-                //echo $query;
446
-                try {
447
-                        $sth = $this->db->prepare($query);
448
-                        $sth->execute();
449
-                } catch(PDOException $e) {
450
-                        echo $e->getMessage();
451
-                        die;
452
-                }
453
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
444
+				}
445
+				//echo $query;
446
+				try {
447
+						$sth = $this->db->prepare($query);
448
+						$sth->execute();
449
+				} catch(PDOException $e) {
450
+						echo $e->getMessage();
451
+						die;
452
+				}
453
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
454 454
 
455
-                return $spotter_array;
456
-        }
455
+				return $spotter_array;
456
+		}
457 457
 
458 458
 	/**
459
-        * Gets Minimal Live Spotter data
460
-        *
461
-        * @return Array the spotter information
462
-        *
463
-        */
464
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
465
-        {
466
-                global $globalDBdriver, $globalLiveInterval;
467
-                date_default_timezone_set('UTC');
468
-
469
-                $filter_query = '';
470
-                if (isset($filter['source']) && !empty($filter['source'])) {
471
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
472
-                }
473
-                // Should use spotter_output also ?
474
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
475
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
476
-                }
477
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
478
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
479
-                }
480
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
481
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
482
-                }
459
+	 * Gets Minimal Live Spotter data
460
+	 *
461
+	 * @return Array the spotter information
462
+	 *
463
+	 */
464
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
465
+		{
466
+				global $globalDBdriver, $globalLiveInterval;
467
+				date_default_timezone_set('UTC');
468
+
469
+				$filter_query = '';
470
+				if (isset($filter['source']) && !empty($filter['source'])) {
471
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
472
+				}
473
+				// Should use spotter_output also ?
474
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
475
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
476
+				}
477
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
478
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
479
+				}
480
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
481
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
482
+				}
483 483
 
484
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
485
-                if ($globalDBdriver == 'mysql') {
486
-                        /*
484
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
485
+				if ($globalDBdriver == 'mysql') {
486
+						/*
487 487
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
488 488
                     		    FROM spotter_archive 
489 489
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -494,95 +494,95 @@  discard block
 block discarded – undo
494 494
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
495 495
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
496 496
 
497
-                } else {
498
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
499
-                       /*
497
+				} else {
498
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
499
+					   /*
500 500
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
501 501
                         	    FROM spotter_archive_output 
502 502
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
503 503
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
504 504
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
505 505
                         */
506
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
506
+						$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
507 507
                         	    FROM spotter_archive_output 
508 508
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
509 509
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
510 510
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
511 511
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
512 512
                         	    
513
-                }
514
-                //echo $query;
515
-                try {
516
-                        $sth = $this->db->prepare($query);
517
-                        $sth->execute();
518
-                } catch(PDOException $e) {
519
-                        echo $e->getMessage();
520
-                        die;
521
-                }
522
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
513
+				}
514
+				//echo $query;
515
+				try {
516
+						$sth = $this->db->prepare($query);
517
+						$sth->execute();
518
+				} catch(PDOException $e) {
519
+						echo $e->getMessage();
520
+						die;
521
+				}
522
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
523 523
 
524
-                return $spotter_array;
525
-        }
524
+				return $spotter_array;
525
+		}
526 526
 
527 527
 	 /**
528
-        * Gets count Live Spotter data
529
-        *
530
-        * @return Array the spotter information
531
-        *
532
-        */
533
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
534
-        {
535
-                global $globalDBdriver, $globalLiveInterval;
536
-                date_default_timezone_set('UTC');
537
-
538
-                $filter_query = '';
539
-                if (isset($filter['source']) && !empty($filter['source'])) {
540
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
541
-                }
542
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
543
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
544
-                }
545
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
546
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
547
-                }
548
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
549
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
550
-                }
528
+	  * Gets count Live Spotter data
529
+	  *
530
+	  * @return Array the spotter information
531
+	  *
532
+	  */
533
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
534
+		{
535
+				global $globalDBdriver, $globalLiveInterval;
536
+				date_default_timezone_set('UTC');
551 537
 
552
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
553
-                if ($globalDBdriver == 'mysql') {
538
+				$filter_query = '';
539
+				if (isset($filter['source']) && !empty($filter['source'])) {
540
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
541
+				}
542
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
543
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
544
+				}
545
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
546
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
547
+				}
548
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
549
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
550
+				}
551
+
552
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
553
+				if ($globalDBdriver == 'mysql') {
554 554
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
555 555
 			FROM spotter_archive l 
556 556
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
557
-                } else {
557
+				} else {
558 558
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
559
-                }
560
-                //echo $query;
561
-                try {
562
-                        $sth = $this->db->prepare($query);
563
-                        $sth->execute();
564
-                } catch(PDOException $e) {
565
-                        echo $e->getMessage();
566
-                        die;
567
-                }
559
+				}
560
+				//echo $query;
561
+				try {
562
+						$sth = $this->db->prepare($query);
563
+						$sth->execute();
564
+				} catch(PDOException $e) {
565
+						echo $e->getMessage();
566
+						die;
567
+				}
568 568
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
569 569
 		$sth->closeCursor();
570
-                return $result['nb'];
570
+				return $result['nb'];
571 571
 
572
-        }
572
+		}
573 573
 
574 574
 
575 575
 
576 576
 	// Spotter_Archive_output
577 577
 	
578
-    /**
579
-    * Gets all the spotter information
580
-    *
581
-    * @return Array the spotter information
582
-    *
583
-    */
584
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
585
-    {
578
+	/**
579
+	 * Gets all the spotter information
580
+	 *
581
+	 * @return Array the spotter information
582
+	 *
583
+	 */
584
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
585
+	{
586 586
 	global $globalTimezone, $globalDBdriver;
587 587
 	require_once(dirname(__FILE__).'/class.Translation.php');
588 588
 	$Translation = new Translation($this->db);
@@ -596,159 +596,159 @@  discard block
 block discarded – undo
596 596
 	$filter_query = $this->getFilter($filters);
597 597
 	if ($q != "")
598 598
 	{
599
-	    if (!is_string($q))
600
-	    {
599
+		if (!is_string($q))
600
+		{
601 601
 		return false;
602
-	    } else {
602
+		} else {
603 603
 	        
604 604
 		$q_array = explode(" ", $q);
605 605
 		
606 606
 		foreach ($q_array as $q_item){
607
-		    $additional_query .= " AND (";
608
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
609
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
610
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
611
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
612
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
613
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
614
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
615
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
616
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
617
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
618
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
619
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
620
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
621
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
622
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
623
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
624
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
625
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
626
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
627
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
628
-		    $translate = $Translation->ident2icao($q_item);
629
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
630
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
631
-		    $additional_query .= ")";
607
+			$additional_query .= " AND (";
608
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
609
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
610
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
611
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
612
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
613
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
614
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
615
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
616
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
617
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
618
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
619
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
620
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
621
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
622
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
623
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
624
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
625
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
626
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
627
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
628
+			$translate = $Translation->ident2icao($q_item);
629
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
630
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
631
+			$additional_query .= ")";
632
+		}
632 633
 		}
633
-	    }
634 634
 	}
635 635
 	
636 636
 	if ($registration != "")
637 637
 	{
638
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
639
-	    if (!is_string($registration))
640
-	    {
638
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
639
+		if (!is_string($registration))
640
+		{
641 641
 		return false;
642
-	    } else {
642
+		} else {
643 643
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
644
-	    }
644
+		}
645 645
 	}
646 646
 	
647 647
 	if ($aircraft_icao != "")
648 648
 	{
649
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
650
-	    if (!is_string($aircraft_icao))
651
-	    {
649
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
650
+		if (!is_string($aircraft_icao))
651
+		{
652 652
 		return false;
653
-	    } else {
653
+		} else {
654 654
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
655
-	    }
655
+		}
656 656
 	}
657 657
 	
658 658
 	if ($aircraft_manufacturer != "")
659 659
 	{
660
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
661
-	    if (!is_string($aircraft_manufacturer))
662
-	    {
660
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
661
+		if (!is_string($aircraft_manufacturer))
662
+		{
663 663
 		return false;
664
-	    } else {
664
+		} else {
665 665
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
666
-	    }
666
+		}
667 667
 	}
668 668
 	
669 669
 	if ($highlights == "true")
670 670
 	{
671
-	    if (!is_string($highlights))
672
-	    {
671
+		if (!is_string($highlights))
672
+		{
673 673
 		return false;
674
-	    } else {
674
+		} else {
675 675
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
676
-	    }
676
+		}
677 677
 	}
678 678
 	
679 679
 	if ($airline_icao != "")
680 680
 	{
681
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
682
-	    if (!is_string($airline_icao))
683
-	    {
681
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
682
+		if (!is_string($airline_icao))
683
+		{
684 684
 		return false;
685
-	    } else {
685
+		} else {
686 686
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
687
-	    }
687
+		}
688 688
 	}
689 689
 	
690 690
 	if ($airline_country != "")
691 691
 	{
692
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
693
-	    if (!is_string($airline_country))
694
-	    {
692
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
693
+		if (!is_string($airline_country))
694
+		{
695 695
 		return false;
696
-	    } else {
696
+		} else {
697 697
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
698
-	    }
698
+		}
699 699
 	}
700 700
 	
701 701
 	if ($airline_type != "")
702 702
 	{
703
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
704
-	    if (!is_string($airline_type))
705
-	    {
703
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
704
+		if (!is_string($airline_type))
705
+		{
706 706
 		return false;
707
-	    } else {
707
+		} else {
708 708
 		if ($airline_type == "passenger")
709 709
 		{
710
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
710
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
711 711
 		}
712 712
 		if ($airline_type == "cargo")
713 713
 		{
714
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
714
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
715 715
 		}
716 716
 		if ($airline_type == "military")
717 717
 		{
718
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
718
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
719
+		}
719 720
 		}
720
-	    }
721 721
 	}
722 722
 	
723 723
 	if ($airport != "")
724 724
 	{
725
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
726
-	    if (!is_string($airport))
727
-	    {
725
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
726
+		if (!is_string($airport))
727
+		{
728 728
 		return false;
729
-	    } else {
729
+		} else {
730 730
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
731
-	    }
731
+		}
732 732
 	}
733 733
 	
734 734
 	if ($airport_country != "")
735 735
 	{
736
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
737
-	    if (!is_string($airport_country))
738
-	    {
736
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
737
+		if (!is_string($airport_country))
738
+		{
739 739
 		return false;
740
-	    } else {
740
+		} else {
741 741
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
742
-	    }
742
+		}
743 743
 	}
744 744
     
745 745
 	if ($callsign != "")
746 746
 	{
747
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
748
-	    if (!is_string($callsign))
749
-	    {
747
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
748
+		if (!is_string($callsign))
749
+		{
750 750
 		return false;
751
-	    } else {
751
+		} else {
752 752
 		$translate = $Translation->ident2icao($callsign);
753 753
 		if ($translate != $callsign) {
754 754
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -756,81 +756,81 @@  discard block
 block discarded – undo
756 756
 		} else {
757 757
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
758 758
 		}
759
-	    }
759
+		}
760 760
 	}
761 761
 
762 762
 	if ($owner != "")
763 763
 	{
764
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
765
-	    if (!is_string($owner))
766
-	    {
764
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
765
+		if (!is_string($owner))
766
+		{
767 767
 		return false;
768
-	    } else {
768
+		} else {
769 769
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
770
-	    }
770
+		}
771 771
 	}
772 772
 
773 773
 	if ($pilot_name != "")
774 774
 	{
775
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
776
-	    if (!is_string($pilot_name))
777
-	    {
775
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
776
+		if (!is_string($pilot_name))
777
+		{
778 778
 		return false;
779
-	    } else {
779
+		} else {
780 780
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
781
-	    }
781
+		}
782 782
 	}
783 783
 	
784 784
 	if ($pilot_id != "")
785 785
 	{
786
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
787
-	    if (!is_string($pilot_id))
788
-	    {
786
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
787
+		if (!is_string($pilot_id))
788
+		{
789 789
 		return false;
790
-	    } else {
790
+		} else {
791 791
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
792
-	    }
792
+		}
793 793
 	}
794 794
 	
795 795
 	if ($departure_airport_route != "")
796 796
 	{
797
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
798
-	    if (!is_string($departure_airport_route))
799
-	    {
797
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
798
+		if (!is_string($departure_airport_route))
799
+		{
800 800
 		return false;
801
-	    } else {
801
+		} else {
802 802
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
803
-	    }
803
+		}
804 804
 	}
805 805
 	
806 806
 	if ($arrival_airport_route != "")
807 807
 	{
808
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
809
-	    if (!is_string($arrival_airport_route))
810
-	    {
808
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
809
+		if (!is_string($arrival_airport_route))
810
+		{
811 811
 		return false;
812
-	    } else {
812
+		} else {
813 813
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
814
-	    }
814
+		}
815 815
 	}
816 816
 	
817 817
 	if ($altitude != "")
818 818
 	{
819
-	    $altitude_array = explode(",", $altitude);
819
+		$altitude_array = explode(",", $altitude);
820 820
 	    
821
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
822
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
821
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
822
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
823 823
 	    
824 824
 
825
-	    if ($altitude_array[1] != "")
826
-	    {                
825
+		if ($altitude_array[1] != "")
826
+		{                
827 827
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
828 828
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
829 829
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
830
-	    } else {
830
+		} else {
831 831
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
832 832
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
833
-	    }
833
+		}
834 834
 	}
835 835
 	
836 836
 	if ($date_posted != "")
@@ -915,14 +915,14 @@  discard block
 block discarded – undo
915 915
 		}
916 916
 	}
917 917
 
918
-    /**
919
-    * Gets all the spotter information based on the callsign
920
-    *
921
-    * @return Array the spotter information
922
-    *
923
-    */
924
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
925
-    {
918
+	/**
919
+	 * Gets all the spotter information based on the callsign
920
+	 *
921
+	 * @return Array the spotter information
922
+	 *
923
+	 */
924
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
925
+	{
926 926
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
927 927
 	
928 928
 	date_default_timezone_set('UTC');
@@ -934,35 +934,35 @@  discard block
 block discarded – undo
934 934
 	
935 935
 	if ($ident != "")
936 936
 	{
937
-	    if (!is_string($ident))
938
-	    {
937
+		if (!is_string($ident))
938
+		{
939 939
 		return false;
940
-	    } else {
940
+		} else {
941 941
 		$additional_query = " AND spotter_archive_output.ident = :ident";
942 942
 		$query_values = array(':ident' => $ident);
943
-	    }
943
+		}
944 944
 	}
945 945
 	
946 946
 	if ($limit != "")
947 947
 	{
948
-	    $limit_array = explode(",", $limit);
948
+		$limit_array = explode(",", $limit);
949 949
 	    
950
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
951
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
950
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
951
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
952 952
 	    
953
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
954
-	    {
953
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
954
+		{
955 955
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
956 956
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
957
-	    }
957
+		}
958 958
 	}
959 959
 
960 960
 	if ($sort != "")
961 961
 	{
962
-	    $search_orderby_array = $Spotter->getOrderBy();
963
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
962
+		$search_orderby_array = $Spotter->getOrderBy();
963
+		$orderby_query = $search_orderby_array[$sort]['sql'];
964 964
 	} else {
965
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
965
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
966 966
 	}
967 967
 
968 968
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -970,17 +970,17 @@  discard block
 block discarded – undo
970 970
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
971 971
 
972 972
 	return $spotter_array;
973
-    }
973
+	}
974 974
 
975 975
 
976
-    /**
977
-    * Gets all the spotter information based on the owner
978
-    *
979
-    * @return Array the spotter information
980
-    *
981
-    */
982
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
983
-    {
976
+	/**
977
+	 * Gets all the spotter information based on the owner
978
+	 *
979
+	 * @return Array the spotter information
980
+	 *
981
+	 */
982
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
983
+	{
984 984
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
985 985
 	
986 986
 	date_default_timezone_set('UTC');
@@ -993,35 +993,35 @@  discard block
 block discarded – undo
993 993
 	
994 994
 	if ($owner != "")
995 995
 	{
996
-	    if (!is_string($owner))
997
-	    {
996
+		if (!is_string($owner))
997
+		{
998 998
 		return false;
999
-	    } else {
999
+		} else {
1000 1000
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
1001 1001
 		$query_values = array(':owner' => $owner);
1002
-	    }
1002
+		}
1003 1003
 	}
1004 1004
 	
1005 1005
 	if ($limit != "")
1006 1006
 	{
1007
-	    $limit_array = explode(",", $limit);
1007
+		$limit_array = explode(",", $limit);
1008 1008
 	    
1009
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1010
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1009
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1010
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1011 1011
 	    
1012
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1013
-	    {
1012
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1013
+		{
1014 1014
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1015 1015
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1016
-	    }
1016
+		}
1017 1017
 	}
1018 1018
 
1019 1019
 	if ($sort != "")
1020 1020
 	{
1021
-	    $search_orderby_array = $Spotter->getOrderBy();
1022
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1021
+		$search_orderby_array = $Spotter->getOrderBy();
1022
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1023 1023
 	} else {
1024
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1024
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1025 1025
 	}
1026 1026
 
1027 1027
 	$query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1029,16 +1029,16 @@  discard block
 block discarded – undo
1029 1029
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1030 1030
 
1031 1031
 	return $spotter_array;
1032
-    }
1033
-
1034
-    /**
1035
-    * Gets all the spotter information based on the pilot
1036
-    *
1037
-    * @return Array the spotter information
1038
-    *
1039
-    */
1040
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1041
-    {
1032
+	}
1033
+
1034
+	/**
1035
+	 * Gets all the spotter information based on the pilot
1036
+	 *
1037
+	 * @return Array the spotter information
1038
+	 *
1039
+	 */
1040
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1041
+	{
1042 1042
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1043 1043
 	
1044 1044
 	date_default_timezone_set('UTC');
@@ -1057,24 +1057,24 @@  discard block
 block discarded – undo
1057 1057
 	
1058 1058
 	if ($limit != "")
1059 1059
 	{
1060
-	    $limit_array = explode(",", $limit);
1060
+		$limit_array = explode(",", $limit);
1061 1061
 	    
1062
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1063
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1062
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1063
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1064 1064
 	    
1065
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1066
-	    {
1065
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1066
+		{
1067 1067
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1068 1068
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1069
-	    }
1069
+		}
1070 1070
 	}
1071 1071
 
1072 1072
 	if ($sort != "")
1073 1073
 	{
1074
-	    $search_orderby_array = $Spotter->getOrderBy();
1075
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1074
+		$search_orderby_array = $Spotter->getOrderBy();
1075
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1076 1076
 	} else {
1077
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1077
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1078 1078
 	}
1079 1079
 
1080 1080
 	$query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1082,16 +1082,16 @@  discard block
 block discarded – undo
1082 1082
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1083 1083
 
1084 1084
 	return $spotter_array;
1085
-    }
1086
-
1087
-    /**
1088
-    * Gets all number of flight over countries
1089
-    *
1090
-    * @return Array the airline country list
1091
-    *
1092
-    */
1093
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1094
-    {
1085
+	}
1086
+
1087
+	/**
1088
+	 * Gets all number of flight over countries
1089
+	 *
1090
+	 * @return Array the airline country list
1091
+	 *
1092
+	 */
1093
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1094
+	{
1095 1095
 	global $globalDBdriver;
1096 1096
 	/*
1097 1097
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1101,14 +1101,14 @@  discard block
 block discarded – undo
1101 1101
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1102 1102
 		    FROM countries c, spotter_archive s
1103 1103
 		    WHERE c.iso2 = s.over_country ";
1104
-                if ($olderthanmonths > 0) {
1105
-            		if ($globalDBdriver == 'mysql') {
1104
+				if ($olderthanmonths > 0) {
1105
+					if ($globalDBdriver == 'mysql') {
1106 1106
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1107 1107
 			} else {
1108 1108
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1109 1109
 			}
1110 1110
 		}
1111
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1111
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1112 1112
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1113 1113
 	if ($limit) $query .= " LIMIT 0,10";
1114 1114
       
@@ -1121,23 +1121,23 @@  discard block
 block discarded – undo
1121 1121
         
1122 1122
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1123 1123
 	{
1124
-	    $temp_array['flight_count'] = $row['nb'];
1125
-	    $temp_array['flight_country'] = $row['name'];
1126
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1127
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1128
-	    $flight_array[] = $temp_array;
1124
+		$temp_array['flight_count'] = $row['nb'];
1125
+		$temp_array['flight_country'] = $row['name'];
1126
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1127
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1128
+		$flight_array[] = $temp_array;
1129 1129
 	}
1130 1130
 	return $flight_array;
1131
-    }
1132
-
1133
-    /**
1134
-    * Gets all number of flight over countries
1135
-    *
1136
-    * @return Array the airline country list
1137
-    *
1138
-    */
1139
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1140
-    {
1131
+	}
1132
+
1133
+	/**
1134
+	 * Gets all number of flight over countries
1135
+	 *
1136
+	 * @return Array the airline country list
1137
+	 *
1138
+	 */
1139
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1140
+	{
1141 1141
 	global $globalDBdriver;
1142 1142
 	/*
1143 1143
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1147,14 +1147,14 @@  discard block
 block discarded – undo
1147 1147
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1148 1148
 		    FROM countries c, spotter_archive s, spotter_output o
1149 1149
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1150
-                if ($olderthanmonths > 0) {
1151
-            		if ($globalDBdriver == 'mysql') {
1150
+				if ($olderthanmonths > 0) {
1151
+					if ($globalDBdriver == 'mysql') {
1152 1152
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1153 1153
 			} else {
1154 1154
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1155 1155
 			}
1156 1156
 		}
1157
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1157
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1158 1158
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1159 1159
 	if ($limit) $query .= " LIMIT 0,10";
1160 1160
       
@@ -1167,24 +1167,24 @@  discard block
 block discarded – undo
1167 1167
         
1168 1168
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1169 1169
 	{
1170
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1171
-	    $temp_array['flight_count'] = $row['nb'];
1172
-	    $temp_array['flight_country'] = $row['name'];
1173
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1174
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1175
-	    $flight_array[] = $temp_array;
1170
+		$temp_array['airline_icao'] = $row['airline_icao'];
1171
+		$temp_array['flight_count'] = $row['nb'];
1172
+		$temp_array['flight_country'] = $row['name'];
1173
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1174
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1175
+		$flight_array[] = $temp_array;
1176 1176
 	}
1177 1177
 	return $flight_array;
1178
-    }
1179
-
1180
-    /**
1181
-    * Gets last spotter information based on a particular callsign
1182
-    *
1183
-    * @return Array the spotter information
1184
-    *
1185
-    */
1186
-    public function getDateArchiveSpotterDataById($id,$date)
1187
-    {
1178
+	}
1179
+
1180
+	/**
1181
+	 * Gets last spotter information based on a particular callsign
1182
+	 *
1183
+	 * @return Array the spotter information
1184
+	 *
1185
+	 */
1186
+	public function getDateArchiveSpotterDataById($id,$date)
1187
+	{
1188 1188
 	$Spotter = new Spotter($this->db);
1189 1189
 	date_default_timezone_set('UTC');
1190 1190
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1192,16 +1192,16 @@  discard block
 block discarded – undo
1192 1192
 	$date = date('c',$date);
1193 1193
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1194 1194
 	return $spotter_array;
1195
-    }
1196
-
1197
-    /**
1198
-    * Gets all the spotter information based on a particular callsign
1199
-    *
1200
-    * @return Array the spotter information
1201
-    *
1202
-    */
1203
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1204
-    {
1195
+	}
1196
+
1197
+	/**
1198
+	 * Gets all the spotter information based on a particular callsign
1199
+	 *
1200
+	 * @return Array the spotter information
1201
+	 *
1202
+	 */
1203
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1204
+	{
1205 1205
 	$Spotter = new Spotter($this->db);
1206 1206
 	date_default_timezone_set('UTC');
1207 1207
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1209,16 +1209,16 @@  discard block
 block discarded – undo
1209 1209
 	$date = date('c',$date);
1210 1210
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1211 1211
 	return $spotter_array;
1212
-    }
1213
-
1214
-    /**
1215
-    * Gets all the spotter information based on the airport
1216
-    *
1217
-    * @return Array the spotter information
1218
-    *
1219
-    */
1220
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1221
-    {
1212
+	}
1213
+
1214
+	/**
1215
+	 * Gets all the spotter information based on the airport
1216
+	 *
1217
+	 * @return Array the spotter information
1218
+	 *
1219
+	 */
1220
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1221
+	{
1222 1222
 	global $global_query;
1223 1223
 	$Spotter = new Spotter($this->db);
1224 1224
 	date_default_timezone_set('UTC');
@@ -1229,35 +1229,35 @@  discard block
 block discarded – undo
1229 1229
 	
1230 1230
 	if ($airport != "")
1231 1231
 	{
1232
-	    if (!is_string($airport))
1233
-	    {
1232
+		if (!is_string($airport))
1233
+		{
1234 1234
 		return false;
1235
-	    } else {
1235
+		} else {
1236 1236
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1237 1237
 		$query_values = array(':airport' => $airport);
1238
-	    }
1238
+		}
1239 1239
 	}
1240 1240
 	
1241 1241
 	if ($limit != "")
1242 1242
 	{
1243
-	    $limit_array = explode(",", $limit);
1243
+		$limit_array = explode(",", $limit);
1244 1244
 	    
1245
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1246
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1245
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1246
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1247 1247
 	    
1248
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1249
-	    {
1248
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1249
+		{
1250 1250
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1251 1251
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1252
-	    }
1252
+		}
1253 1253
 	}
1254 1254
 	
1255 1255
 	if ($sort != "")
1256 1256
 	{
1257
-	    $search_orderby_array = $Spotter->getOrderBy();
1258
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1257
+		$search_orderby_array = $Spotter->getOrderBy();
1258
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1259 1259
 	} else {
1260
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1260
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1261 1261
 	}
1262 1262
 
1263 1263
 	$query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1265,6 +1265,6 @@  discard block
 block discarded – undo
1265 1265
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1266 1266
 
1267 1267
 	return $spotter_array;
1268
-    }
1268
+	}
1269 1269
 }
1270 1270
 ?>
1271 1271
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +40 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection. (SpotterArchive)');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection. (SpotterArchive)');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -116,8 +120,11 @@  discard block
 block discarded – undo
116 120
 			}
117 121
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
118 122
 		}
119
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
120
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123
+		if ($filter_query_where == '' && $where) {
124
+			$filter_query_where = ' WHERE';
125
+		} elseif ($filter_query_where != '' && $and) {
126
+			$filter_query_where .= ' AND';
127
+		}
121 128
 		if ($filter_query_where != '') {
122 129
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
123 130
 		}
@@ -131,10 +138,17 @@  discard block
 block discarded – undo
131 138
 		if ($over_country == '') {
132 139
 			$Spotter = new Spotter($this->db);
133 140
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
134
-			if (!empty($data_country)) $country = $data_country['iso2'];
135
-			else $country = '';
136
-		} else $country = $over_country;
137
-		if ($airline_type === NULL) $airline_type ='';
141
+			if (!empty($data_country)) {
142
+				$country = $data_country['iso2'];
143
+			} else {
144
+				$country = '';
145
+			}
146
+		} else {
147
+			$country = $over_country;
148
+		}
149
+		if ($airline_type === NULL) {
150
+			$airline_type ='';
151
+		}
138 152
 	
139 153
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
140 154
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -630,7 +644,9 @@  discard block
 block discarded – undo
630 644
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
631 645
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
632 646
 		    $translate = $Translation->ident2icao($q_item);
633
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
647
+		    if ($translate != $q_item) {
648
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
649
+		    }
634 650
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
635 651
 		    $additional_query .= ")";
636 652
 		}
@@ -846,7 +862,9 @@  discard block
 block discarded – undo
846 862
 			date_default_timezone_set($globalTimezone);
847 863
 			$datetime = new DateTime();
848 864
 			$offset = $datetime->format('P');
849
-		} else $offset = '+00:00';
865
+		} else {
866
+			$offset = '+00:00';
867
+		}
850 868
 		if ($date_array[1] != "")
851 869
 		{                
852 870
 			$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1112,9 +1130,13 @@  discard block
 block discarded – undo
1112 1130
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1113 1131
 			}
1114 1132
 		}
1115
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1133
+                if ($sincedate != '') {
1134
+                	$query .= "AND date > '".$sincedate."' ";
1135
+                }
1116 1136
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1117
-	if ($limit) $query .= " LIMIT 0,10";
1137
+	if ($limit) {
1138
+		$query .= " LIMIT 0,10";
1139
+	}
1118 1140
       
1119 1141
 	
1120 1142
 	$sth = $this->db->prepare($query);
@@ -1158,9 +1180,13 @@  discard block
 block discarded – undo
1158 1180
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1159 1181
 			}
1160 1182
 		}
1161
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1183
+                if ($sincedate != '') {
1184
+                	$query .= "AND s.date > '".$sincedate."' ";
1185
+                }
1162 1186
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1163
-	if ($limit) $query .= " LIMIT 0,10";
1187
+	if ($limit) {
1188
+		$query .= " LIMIT 0,10";
1189
+	}
1164 1190
       
1165 1191
 	
1166 1192
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -14,82 +14,82 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 				$filters = $globalStatsFilters[$globalFilterName];
23 23
 			} else {
24
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
25 25
 			}
26 26
 		}
27 27
 		if (isset($filter[0]['source'])) {
28
-			$filters = array_merge($filters,$filter);
28
+			$filters = array_merge($filters, $filter);
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
35 35
 				if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') {
36 36
 					if (isset($flt['source'])) {
37
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
38 38
 					} else {
39
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
40 40
 					}
41 41
 				}
42 42
 			}
43 43
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
44 44
 				if (isset($flt['source'])) {
45
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46 46
 				} else {
47
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
48 48
 				}
49 49
 			}
50 50
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
51 51
 				if (isset($flt['source'])) {
52
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53 53
 				} else {
54
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
55 55
 				}
56 56
 			}
57 57
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
58 58
 				if (isset($flt['source'])) {
59
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60 60
 				} else {
61
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
62 62
 				}
63 63
 			}
64 64
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
65 65
 				if (isset($flt['source'])) {
66
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
67 67
 				}
68 68
 			}
69 69
 		}
70 70
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
71 71
 			if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') {
72
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
73 73
 			}
74 74
 		}
75 75
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
76 76
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 		}
78 78
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 		}
81 81
 		if (isset($filter['source']) && !empty($filter['source'])) {
82 82
 			if (count($filter['source']) == 1) {
83 83
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
84 84
 			} else {
85
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
85
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
86 86
 			}
87 87
 		}
88 88
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
89 89
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
90 90
 		}
91 91
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
92
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
92
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
93 93
 		}
94 94
 		if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
95 95
 			$filter_query_date = '';
@@ -114,41 +114,41 @@  discard block
 block discarded – undo
114 114
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
115 115
 				}
116 116
 			}
117
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
117
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
118 118
 		}
119 119
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
120 120
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
121 121
 		if ($filter_query_where != '') {
122
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
122
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
123 123
 		}
124 124
 		$filter_query = $filter_query_join.$filter_query_where;
125 125
 		return $filter_query;
126 126
 	}
127 127
 
128 128
 	// Spotter_archive
129
-	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
129
+	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
130 130
 		require_once(dirname(__FILE__).'/class.Spotter.php');
131 131
 		if ($over_country == '') {
132 132
 			$Spotter = new Spotter($this->db);
133
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
133
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
134 134
 			if (!empty($data_country)) $country = $data_country['iso2'];
135 135
 			else $country = '';
136 136
 		} else $country = $over_country;
137
-		if ($airline_type === NULL) $airline_type ='';
137
+		if ($airline_type === NULL) $airline_type = '';
138 138
 	
139 139
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
140 140
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
141 141
 
142 142
 		// Route is not added in spotter_archive
143
-		$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude)
143
+		$query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name,real_altitude)
144 144
 		        VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name,:real_altitude)";
145 145
 
146
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name,':real_altitude' => $real_altitude);
146
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name, ':real_altitude' => $real_altitude);
147 147
 		try {
148 148
 			$sth = $this->db->prepare($query);
149 149
 			$sth->execute($query_values);
150 150
 			$sth->closeCursor();
151
-		} catch(PDOException $e) {
151
+		} catch (PDOException $e) {
152 152
 			return "error : ".$e->getMessage();
153 153
 		}
154 154
 		return "success";
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 
169 169
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
170 170
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
171
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
171
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
172 172
 
173
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
173
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
174 174
 
175 175
                 return $spotter_array;
176 176
         }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
190 190
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
191 191
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
192
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
192
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
193 193
 
194 194
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
195 195
                   /*
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
                 }
203 203
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
204 204
                 */
205
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
205
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
206 206
 
207 207
                 return $spotter_array;
208 208
         }
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 	{
218 218
                 date_default_timezone_set('UTC');
219 219
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
220
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
220
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
221 221
 
222 222
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
223 223
 
224 224
                 try {
225 225
                         $sth = $this->db->prepare($query);
226 226
                         $sth->execute(array(':id' => $id));
227
-                } catch(PDOException $e) {
227
+                } catch (PDOException $e) {
228 228
                         echo $e->getMessage();
229 229
                         die;
230 230
                 }
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
         {
244 244
                 date_default_timezone_set('UTC');
245 245
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
246
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
246
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
247 247
 
248 248
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
249 249
 
250 250
                 try {
251 251
                         $sth = $this->db->prepare($query);
252 252
                         $sth->execute(array(':id' => $id));
253
-                } catch(PDOException $e) {
253
+                } catch (PDOException $e) {
254 254
                         echo $e->getMessage();
255 255
                         die;
256 256
                 }
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
                 date_default_timezone_set('UTC');
273 273
 
274 274
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
275
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
275
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
276 276
 
277 277
                 try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute(array(':ident' => $ident));
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         echo $e->getMessage();
282 282
                         die;
283 283
                 }
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
                 date_default_timezone_set('UTC');
299 299
 
300 300
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
301
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
301
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
302 302
 
303 303
                 try {
304 304
                         $sth = $this->db->prepare($query);
305 305
                         $sth->execute(array(':id' => $id));
306
-                } catch(PDOException $e) {
306
+                } catch (PDOException $e) {
307 307
                         echo $e->getMessage();
308 308
                         die;
309 309
                 }
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
 	{
323 323
 		date_default_timezone_set('UTC');
324 324
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
325
-		$query  = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
325
+		$query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
326 326
 		try {
327 327
 			$sth = $this->db->prepare($query);
328 328
 			$sth->execute(array(':id' => $id));
329
-		} catch(PDOException $e) {
329
+		} catch (PDOException $e) {
330 330
 			echo $e->getMessage();
331 331
 			die;
332 332
 		}
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
 	{
345 345
 		date_default_timezone_set('UTC');
346 346
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
347
-		$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
347
+		$query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
348 348
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
349 349
 		try {
350 350
 			$sth = $this->db->prepare($query);
351 351
 			$sth->execute(array(':ident' => $ident));
352
-		} catch(PDOException $e) {
352
+		} catch (PDOException $e) {
353 353
 			echo $e->getMessage();
354 354
 			die;
355 355
 		}
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
         * @return Array the spotter information
366 366
         *
367 367
         */
368
-	public function getSpotterArchiveData($ident,$flightaware_id,$date)
368
+	public function getSpotterArchiveData($ident, $flightaware_id, $date)
369 369
 	{
370 370
 		$Spotter = new Spotter($this->db);
371 371
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
372
-		$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
373
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
372
+		$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
373
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
374 374
 		return $spotter_array;
375 375
 	}
376 376
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 		try {
386 386
 			$sth = $this->db->prepare($query);
387 387
 			$sth->execute();
388
-		} catch(PDOException $e) {
388
+		} catch (PDOException $e) {
389 389
 			echo $e->getMessage();
390 390
 			die;
391 391
 		}
@@ -397,24 +397,24 @@  discard block
 block discarded – undo
397 397
         * @return Array the spotter information
398 398
         *
399 399
         */
400
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
400
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
401 401
         {
402 402
                 global $globalDBdriver, $globalLiveInterval;
403 403
                 date_default_timezone_set('UTC');
404 404
 
405 405
                 $filter_query = '';
406 406
                 if (isset($filter['source']) && !empty($filter['source'])) {
407
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
407
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
408 408
                 }
409 409
                 // Use spotter_output also ?
410 410
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
411
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
411
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
412 412
                 }
413 413
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
414 414
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
415 415
                 }
416 416
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
417
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
417
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
418 418
                 }
419 419
 
420 420
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
434 434
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
435 435
 */
436
-			$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
436
+			$query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
437 437
 				    FROM spotter_archive 
438 438
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
439 439
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
440 440
                         	    '.$filter_query.' ORDER BY flightaware_id';
441 441
                 } else {
442 442
                         //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
443
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
443
+                        $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
444 444
                         	    FROM spotter_archive 
445 445
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
446 446
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
                 try {
451 451
                         $sth = $this->db->prepare($query);
452 452
                         $sth->execute();
453
-                } catch(PDOException $e) {
453
+                } catch (PDOException $e) {
454 454
                         echo $e->getMessage();
455 455
                         die;
456 456
                 }
@@ -465,24 +465,24 @@  discard block
 block discarded – undo
465 465
         * @return Array the spotter information
466 466
         *
467 467
         */
468
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
468
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
469 469
         {
470 470
                 global $globalDBdriver, $globalLiveInterval;
471 471
                 date_default_timezone_set('UTC');
472 472
 
473 473
                 $filter_query = '';
474 474
                 if (isset($filter['source']) && !empty($filter['source'])) {
475
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
475
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
476 476
                 }
477 477
                 // Should use spotter_output also ?
478 478
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
479
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
479
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
480 480
                 }
481 481
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
482 482
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
483 483
                 }
484 484
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
485
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
485
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
486 486
                 }
487 487
 
488 488
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
                     		    FROM spotter_archive 
493 493
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
494 494
 			*/
495
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
495
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
496 496
 				    FROM spotter_archive_output 
497 497
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
498 498
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
508 508
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
509 509
                         */
510
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
510
+                        $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
511 511
                         	    FROM spotter_archive_output 
512 512
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
513 513
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
                 try {
520 520
                         $sth = $this->db->prepare($query);
521 521
                         $sth->execute();
522
-                } catch(PDOException $e) {
522
+                } catch (PDOException $e) {
523 523
                         echo $e->getMessage();
524 524
                         die;
525 525
                 }
@@ -534,23 +534,23 @@  discard block
 block discarded – undo
534 534
         * @return Array the spotter information
535 535
         *
536 536
         */
537
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
537
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
538 538
         {
539 539
                 global $globalDBdriver, $globalLiveInterval;
540 540
                 date_default_timezone_set('UTC');
541 541
 
542 542
                 $filter_query = '';
543 543
                 if (isset($filter['source']) && !empty($filter['source'])) {
544
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
544
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
545 545
                 }
546 546
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
547
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
547
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
548 548
                 }
549 549
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
550 550
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
551 551
                 }
552 552
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
553
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
553
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
554 554
                 }
555 555
 
556 556
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
                 try {
566 566
                         $sth = $this->db->prepare($query);
567 567
                         $sth->execute();
568
-                } catch(PDOException $e) {
568
+                } catch (PDOException $e) {
569 569
                         echo $e->getMessage();
570 570
                         die;
571 571
                 }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
     * @return Array the spotter information
586 586
     *
587 587
     */
588
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
588
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
589 589
     {
590 590
 	global $globalTimezone, $globalDBdriver;
591 591
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	        
608 608
 		$q_array = explode(" ", $q);
609 609
 		
610
-		foreach ($q_array as $q_item){
610
+		foreach ($q_array as $q_item) {
611 611
 		    $additional_query .= " AND (";
612 612
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
613 613
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 	
640 640
 	if ($registration != "")
641 641
 	{
642
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
642
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
643 643
 	    if (!is_string($registration))
644 644
 	    {
645 645
 		return false;
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	
651 651
 	if ($aircraft_icao != "")
652 652
 	{
653
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
653
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
654 654
 	    if (!is_string($aircraft_icao))
655 655
 	    {
656 656
 		return false;
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 	
662 662
 	if ($aircraft_manufacturer != "")
663 663
 	{
664
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
664
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
665 665
 	    if (!is_string($aircraft_manufacturer))
666 666
 	    {
667 667
 		return false;
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 	
683 683
 	if ($airline_icao != "")
684 684
 	{
685
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
685
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
686 686
 	    if (!is_string($airline_icao))
687 687
 	    {
688 688
 		return false;
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	
694 694
 	if ($airline_country != "")
695 695
 	{
696
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
696
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
697 697
 	    if (!is_string($airline_country))
698 698
 	    {
699 699
 		return false;
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 	
705 705
 	if ($airline_type != "")
706 706
 	{
707
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
707
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
708 708
 	    if (!is_string($airline_type))
709 709
 	    {
710 710
 		return false;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 	
727 727
 	if ($airport != "")
728 728
 	{
729
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
729
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
730 730
 	    if (!is_string($airport))
731 731
 	    {
732 732
 		return false;
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	
738 738
 	if ($airport_country != "")
739 739
 	{
740
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
740
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
741 741
 	    if (!is_string($airport_country))
742 742
 	    {
743 743
 		return false;
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
     
749 749
 	if ($callsign != "")
750 750
 	{
751
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
751
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
752 752
 	    if (!is_string($callsign))
753 753
 	    {
754 754
 		return false;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 		$translate = $Translation->ident2icao($callsign);
757 757
 		if ($translate != $callsign) {
758 758
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
759
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
759
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
760 760
 		} else {
761 761
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
762 762
 		}
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 
766 766
 	if ($owner != "")
767 767
 	{
768
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
768
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
769 769
 	    if (!is_string($owner))
770 770
 	    {
771 771
 		return false;
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 
777 777
 	if ($pilot_name != "")
778 778
 	{
779
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
779
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
780 780
 	    if (!is_string($pilot_name))
781 781
 	    {
782 782
 		return false;
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	
788 788
 	if ($pilot_id != "")
789 789
 	{
790
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
790
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
791 791
 	    if (!is_string($pilot_id))
792 792
 	    {
793 793
 		return false;
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 	
799 799
 	if ($departure_airport_route != "")
800 800
 	{
801
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
801
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
802 802
 	    if (!is_string($departure_airport_route))
803 803
 	    {
804 804
 		return false;
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 	
810 810
 	if ($arrival_airport_route != "")
811 811
 	{
812
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
812
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
813 813
 	    if (!is_string($arrival_airport_route))
814 814
 	    {
815 815
 		return false;
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 	{
823 823
 	    $altitude_array = explode(",", $altitude);
824 824
 	    
825
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
826
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
825
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
826
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
827 827
 	    
828 828
 
829 829
 	    if ($altitude_array[1] != "")
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 	if ($date_posted != "")
841 841
 	{
842 842
 		$date_array = explode(",", $date_posted);
843
-		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
844
-		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
843
+		$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
844
+		$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
845 845
 		if ($globalTimezone != '') {
846 846
 			date_default_timezone_set($globalTimezone);
847 847
 			$datetime = new DateTime();
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 		if ($limit != "")
869 869
 		{
870 870
 			$limit_array = explode(",", $limit);
871
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
872
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
871
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
872
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
873 873
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
874 874
 			{
875 875
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 			}
878 878
 		}
879 879
 		if ($origLat != "" && $origLon != "" && $dist != "") {
880
-			$dist = number_format($dist*0.621371,2,'.','');
881
-			$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
880
+			$dist = number_format($dist*0.621371, 2, '.', '');
881
+			$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
882 882
 			      FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
883 883
 			      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
884 884
 		} else {
@@ -894,12 +894,12 @@  discard block
 block discarded – undo
894 894
 				$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
895 895
 			}
896 896
 
897
-			$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
897
+			$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
898 898
 			    WHERE spotter_archive_output.ident <> '' 
899 899
 			    ".$additional_query."
900 900
 			    ".$filter_query.$orderby_query;
901 901
 		}
902
-		$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
902
+		$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
903 903
 		return $spotter_array;
904 904
 	}
905 905
 
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 		try {
915 915
 			$sth = $this->db->prepare($query);
916 916
 			$sth->execute();
917
-		} catch(PDOException $e) {
917
+		} catch (PDOException $e) {
918 918
 			return "error";
919 919
 		}
920 920
 	}
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 	{
952 952
 	    $limit_array = explode(",", $limit);
953 953
 	    
954
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
955
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
954
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
955
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
956 956
 	    
957 957
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
958 958
 	    {
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 	$query_values = array();
994 994
 	$limit_query = '';
995 995
 	$additional_query = '';
996
-	$filter_query = $this->getFilter($filter,true,true);
996
+	$filter_query = $this->getFilter($filter, true, true);
997 997
 	
998 998
 	if ($owner != "")
999 999
 	{
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
 	{
1011 1011
 	    $limit_array = explode(",", $limit);
1012 1012
 	    
1013
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1014
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1013
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1014
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1015 1015
 	    
1016 1016
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1017 1017
 	    {
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	$query_values = array();
1052 1052
 	$limit_query = '';
1053 1053
 	$additional_query = '';
1054
-	$filter_query = $this->getFilter($filter,true,true);
1054
+	$filter_query = $this->getFilter($filter, true, true);
1055 1055
 	
1056 1056
 	if ($pilot != "")
1057 1057
 	{
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 	{
1064 1064
 	    $limit_array = explode(",", $limit);
1065 1065
 	    
1066
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1067
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1066
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1067
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1068 1068
 	    
1069 1069
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1070 1070
 	    {
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
     * @return Array the airline country list
1095 1095
     *
1096 1096
     */
1097
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1097
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1098 1098
     {
1099 1099
 	global $globalDBdriver;
1100 1100
 	/*
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 	$flight_array = array();
1124 1124
 	$temp_array = array();
1125 1125
         
1126
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1126
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1127 1127
 	{
1128 1128
 	    $temp_array['flight_count'] = $row['nb'];
1129 1129
 	    $temp_array['flight_country'] = $row['name'];
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
     * @return Array the airline country list
1141 1141
     *
1142 1142
     */
1143
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1143
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1144 1144
     {
1145 1145
 	global $globalDBdriver;
1146 1146
 	/*
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	$flight_array = array();
1170 1170
 	$temp_array = array();
1171 1171
         
1172
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1172
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1173 1173
 	{
1174 1174
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1175 1175
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1187,14 +1187,14 @@  discard block
 block discarded – undo
1187 1187
     * @return Array the spotter information
1188 1188
     *
1189 1189
     */
1190
-    public function getDateArchiveSpotterDataById($id,$date)
1190
+    public function getDateArchiveSpotterDataById($id, $date)
1191 1191
     {
1192 1192
 	$Spotter = new Spotter($this->db);
1193 1193
 	date_default_timezone_set('UTC');
1194 1194
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1195
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1196
-	$date = date('c',$date);
1197
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1195
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1196
+	$date = date('c', $date);
1197
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1198 1198
 	return $spotter_array;
1199 1199
     }
1200 1200
 
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
     * @return Array the spotter information
1205 1205
     *
1206 1206
     */
1207
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1207
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1208 1208
     {
1209 1209
 	$Spotter = new Spotter($this->db);
1210 1210
 	date_default_timezone_set('UTC');
1211 1211
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1212
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1213
-	$date = date('c',$date);
1214
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1212
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1213
+	$date = date('c', $date);
1214
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1215 1215
 	return $spotter_array;
1216 1216
     }
1217 1217
 
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
     * @return Array the spotter information
1222 1222
     *
1223 1223
     */
1224
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1224
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1225 1225
     {
1226 1226
 	global $global_query;
1227 1227
 	$Spotter = new Spotter($this->db);
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 	$query_values = array();
1230 1230
 	$limit_query = '';
1231 1231
 	$additional_query = '';
1232
-	$filter_query = $this->getFilter($filters,true,true);
1232
+	$filter_query = $this->getFilter($filters, true, true);
1233 1233
 	
1234 1234
 	if ($airport != "")
1235 1235
 	{
@@ -1246,8 +1246,8 @@  discard block
 block discarded – undo
1246 1246
 	{
1247 1247
 	    $limit_array = explode(",", $limit);
1248 1248
 	    
1249
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1250
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1249
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1250
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1251 1251
 	    
1252 1252
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1253 1253
 	    {
Please login to merge, or discard this patch.
require/class.Stats.php 4 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -405,17 +405,17 @@  discard block
 block discarded – undo
405 405
 			}
406 406
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
407 407
 		} else $all = array();
408
-                if (empty($all)) {
409
-	                $Spotter = new Spotter($this->db);
410
-            		$filters = array();
408
+				if (empty($all)) {
409
+					$Spotter = new Spotter($this->db);
410
+					$filters = array();
411 411
 			$filters = array('year' => $year,'month' => $month);
412
-            		if ($filter_name != '') {
413
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
412
+					if ($filter_name != '') {
413
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
414 414
 			}
415 415
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
416
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
417
-                }
418
-                return $all;
416
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
417
+				}
418
+				return $all;
419 419
 	}
420 420
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
421 421
 		global $globalStatsFilters;
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 			return "error : ".$e->getMessage();
1613 1613
 		}
1614 1614
 	}
1615
-        /*
1615
+		/*
1616 1616
 	public function getStatsSource($date,$stats_type = '') {
1617 1617
 		if ($stats_type == '') {
1618 1618
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -2574,8 +2574,8 @@  discard block
 block discarded – undo
2574 2574
 					}
2575 2575
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2576 2576
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2577
-				    	foreach ($alldata as $number) {
2578
-			    			$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);
2577
+						foreach ($alldata as $number) {
2578
+							$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);
2579 2579
 					}
2580 2580
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2581 2581
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
Please login to merge, or discard this patch.
Doc Comments   +51 added lines patch added patch discarded remove patch
@@ -21,6 +21,10 @@  discard block
 block discarded – undo
21 21
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
22 22
 	}
23 23
 
24
+	/**
25
+	 * @param string $type
26
+	 * @param string $stats_date
27
+	 */
24 28
 	public function addLastStatsUpdate($type,$stats_date) {
25 29
 		$query = "DELETE FROM config WHERE name = :type;
26 30
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -1415,6 +1419,10 @@  discard block
 block discarded – undo
1415 1419
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1416 1420
 		return $all;
1417 1421
 	}
1422
+
1423
+	/**
1424
+	 * @param string $type
1425
+	 */
1418 1426
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1419 1427
 		if ($filter_name == '') $filter_name = $this->filter_name;
1420 1428
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1426,6 +1434,11 @@  discard block
 block discarded – undo
1426 1434
 			echo "error : ".$e->getMessage();
1427 1435
 		}
1428 1436
 	}
1437
+
1438
+	/**
1439
+	 * @param string $type
1440
+	 * @param string $year
1441
+	 */
1429 1442
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1430 1443
 		if ($filter_name == '') $filter_name = $this->filter_name;
1431 1444
 		global $globalArchiveMonths, $globalDBdriver;
@@ -1625,6 +1638,10 @@  discard block
 block discarded – undo
1625 1638
 		else return 0;
1626 1639
 	}
1627 1640
 
1641
+	/**
1642
+	 * @param string $type
1643
+	 * @param string $stats_date
1644
+	 */
1628 1645
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1629 1646
 		global $globalDBdriver;
1630 1647
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -1678,6 +1695,9 @@  discard block
 block discarded – undo
1678 1695
         }
1679 1696
         */
1680 1697
 
1698
+	/**
1699
+	 * @param string $stats_type
1700
+	 */
1681 1701
 	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1682 1702
 		global $globalDBdriver;
1683 1703
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
@@ -1721,6 +1741,9 @@  discard block
 block discarded – undo
1721 1741
 		return $all;
1722 1742
 	}
1723 1743
 
1744
+	/**
1745
+	 * @param string $stats_type
1746
+	 */
1724 1747
 	public function addStatSource($data,$source_name,$stats_type,$date) {
1725 1748
 		global $globalDBdriver;
1726 1749
 		if ($globalDBdriver == 'mysql') {
@@ -1736,6 +1759,10 @@  discard block
 block discarded – undo
1736 1759
 			return "error : ".$e->getMessage();
1737 1760
 		}
1738 1761
 	}
1762
+
1763
+	/**
1764
+	 * @param string $type
1765
+	 */
1739 1766
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1740 1767
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1741 1768
 		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
@@ -1746,6 +1773,10 @@  discard block
 block discarded – undo
1746 1773
 			return "error : ".$e->getMessage();
1747 1774
 		}
1748 1775
 	}
1776
+
1777
+	/**
1778
+	 * @param string $type
1779
+	 */
1749 1780
 	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
1750 1781
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1751 1782
 		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
@@ -1756,6 +1787,10 @@  discard block
 block discarded – undo
1756 1787
 			return "error : ".$e->getMessage();
1757 1788
 		}
1758 1789
 	}
1790
+
1791
+	/**
1792
+	 * @param string $type
1793
+	 */
1759 1794
 	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
1760 1795
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
1761 1796
 		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
@@ -2068,6 +2103,10 @@  discard block
 block discarded – undo
2068 2103
 			return "error : ".$e->getMessage();
2069 2104
 		}
2070 2105
 	}
2106
+
2107
+	/**
2108
+	 * @param string $type
2109
+	 */
2071 2110
 	public function deleteStatFlight($type) {
2072 2111
 		$query = "DELETE FROM stats_flight WHERE stats_type = :type";
2073 2112
 		$query_values = array(':type' => $type);
@@ -2078,6 +2117,10 @@  discard block
 block discarded – undo
2078 2117
 			return "error : ".$e->getMessage();
2079 2118
 		}
2080 2119
 	}
2120
+
2121
+	/**
2122
+	 * @param string $type
2123
+	 */
2081 2124
 	public function deleteStatMarine($type) {
2082 2125
 		$query = "DELETE FROM stats_marine WHERE stats_type = :type";
2083 2126
 		$query_values = array(':type' => $type);
@@ -2088,6 +2131,10 @@  discard block
 block discarded – undo
2088 2131
 			return "error : ".$e->getMessage();
2089 2132
 		}
2090 2133
 	}
2134
+
2135
+	/**
2136
+	 * @param string $type
2137
+	 */
2091 2138
 	public function deleteStatTracker($type) {
2092 2139
 		$query = "DELETE FROM stats_tracker WHERE stats_type = :type";
2093 2140
 		$query_values = array(':type' => $type);
@@ -2098,6 +2145,10 @@  discard block
 block discarded – undo
2098 2145
 			return "error : ".$e->getMessage();
2099 2146
 		}
2100 2147
 	}
2148
+
2149
+	/**
2150
+	 * @param string $type
2151
+	 */
2101 2152
 	public function deleteStatAirport($type) {
2102 2153
 		$query = "DELETE FROM stats_airport WHERE stats_type = :type";
2103 2154
 		$query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Spacing   +643 added lines, -643 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
29 29
 	}
30 30
 
31
-	public function addLastStatsUpdate($type,$stats_date) {
31
+	public function addLastStatsUpdate($type, $stats_date) {
32 32
 		$query = "DELETE FROM config WHERE name = :type;
33 33
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
34
-		$query_values = array('type' => $type,':stats_date' => $stats_date);
34
+		$query_values = array('type' => $type, ':stats_date' => $stats_date);
35 35
 		try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute($query_values);
38
-		} catch(PDOException $e) {
38
+		} catch (PDOException $e) {
39 39
 			return "error : ".$e->getMessage();
40 40
 		}
41 41
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		try {
46 46
 			$sth = $this->db->prepare($query);
47 47
 			$sth->execute(array(':type' => $type));
48
-		} catch(PDOException $e) {
48
+		} catch (PDOException $e) {
49 49
 			echo "error : ".$e->getMessage();
50 50
 		}
51 51
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		try {
67 67
 			$sth = $this->db->prepare($query);
68 68
 			$sth->execute(array(':filter_name' => $filter_name));
69
-		} catch(PDOException $e) {
69
+		} catch (PDOException $e) {
70 70
 			return "error : ".$e->getMessage();
71 71
 		}
72 72
 	}
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		try {
80 80
 			$sth = $this->db->prepare($query);
81 81
 			$sth->execute();
82
-		} catch(PDOException $e) {
82
+		} catch (PDOException $e) {
83 83
 			return "error : ".$e->getMessage();
84 84
 		}
85 85
 		$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
86 86
 		try {
87 87
 			$sth = $this->db->prepare($query);
88 88
 			$sth->execute(array(':filter_name' => $filter_name));
89
-		} catch(PDOException $e) {
89
+		} catch (PDOException $e) {
90 90
 			return "error : ".$e->getMessage();
91 91
 		}
92 92
 	}
@@ -98,77 +98,77 @@  discard block
 block discarded – undo
98 98
 		 try {
99 99
 			$sth = $this->db->prepare($query);
100 100
 			$sth->execute(array(':filter_name' => $filter_name));
101
-		} catch(PDOException $e) {
101
+		} catch (PDOException $e) {
102 102
 			echo "error : ".$e->getMessage();
103 103
 		}
104 104
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
105 105
 		if (empty($all)) {
106 106
 			$filters = array();
107 107
 			if ($filter_name != '') {
108
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
108
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
109 109
 			}
110 110
 			$Spotter = new Spotter($this->db);
111
-			$all = $Spotter->getAllAirlineNames('',NULL,$filters);
111
+			$all = $Spotter->getAllAirlineNames('', NULL, $filters);
112 112
 		}
113 113
 		return $all;
114 114
 	}
115
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
115
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
118 118
 		try {
119 119
 			$sth = $this->db->prepare($query);
120
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-		} catch(PDOException $e) {
120
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+		} catch (PDOException $e) {
122 122
 			echo "error : ".$e->getMessage();
123 123
 		}
124 124
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125 125
 		return $all;
126 126
 	}
127
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
127
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
128 128
 		if ($filter_name == '') $filter_name = $this->filter_name;
129 129
 		$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
130 130
 		try {
131 131
 			$sth = $this->db->prepare($query);
132
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
133
-		} catch(PDOException $e) {
132
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
133
+		} catch (PDOException $e) {
134 134
 			echo "error : ".$e->getMessage();
135 135
 		}
136 136
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
137 137
 		return $all;
138 138
 	}
139
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
139
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
140 140
 		if ($filter_name == '') $filter_name = $this->filter_name;
141 141
 		$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
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
 		return $all;
150 150
 	}
151 151
 
152
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
152
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
153 153
 		if ($filter_name == '') $filter_name = $this->filter_name;
154 154
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
155 155
 		try {
156 156
 			$sth = $this->db->prepare($query);
157
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
158
-		} catch(PDOException $e) {
157
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
158
+		} catch (PDOException $e) {
159 159
 			echo "error : ".$e->getMessage();
160 160
 		}
161 161
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
162 162
 		return $all;
163 163
 	}
164 164
 
165
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
165
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
166 166
 		if ($filter_name == '') $filter_name = $this->filter_name;
167 167
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
168 168
 		try {
169 169
 			$sth = $this->db->prepare($query);
170
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
171
-		} catch(PDOException $e) {
170
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
171
+		} catch (PDOException $e) {
172 172
 			echo "error : ".$e->getMessage();
173 173
 		}
174 174
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
 	}
177 177
 
178 178
 
179
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
179
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
182
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
183 183
 			$Spotter = new Spotter($this->db);
184
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
184
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
185 185
 			$alliance_airlines = array();
186 186
 			foreach ($airlines as $airline) {
187
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
187
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
188 188
 			}
189 189
 			if ($year == '' && $month == '') {
190
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
191
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
190
+				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
191
+				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
192 192
 				try {
193 193
 					$sth = $this->db->prepare($query);
194 194
 					$sth->execute(array(':filter_name' => $filter_name));
195
-				} catch(PDOException $e) {
195
+				} catch (PDOException $e) {
196 196
 					echo "error : ".$e->getMessage();
197 197
 				}
198 198
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -203,29 +203,29 @@  discard block
 block discarded – undo
203 203
 				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
204 204
 				try {
205 205
 					$sth = $this->db->prepare($query);
206
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
207
-				} catch(PDOException $e) {
206
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
207
+				} catch (PDOException $e) {
208 208
 					echo "error : ".$e->getMessage();
209 209
 				}
210 210
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
211 211
 			} else $all = array();
212 212
 		}
213 213
 		if (empty($all)) {
214
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
215
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
214
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
215
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
216 216
 			} else {
217
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
217
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
218 218
 			}
219 219
 			if ($filter_name != '') {
220
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
220
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
221 221
 			}
222 222
 			$Spotter = new Spotter($this->db);
223 223
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
224
-			$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
224
+			$all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
225 225
 		}
226 226
 		return $all;
227 227
 	}
228
-	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
228
+	public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -234,23 +234,23 @@  discard block
 block discarded – undo
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236 236
 				$sth->execute(array(':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242 242
 		if (empty($all)) {
243
-			$filters = array('year' => $year,'month' => $month);
243
+			$filters = array('year' => $year, 'month' => $month);
244 244
 			if ($filter_name != '') {
245
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Marine = new Marine($this->db);
248 248
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
249
-			$all = $Marine->countAllMarineTypes($limit,0,'',$filters);
249
+			$all = $Marine->countAllMarineTypes($limit, 0, '', $filters);
250 250
 		}
251 251
 		return $all;
252 252
 	}
253
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
253
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
254 254
 		global $globalStatsFilters;
255 255
 		if ($filter_name == '') $filter_name = $this->filter_name;
256 256
 		if ($year == '' && $month == '') {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			try {
260 260
 				$sth = $this->db->prepare($query);
261 261
 				$sth->execute(array(':filter_name' => $filter_name));
262
-			} catch(PDOException $e) {
262
+			} catch (PDOException $e) {
263 263
 				echo "error : ".$e->getMessage();
264 264
 			}
265 265
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -267,32 +267,32 @@  discard block
 block discarded – undo
267 267
 		if (empty($all)) {
268 268
 			$Spotter = new Spotter($this->db);
269 269
 			$filters = array();
270
-			$filters = array('year' => $year,'month' => $month);
270
+			$filters = array('year' => $year, 'month' => $month);
271 271
 			if ($filter_name != '') {
272
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
272
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
273 273
 			}
274 274
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
275
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
275
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
276 276
 		}
277 277
 		return $all;
278 278
 	}
279
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
279
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
280 280
 		global $globalStatsFilters;
281 281
 		if ($filter_name == '') $filter_name = $this->filter_name;
282
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
282
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
283 283
 			$Spotter = new Spotter($this->db);
284
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
284
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
285 285
 			$alliance_airlines = array();
286 286
 			foreach ($airlines as $airline) {
287
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
287
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
288 288
 			}
289 289
 			if ($year == '' && $month == '') {
290
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
291
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
290
+				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
291
+				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
292 292
 				try {
293 293
 					$sth = $this->db->prepare($query);
294 294
 					$sth->execute(array(':filter_name' => $filter_name));
295
-				} catch(PDOException $e) {
295
+				} catch (PDOException $e) {
296 296
 					echo "error : ".$e->getMessage();
297 297
 				}
298 298
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -303,21 +303,21 @@  discard block
 block discarded – undo
303 303
 				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";
304 304
 				try {
305 305
 					$sth = $this->db->prepare($query);
306
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
307
-				} catch(PDOException $e) {
306
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
307
+				} catch (PDOException $e) {
308 308
 					echo "error : ".$e->getMessage();
309 309
 				}
310 310
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
311 311
 			} else $all = array();
312 312
 		}
313 313
 		if (empty($all)) {
314
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
315
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
314
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
315
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
316 316
 			} else {
317
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
317
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
318 318
 			}
319 319
 			if ($filter_name != '') {
320
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
320
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
321 321
 			}
322 322
 			$Spotter = new Spotter($this->db);
323 323
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -326,23 +326,23 @@  discard block
 block discarded – undo
326 326
 		return $all;
327 327
 	}
328 328
 
329
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
329
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
330 330
 		global $globalStatsFilters;
331 331
 		if ($filter_name == '') $filter_name = $this->filter_name;
332
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
332
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
333 333
 			$Spotter = new Spotter($this->db);
334
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
334
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
335 335
 			$alliance_airlines = array();
336 336
 			foreach ($airlines as $airline) {
337
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
337
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
338 338
 			}
339 339
 			if ($year == '' && $month == '') {
340
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
341
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
340
+				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
341
+				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
342 342
 				try {
343 343
 					$sth = $this->db->prepare($query);
344 344
 					$sth->execute(array(':filter_name' => $filter_name));
345
-				} catch(PDOException $e) {
345
+				} catch (PDOException $e) {
346 346
 					echo "error : ".$e->getMessage();
347 347
 				}
348 348
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -353,61 +353,61 @@  discard block
 block discarded – undo
353 353
 				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
354 354
 				try {
355 355
 					$sth = $this->db->prepare($query);
356
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
357
-				} catch(PDOException $e) {
356
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
357
+				} catch (PDOException $e) {
358 358
 					echo "error : ".$e->getMessage();
359 359
 				}
360 360
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
361 361
 			} else $all = array();
362 362
 		}
363 363
 		if (empty($all)) {
364
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
365
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
364
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
365
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
366 366
 			} else {
367
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
367
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
368 368
 			}
369 369
 			if ($filter_name != '') {
370
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
370
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
371 371
 			}
372 372
 			$Spotter = new Spotter($this->db);
373 373
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
374
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
374
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
375 375
 		}
376 376
 		return $all;
377 377
 	}
378 378
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
379 379
 		global $globalStatsFilters;
380 380
 		if ($filter_name == '') $filter_name = $this->filter_name;
381
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
381
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
382 382
 			$Spotter = new Spotter($this->db);
383
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
383
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
384 384
 			$alliance_airlines = array();
385 385
 			foreach ($airlines as $airline) {
386
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
386
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
387 387
 			}
388
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
389
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
388
+			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
389
+			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
390 390
 			$query_values = array(':filter_name' => $filter_name);
391 391
 		} else {
392 392
 			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
393 393
 			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
394
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
394
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
395 395
 		}
396 396
 		try {
397 397
 			$sth = $this->db->prepare($query);
398 398
 			$sth->execute($query_values);
399
-		} catch(PDOException $e) {
399
+		} catch (PDOException $e) {
400 400
 			echo "error : ".$e->getMessage();
401 401
 		}
402 402
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
403 403
 		if (empty($all)) {
404
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
405
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
404
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
405
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
406 406
 			} else {
407
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
407
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
408 408
 			}
409 409
 			if ($filter_name != '') {
410
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
410
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
411 411
 			}
412 412
 			$Spotter = new Spotter($this->db);
413 413
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		return $all;
417 417
 	}
418 418
 
419
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
419
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
420 420
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
421 421
 		if ($filter_name == '') $filter_name = $this->filter_name;
422 422
 		if ($year == '' && $month == '') {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 			if (isset($forsource)) {
426 426
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
427 427
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
428
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
428
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
429 429
 			} else {
430 430
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
431 431
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 			try {
435 435
 				$sth = $this->db->prepare($query);
436 436
 				$sth->execute($query_values);
437
-			} catch(PDOException $e) {
437
+			} catch (PDOException $e) {
438 438
 				echo "error : ".$e->getMessage();
439 439
 			}
440 440
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -442,32 +442,32 @@  discard block
 block discarded – undo
442 442
                 if (empty($all)) {
443 443
 	                $Spotter = new Spotter($this->db);
444 444
             		$filters = array();
445
-			$filters = array('year' => $year,'month' => $month);
445
+			$filters = array('year' => $year, 'month' => $month);
446 446
             		if ($filter_name != '') {
447
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
447
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
448 448
 			}
449 449
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
450
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
450
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
451 451
                 }
452 452
                 return $all;
453 453
 	}
454
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
454
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
455 455
 		global $globalStatsFilters;
456 456
 		if ($filter_name == '') $filter_name = $this->filter_name;
457
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
457
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
458 458
 			$Spotter = new Spotter($this->db);
459
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
459
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
460 460
 			$alliance_airlines = array();
461 461
 			foreach ($airlines as $airline) {
462
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
462
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
463 463
 			}
464 464
 			if ($year == '' && $month == '') {
465
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
466
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
465
+				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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
466
+				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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
467 467
 				try {
468 468
 					$sth = $this->db->prepare($query);
469 469
 					$sth->execute(array(':filter_name' => $filter_name));
470
-				} catch(PDOException $e) {
470
+				} catch (PDOException $e) {
471 471
 					echo "error : ".$e->getMessage();
472 472
 				}
473 473
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -478,45 +478,45 @@  discard block
 block discarded – undo
478 478
 				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";
479 479
 				try {
480 480
 					$sth = $this->db->prepare($query);
481
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
482
-				} catch(PDOException $e) {
481
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
482
+				} catch (PDOException $e) {
483 483
 					echo "error : ".$e->getMessage();
484 484
 				}
485 485
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486 486
 			} else $all = array();
487 487
 		}
488 488
 		if (empty($all)) {
489
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
490
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
489
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
490
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
491 491
 			} else {
492
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
492
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
493 493
 			}
494 494
 			if ($filter_name != '') {
495
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
495
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
496 496
 			}
497 497
 			$Spotter = new Spotter($this->db);
498 498
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
499
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
499
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
500 500
 		}
501 501
 		return $all;
502 502
 	}
503
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
503
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
504 504
 		global $globalStatsFilters;
505 505
 		if ($filter_name == '') $filter_name = $this->filter_name;
506
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
506
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
507 507
 			$Spotter = new Spotter($this->db);
508
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
508
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
509 509
 			$alliance_airlines = array();
510 510
 			foreach ($airlines as $airline) {
511
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
511
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
512 512
 			}
513 513
 			if ($year == '' && $month == '') {
514
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
515
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
514
+				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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
515
+				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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
516 516
 				 try {
517 517
 					$sth = $this->db->prepare($query);
518 518
 					$sth->execute(array(':filter_name' => $filter_name));
519
-				} catch(PDOException $e) {
519
+				} catch (PDOException $e) {
520 520
 					echo "error : ".$e->getMessage();
521 521
 				}
522 522
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -527,46 +527,46 @@  discard block
 block discarded – undo
527 527
 				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";
528 528
 				 try {
529 529
 					$sth = $this->db->prepare($query);
530
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
531
-				} catch(PDOException $e) {
530
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
531
+				} catch (PDOException $e) {
532 532
 					echo "error : ".$e->getMessage();
533 533
 				}
534 534
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
535 535
 			} else $all = array();
536 536
 		}
537 537
 		if (empty($all)) {
538
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
539
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
538
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
539
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
540 540
 			} else {
541
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
541
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
542 542
 			}
543 543
 			if ($filter_name != '') {
544
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
544
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
545 545
 			}
546 546
 			$Spotter = new Spotter($this->db);
547 547
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
548
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
548
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
549 549
 		}
550 550
 		return $all;
551 551
 	}
552
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
552
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
553 553
 		$Connection = new Connection($this->db);
554 554
 		if ($filter_name == '') $filter_name = $this->filter_name;
555 555
 		if ($Connection->tableExists('countries')) {
556
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
556
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
557 557
 				$Spotter = new Spotter($this->db);
558
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
558
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
559 559
 				if ($year == '' && $month == '') {
560 560
 					$alliance_airlines = array();
561 561
 					foreach ($airlines as $airline) {
562
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
562
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
563 563
 					}
564
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
565
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
564
+					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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
565
+					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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
566 566
 					 try {
567 567
 						$sth = $this->db->prepare($query);
568 568
 						$sth->execute(array(':filter_name' => $filter_name));
569
-					} catch(PDOException $e) {
569
+					} catch (PDOException $e) {
570 570
 						echo "error : ".$e->getMessage();
571 571
 					}
572 572
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
 					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";
579 579
 					 try {
580 580
 						$sth = $this->db->prepare($query);
581
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
582
-					} catch(PDOException $e) {
581
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
582
+					} catch (PDOException $e) {
583 583
 						echo "error : ".$e->getMessage();
584 584
 					}
585 585
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			return $Spotter->countAllFlightOverCountries($limit);
591 591
 		} else return array();
592 592
 	}
593
-	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
593
+	public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
594 594
 		$Connection = new Connection($this->db);
595 595
 		if ($filter_name == '') $filter_name = $this->filter_name;
596 596
 		if ($Connection->tableExists('countries')) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 				 try {
602 602
 					$sth = $this->db->prepare($query);
603 603
 					$sth->execute(array(':filter_name' => $filter_name));
604
-				} catch(PDOException $e) {
604
+				} catch (PDOException $e) {
605 605
 					echo "error : ".$e->getMessage();
606 606
 				}
607 607
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -609,15 +609,15 @@  discard block
 block discarded – undo
609 609
 			if (empty($all)) {
610 610
 				$filters = array();
611 611
 				if ($filter_name != '') {
612
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
612
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
613 613
 				}
614 614
 				$Marine = new Marine($this->db);
615
-				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
615
+				$all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters);
616 616
 			}
617 617
 			return $all;
618 618
 		} else return array();
619 619
 	}
620
-	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
620
+	public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
621 621
 		global $globalStatsFilters;
622 622
 		$Connection = new Connection($this->db);
623 623
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -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
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -638,15 +638,15 @@  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
 				$Tracker = new Tracker($this->db);
644
-				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
644
+				$all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters);
645 645
 			}
646 646
 			return $all;
647 647
 		} else return array();
648 648
 	}
649
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
649
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
650 650
 		global $globalStatsFilters;
651 651
 		if ($filter_name == '') $filter_name = $this->filter_name;
652 652
 		if ($year == '' && $month == '') {
@@ -654,41 +654,41 @@  discard block
 block discarded – undo
654 654
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
655 655
 			try {
656 656
 				$sth = $this->db->prepare($query);
657
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
658
-			} catch(PDOException $e) {
657
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
658
+			} catch (PDOException $e) {
659 659
 				echo "error : ".$e->getMessage();
660 660
 			}
661 661
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
662 662
 		} else $all = array();
663 663
 		if (empty($all)) {
664
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
664
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
665 665
 			if ($filter_name != '') {
666
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
666
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
667 667
 			}
668 668
 			$Spotter = new Spotter($this->db);
669 669
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
670
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
670
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
671 671
 		}
672 672
 		return $all;
673 673
 	}
674 674
 
675
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
675
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
676 676
 		global $globalStatsFilters;
677 677
 		if ($filter_name == '') $filter_name = $this->filter_name;
678
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
678
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
679 679
 			$Spotter = new Spotter($this->db);
680
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
680
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
681 681
 			if ($year == '' && $month == '') {
682 682
 				$alliance_airlines = array();
683 683
 				foreach ($airlines as $airline) {
684
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
684
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
685 685
 				}
686
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
687
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
686
+				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
687
+				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
688 688
 				try {
689 689
 					$sth = $this->db->prepare($query);
690 690
 					$sth->execute(array(':filter_name' => $filter_name));
691
-				} catch(PDOException $e) {
691
+				} catch (PDOException $e) {
692 692
 					echo "error : ".$e->getMessage();
693 693
 				}
694 694
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -699,45 +699,45 @@  discard block
 block discarded – undo
699 699
 				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";
700 700
 				try {
701 701
 					$sth = $this->db->prepare($query);
702
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
703
-				} catch(PDOException $e) {
702
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
703
+				} catch (PDOException $e) {
704 704
 					echo "error : ".$e->getMessage();
705 705
 				}
706 706
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
707 707
 			} else $all = array();
708 708
 		}
709 709
 		if (empty($all)) {
710
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
711
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
710
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
711
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
712 712
 			} else {
713
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
713
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
714 714
 			}
715 715
 			if ($filter_name != '') {
716
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
716
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
717 717
 			}
718 718
 			$Spotter = new Spotter($this->db);
719 719
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
720
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
720
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
721 721
 		}
722 722
 		return $all;
723 723
 	}
724
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
724
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
725 725
 		global $globalStatsFilters;
726 726
 		if ($filter_name == '') $filter_name = $this->filter_name;
727
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
727
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
728 728
 			$Spotter = new Spotter($this->db);
729
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
729
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
730 730
 			if ($year == '' && $month == '') {
731 731
 				$alliance_airlines = array();
732 732
 				foreach ($airlines as $airline) {
733
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
733
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
734 734
 				}
735
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
736
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
735
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
736
+				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
737 737
 				try {
738 738
 					$sth = $this->db->prepare($query);
739 739
 					$sth->execute(array(':filter_name' => $filter_name));
740
-				} catch(PDOException $e) {
740
+				} catch (PDOException $e) {
741 741
 					echo "error : ".$e->getMessage();
742 742
 				}
743 743
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -748,27 +748,27 @@  discard block
 block discarded – undo
748 748
 				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
749 749
 				try {
750 750
 					$sth = $this->db->prepare($query);
751
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
752
-				} catch(PDOException $e) {
751
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
752
+				} catch (PDOException $e) {
753 753
 					echo "error : ".$e->getMessage();
754 754
 				}
755 755
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
756 756
 			} else $all = array();
757 757
 		}
758 758
 		if (empty($all)) {
759
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
760
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
759
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
760
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
761 761
 			} else {
762
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
762
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
763 763
 			}
764 764
 			if ($filter_name != '') {
765
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
765
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
766 766
 			}
767 767
 			$Spotter = new Spotter($this->db);
768 768
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
769 769
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
770
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
771
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
770
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
771
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
772 772
 			$all = array();
773 773
 			foreach ($pall as $value) {
774 774
 				$icao = $value['airport_departure_icao'];
@@ -784,27 +784,27 @@  discard block
 block discarded – undo
784 784
 			foreach ($all as $key => $row) {
785 785
 				$count[$key] = $row['airport_departure_icao_count'];
786 786
 			}
787
-			array_multisort($count,SORT_DESC,$all);
787
+			array_multisort($count, SORT_DESC, $all);
788 788
 		}
789 789
 		return $all;
790 790
 	}
791
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
791
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
792 792
 		global $globalStatsFilters;
793 793
 		if ($filter_name == '') $filter_name = $this->filter_name;
794
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
794
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
795 795
 			$Spotter = new Spotter($this->db);
796
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
796
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
797 797
 			if ($year == '' && $month == '') {
798 798
 				$alliance_airlines = array();
799 799
 				foreach ($airlines as $airline) {
800
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
800
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
801 801
 				}
802
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
803
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
802
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
803
+				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
804 804
 				try {
805 805
 					$sth = $this->db->prepare($query);
806 806
 					$sth->execute(array(':filter_name' => $filter_name));
807
-				} catch(PDOException $e) {
807
+				} catch (PDOException $e) {
808 808
 					echo "error : ".$e->getMessage();
809 809
 				}
810 810
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -815,27 +815,27 @@  discard block
 block discarded – undo
815 815
 				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
816 816
 				try {
817 817
 					$sth = $this->db->prepare($query);
818
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
819
-				} catch(PDOException $e) {
818
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
819
+				} catch (PDOException $e) {
820 820
 					echo "error : ".$e->getMessage();
821 821
 				}
822 822
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
823 823
 			} else $all = array();
824 824
 		}
825 825
 		if (empty($all)) {
826
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
827
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
826
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
827
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
828 828
 			} else {
829
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
829
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
830 830
 			}
831 831
 			if ($filter_name != '') {
832
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
832
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
833 833
 			}
834 834
 			$Spotter = new Spotter($this->db);
835 835
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
836 836
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
837
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
838
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
837
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
838
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
839 839
 			$all = array();
840 840
 			foreach ($pall as $value) {
841 841
 				$icao = $value['airport_arrival_icao'];
@@ -851,26 +851,26 @@  discard block
 block discarded – undo
851 851
 			foreach ($all as $key => $row) {
852 852
 				$count[$key] = $row['airport_arrival_icao_count'];
853 853
 			}
854
-			array_multisort($count,SORT_DESC,$all);
854
+			array_multisort($count, SORT_DESC, $all);
855 855
 		}
856 856
 		return $all;
857 857
 	}
858
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
858
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
859 859
 		global $globalDBdriver, $globalStatsFilters;
860 860
 		if ($filter_name == '') $filter_name = $this->filter_name;
861
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
861
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
862 862
 			$Spotter = new Spotter($this->db);
863
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
863
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
864 864
 			$alliance_airlines = array();
865 865
 			foreach ($airlines as $airline) {
866
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
866
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
867 867
 			}
868 868
 			if ($globalDBdriver == 'mysql') {
869
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
870
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
869
+				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
870
+				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
871 871
 			} else {
872
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
872
+				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873
+				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
874 874
 			}
875 875
 			$query_data = array(':filter_name' => $filter_name);
876 876
 		} else {
@@ -881,23 +881,23 @@  discard block
 block discarded – undo
881 881
 				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";
882 882
 				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";
883 883
 			}
884
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
884
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
885 885
 		}
886 886
 		try {
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_data);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			echo "error : ".$e->getMessage();
891 891
 		}
892 892
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
893 893
 		if (empty($all)) {
894
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
895
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
894
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
895
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
896 896
 			} else {
897 897
 				$filters = array('airlines' => array($stats_airline));
898 898
 			}
899 899
 			if ($filter_name != '') {
900
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
900
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
901 901
 			}
902 902
 			$Spotter = new Spotter($this->db);
903 903
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 		return $all;
906 906
 	}
907 907
 
908
-	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
908
+	public function countAllMarineMonthsLastYear($limit = true, $filter_name = '') {
909 909
 		global $globalDBdriver, $globalStatsFilters;
910 910
 		if ($filter_name == '') $filter_name = $this->filter_name;
911 911
 		if ($globalDBdriver == 'mysql') {
@@ -919,14 +919,14 @@  discard block
 block discarded – undo
919 919
 		try {
920 920
 			$sth = $this->db->prepare($query);
921 921
 			$sth->execute($query_data);
922
-		} catch(PDOException $e) {
922
+		} catch (PDOException $e) {
923 923
 			echo "error : ".$e->getMessage();
924 924
 		}
925 925
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
926 926
 		if (empty($all)) {
927 927
 			$filters = array();
928 928
 			if ($filter_name != '') {
929
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
929
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
930 930
 			}
931 931
 			$Marine = new Marine($this->db);
932 932
 			$all = $Marine->countAllMonthsLastYear($filters);
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 		return $all;
935 935
 	}
936 936
 
937
-	public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') {
937
+	public function countAllTrackerMonthsLastYear($limit = true, $filter_name = '') {
938 938
 		global $globalDBdriver, $globalStatsFilters;
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940 940
 		if ($globalDBdriver == 'mysql') {
@@ -948,14 +948,14 @@  discard block
 block discarded – undo
948 948
 		try {
949 949
 			$sth = $this->db->prepare($query);
950 950
 			$sth->execute($query_data);
951
-		} catch(PDOException $e) {
951
+		} catch (PDOException $e) {
952 952
 			echo "error : ".$e->getMessage();
953 953
 		}
954 954
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
955 955
 		if (empty($all)) {
956 956
 			$filters = array();
957 957
 			if ($filter_name != '') {
958
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
958
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
959 959
 			}
960 960
 			$Tracker = new Tracker($this->db);
961 961
 			$all = $Tracker->countAllMonthsLastYear($filters);
@@ -963,37 +963,37 @@  discard block
 block discarded – undo
963 963
 		return $all;
964 964
 	}
965 965
 	
966
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
966
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
967 967
 		global $globalStatsFilters;
968 968
 		if ($filter_name == '') $filter_name = $this->filter_name;
969
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
969
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
970 970
 			$Spotter = new Spotter($this->db);
971
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
971
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
972 972
 			$alliance_airlines = array();
973 973
 			foreach ($airlines as $airline) {
974
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
974
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
975 975
 			}
976
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
976
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
977 977
 			$query_data = array(':filter_name' => $filter_name);
978 978
 		} else {
979 979
 			$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";
980
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
980
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
981 981
 		}
982 982
 		try {
983 983
 			$sth = $this->db->prepare($query);
984 984
 			$sth->execute($query_data);
985
-		} catch(PDOException $e) {
985
+		} catch (PDOException $e) {
986 986
 			echo "error : ".$e->getMessage();
987 987
 		}
988 988
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
989 989
 		if (empty($all)) {
990
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
991
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
990
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
991
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
992 992
 			} else {
993 993
 				$filters = array('airlines' => array($stats_airline));
994 994
 			}
995 995
 			if ($filter_name != '') {
996
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
996
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
997 997
 			}
998 998
 			$Spotter = new Spotter($this->db);
999 999
 			$all = $Spotter->countAllDatesLastMonth($filters);
@@ -1008,14 +1008,14 @@  discard block
 block discarded – undo
1008 1008
 		try {
1009 1009
 			$sth = $this->db->prepare($query);
1010 1010
 			$sth->execute($query_data);
1011
-		} catch(PDOException $e) {
1011
+		} catch (PDOException $e) {
1012 1012
 			echo "error : ".$e->getMessage();
1013 1013
 		}
1014 1014
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1015 1015
 		if (empty($all)) {
1016 1016
 			$filters = array();
1017 1017
 			if ($filter_name != '') {
1018
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1018
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1019 1019
 			}
1020 1020
 			$Marine = new Marine($this->db);
1021 1021
 			$all = $Marine->countAllDatesLastMonth($filters);
@@ -1030,34 +1030,34 @@  discard block
 block discarded – undo
1030 1030
 		try {
1031 1031
 			$sth = $this->db->prepare($query);
1032 1032
 			$sth->execute($query_data);
1033
-		} catch(PDOException $e) {
1033
+		} catch (PDOException $e) {
1034 1034
 			echo "error : ".$e->getMessage();
1035 1035
 		}
1036 1036
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1037 1037
 		if (empty($all)) {
1038 1038
 			$filters = array();
1039 1039
 			if ($filter_name != '') {
1040
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1040
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1041 1041
 			}
1042 1042
 			$Tracker = new Tracker($this->db);
1043 1043
 			$all = $Tracker->countAllDatesLastMonth($filters);
1044 1044
 		}
1045 1045
 		return $all;
1046 1046
 	}
1047
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
1047
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
1048 1048
 		global $globalDBdriver, $globalStatsFilters;
1049 1049
 		if ($filter_name == '') $filter_name = $this->filter_name;
1050
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1050
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1051 1051
 			$Spotter = new Spotter($this->db);
1052
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1052
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1053 1053
 			$alliance_airlines = array();
1054 1054
 			foreach ($airlines as $airline) {
1055
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1055
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1056 1056
 			}
1057 1057
 			if ($globalDBdriver == 'mysql') {
1058
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1058
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1059 1059
 			} else {
1060
-				$query = "SELECT flight_date as date_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1060
+				$query = "SELECT flight_date as date_name, SUM(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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1061 1061
 			}
1062 1062
 			$query_data = array(':filter_name' => $filter_name);
1063 1063
 		} else {
@@ -1066,23 +1066,23 @@  discard block
 block discarded – undo
1066 1066
 			} else {
1067 1067
 				$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";
1068 1068
 			}
1069
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1069
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1070 1070
 		}
1071 1071
 		try {
1072 1072
 			$sth = $this->db->prepare($query);
1073 1073
 			$sth->execute($query_data);
1074
-		} catch(PDOException $e) {
1074
+		} catch (PDOException $e) {
1075 1075
 			echo "error : ".$e->getMessage();
1076 1076
 		}
1077 1077
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1078 1078
 		if (empty($all)) {
1079
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1080
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1079
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1080
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1081 1081
 			} else {
1082 1082
 				$filters = array('airlines' => array($stats_airline));
1083 1083
 			}
1084 1084
 			if ($filter_name != '') {
1085
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1085
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1086 1086
 			}
1087 1087
 			$Spotter = new Spotter($this->db);
1088 1088
 			$all = $Spotter->countAllDatesLast7Days($filters);
@@ -1101,14 +1101,14 @@  discard block
 block discarded – undo
1101 1101
 		try {
1102 1102
 			$sth = $this->db->prepare($query);
1103 1103
 			$sth->execute($query_data);
1104
-		} catch(PDOException $e) {
1104
+		} catch (PDOException $e) {
1105 1105
 			echo "error : ".$e->getMessage();
1106 1106
 		}
1107 1107
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1108 1108
 		if (empty($all)) {
1109 1109
 			$filters = array();
1110 1110
 			if ($filter_name != '') {
1111
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1111
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1112 1112
 			}
1113 1113
 			$Marine = new Marine($this->db);
1114 1114
 			$all = $Marine->countAllDatesLast7Days($filters);
@@ -1127,51 +1127,51 @@  discard block
 block discarded – undo
1127 1127
 		try {
1128 1128
 			$sth = $this->db->prepare($query);
1129 1129
 			$sth->execute($query_data);
1130
-		} catch(PDOException $e) {
1130
+		} catch (PDOException $e) {
1131 1131
 			echo "error : ".$e->getMessage();
1132 1132
 		}
1133 1133
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1134 1134
 		if (empty($all)) {
1135 1135
 			$filters = array();
1136 1136
 			if ($filter_name != '') {
1137
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1137
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1138 1138
 			}
1139 1139
 			$Tracker = new Tracker($this->db);
1140 1140
 			$all = $Tracker->countAllDatesLast7Days($filters);
1141 1141
 		}
1142 1142
 		return $all;
1143 1143
 	}
1144
-	public function countAllDates($stats_airline = '',$filter_name = '') {
1144
+	public function countAllDates($stats_airline = '', $filter_name = '') {
1145 1145
 		global $globalStatsFilters;
1146 1146
 		if ($filter_name == '') $filter_name = $this->filter_name;
1147
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1147
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1148 1148
 			$Spotter = new Spotter($this->db);
1149
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1149
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1150 1150
 			$alliance_airlines = array();
1151 1151
 			foreach ($airlines as $airline) {
1152
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1152
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1153 1153
 			}
1154
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1154
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1155 1155
 			$query_data = array(':filter_name' => $filter_name);
1156 1156
 		} else {
1157 1157
 			$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 ORDER BY date_count DESC";
1158
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1158
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1159 1159
 		}
1160 1160
 		try {
1161 1161
 			$sth = $this->db->prepare($query);
1162 1162
 			$sth->execute($query_data);
1163
-		} catch(PDOException $e) {
1163
+		} catch (PDOException $e) {
1164 1164
 			echo "error : ".$e->getMessage();
1165 1165
 		}
1166 1166
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1167 1167
 		if (empty($all)) {
1168
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1169
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1168
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1169
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1170 1170
 			} else {
1171 1171
 				$filters = array('airlines' => array($stats_airline));
1172 1172
 			}
1173 1173
 			if ($filter_name != '') {
1174
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1174
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1175 1175
 			}
1176 1176
 			$Spotter = new Spotter($this->db);
1177 1177
 			$all = $Spotter->countAllDates($filters);
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		try {
1187 1187
 			$sth = $this->db->prepare($query);
1188 1188
 			$sth->execute($query_data);
1189
-		} catch(PDOException $e) {
1189
+		} catch (PDOException $e) {
1190 1190
 			echo "error : ".$e->getMessage();
1191 1191
 		}
1192 1192
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 		try {
1209 1209
 			$sth = $this->db->prepare($query);
1210 1210
 			$sth->execute($query_data);
1211
-		} catch(PDOException $e) {
1211
+		} catch (PDOException $e) {
1212 1212
 			echo "error : ".$e->getMessage();
1213 1213
 		}
1214 1214
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1230,34 +1230,34 @@  discard block
 block discarded – undo
1230 1230
 		try {
1231 1231
 			$sth = $this->db->prepare($query);
1232 1232
 			$sth->execute($query_data);
1233
-		} catch(PDOException $e) {
1233
+		} catch (PDOException $e) {
1234 1234
 			echo "error : ".$e->getMessage();
1235 1235
 		}
1236 1236
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1237 1237
 		if (empty($all)) {
1238 1238
 			$filters = array();
1239 1239
 			if ($filter_name != '') {
1240
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1240
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1241 1241
 			}
1242 1242
 			$Spotter = new Spotter($this->db);
1243 1243
 			$all = $Spotter->countAllDatesByAirlines($filters);
1244 1244
 		}
1245 1245
 		return $all;
1246 1246
 	}
1247
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
1247
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
1248 1248
 		global $globalStatsFilters, $globalDBdriver;
1249 1249
 		if ($filter_name == '') $filter_name = $this->filter_name;
1250
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1250
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1251 1251
 			$Spotter = new Spotter($this->db);
1252
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1252
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1253 1253
 			$alliance_airlines = array();
1254 1254
 			foreach ($airlines as $airline) {
1255
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1255
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1256 1256
 			}
1257 1257
 			if ($globalDBdriver == 'mysql') {
1258
-				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1258
+				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1259 1259
 			} else {
1260
-				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1260
+				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1261 1261
 			}
1262 1262
 			$query_data = array(':filter_name' => $filter_name);
1263 1263
 		} else {
@@ -1271,18 +1271,18 @@  discard block
 block discarded – undo
1271 1271
 		try {
1272 1272
 			$sth = $this->db->prepare($query);
1273 1273
 			$sth->execute($query_data);
1274
-		} catch(PDOException $e) {
1274
+		} catch (PDOException $e) {
1275 1275
 			echo "error : ".$e->getMessage();
1276 1276
 		}
1277 1277
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1278 1278
 		if (empty($all)) {
1279
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1280
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1279
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1280
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1281 1281
 			} else {
1282 1282
 				$filters = array('airlines' => array($stats_airline));
1283 1283
 			}
1284 1284
 			if ($filter_name != '') {
1285
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1285
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1286 1286
 			}
1287 1287
 			$Spotter = new Spotter($this->db);
1288 1288
 			$all = $Spotter->countAllMonths($filters);
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 		try {
1300 1300
 			$sth = $this->db->prepare($query);
1301 1301
 			$sth->execute();
1302
-		} catch(PDOException $e) {
1302
+		} catch (PDOException $e) {
1303 1303
 			echo "error : ".$e->getMessage();
1304 1304
 		}
1305 1305
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 		try {
1320 1320
 			$sth = $this->db->prepare($query);
1321 1321
 			$sth->execute();
1322
-		} catch(PDOException $e) {
1322
+		} catch (PDOException $e) {
1323 1323
 			echo "error : ".$e->getMessage();
1324 1324
 		}
1325 1325
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1336,32 +1336,32 @@  discard block
 block discarded – undo
1336 1336
 		try {
1337 1337
 			$sth = $this->db->prepare($query);
1338 1338
 			$sth->execute(array(':filter_name' => $filter_name));
1339
-		} catch(PDOException $e) {
1339
+		} catch (PDOException $e) {
1340 1340
 			echo "error : ".$e->getMessage();
1341 1341
 		}
1342 1342
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1343 1343
 		if (empty($all)) {
1344 1344
 			$filters = array();
1345 1345
 			if ($filter_name != '') {
1346
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1346
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1347 1347
 			}
1348 1348
 			$Spotter = new Spotter($this->db);
1349 1349
 			$all = $Spotter->countAllMilitaryMonths($filters);
1350 1350
 		}
1351 1351
 		return $all;
1352 1352
 	}
1353
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1353
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1354 1354
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1355 1355
 		if ($filter_name == '') $filter_name = $this->filter_name;
1356
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1356
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1357 1357
 			$Spotter = new Spotter($this->db);
1358
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1358
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1359 1359
 			$alliance_airlines = array();
1360 1360
 			foreach ($airlines as $airline) {
1361
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1361
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1362 1362
 			}
1363
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1364
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1363
+			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1364
+			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1365 1365
 			$query_data = array(':filter_name' => $filter_name);
1366 1366
 		} else {
1367 1367
 			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";
@@ -1379,25 +1379,25 @@  discard block
 block discarded – undo
1379 1379
 		try {
1380 1380
 			$sth = $this->db->prepare($query);
1381 1381
 			$sth->execute($query_data);
1382
-		} catch(PDOException $e) {
1382
+		} catch (PDOException $e) {
1383 1383
 			echo "error : ".$e->getMessage();
1384 1384
 		}
1385 1385
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1386 1386
 		if (empty($all)) {
1387
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1388
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1387
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1388
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1389 1389
 			} else {
1390 1390
 				$filters = array('airlines' => array($stats_airline));
1391 1391
 			}
1392 1392
 			if ($filter_name != '') {
1393
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1393
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1394 1394
 			}
1395 1395
 			$Spotter = new Spotter($this->db);
1396
-			$all = $Spotter->countAllHours($orderby,$filters);
1396
+			$all = $Spotter->countAllHours($orderby, $filters);
1397 1397
 		}
1398 1398
 		return $all;
1399 1399
 	}
1400
-	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1400
+	public function countAllMarineHours($orderby = 'hour', $limit = true, $filter_name = '') {
1401 1401
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1402 1402
 		if ($filter_name == '') $filter_name = $this->filter_name;
1403 1403
 		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1414,21 +1414,21 @@  discard block
 block discarded – undo
1414 1414
 		try {
1415 1415
 			$sth = $this->db->prepare($query);
1416 1416
 			$sth->execute($query_data);
1417
-		} catch(PDOException $e) {
1417
+		} catch (PDOException $e) {
1418 1418
 			echo "error : ".$e->getMessage();
1419 1419
 		}
1420 1420
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1421 1421
 		if (empty($all)) {
1422 1422
 			$filters = array();
1423 1423
 			if ($filter_name != '') {
1424
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1424
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1425 1425
 			}
1426 1426
 			$Marine = new Marine($this->db);
1427
-			$all = $Marine->countAllHours($orderby,$filters);
1427
+			$all = $Marine->countAllHours($orderby, $filters);
1428 1428
 		}
1429 1429
 		return $all;
1430 1430
 	}
1431
-	public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') {
1431
+	public function countAllTrackerHours($orderby = 'hour', $limit = true, $filter_name = '') {
1432 1432
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1433 1433
 		if ($filter_name == '') $filter_name = $this->filter_name;
1434 1434
 		if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1445,33 +1445,33 @@  discard block
 block discarded – undo
1445 1445
 		try {
1446 1446
 			$sth = $this->db->prepare($query);
1447 1447
 			$sth->execute($query_data);
1448
-		} catch(PDOException $e) {
1448
+		} catch (PDOException $e) {
1449 1449
 			echo "error : ".$e->getMessage();
1450 1450
 		}
1451 1451
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1452 1452
 		if (empty($all)) {
1453 1453
 			$filters = array();
1454 1454
 			if ($filter_name != '') {
1455
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1455
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1456 1456
 			}
1457 1457
 			$Tracker = new Tracker($this->db);
1458
-			$all = $Tracker->countAllHours($orderby,$filters);
1458
+			$all = $Tracker->countAllHours($orderby, $filters);
1459 1459
 		}
1460 1460
 		return $all;
1461 1461
 	}
1462
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1462
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1463 1463
 		global $globalStatsFilters;
1464 1464
 		if ($filter_name == '') $filter_name = $this->filter_name;
1465 1465
 		if ($year == '') $year = date('Y');
1466
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1466
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1467 1467
 		if (empty($all)) {
1468
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1469
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1468
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1469
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1470 1470
 			} else {
1471
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1471
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1472 1472
 			}
1473 1473
 			if ($filter_name != '') {
1474
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1474
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1475 1475
 			}
1476 1476
 			$Spotter = new Spotter($this->db);
1477 1477
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1479,15 +1479,15 @@  discard block
 block discarded – undo
1479 1479
 		}
1480 1480
 		return $all;
1481 1481
 	}
1482
-	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1482
+	public function countOverallMarine($filter_name = '', $year = '', $month = '') {
1483 1483
 		global $globalStatsFilters;
1484 1484
 		if ($filter_name == '') $filter_name = $this->filter_name;
1485 1485
 		if ($year == '') $year = date('Y');
1486
-		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1486
+		$all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month);
1487 1487
 		if (empty($all)) {
1488
-			$filters = array('year' => $year,'month' => $month);
1488
+			$filters = array('year' => $year, 'month' => $month);
1489 1489
 			if ($filter_name != '') {
1490
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1490
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1491 1491
 			}
1492 1492
 			$Marine = new Marine($this->db);
1493 1493
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1495,15 +1495,15 @@  discard block
 block discarded – undo
1495 1495
 		}
1496 1496
 		return $all;
1497 1497
 	}
1498
-	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1498
+	public function countOverallTracker($filter_name = '', $year = '', $month = '') {
1499 1499
 		global $globalStatsFilters;
1500 1500
 		if ($filter_name == '') $filter_name = $this->filter_name;
1501 1501
 		if ($year == '') $year = date('Y');
1502
-		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1502
+		$all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month);
1503 1503
 		if (empty($all)) {
1504
-			$filters = array('year' => $year,'month' => $month);
1504
+			$filters = array('year' => $year, 'month' => $month);
1505 1505
 			if ($filter_name != '') {
1506
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1506
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1507 1507
 			}
1508 1508
 			$Tracker = new Tracker($this->db);
1509 1509
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1511,16 +1511,16 @@  discard block
 block discarded – undo
1511 1511
 		}
1512 1512
 		return $all;
1513 1513
 	}
1514
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1514
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1515 1515
 		global $globalStatsFilters;
1516 1516
 		if ($filter_name == '') $filter_name = $this->filter_name;
1517 1517
 		if ($year == '') $year = date('Y');
1518
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1518
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1519 1519
 		if (empty($all)) {
1520 1520
 			$filters = array();
1521
-			$filters = array('year' => $year,'month' => $month);
1521
+			$filters = array('year' => $year, 'month' => $month);
1522 1522
 			if ($filter_name != '') {
1523
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1523
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1524 1524
 			}
1525 1525
 			$Spotter = new Spotter($this->db);
1526 1526
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1528,19 +1528,19 @@  discard block
 block discarded – undo
1528 1528
 		}
1529 1529
 		return $all;
1530 1530
 	}
1531
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1531
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1532 1532
 		global $globalStatsFilters;
1533 1533
 		if ($filter_name == '') $filter_name = $this->filter_name;
1534 1534
 		if ($year == '') $year = date('Y');
1535
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1535
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1536 1536
 		if (empty($all)) {
1537
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1538
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1537
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1538
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1539 1539
 			} else {
1540
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1540
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1541 1541
 			}
1542 1542
 			if ($filter_name != '') {
1543
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1543
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1544 1544
 			}
1545 1545
 			$Spotter = new Spotter($this->db);
1546 1546
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1548,48 +1548,48 @@  discard block
 block discarded – undo
1548 1548
 		}
1549 1549
 		return $all;
1550 1550
 	}
1551
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1551
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1552 1552
 		global $globalStatsFilters;
1553 1553
 		if ($filter_name == '') $filter_name = $this->filter_name;
1554
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1554
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1555 1555
 			$Spotter = new Spotter($this->db);
1556
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1556
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1557 1557
 			if ($year == '' && $month == '') {
1558 1558
 				$alliance_airlines = array();
1559 1559
 				foreach ($airlines as $airline) {
1560
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1560
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1561 1561
 				}
1562
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1562
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1563 1563
 				try {
1564 1564
 					$sth = $this->db->prepare($query);
1565 1565
 					$sth->execute(array(':filter_name' => $filter_name));
1566
-				} catch(PDOException $e) {
1566
+				} catch (PDOException $e) {
1567 1567
 					echo "error : ".$e->getMessage();
1568 1568
 				}
1569 1569
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1570 1570
 				$all = $result[0]['nb'];
1571
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1571
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1572 1572
 		} else {
1573 1573
 			if ($year == '' && $month == '') {
1574 1574
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1575 1575
 				try {
1576 1576
 					$sth = $this->db->prepare($query);
1577
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1578
-				} catch(PDOException $e) {
1577
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1578
+				} catch (PDOException $e) {
1579 1579
 					echo "error : ".$e->getMessage();
1580 1580
 				}
1581 1581
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1582 1582
 				$all = $result[0]['nb'];
1583
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1583
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1584 1584
 		}
1585 1585
 		if (empty($all)) {
1586
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1587
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1586
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1587
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1588 1588
 			} else {
1589
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1589
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1590 1590
 			}
1591 1591
 			if ($filter_name != '') {
1592
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1592
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1593 1593
 			}
1594 1594
 			$Spotter = new Spotter($this->db);
1595 1595
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
 		}
1598 1598
 		return $all;
1599 1599
 	}
1600
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1600
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1601 1601
 		global $globalStatsFilters;
1602 1602
 		if ($filter_name == '') $filter_name = $this->filter_name;
1603 1603
 		if ($year == '' && $month == '') {
@@ -1605,17 +1605,17 @@  discard block
 block discarded – undo
1605 1605
 			try {
1606 1606
 				$sth = $this->db->prepare($query);
1607 1607
 				$sth->execute(array(':filter_name' => $filter_name));
1608
-			} catch(PDOException $e) {
1608
+			} catch (PDOException $e) {
1609 1609
 				echo "error : ".$e->getMessage();
1610 1610
 			}
1611 1611
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1612 1612
 			$all = $result[0]['nb_airline'];
1613
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1613
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1614 1614
 		if (empty($all)) {
1615 1615
 			$filters = array();
1616
-			$filters = array('year' => $year,'month' => $month);
1616
+			$filters = array('year' => $year, 'month' => $month);
1617 1617
 			if ($filter_name != '') {
1618
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1618
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1619 1619
 			}
1620 1620
 			$Spotter = new Spotter($this->db);
1621 1621
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 		}
1624 1624
 		return $all;
1625 1625
 	}
1626
-	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1626
+	public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') {
1627 1627
 		global $globalStatsFilters;
1628 1628
 		if ($filter_name == '') $filter_name = $this->filter_name;
1629 1629
 		$all = array();
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 			try {
1633 1633
 				$sth = $this->db->prepare($query);
1634 1634
 				$sth->execute(array(':filter_name' => $filter_name));
1635
-			} catch(PDOException $e) {
1635
+			} catch (PDOException $e) {
1636 1636
 				echo "error : ".$e->getMessage();
1637 1637
 			}
1638 1638
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1640,9 +1640,9 @@  discard block
 block discarded – undo
1640 1640
 		}
1641 1641
 		if (empty($all)) {
1642 1642
 			$filters = array();
1643
-			$filters = array('year' => $year,'month' => $month);
1643
+			$filters = array('year' => $year, 'month' => $month);
1644 1644
 			if ($filter_name != '') {
1645
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1645
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1646 1646
 			}
1647 1647
 			$Marine = new Marine($this->db);
1648 1648
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1650,29 +1650,29 @@  discard block
 block discarded – undo
1650 1650
 		}
1651 1651
 		return $all;
1652 1652
 	}
1653
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1653
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1654 1654
 		global $globalStatsFilters;
1655 1655
 		if ($filter_name == '') $filter_name = $this->filter_name;
1656
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1656
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1657 1657
 			$Spotter = new Spotter($this->db);
1658
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1658
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1659 1659
 			if ($year == '' && $month == '') {
1660 1660
 				$alliance_airlines = array();
1661 1661
 				foreach ($airlines as $airline) {
1662
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1662
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1663 1663
 				}
1664
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1664
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1665 1665
 				$query_values = array(':filter_name' => $filter_name);
1666 1666
 				try {
1667 1667
 					$sth = $this->db->prepare($query);
1668 1668
 					$sth->execute($query_values);
1669
-				} catch(PDOException $e) {
1669
+				} catch (PDOException $e) {
1670 1670
 					echo "error : ".$e->getMessage();
1671 1671
 				}
1672 1672
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1673 1673
 				$all = $result[0]['nb'];
1674 1674
 			} else {
1675
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1675
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1676 1676
 			}
1677 1677
 		} else {
1678 1678
 			if ($year == '' && $month == '') {
@@ -1681,23 +1681,23 @@  discard block
 block discarded – undo
1681 1681
 				try {
1682 1682
 					$sth = $this->db->prepare($query);
1683 1683
 					$sth->execute($query_values);
1684
-				} catch(PDOException $e) {
1684
+				} catch (PDOException $e) {
1685 1685
 					echo "error : ".$e->getMessage();
1686 1686
 				}
1687 1687
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1688 1688
 				$all = $result[0]['nb'];
1689 1689
 			} else {
1690
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1690
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1691 1691
 			}
1692 1692
 		}
1693 1693
 		if (empty($all)) {
1694
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1695
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1694
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1695
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1696 1696
 			} else {
1697
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1697
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1698 1698
 			}
1699 1699
 			if ($filter_name != '') {
1700
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1700
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1701 1701
 			}
1702 1702
 			$Spotter = new Spotter($this->db);
1703 1703
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 		}
1706 1706
 		return $all;
1707 1707
 	}
1708
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1708
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1709 1709
 		global $globalStatsFilters;
1710 1710
 		if ($filter_name == '') $filter_name = $this->filter_name;
1711 1711
 		//if ($year == '') $year = date('Y');
@@ -1715,18 +1715,18 @@  discard block
 block discarded – undo
1715 1715
 			try {
1716 1716
 				$sth = $this->db->prepare($query);
1717 1717
 				$sth->execute($query_values);
1718
-			} catch(PDOException $e) {
1718
+			} catch (PDOException $e) {
1719 1719
 				echo "error : ".$e->getMessage();
1720 1720
 			}
1721 1721
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1722 1722
 			$all = $result[0]['nb'];
1723 1723
 		} else {
1724
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1724
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1725 1725
 		}
1726 1726
 		if (empty($all)) {
1727
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1727
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1728 1728
 			if ($filter_name != '') {
1729
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1729
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1730 1730
 			}
1731 1731
 			$Spotter = new Spotter($this->db);
1732 1732
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1735,104 +1735,104 @@  discard block
 block discarded – undo
1735 1735
 		return $all;
1736 1736
 	}
1737 1737
 
1738
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1738
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1739 1739
 		if ($filter_name == '') $filter_name = $this->filter_name;
1740
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1740
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1741 1741
 			$Spotter = new Spotter($this->db);
1742
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1742
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1743 1743
 			$alliance_airlines = array();
1744 1744
 			foreach ($airlines as $airline) {
1745
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1745
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1746 1746
 			}
1747
-			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1748
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1747
+			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1748
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1749 1749
 		} else {
1750 1750
 			$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";
1751
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1751
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1752 1752
 		}
1753 1753
 		try {
1754 1754
 			$sth = $this->db->prepare($query);
1755 1755
 			$sth->execute($query_values);
1756
-		} catch(PDOException $e) {
1756
+		} catch (PDOException $e) {
1757 1757
 			echo "error : ".$e->getMessage();
1758 1758
 		}
1759 1759
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1760 1760
 		return $all;
1761 1761
 	}
1762
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1762
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1763 1763
 		if ($filter_name == '') $filter_name = $this->filter_name;
1764 1764
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1765
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1765
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1766 1766
 		try {
1767 1767
 			$sth = $this->db->prepare($query);
1768 1768
 			$sth->execute($query_values);
1769
-		} catch(PDOException $e) {
1769
+		} catch (PDOException $e) {
1770 1770
 			echo "error : ".$e->getMessage();
1771 1771
 		}
1772 1772
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1773 1773
 		return $all;
1774 1774
 	}
1775
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1775
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1776 1776
 		if ($filter_name == '') $filter_name = $this->filter_name;
1777 1777
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1778
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1778
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1779 1779
 		try {
1780 1780
 			$sth = $this->db->prepare($query);
1781 1781
 			$sth->execute($query_values);
1782
-		} catch(PDOException $e) {
1782
+		} catch (PDOException $e) {
1783 1783
 			echo "error : ".$e->getMessage();
1784 1784
 		}
1785 1785
 	}
1786
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1786
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1787 1787
 		if ($filter_name == '') $filter_name = $this->filter_name;
1788 1788
 		global $globalArchiveMonths, $globalDBdriver;
1789
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1789
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1790 1790
 			$Spotter = new Spotter($this->db);
1791
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1791
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1792 1792
 			$alliance_airlines = array();
1793 1793
 			foreach ($airlines as $airline) {
1794
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1794
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1795 1795
 			}
1796 1796
 			if ($globalDBdriver == 'mysql') {
1797 1797
 				if ($month == '') {
1798
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1798
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1799 1799
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1800 1800
 				} else {
1801
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1802
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1801
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1802
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1803 1803
 				}
1804 1804
 			} else {
1805 1805
 				if ($month == '') {
1806
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1806
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1807 1807
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1808 1808
 				} else {
1809
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1810
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1809
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1810
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1811 1811
 				}
1812 1812
 			}
1813 1813
 		} else {
1814 1814
 			if ($globalDBdriver == 'mysql') {
1815 1815
 				if ($month == '') {
1816 1816
 					$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";
1817
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1817
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1818 1818
 				} else {
1819 1819
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1820
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1820
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1821 1821
 				}
1822 1822
 			} else {
1823 1823
 				if ($month == '') {
1824 1824
 					$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";
1825
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1825
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1826 1826
 				} else {
1827 1827
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1828
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1828
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1829 1829
 				}
1830 1830
 			}
1831 1831
 		}
1832 1832
 		try {
1833 1833
 			$sth = $this->db->prepare($query);
1834 1834
 			$sth->execute($query_values);
1835
-		} catch(PDOException $e) {
1835
+		} catch (PDOException $e) {
1836 1836
 			echo "error : ".$e->getMessage();
1837 1837
 		}
1838 1838
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1841,17 +1841,17 @@  discard block
 block discarded – undo
1841 1841
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1842 1842
 		global $globalArchiveMonths, $globalDBdriver;
1843 1843
 		if ($filter_name == '') $filter_name = $this->filter_name;
1844
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1844
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1845 1845
 			$Spotter = new Spotter($this->db);
1846
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1846
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1847 1847
 			$alliance_airlines = array();
1848 1848
 			foreach ($airlines as $airline) {
1849
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1849
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1850 1850
 			}
1851 1851
 			if ($globalDBdriver == 'mysql') {
1852
-				$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1852
+				$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1853 1853
 			} else {
1854
-				$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1854
+				$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 IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1855 1855
 			}
1856 1856
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1857 1857
 		} else {
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 		try {
1866 1866
 			$sth = $this->db->prepare($query);
1867 1867
 			$sth->execute($query_values);
1868
-		} catch(PDOException $e) {
1868
+		} catch (PDOException $e) {
1869 1869
 			echo "error : ".$e->getMessage();
1870 1870
 		}
1871 1871
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1874,17 +1874,17 @@  discard block
 block discarded – undo
1874 1874
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1875 1875
 		global $globalArchiveMonths, $globalDBdriver;
1876 1876
 		if ($filter_name == '') $filter_name = $this->filter_name;
1877
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1877
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1878 1878
 			$Spotter = new Spotter($this->db);
1879
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1879
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1880 1880
 			$alliance_airlines = array();
1881 1881
 			foreach ($airlines as $airline) {
1882
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1882
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1883 1883
 			}
1884 1884
 			if ($globalDBdriver == 'mysql') {
1885
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1885
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1886 1886
 			} else {
1887
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1887
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1888 1888
 			}
1889 1889
 		} else {
1890 1890
 			if ($globalDBdriver == 'mysql') {
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 		try {
1897 1897
 			$sth = $this->db->prepare($query);
1898 1898
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1899
-		} catch(PDOException $e) {
1899
+		} catch (PDOException $e) {
1900 1900
 			echo "error : ".$e->getMessage();
1901 1901
 		}
1902 1902
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 		try {
1914 1914
 			$sth = $this->db->prepare($query);
1915 1915
 			$sth->execute(array(':filter_name' => $filter_name));
1916
-		} catch(PDOException $e) {
1916
+		} catch (PDOException $e) {
1917 1917
 			echo "error : ".$e->getMessage();
1918 1918
 		}
1919 1919
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1930,20 +1930,20 @@  discard block
 block discarded – undo
1930 1930
 		try {
1931 1931
 			$sth = $this->db->prepare($query);
1932 1932
 			$sth->execute(array(':filter_name' => $filter_name));
1933
-		} catch(PDOException $e) {
1933
+		} catch (PDOException $e) {
1934 1934
 			echo "error : ".$e->getMessage();
1935 1935
 		}
1936 1936
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1937 1937
 		return $all[0]['total'];
1938 1938
 	}
1939
-	public function getStatsOwner($owner_name,$filter_name = '') {
1939
+	public function getStatsOwner($owner_name, $filter_name = '') {
1940 1940
 		global $globalArchiveMonths, $globalDBdriver;
1941 1941
 		if ($filter_name == '') $filter_name = $this->filter_name;
1942 1942
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1943 1943
 		try {
1944 1944
 			$sth = $this->db->prepare($query);
1945
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1946
-		} catch(PDOException $e) {
1945
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1946
+		} catch (PDOException $e) {
1947 1947
 			echo "error : ".$e->getMessage();
1948 1948
 		}
1949 1949
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1961,20 +1961,20 @@  discard block
 block discarded – undo
1961 1961
 		try {
1962 1962
 			$sth = $this->db->prepare($query);
1963 1963
 			$sth->execute(array(':filter_name' => $filter_name));
1964
-		} catch(PDOException $e) {
1964
+		} catch (PDOException $e) {
1965 1965
 			echo "error : ".$e->getMessage();
1966 1966
 		}
1967 1967
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1968 1968
 		return $all[0]['total'];
1969 1969
 	}
1970
-	public function getStatsPilot($pilot,$filter_name = '') {
1970
+	public function getStatsPilot($pilot, $filter_name = '') {
1971 1971
 		global $globalArchiveMonths, $globalDBdriver;
1972 1972
 		if ($filter_name == '') $filter_name = $this->filter_name;
1973 1973
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1974 1974
 		try {
1975 1975
 			$sth = $this->db->prepare($query);
1976
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1977
-		} catch(PDOException $e) {
1976
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1977
+		} catch (PDOException $e) {
1978 1978
 			echo "error : ".$e->getMessage();
1979 1979
 		}
1980 1980
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 		else return 0;
1983 1983
 	}
1984 1984
 
1985
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1985
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1986 1986
 		global $globalDBdriver;
1987 1987
 		if ($filter_name == '') $filter_name = $this->filter_name;
1988 1988
 		if ($globalDBdriver == 'mysql') {
@@ -1990,15 +1990,15 @@  discard block
 block discarded – undo
1990 1990
 		} else {
1991 1991
 			$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);"; 
1992 1992
 		}
1993
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1993
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1994 1994
 		try {
1995 1995
 			$sth = $this->db->prepare($query);
1996 1996
 			$sth->execute($query_values);
1997
-		} catch(PDOException $e) {
1997
+		} catch (PDOException $e) {
1998 1998
 			return "error : ".$e->getMessage();
1999 1999
 		}
2000 2000
 	}
2001
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
2001
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
2002 2002
 		global $globalDBdriver;
2003 2003
 		if ($filter_name == '') $filter_name = $this->filter_name;
2004 2004
 		if ($globalDBdriver == 'mysql') {
@@ -2007,11 +2007,11 @@  discard block
 block discarded – undo
2007 2007
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
2008 2008
 			$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);"; 
2009 2009
 		}
2010
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2010
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2011 2011
 		try {
2012 2012
 			$sth = $this->db->prepare($query);
2013 2013
 			$sth->execute($query_values);
2014
-		} catch(PDOException $e) {
2014
+		} catch (PDOException $e) {
2015 2015
 			return "error : ".$e->getMessage();
2016 2016
 		}
2017 2017
 	}
@@ -2035,95 +2035,95 @@  discard block
 block discarded – undo
2035 2035
         }
2036 2036
         */
2037 2037
 
2038
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
2038
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
2039 2039
 		global $globalDBdriver;
2040 2040
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
2041 2041
 		$query_values = array();
2042 2042
 		if ($globalDBdriver == 'mysql') {
2043 2043
 			if ($year != '') {
2044 2044
 				$query .= ' AND YEAR(stats_date) = :year';
2045
-				$query_values = array_merge($query_values,array(':year' => $year));
2045
+				$query_values = array_merge($query_values, array(':year' => $year));
2046 2046
 			}
2047 2047
 			if ($month != '') {
2048 2048
 				$query .= ' AND MONTH(stats_date) = :month';
2049
-				$query_values = array_merge($query_values,array(':month' => $month));
2049
+				$query_values = array_merge($query_values, array(':month' => $month));
2050 2050
 			}
2051 2051
 			if ($day != '') {
2052 2052
 				$query .= ' AND DAY(stats_date) = :day';
2053
-				$query_values = array_merge($query_values,array(':day' => $day));
2053
+				$query_values = array_merge($query_values, array(':day' => $day));
2054 2054
 			}
2055 2055
 		} else {
2056 2056
 			if ($year != '') {
2057 2057
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
2058
-				$query_values = array_merge($query_values,array(':year' => $year));
2058
+				$query_values = array_merge($query_values, array(':year' => $year));
2059 2059
 			}
2060 2060
 			if ($month != '') {
2061 2061
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
2062
-				$query_values = array_merge($query_values,array(':month' => $month));
2062
+				$query_values = array_merge($query_values, array(':month' => $month));
2063 2063
 			}
2064 2064
 			if ($day != '') {
2065 2065
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
2066
-				$query_values = array_merge($query_values,array(':day' => $day));
2066
+				$query_values = array_merge($query_values, array(':day' => $day));
2067 2067
 			}
2068 2068
 		}
2069 2069
 		$query .= " ORDER BY source_name";
2070
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
2070
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
2071 2071
 		try {
2072 2072
 			$sth = $this->db->prepare($query);
2073 2073
 			$sth->execute($query_values);
2074
-		} catch(PDOException $e) {
2074
+		} catch (PDOException $e) {
2075 2075
 			echo "error : ".$e->getMessage();
2076 2076
 		}
2077 2077
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
2078 2078
 		return $all;
2079 2079
 	}
2080 2080
 
2081
-	public function addStatSource($data,$source_name,$stats_type,$date) {
2081
+	public function addStatSource($data, $source_name, $stats_type, $date) {
2082 2082
 		global $globalDBdriver;
2083 2083
 		if ($globalDBdriver == 'mysql') {
2084 2084
 			$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";
2085 2085
 		} else {
2086 2086
 			$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);"; 
2087 2087
 		}
2088
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
2088
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
2089 2089
 		try {
2090 2090
 			$sth = $this->db->prepare($query);
2091 2091
 			$sth->execute($query_values);
2092
-		} catch(PDOException $e) {
2092
+		} catch (PDOException $e) {
2093 2093
 			return "error : ".$e->getMessage();
2094 2094
 		}
2095 2095
 	}
2096
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
2096
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
2097 2097
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
2098
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2098
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2099 2099
 		try {
2100 2100
 			$sth = $this->db->prepare($query);
2101 2101
 			$sth->execute($query_values);
2102
-		} catch(PDOException $e) {
2102
+		} catch (PDOException $e) {
2103 2103
 			return "error : ".$e->getMessage();
2104 2104
 		}
2105 2105
 	}
2106
-	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
2106
+	public function addStatMarine($type, $date_name, $cnt, $filter_name = '') {
2107 2107
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2108
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2108
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2109 2109
 		try {
2110 2110
 			$sth = $this->db->prepare($query);
2111 2111
 			$sth->execute($query_values);
2112
-		} catch(PDOException $e) {
2112
+		} catch (PDOException $e) {
2113 2113
 			return "error : ".$e->getMessage();
2114 2114
 		}
2115 2115
 	}
2116
-	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
2116
+	public function addStatTracker($type, $date_name, $cnt, $filter_name = '') {
2117 2117
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2118
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2118
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2119 2119
 		try {
2120 2120
 			$sth = $this->db->prepare($query);
2121 2121
 			$sth->execute($query_values);
2122
-		} catch(PDOException $e) {
2122
+		} catch (PDOException $e) {
2123 2123
 			return "error : ".$e->getMessage();
2124 2124
 		}
2125 2125
 	}
2126
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
2126
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
2127 2127
 		global $globalDBdriver;
2128 2128
 		if ($globalDBdriver == 'mysql') {
2129 2129
 			if ($reset) {
@@ -2138,15 +2138,15 @@  discard block
 block discarded – undo
2138 2138
 				$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);"; 
2139 2139
 			}
2140 2140
 		}
2141
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2141
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2142 2142
 		try {
2143 2143
 			$sth = $this->db->prepare($query);
2144 2144
 			$sth->execute($query_values);
2145
-		} catch(PDOException $e) {
2145
+		} catch (PDOException $e) {
2146 2146
 			return "error : ".$e->getMessage();
2147 2147
 		}
2148 2148
 	}
2149
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
2149
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2150 2150
 		global $globalDBdriver;
2151 2151
 		if ($globalDBdriver == 'mysql') {
2152 2152
 			if ($reset) {
@@ -2161,15 +2161,15 @@  discard block
 block discarded – undo
2161 2161
 				$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);"; 
2162 2162
 			}
2163 2163
 		}
2164
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
2164
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
2165 2165
 		try {
2166 2166
 			$sth = $this->db->prepare($query);
2167 2167
 			$sth->execute($query_values);
2168
-		} catch(PDOException $e) {
2168
+		} catch (PDOException $e) {
2169 2169
 			return "error : ".$e->getMessage();
2170 2170
 		}
2171 2171
 	}
2172
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
2172
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2173 2173
 		global $globalDBdriver;
2174 2174
 		if ($globalDBdriver == 'mysql') {
2175 2175
 			if ($reset) {
@@ -2184,15 +2184,15 @@  discard block
 block discarded – undo
2184 2184
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
2185 2185
 			}
2186 2186
 		}
2187
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
2187
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
2188 2188
 		try {
2189 2189
 			$sth = $this->db->prepare($query);
2190 2190
 			$sth->execute($query_values);
2191
-		} catch(PDOException $e) {
2191
+		} catch (PDOException $e) {
2192 2192
 			return "error : ".$e->getMessage();
2193 2193
 		}
2194 2194
 	}
2195
-	public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2195
+	public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2196 2196
 		global $globalDBdriver;
2197 2197
 		if ($globalDBdriver == 'mysql') {
2198 2198
 			if ($reset) {
@@ -2207,15 +2207,15 @@  discard block
 block discarded – undo
2207 2207
 				$query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2208 2208
 			}
2209 2209
 		}
2210
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2210
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2211 2211
 		try {
2212 2212
 			$sth = $this->db->prepare($query);
2213 2213
 			$sth->execute($query_values);
2214
-		} catch(PDOException $e) {
2214
+		} catch (PDOException $e) {
2215 2215
 			return "error : ".$e->getMessage();
2216 2216
 		}
2217 2217
 	}
2218
-	public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2218
+	public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2219 2219
 		global $globalDBdriver;
2220 2220
 		if ($globalDBdriver == 'mysql') {
2221 2221
 			if ($reset) {
@@ -2230,15 +2230,15 @@  discard block
 block discarded – undo
2230 2230
 				$query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2231 2231
 			}
2232 2232
 		}
2233
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2233
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2234 2234
 		try {
2235 2235
 			$sth = $this->db->prepare($query);
2236 2236
 			$sth->execute($query_values);
2237
-		} catch(PDOException $e) {
2237
+		} catch (PDOException $e) {
2238 2238
 			return "error : ".$e->getMessage();
2239 2239
 		}
2240 2240
 	}
2241
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2241
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2242 2242
 		global $globalDBdriver;
2243 2243
 		if ($globalDBdriver == 'mysql') {
2244 2244
 			if ($reset) {
@@ -2253,15 +2253,15 @@  discard block
 block discarded – undo
2253 2253
 				$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);"; 
2254 2254
 			}
2255 2255
 		}
2256
-		$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);
2256
+		$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);
2257 2257
 		try {
2258 2258
 			$sth = $this->db->prepare($query);
2259 2259
 			$sth->execute($query_values);
2260
-		} catch(PDOException $e) {
2260
+		} catch (PDOException $e) {
2261 2261
 			return "error : ".$e->getMessage();
2262 2262
 		}
2263 2263
 	}
2264
-	public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) {
2264
+	public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) {
2265 2265
 		global $globalDBdriver;
2266 2266
 		if ($globalDBdriver == 'mysql') {
2267 2267
 			if ($reset) {
@@ -2276,15 +2276,15 @@  discard block
 block discarded – undo
2276 2276
 				$query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type_id = :type_id AND filter_name = :filter_name);"; 
2277 2277
 			}
2278 2278
 		}
2279
-		$query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name);
2279
+		$query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name);
2280 2280
 		try {
2281 2281
 			$sth = $this->db->prepare($query);
2282 2282
 			$sth->execute($query_values);
2283
-		} catch(PDOException $e) {
2283
+		} catch (PDOException $e) {
2284 2284
 			return "error : ".$e->getMessage();
2285 2285
 		}
2286 2286
 	}
2287
-	public function addStatTrackerType($type,$cnt, $filter_name = '', $reset = false) {
2287
+	public function addStatTrackerType($type, $cnt, $filter_name = '', $reset = false) {
2288 2288
 		global $globalDBdriver;
2289 2289
 		if ($globalDBdriver == 'mysql') {
2290 2290
 			if ($reset) {
@@ -2299,15 +2299,15 @@  discard block
 block discarded – undo
2299 2299
 				$query = "UPDATE stats_tracker_type SET cnt = cnt+:cnt WHERE type = :type AND filter_name = :filter_name; INSERT INTO stats_tracker_type (type,cnt,filter_name) SELECT :type,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_type WHERE type = :type AND filter_name = :filter_name);"; 
2300 2300
 			}
2301 2301
 		}
2302
-		$query_values = array(':type' => $type,':cnt' => $cnt, ':filter_name' => $filter_name);
2302
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':filter_name' => $filter_name);
2303 2303
 		try {
2304 2304
 			$sth = $this->db->prepare($query);
2305 2305
 			$sth->execute($query_values);
2306
-		} catch(PDOException $e) {
2306
+		} catch (PDOException $e) {
2307 2307
 			return "error : ".$e->getMessage();
2308 2308
 		}
2309 2309
 	}
2310
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
2310
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
2311 2311
 		global $globalDBdriver;
2312 2312
 		if ($globalDBdriver == 'mysql') {
2313 2313
 			if ($reset) {
@@ -2322,15 +2322,15 @@  discard block
 block discarded – undo
2322 2322
 				$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);"; 
2323 2323
 			}
2324 2324
 		}
2325
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
2325
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2326 2326
 		try {
2327 2327
 			$sth = $this->db->prepare($query);
2328 2328
 			$sth->execute($query_values);
2329
-		} catch(PDOException $e) {
2329
+		} catch (PDOException $e) {
2330 2330
 			return "error : ".$e->getMessage();
2331 2331
 		}
2332 2332
 	}
2333
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
2333
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
2334 2334
 		global $globalDBdriver;
2335 2335
 		if ($globalDBdriver == 'mysql') {
2336 2336
 			if ($reset) {
@@ -2345,15 +2345,15 @@  discard block
 block discarded – undo
2345 2345
 				$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);"; 
2346 2346
 			}
2347 2347
 		}
2348
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2348
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2349 2349
 		try {
2350 2350
 			$sth = $this->db->prepare($query);
2351 2351
 			$sth->execute($query_values);
2352
-		} catch(PDOException $e) {
2352
+		} catch (PDOException $e) {
2353 2353
 			return "error : ".$e->getMessage();
2354 2354
 		}
2355 2355
 	}
2356
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
2356
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
2357 2357
 		global $globalDBdriver;
2358 2358
 		if ($globalDBdriver == 'mysql') {
2359 2359
 			if ($reset) {
@@ -2368,15 +2368,15 @@  discard block
 block discarded – undo
2368 2368
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
2369 2369
 			}
2370 2370
 		}
2371
-		$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
2371
+		$query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
2372 2372
 		try {
2373 2373
 			$sth = $this->db->prepare($query);
2374 2374
 			$sth->execute($query_values);
2375
-		} catch(PDOException $e) {
2375
+		} catch (PDOException $e) {
2376 2376
 			return "error : ".$e->getMessage();
2377 2377
 		}
2378 2378
 	}
2379
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
2379
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
2380 2380
 		global $globalDBdriver;
2381 2381
 		if ($airport_icao != '') {
2382 2382
 			if ($globalDBdriver == 'mysql') {
@@ -2392,16 +2392,16 @@  discard block
 block discarded – undo
2392 2392
 					$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);"; 
2393 2393
 				}
2394 2394
 			}
2395
-			$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);
2395
+			$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);
2396 2396
 			try {
2397 2397
 				$sth = $this->db->prepare($query);
2398 2398
 				$sth->execute($query_values);
2399
-			} catch(PDOException $e) {
2399
+			} catch (PDOException $e) {
2400 2400
 				return "error : ".$e->getMessage();
2401 2401
 			}
2402 2402
 		}
2403 2403
 	}
2404
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
2404
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
2405 2405
 		global $globalDBdriver;
2406 2406
 		if ($airport_icao != '') {
2407 2407
 			if ($globalDBdriver == 'mysql') {
@@ -2409,16 +2409,16 @@  discard block
 block discarded – undo
2409 2409
 			} else {
2410 2410
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2411 2411
 			}
2412
-			$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);
2412
+			$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);
2413 2413
 			 try {
2414 2414
 				$sth = $this->db->prepare($query);
2415 2415
 				$sth->execute($query_values);
2416
-			} catch(PDOException $e) {
2416
+			} catch (PDOException $e) {
2417 2417
 				return "error : ".$e->getMessage();
2418 2418
 			}
2419 2419
 		}
2420 2420
 	}
2421
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
2421
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
2422 2422
 		global $globalDBdriver;
2423 2423
 		if ($airport_icao != '') {
2424 2424
 			if ($globalDBdriver == 'mysql') {
@@ -2434,16 +2434,16 @@  discard block
 block discarded – undo
2434 2434
 					$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);"; 
2435 2435
 				}
2436 2436
 			}
2437
-			$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);
2437
+			$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);
2438 2438
 			try {
2439 2439
 				$sth = $this->db->prepare($query);
2440 2440
 				$sth->execute($query_values);
2441
-			} catch(PDOException $e) {
2441
+			} catch (PDOException $e) {
2442 2442
 				return "error : ".$e->getMessage();
2443 2443
 			}
2444 2444
 		}
2445 2445
 	}
2446
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
2446
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
2447 2447
 		global $globalDBdriver;
2448 2448
 		if ($airport_icao != '') {
2449 2449
 			if ($globalDBdriver == 'mysql') {
@@ -2451,11 +2451,11 @@  discard block
 block discarded – undo
2451 2451
 			} else {
2452 2452
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2453 2453
 			}
2454
-			$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);
2454
+			$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);
2455 2455
 			try {
2456 2456
 				$sth = $this->db->prepare($query);
2457 2457
 				$sth->execute($query_values);
2458
-			} catch(PDOException $e) {
2458
+			} catch (PDOException $e) {
2459 2459
 				return "error : ".$e->getMessage();
2460 2460
 			}
2461 2461
 		}
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
 		try {
2468 2468
 			$sth = $this->db->prepare($query);
2469 2469
 			$sth->execute($query_values);
2470
-		} catch(PDOException $e) {
2470
+		} catch (PDOException $e) {
2471 2471
 			return "error : ".$e->getMessage();
2472 2472
 		}
2473 2473
 	}
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
 		try {
2478 2478
 			$sth = $this->db->prepare($query);
2479 2479
 			$sth->execute($query_values);
2480
-		} catch(PDOException $e) {
2480
+		} catch (PDOException $e) {
2481 2481
 			return "error : ".$e->getMessage();
2482 2482
 		}
2483 2483
 	}
@@ -2487,7 +2487,7 @@  discard block
 block discarded – undo
2487 2487
 		try {
2488 2488
 			$sth = $this->db->prepare($query);
2489 2489
 			$sth->execute($query_values);
2490
-		} catch(PDOException $e) {
2490
+		} catch (PDOException $e) {
2491 2491
 			return "error : ".$e->getMessage();
2492 2492
 		}
2493 2493
 	}
@@ -2497,7 +2497,7 @@  discard block
 block discarded – undo
2497 2497
 		try {
2498 2498
 			$sth = $this->db->prepare($query);
2499 2499
 			$sth->execute($query_values);
2500
-		} catch(PDOException $e) {
2500
+		} catch (PDOException $e) {
2501 2501
 			return "error : ".$e->getMessage();
2502 2502
 		}
2503 2503
 	}
@@ -2507,13 +2507,13 @@  discard block
 block discarded – undo
2507 2507
 		try {
2508 2508
 			$sth = $this->db->prepare($query);
2509 2509
 			$sth->execute($query_values);
2510
-		} catch(PDOException $e) {
2510
+		} catch (PDOException $e) {
2511 2511
 			return "error : ".$e->getMessage();
2512 2512
 		}
2513 2513
 	}
2514 2514
 
2515 2515
 	public function addOldStats() {
2516
-		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
2516
+		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
2517 2517
 		$Common = new Common();
2518 2518
 		$Connection = new Connection($this->db);
2519 2519
 		date_default_timezone_set('UTC');
@@ -2528,9 +2528,9 @@  discard block
 block discarded – undo
2528 2528
 			$filtername = 'marine';
2529 2529
 			if ($Connection->tableExists('countries')) {
2530 2530
 				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2531
-				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2531
+				$alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day);
2532 2532
 				foreach ($alldata as $number) {
2533
-					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2533
+					echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset);
2534 2534
 				}
2535 2535
 			}
2536 2536
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2540,44 +2540,44 @@  discard block
 block discarded – undo
2540 2540
 			$lastyear = false;
2541 2541
 			foreach ($alldata as $number) {
2542 2542
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2543
-				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2543
+				$this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2544 2544
 			}
2545 2545
 			echo 'Marine data...'."\n";
2546 2546
 			$this->deleteStatMarine('month');
2547 2547
 			echo '-> countAllDatesLastMonth...'."\n";
2548 2548
 			$alldata = $Marine->countAllDatesLastMonth($filter_last_month);
2549 2549
 			foreach ($alldata as $number) {
2550
-				$this->addStatMarine('month',$number['date_name'],$number['date_count']);
2550
+				$this->addStatMarine('month', $number['date_name'], $number['date_count']);
2551 2551
 			}
2552 2552
 			echo '-> countAllDates...'."\n";
2553 2553
 			$previousdata = $this->countAllDatesMarine();
2554 2554
 			$this->deleteStatMarine('date');
2555
-			$alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month));
2555
+			$alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month));
2556 2556
 			$values = array();
2557 2557
 			foreach ($alldata as $cnt) {
2558 2558
 				$values[] = $cnt['date_count'];
2559 2559
 			}
2560
-			array_multisort($values,SORT_DESC,$alldata);
2561
-			array_splice($alldata,11);
2560
+			array_multisort($values, SORT_DESC, $alldata);
2561
+			array_splice($alldata, 11);
2562 2562
 			foreach ($alldata as $number) {
2563
-				$this->addStatMarine('date',$number['date_name'],$number['date_count']);
2563
+				$this->addStatMarine('date', $number['date_name'], $number['date_count']);
2564 2564
 			}
2565 2565
 			
2566 2566
 			$this->deleteStatMarine('hour');
2567 2567
 			echo '-> countAllHours...'."\n";
2568
-			$alldata = $Marine->countAllHours('hour',$filter_last_month);
2568
+			$alldata = $Marine->countAllHours('hour', $filter_last_month);
2569 2569
 			foreach ($alldata as $number) {
2570
-				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2570
+				$this->addStatMarine('hour', $number['hour_name'], $number['hour_count']);
2571 2571
 			}
2572 2572
 			if ($globalDebug) echo 'Count all types...'."\n";
2573
-			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2573
+			$alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day);
2574 2574
 			foreach ($alldata as $number) {
2575
-				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
2575
+				$this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset);
2576 2576
 			}
2577 2577
 
2578 2578
 			echo 'Insert last stats update date...'."\n";
2579 2579
 			date_default_timezone_set('UTC');
2580
-			$this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s'));
2580
+			$this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s'));
2581 2581
 		}
2582 2582
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2583 2583
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
@@ -2589,9 +2589,9 @@  discard block
 block discarded – undo
2589 2589
 			$Tracker = new Tracker($this->db);
2590 2590
 			if ($Connection->tableExists('countries')) {
2591 2591
 				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2592
-				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2592
+				$alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day);
2593 2593
 				foreach ($alldata as $number) {
2594
-					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2594
+					$this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset);
2595 2595
 				}
2596 2596
 			}
2597 2597
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2601,43 +2601,43 @@  discard block
 block discarded – undo
2601 2601
 			$lastyear = false;
2602 2602
 			foreach ($alldata as $number) {
2603 2603
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2604
-				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2604
+				$this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2605 2605
 			}
2606 2606
 			echo 'Tracker data...'."\n";
2607 2607
 			$this->deleteStatTracker('month');
2608 2608
 			echo '-> countAllDatesLastMonth...'."\n";
2609 2609
 			$alldata = $Tracker->countAllDatesLastMonth($filter_last_month);
2610 2610
 			foreach ($alldata as $number) {
2611
-				$this->addStatTracker('month',$number['date_name'],$number['date_count']);
2611
+				$this->addStatTracker('month', $number['date_name'], $number['date_count']);
2612 2612
 			}
2613 2613
 			echo '-> countAllDates...'."\n";
2614 2614
 			$previousdata = $this->countAllDatesTracker();
2615 2615
 			$this->deleteStatTracker('date');
2616
-			$alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month));
2616
+			$alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month));
2617 2617
 			$values = array();
2618 2618
 			foreach ($alldata as $cnt) {
2619 2619
 				$values[] = $cnt['date_count'];
2620 2620
 			}
2621
-			array_multisort($values,SORT_DESC,$alldata);
2622
-			array_splice($alldata,11);
2621
+			array_multisort($values, SORT_DESC, $alldata);
2622
+			array_splice($alldata, 11);
2623 2623
 			foreach ($alldata as $number) {
2624
-				$this->addStatTracker('date',$number['date_name'],$number['date_count']);
2624
+				$this->addStatTracker('date', $number['date_name'], $number['date_count']);
2625 2625
 			}
2626 2626
 			
2627 2627
 			$this->deleteStatTracker('hour');
2628 2628
 			echo '-> countAllHours...'."\n";
2629
-			$alldata = $Tracker->countAllHours('hour',$filter_last_month);
2629
+			$alldata = $Tracker->countAllHours('hour', $filter_last_month);
2630 2630
 			foreach ($alldata as $number) {
2631
-				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2631
+				$this->addStatTracker('hour', $number['hour_name'], $number['hour_count']);
2632 2632
 			}
2633 2633
 			if ($globalDebug) echo 'Count all types...'."\n";
2634
-			$alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day);
2634
+			$alldata = $Tracker->countAllTrackerTypes(false, 0, $last_update_day);
2635 2635
 			foreach ($alldata as $number) {
2636
-				$this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset);
2636
+				$this->addStatTrackerType($number['tracker_type'], $number['tracker_type_count'], '', $reset);
2637 2637
 			}
2638 2638
 			echo 'Insert last stats update date...'."\n";
2639 2639
 			date_default_timezone_set('UTC');
2640
-			$this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s'));
2640
+			$this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s'));
2641 2641
 		}
2642 2642
 
2643 2643
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
@@ -2655,41 +2655,41 @@  discard block
 block discarded – undo
2655 2655
 			$Spotter = new Spotter($this->db);
2656 2656
 
2657 2657
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2658
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2658
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
2659 2659
 			foreach ($alldata as $number) {
2660
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2660
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2661 2661
 			}
2662 2662
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2663
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2663
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2664 2664
 			foreach ($alldata as $number) {
2665
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2665
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2666 2666
 			}
2667 2667
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2668
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2668
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2669 2669
 			foreach ($alldata as $number) {
2670
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2670
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2671 2671
 			}
2672 2672
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2673
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2673
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2674 2674
 			foreach ($alldata as $number) {
2675
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2675
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2676 2676
 			}
2677 2677
 			if ($globalDebug) echo 'Count all owners...'."\n";
2678
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2678
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2679 2679
 			foreach ($alldata as $number) {
2680
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2680
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2681 2681
 			}
2682 2682
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2683
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2683
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2684 2684
 			foreach ($alldata as $number) {
2685 2685
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2686
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2686
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2687 2687
 			}
2688 2688
 			
2689 2689
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2690
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2690
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2691 2691
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2692
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2692
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2693 2693
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2694 2694
 			$alldata = array();
2695 2695
 			foreach ($pall as $value) {
@@ -2706,14 +2706,14 @@  discard block
 block discarded – undo
2706 2706
 			foreach ($alldata as $key => $row) {
2707 2707
 				$count[$key] = $row['airport_departure_icao_count'];
2708 2708
 			}
2709
-			array_multisort($count,SORT_DESC,$alldata);
2709
+			array_multisort($count, SORT_DESC, $alldata);
2710 2710
 			foreach ($alldata as $number) {
2711
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
2711
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
2712 2712
 			}
2713 2713
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2714
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2714
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2715 2715
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2716
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2716
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2717 2717
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2718 2718
 			$alldata = array();
2719 2719
 			foreach ($pall as $value) {
@@ -2730,18 +2730,18 @@  discard block
 block discarded – undo
2730 2730
 			foreach ($alldata as $key => $row) {
2731 2731
 				$count[$key] = $row['airport_arrival_icao_count'];
2732 2732
 			}
2733
-			array_multisort($count,SORT_DESC,$alldata);
2733
+			array_multisort($count, SORT_DESC, $alldata);
2734 2734
 			foreach ($alldata as $number) {
2735
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
2735
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
2736 2736
 			}
2737 2737
 			if ($Connection->tableExists('countries')) {
2738 2738
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2739 2739
 				//$SpotterArchive = new SpotterArchive();
2740 2740
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2741 2741
 				$Spotter = new Spotter($this->db);
2742
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2742
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2743 2743
 				foreach ($alldata as $number) {
2744
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2744
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2745 2745
 				}
2746 2746
 			}
2747 2747
 			
@@ -2751,12 +2751,12 @@  discard block
 block discarded – undo
2751 2751
 				$this->deleteStatsByType('fatalities_byyear');
2752 2752
 				$alldata = $Accident->countFatalitiesByYear();
2753 2753
 				foreach ($alldata as $number) {
2754
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2754
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2755 2755
 				}
2756 2756
 				$this->deleteStatsByType('fatalities_bymonth');
2757 2757
 				$alldata = $Accident->countFatalitiesLast12Months();
2758 2758
 				foreach ($alldata as $number) {
2759
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2759
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2760 2760
 				}
2761 2761
 			}
2762 2762
 
@@ -2770,37 +2770,37 @@  discard block
 block discarded – undo
2770 2770
 			$lastyear = false;
2771 2771
 			foreach ($alldata as $number) {
2772 2772
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2773
-				$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'])));
2773
+				$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'])));
2774 2774
 			}
2775 2775
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2776 2776
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2777 2777
 			foreach ($alldata as $number) {
2778
-				$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'])));
2778
+				$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'])));
2779 2779
 			}
2780 2780
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2781 2781
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2782 2782
 			foreach ($alldata as $number) {
2783
-				$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'])));
2783
+				$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'])));
2784 2784
 			}
2785 2785
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2786 2786
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2787 2787
 			foreach ($alldata as $number) {
2788
-				$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'])));
2788
+				$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'])));
2789 2789
 			}
2790 2790
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2791 2791
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2792 2792
 			foreach ($alldata as $number) {
2793
-				$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'])));
2793
+				$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'])));
2794 2794
 			}
2795 2795
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2796 2796
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2797 2797
 			foreach ($alldata as $number) {
2798
-				$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'])));
2798
+				$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'])));
2799 2799
 			}
2800 2800
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2801 2801
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2802 2802
 			foreach ($alldata as $number) {
2803
-				$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'])));
2803
+				$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'])));
2804 2804
 			}
2805 2805
 			if ($globalDebug) echo 'Airports data...'."\n";
2806 2806
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
 			}
2846 2846
 			$alldata = $pall;
2847 2847
 			foreach ($alldata as $number) {
2848
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2848
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2849 2849
 			}
2850 2850
 			echo '...Arrival'."\n";
2851 2851
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2886,7 +2886,7 @@  discard block
 block discarded – undo
2886 2886
 			}
2887 2887
 			$alldata = $pall;
2888 2888
 			foreach ($alldata as $number) {
2889
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2889
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2890 2890
 			}
2891 2891
 
2892 2892
 			echo 'Flights data...'."\n";
@@ -2894,28 +2894,28 @@  discard block
 block discarded – undo
2894 2894
 			echo '-> countAllDatesLastMonth...'."\n";
2895 2895
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2896 2896
 			foreach ($alldata as $number) {
2897
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2897
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2898 2898
 			}
2899 2899
 			echo '-> countAllDates...'."\n";
2900 2900
 			$previousdata = $this->countAllDates();
2901 2901
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2902 2902
 			$this->deleteStatFlight('date');
2903
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2903
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2904 2904
 			$values = array();
2905 2905
 			foreach ($alldata as $cnt) {
2906 2906
 				$values[] = $cnt['date_count'];
2907 2907
 			}
2908
-			array_multisort($values,SORT_DESC,$alldata);
2909
-			array_splice($alldata,11);
2908
+			array_multisort($values, SORT_DESC, $alldata);
2909
+			array_splice($alldata, 11);
2910 2910
 			foreach ($alldata as $number) {
2911
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2911
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2912 2912
 			}
2913 2913
 			
2914 2914
 			$this->deleteStatFlight('hour');
2915 2915
 			echo '-> countAllHours...'."\n";
2916
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2916
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2917 2917
 			foreach ($alldata as $number) {
2918
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2918
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2919 2919
 			}
2920 2920
 
2921 2921
 			// Count by airlines
@@ -2924,42 +2924,42 @@  discard block
 block discarded – undo
2924 2924
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2925 2925
 				$SpotterArchive = new SpotterArchive($this->db);
2926 2926
 				//$Spotter = new Spotter($this->db);
2927
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2927
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2928 2928
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2929 2929
 				foreach ($alldata as $number) {
2930
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2930
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2931 2931
 				}
2932 2932
 			}
2933 2933
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2934 2934
 			$Spotter = new Spotter($this->db);
2935
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2935
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2936 2936
 			foreach ($alldata as $number) {
2937
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2937
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2938 2938
 			}
2939 2939
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2940
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2940
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2941 2941
 			foreach ($alldata as $number) {
2942
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2942
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2943 2943
 			}
2944 2944
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2945
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2945
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2946 2946
 			foreach ($alldata as $number) {
2947
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2947
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2948 2948
 			}
2949 2949
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2950
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2950
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2951 2951
 			foreach ($alldata as $number) {
2952
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2952
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2953 2953
 			}
2954 2954
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2955
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2955
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2956 2956
 			foreach ($alldata as $number) {
2957
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2957
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2958 2958
 			}
2959 2959
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2960
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2960
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2961 2961
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2962
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2962
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2963 2963
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2964 2964
 			//$alldata = array();
2965 2965
 			foreach ($dall as $value) {
@@ -2979,12 +2979,12 @@  discard block
 block discarded – undo
2979 2979
 			}
2980 2980
 			$alldata = $pall;
2981 2981
 			foreach ($alldata as $number) {
2982
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
2982
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
2983 2983
 			}
2984 2984
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2985
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2985
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2986 2986
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2987
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2987
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2988 2988
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2989 2989
 			//$alldata = array();
2990 2990
 			foreach ($dall as $value) {
@@ -3004,7 +3004,7 @@  discard block
 block discarded – undo
3004 3004
 			}
3005 3005
 			$alldata = $pall;
3006 3006
 			foreach ($alldata as $number) {
3007
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
3007
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
3008 3008
 			}
3009 3009
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
3010 3010
 			$Spotter = new Spotter($this->db);
@@ -3012,27 +3012,27 @@  discard block
 block discarded – undo
3012 3012
 			$lastyear = false;
3013 3013
 			foreach ($alldata as $number) {
3014 3014
 				if ($number['year_name'] != date('Y')) $lastyear = true;
3015
-				$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']);
3015
+				$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']);
3016 3016
 			}
3017 3017
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3018 3018
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
3019 3019
 			foreach ($alldata as $number) {
3020
-				$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']);
3020
+				$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']);
3021 3021
 			}
3022 3022
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3023 3023
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
3024 3024
 			foreach ($alldata as $number) {
3025
-				$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']);
3025
+				$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']);
3026 3026
 			}
3027 3027
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3028 3028
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
3029 3029
 			foreach ($alldata as $number) {
3030
-				$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']);
3030
+				$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']);
3031 3031
 			}
3032 3032
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3033 3033
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
3034 3034
 			foreach ($alldata as $number) {
3035
-				$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']);
3035
+				$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']);
3036 3036
 			}
3037 3037
 			if ($globalDebug) echo '...Departure'."\n";
3038 3038
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -3055,7 +3055,7 @@  discard block
 block discarded – undo
3055 3055
 			}
3056 3056
 			$alldata = $pall;
3057 3057
 			foreach ($alldata as $number) {
3058
-				$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']);
3058
+				$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']);
3059 3059
 			}
3060 3060
 			if ($globalDebug) echo '...Arrival'."\n";
3061 3061
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -3078,32 +3078,32 @@  discard block
 block discarded – undo
3078 3078
 			}
3079 3079
 			$alldata = $pall;
3080 3080
 			foreach ($alldata as $number) {
3081
-				$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']);
3081
+				$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']);
3082 3082
 			}
3083 3083
 
3084 3084
 			if ($globalDebug) echo 'Flights data...'."\n";
3085 3085
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3086 3086
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
3087 3087
 			foreach ($alldata as $number) {
3088
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
3088
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
3089 3089
 			}
3090 3090
 			if ($globalDebug) echo '-> countAllDates...'."\n";
3091 3091
 			//$previousdata = $this->countAllDatesByAirlines();
3092
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
3092
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
3093 3093
 			$values = array();
3094 3094
 			foreach ($alldata as $cnt) {
3095 3095
 				$values[] = $cnt['date_count'];
3096 3096
 			}
3097
-			array_multisort($values,SORT_DESC,$alldata);
3098
-			array_splice($alldata,11);
3097
+			array_multisort($values, SORT_DESC, $alldata);
3098
+			array_splice($alldata, 11);
3099 3099
 			foreach ($alldata as $number) {
3100
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
3100
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
3101 3101
 			}
3102 3102
 			
3103 3103
 			if ($globalDebug) echo '-> countAllHours...'."\n";
3104
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
3104
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
3105 3105
 			foreach ($alldata as $number) {
3106
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
3106
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
3107 3107
 			}
3108 3108
 
3109 3109
 			// Stats by filters
@@ -3127,7 +3127,7 @@  discard block
 block discarded – undo
3127 3127
 							$last_update_day = date('Y').'-01-01 00:00:00';
3128 3128
 						}
3129 3129
 					}
3130
-					if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
3130
+					if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
3131 3131
 						$last_update_day = date('Y').'-01-01 00:00:00';
3132 3132
 						$reset = true;
3133 3133
 					}
@@ -3135,38 +3135,38 @@  discard block
 block discarded – undo
3135 3135
 					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3136 3136
 					$Spotter = new Spotter($this->db);
3137 3137
 					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3138
-					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
3138
+					$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
3139 3139
 					foreach ($alldata as $number) {
3140
-						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
3140
+						$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
3141 3141
 					}
3142 3142
 					if ($globalDebug) echo 'Count all airlines...'."\n";
3143
-					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3143
+					$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
3144 3144
 					foreach ($alldata as $number) {
3145
-						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3145
+						$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
3146 3146
 					}
3147 3147
 					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3148
-					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3148
+					$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
3149 3149
 					foreach ($alldata as $number) {
3150
-						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3150
+						$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
3151 3151
 					}
3152 3152
 					if ($globalDebug) echo 'Count all callsigns...'."\n";
3153
-					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3153
+					$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
3154 3154
 					foreach ($alldata as $number) {
3155
-						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3155
+						$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
3156 3156
 					}
3157 3157
 					if ($globalDebug) echo 'Count all owners...'."\n";
3158
-					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3158
+					$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
3159 3159
 					foreach ($alldata as $number) {
3160
-						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3160
+						$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
3161 3161
 					}
3162 3162
 					if ($globalDebug) echo 'Count all pilots...'."\n";
3163
-					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3163
+					$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
3164 3164
 					foreach ($alldata as $number) {
3165
-						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3165
+						$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
3166 3166
 					}
3167 3167
 					if ($globalDebug) echo 'Count departure airports...'."\n";
3168
-					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3169
-					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3168
+					$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
3169
+					$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
3170 3170
 					$alldata = array();
3171 3171
 					foreach ($pall as $value) {
3172 3172
 						$icao = $value['airport_departure_icao'];
@@ -3182,13 +3182,13 @@  discard block
 block discarded – undo
3182 3182
 					foreach ($alldata as $key => $row) {
3183 3183
 						$count[$key] = $row['airport_departure_icao_count'];
3184 3184
 					}
3185
-					array_multisort($count,SORT_DESC,$alldata);
3185
+					array_multisort($count, SORT_DESC, $alldata);
3186 3186
 					foreach ($alldata as $number) {
3187
-						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
3187
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
3188 3188
 					}
3189 3189
 					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3190
-					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3191
-					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3190
+					$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
3191
+					$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
3192 3192
 					$alldata = array();
3193 3193
 					foreach ($pall as $value) {
3194 3194
 						$icao = $value['airport_arrival_icao'];
@@ -3204,9 +3204,9 @@  discard block
 block discarded – undo
3204 3204
 					foreach ($alldata as $key => $row) {
3205 3205
 						$count[$key] = $row['airport_arrival_icao_count'];
3206 3206
 					}
3207
-					array_multisort($count,SORT_DESC,$alldata);
3207
+					array_multisort($count, SORT_DESC, $alldata);
3208 3208
 					foreach ($alldata as $number) {
3209
-						echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
3209
+						echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
3210 3210
 					}
3211 3211
 					if ($globalDebug) echo 'Count all months...'."\n";
3212 3212
 					$Spotter = new Spotter($this->db);
@@ -3214,36 +3214,36 @@  discard block
 block discarded – undo
3214 3214
 					$lastyear = false;
3215 3215
 					foreach ($alldata as $number) {
3216 3216
 						if ($number['year_name'] != date('Y')) $lastyear = true;
3217
-						$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);
3217
+						$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);
3218 3218
 					}
3219 3219
 					if ($globalDebug) echo 'Count all owners by months...'."\n";
3220 3220
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3221 3221
 					foreach ($alldata as $number) {
3222
-						$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);
3222
+						$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);
3223 3223
 					}
3224 3224
 					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3225 3225
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3226 3226
 					foreach ($alldata as $number) {
3227
-						$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);
3227
+						$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);
3228 3228
 					}
3229 3229
 					if ($globalDebug) echo 'Count all military by months...'."\n";
3230 3230
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3231 3231
 					foreach ($alldata as $number) {
3232
-						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3232
+						$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3233 3233
 					}
3234 3234
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3235 3235
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3236 3236
 				    	foreach ($alldata as $number) {
3237
-			    			$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);
3237
+			    			$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);
3238 3238
 					}
3239 3239
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3240 3240
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3241 3241
 					foreach ($alldata as $number) {
3242
-						$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);
3242
+						$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);
3243 3243
 					}
3244 3244
 					echo '...Departure'."\n";
3245
-					$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
3246
-					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
3245
+					$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
3246
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
3247 3247
 					foreach ($dall as $value) {
3248 3248
 						$icao = $value['departure_airport_icao'];
3249 3249
 						$ddate = $value['date'];
@@ -3261,11 +3261,11 @@  discard block
 block discarded – undo
3261 3261
 					}
3262 3262
 					$alldata = $pall;
3263 3263
 					foreach ($alldata as $number) {
3264
-						$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);
3264
+						$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);
3265 3265
 					}
3266 3266
 					echo '...Arrival'."\n";
3267
-					$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
3268
-					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
3267
+					$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
3268
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
3269 3269
 					foreach ($dall as $value) {
3270 3270
 						$icao = $value['arrival_airport_icao'];
3271 3271
 						$ddate = $value['date'];
@@ -3283,39 +3283,39 @@  discard block
 block discarded – undo
3283 3283
 					}
3284 3284
 					$alldata = $pall;
3285 3285
 					foreach ($alldata as $number) {
3286
-						$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);
3286
+						$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);
3287 3287
 					}
3288 3288
 					echo 'Flights data...'."\n";
3289 3289
 					echo '-> countAllDatesLastMonth...'."\n";
3290 3290
 					$alldata = $Spotter->countAllDatesLastMonth($filter);
3291 3291
 					foreach ($alldata as $number) {
3292
-						$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
3292
+						$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
3293 3293
 					}
3294 3294
 					echo '-> countAllDates...'."\n";
3295
-					$previousdata = $this->countAllDates('',$filter_name);
3296
-					$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
3295
+					$previousdata = $this->countAllDates('', $filter_name);
3296
+					$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
3297 3297
 					$values = array();
3298 3298
 					foreach ($alldata as $cnt) {
3299 3299
 						$values[] = $cnt['date_count'];
3300 3300
 					}
3301
-					array_multisort($values,SORT_DESC,$alldata);
3302
-					array_splice($alldata,11);
3301
+					array_multisort($values, SORT_DESC, $alldata);
3302
+					array_splice($alldata, 11);
3303 3303
 					foreach ($alldata as $number) {
3304
-						$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
3304
+						$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
3305 3305
 					}
3306 3306
 				
3307 3307
 					echo '-> countAllHours...'."\n";
3308
-					$alldata = $Spotter->countAllHours('hour',$filter);
3308
+					$alldata = $Spotter->countAllHours('hour', $filter);
3309 3309
 					foreach ($alldata as $number) {
3310
-						$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
3310
+						$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
3311 3311
 					}
3312 3312
 					echo 'Insert last stats update date...'."\n";
3313 3313
 					date_default_timezone_set('UTC');
3314
-					$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
3314
+					$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
3315 3315
 					if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
3316
-						if (date('Y',strtotime($last_update_day)) != date('Y')) {
3316
+						if (date('Y', strtotime($last_update_day)) != date('Y')) {
3317 3317
 							$this->deleteOldStats($filter_name);
3318
-							$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
3318
+							$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
3319 3319
 						}
3320 3320
 					}
3321 3321
 				}
@@ -3328,16 +3328,16 @@  discard block
 block discarded – undo
3328 3328
 				// SUM all previous month to put as year
3329 3329
 				$previous_year = date('Y');
3330 3330
 				$previous_year--;
3331
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3332
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3333
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3334
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3331
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3332
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3333
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3334
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3335 3335
 				$allairlines = $this->getAllAirlineNames();
3336 3336
 				foreach ($allairlines as $data) {
3337
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3338
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3339
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3340
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3337
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3338
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3339
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3340
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3341 3341
 				}
3342 3342
 				
3343 3343
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -3346,21 +3346,21 @@  discard block
 block discarded – undo
3346 3346
 						try {
3347 3347
 							$sth = $this->db->prepare($query);
3348 3348
 							$sth->execute();
3349
-						} catch(PDOException $e) {
3349
+						} catch (PDOException $e) {
3350 3350
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3351 3351
 						}
3352 3352
 						$query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'";
3353 3353
 						try {
3354 3354
 							$sth = $this->db->prepare($query);
3355 3355
 							$sth->execute();
3356
-						} catch(PDOException $e) {
3356
+						} catch (PDOException $e) {
3357 3357
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3358 3358
 						}
3359 3359
 						$query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'";
3360 3360
 						try {
3361 3361
 							$sth = $this->db->prepare($query);
3362 3362
 							$sth->execute();
3363
-						} catch(PDOException $e) {
3363
+						} catch (PDOException $e) {
3364 3364
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3365 3365
 						}
3366 3366
 					}
@@ -3373,7 +3373,7 @@  discard block
 block discarded – undo
3373 3373
 					try {
3374 3374
 						$sth = $this->db->prepare($query);
3375 3375
 						$sth->execute();
3376
-					} catch(PDOException $e) {
3376
+					} catch (PDOException $e) {
3377 3377
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3378 3378
 					}
3379 3379
 					if ($globalDBdriver == 'mysql') {
@@ -3384,7 +3384,7 @@  discard block
 block discarded – undo
3384 3384
 					try {
3385 3385
 						$sth = $this->db->prepare($query);
3386 3386
 						$sth->execute();
3387
-					} catch(PDOException $e) {
3387
+					} catch (PDOException $e) {
3388 3388
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3389 3389
 					}
3390 3390
 					if ($globalDBdriver == 'mysql') {
@@ -3395,15 +3395,15 @@  discard block
 block discarded – undo
3395 3395
 					try {
3396 3396
 						$sth = $this->db->prepare($query);
3397 3397
 						$sth->execute();
3398
-					} catch(PDOException $e) {
3398
+					} catch (PDOException $e) {
3399 3399
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3400 3400
 					}
3401 3401
 				}
3402 3402
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
3403 3403
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
3404
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
3404
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
3405 3405
 						$this->deleteOldStats();
3406
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
3406
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
3407 3407
 						$lastyearupdate = true;
3408 3408
 					}
3409 3409
 				}
@@ -3425,7 +3425,7 @@  discard block
 block discarded – undo
3425 3425
 					try {
3426 3426
 						$sth = $this->db->prepare($query);
3427 3427
 						$sth->execute();
3428
-					} catch(PDOException $e) {
3428
+					} catch (PDOException $e) {
3429 3429
 						return "error : ".$e->getMessage();
3430 3430
 					}
3431 3431
 					echo 'Archive old tracker data...'."\n";
@@ -3441,7 +3441,7 @@  discard block
 block discarded – undo
3441 3441
 					try {
3442 3442
 						$sth = $this->db->prepare($query);
3443 3443
 						$sth->execute();
3444
-					} catch(PDOException $e) {
3444
+					} catch (PDOException $e) {
3445 3445
 						return "error : ".$e->getMessage();
3446 3446
 					}
3447 3447
 					echo 'Archive old marine data...'."\n";
@@ -3457,7 +3457,7 @@  discard block
 block discarded – undo
3457 3457
 					try {
3458 3458
 						$sth = $this->db->prepare($query);
3459 3459
 						$sth->execute();
3460
-					} catch(PDOException $e) {
3460
+					} catch (PDOException $e) {
3461 3461
 						return "error : ".$e->getMessage();
3462 3462
 					}
3463 3463
 				}
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
 				try {
3471 3471
 					$sth = $this->db->prepare($query);
3472 3472
 					$sth->execute();
3473
-				} catch(PDOException $e) {
3473
+				} catch (PDOException $e) {
3474 3474
 					return "error : ".$e->getMessage();
3475 3475
 				}
3476 3476
 				echo 'Deleting old tracker data...'."\n";
@@ -3482,7 +3482,7 @@  discard block
 block discarded – undo
3482 3482
 				try {
3483 3483
 					$sth = $this->db->prepare($query);
3484 3484
 					$sth->execute();
3485
-				} catch(PDOException $e) {
3485
+				} catch (PDOException $e) {
3486 3486
 					return "error : ".$e->getMessage();
3487 3487
 				}
3488 3488
 				echo 'Deleting old marine data...'."\n";
@@ -3494,14 +3494,14 @@  discard block
 block discarded – undo
3494 3494
 				try {
3495 3495
 					$sth = $this->db->prepare($query);
3496 3496
 					$sth->execute();
3497
-				} catch(PDOException $e) {
3497
+				} catch (PDOException $e) {
3498 3498
 					return "error : ".$e->getMessage();
3499 3499
 				}
3500 3500
 			}
3501 3501
 			if (!isset($lastyearupdate)) {
3502 3502
 				echo 'Insert last stats update date...'."\n";
3503 3503
 				date_default_timezone_set('UTC');
3504
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
3504
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
3505 3505
 			}
3506 3506
 			if ($globalStatsResetYear) {
3507 3507
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +778 added lines, -273 removed lines patch added patch discarded remove patch
@@ -22,10 +22,14 @@  discard block
 block discarded – undo
22 22
 	*/
23 23
 	public function __construct($dbc = null) {
24 24
 		global $globalFilterName;
25
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
25
+		if (isset($globalFilterName)) {
26
+			$this->filter_name = $globalFilterName;
27
+		}
26 28
 		$Connection = new Connection($dbc);
27 29
 		$this->db = $Connection->db();
28
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
30
+		if ($this->db === null) {
31
+			die('Error: No DB connection. (Stats)');
32
+		}
29 33
 	}
30 34
 
31 35
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -93,7 +97,9 @@  discard block
 block discarded – undo
93 97
 
94 98
 	public function getAllAirlineNames($filter_name = '') {
95 99
 		global $globalStatsFilters;
96
-		if ($filter_name == '') $filter_name = $this->filter_name;
100
+		if ($filter_name == '') {
101
+			$filter_name = $this->filter_name;
102
+		}
97 103
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
98 104
 		 try {
99 105
 			$sth = $this->db->prepare($query);
@@ -113,7 +119,9 @@  discard block
 block discarded – undo
113 119
 		return $all;
114 120
 	}
115 121
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
122
+		if ($filter_name == '') {
123
+			$filter_name = $this->filter_name;
124
+		}
117 125
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
118 126
 		try {
119 127
 			$sth = $this->db->prepare($query);
@@ -125,7 +133,9 @@  discard block
 block discarded – undo
125 133
 		return $all;
126 134
 	}
127 135
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
128
-		if ($filter_name == '') $filter_name = $this->filter_name;
136
+		if ($filter_name == '') {
137
+			$filter_name = $this->filter_name;
138
+		}
129 139
 		$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
130 140
 		try {
131 141
 			$sth = $this->db->prepare($query);
@@ -137,7 +147,9 @@  discard block
 block discarded – undo
137 147
 		return $all;
138 148
 	}
139 149
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
140
-		if ($filter_name == '') $filter_name = $this->filter_name;
150
+		if ($filter_name == '') {
151
+			$filter_name = $this->filter_name;
152
+		}
141 153
 		$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
142 154
 		try {
143 155
 			$sth = $this->db->prepare($query);
@@ -150,7 +162,9 @@  discard block
 block discarded – undo
150 162
 	}
151 163
 
152 164
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
153
-		if ($filter_name == '') $filter_name = $this->filter_name;
165
+		if ($filter_name == '') {
166
+			$filter_name = $this->filter_name;
167
+		}
154 168
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
155 169
 		try {
156 170
 			$sth = $this->db->prepare($query);
@@ -163,7 +177,9 @@  discard block
 block discarded – undo
163 177
 	}
164 178
 
165 179
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
166
-		if ($filter_name == '') $filter_name = $this->filter_name;
180
+		if ($filter_name == '') {
181
+			$filter_name = $this->filter_name;
182
+		}
167 183
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
168 184
 		try {
169 185
 			$sth = $this->db->prepare($query);
@@ -178,7 +194,9 @@  discard block
 block discarded – undo
178 194
 
179 195
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
180 196
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
197
+		if ($filter_name == '') {
198
+			$filter_name = $this->filter_name;
199
+		}
182 200
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
183 201
 			$Spotter = new Spotter($this->db);
184 202
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -187,8 +205,11 @@  discard block
 block discarded – undo
187 205
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
188 206
 			}
189 207
 			if ($year == '' && $month == '') {
190
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
191
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
208
+				if ($limit) {
209
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
210
+				} else {
211
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
212
+				}
192 213
 				try {
193 214
 					$sth = $this->db->prepare($query);
194 215
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -196,11 +217,16 @@  discard block
 block discarded – undo
196 217
 					echo "error : ".$e->getMessage();
197 218
 				}
198 219
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
199
-			} else $all = array();
220
+			} else {
221
+				$all = array();
222
+			}
200 223
 		} else {
201 224
 			if ($year == '' && $month == '') {
202
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
203
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
225
+				if ($limit) {
226
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
227
+				} else {
228
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
229
+				}
204 230
 				try {
205 231
 					$sth = $this->db->prepare($query);
206 232
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -208,7 +234,9 @@  discard block
 block discarded – undo
208 234
 					echo "error : ".$e->getMessage();
209 235
 				}
210 236
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
211
-			} else $all = array();
237
+			} else {
238
+				$all = array();
239
+			}
212 240
 		}
213 241
 		if (empty($all)) {
214 242
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -227,10 +255,15 @@  discard block
 block discarded – undo
227 255
 	}
228 256
 	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
229 257
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
258
+		if ($filter_name == '') {
259
+			$filter_name = $this->filter_name;
260
+		}
231 261
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
262
+			if ($limit) {
263
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
264
+			} else {
265
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
266
+			}
234 267
 			try {
235 268
 				$sth = $this->db->prepare($query);
236 269
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -238,7 +271,9 @@  discard block
 block discarded – undo
238 271
 				echo "error : ".$e->getMessage();
239 272
 			}
240 273
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
274
+		} else {
275
+			$all = array();
276
+		}
242 277
 		if (empty($all)) {
243 278
 			$filters = array('year' => $year,'month' => $month);
244 279
 			if ($filter_name != '') {
@@ -252,10 +287,15 @@  discard block
 block discarded – undo
252 287
 	}
253 288
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
254 289
 		global $globalStatsFilters;
255
-		if ($filter_name == '') $filter_name = $this->filter_name;
290
+		if ($filter_name == '') {
291
+			$filter_name = $this->filter_name;
292
+		}
256 293
 		if ($year == '' && $month == '') {
257
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
258
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
294
+			if ($limit) {
295
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
296
+			} else {
297
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
298
+			}
259 299
 			try {
260 300
 				$sth = $this->db->prepare($query);
261 301
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -263,7 +303,9 @@  discard block
 block discarded – undo
263 303
 				echo "error : ".$e->getMessage();
264 304
 			}
265 305
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
266
-		} else $all = array();
306
+		} else {
307
+			$all = array();
308
+		}
267 309
 		if (empty($all)) {
268 310
 			$Spotter = new Spotter($this->db);
269 311
 			$filters = array();
@@ -278,7 +320,9 @@  discard block
 block discarded – undo
278 320
 	}
279 321
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
280 322
 		global $globalStatsFilters;
281
-		if ($filter_name == '') $filter_name = $this->filter_name;
323
+		if ($filter_name == '') {
324
+			$filter_name = $this->filter_name;
325
+		}
282 326
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
283 327
 			$Spotter = new Spotter($this->db);
284 328
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -287,8 +331,11 @@  discard block
 block discarded – undo
287 331
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
288 332
 			}
289 333
 			if ($year == '' && $month == '') {
290
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
291
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
334
+				if ($limit) {
335
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
336
+				} else {
337
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
338
+				}
292 339
 				try {
293 340
 					$sth = $this->db->prepare($query);
294 341
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -296,11 +343,16 @@  discard block
 block discarded – undo
296 343
 					echo "error : ".$e->getMessage();
297 344
 				}
298 345
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
299
-			} else $all = array();
346
+			} else {
347
+				$all = array();
348
+			}
300 349
 		} else {
301 350
 			if ($year == '' && $month == '') {
302
-				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";
303
-				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";
351
+				if ($limit) {
352
+					$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";
353
+				} else {
354
+					$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";
355
+				}
304 356
 				try {
305 357
 					$sth = $this->db->prepare($query);
306 358
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -308,7 +360,9 @@  discard block
 block discarded – undo
308 360
 					echo "error : ".$e->getMessage();
309 361
 				}
310 362
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
311
-			} else $all = array();
363
+			} else {
364
+				$all = array();
365
+			}
312 366
 		}
313 367
 		if (empty($all)) {
314 368
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -328,7 +382,9 @@  discard block
 block discarded – undo
328 382
 
329 383
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
330 384
 		global $globalStatsFilters;
331
-		if ($filter_name == '') $filter_name = $this->filter_name;
385
+		if ($filter_name == '') {
386
+			$filter_name = $this->filter_name;
387
+		}
332 388
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
333 389
 			$Spotter = new Spotter($this->db);
334 390
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -337,8 +393,11 @@  discard block
 block discarded – undo
337 393
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
338 394
 			}
339 395
 			if ($year == '' && $month == '') {
340
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
341
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
396
+				if ($limit) {
397
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
398
+				} else {
399
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
400
+				}
342 401
 				try {
343 402
 					$sth = $this->db->prepare($query);
344 403
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -346,11 +405,16 @@  discard block
 block discarded – undo
346 405
 					echo "error : ".$e->getMessage();
347 406
 				}
348 407
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
349
-			} else $all = array();
408
+			} else {
409
+				$all = array();
410
+			}
350 411
 		} else {
351 412
 			if ($year == '' && $month == '') {
352
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
353
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
413
+				if ($limit) {
414
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
415
+				} else {
416
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
417
+				}
354 418
 				try {
355 419
 					$sth = $this->db->prepare($query);
356 420
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -358,7 +422,9 @@  discard block
 block discarded – undo
358 422
 					echo "error : ".$e->getMessage();
359 423
 				}
360 424
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
361
-			} else $all = array();
425
+			} else {
426
+				$all = array();
427
+			}
362 428
 		}
363 429
 		if (empty($all)) {
364 430
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -377,7 +443,9 @@  discard block
 block discarded – undo
377 443
 	}
378 444
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
379 445
 		global $globalStatsFilters;
380
-		if ($filter_name == '') $filter_name = $this->filter_name;
446
+		if ($filter_name == '') {
447
+			$filter_name = $this->filter_name;
448
+		}
381 449
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
382 450
 			$Spotter = new Spotter($this->db);
383 451
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -385,12 +453,18 @@  discard block
 block discarded – undo
385 453
 			foreach ($airlines as $airline) {
386 454
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
387 455
 			}
388
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
389
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
456
+			if ($limit) {
457
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
458
+			} else {
459
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
460
+			}
390 461
 			$query_values = array(':filter_name' => $filter_name);
391 462
 		} else {
392
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
393
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
463
+			if ($limit) {
464
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
465
+			} else {
466
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
467
+			}
394 468
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
395 469
 		}
396 470
 		try {
@@ -418,17 +492,29 @@  discard block
 block discarded – undo
418 492
 
419 493
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
420 494
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
421
-		if ($filter_name == '') $filter_name = $this->filter_name;
495
+		if ($filter_name == '') {
496
+			$filter_name = $this->filter_name;
497
+		}
422 498
 		if ($year == '' && $month == '') {
423
-			if ($globalVATSIM) $forsource = 'vatsim';
424
-			if ($globalIVAO) $forsource = 'ivao';
499
+			if ($globalVATSIM) {
500
+				$forsource = 'vatsim';
501
+			}
502
+			if ($globalIVAO) {
503
+				$forsource = 'ivao';
504
+			}
425 505
 			if (isset($forsource)) {
426
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
427
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
506
+				if ($limit) {
507
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
508
+				} else {
509
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
510
+				}
428 511
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
429 512
 			} else {
430
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
431
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
513
+				if ($limit) {
514
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
515
+				} else {
516
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
517
+				}
432 518
 				$query_values = array(':filter_name' => $filter_name);
433 519
 			}
434 520
 			try {
@@ -438,7 +524,9 @@  discard block
 block discarded – undo
438 524
 				echo "error : ".$e->getMessage();
439 525
 			}
440 526
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
441
-		} else $all = array();
527
+		} else {
528
+			$all = array();
529
+		}
442 530
                 if (empty($all)) {
443 531
 	                $Spotter = new Spotter($this->db);
444 532
             		$filters = array();
@@ -453,7 +541,9 @@  discard block
 block discarded – undo
453 541
 	}
454 542
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
455 543
 		global $globalStatsFilters;
456
-		if ($filter_name == '') $filter_name = $this->filter_name;
544
+		if ($filter_name == '') {
545
+			$filter_name = $this->filter_name;
546
+		}
457 547
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
458 548
 			$Spotter = new Spotter($this->db);
459 549
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -462,8 +552,11 @@  discard block
 block discarded – undo
462 552
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
463 553
 			}
464 554
 			if ($year == '' && $month == '') {
465
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
466
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
555
+				if ($limit) {
556
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
557
+				} else {
558
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
559
+				}
467 560
 				try {
468 561
 					$sth = $this->db->prepare($query);
469 562
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -471,11 +564,16 @@  discard block
 block discarded – undo
471 564
 					echo "error : ".$e->getMessage();
472 565
 				}
473 566
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
474
-			} else $all = array();
567
+			} else {
568
+				$all = array();
569
+			}
475 570
 		} else {
476 571
 			if ($year == '' && $month == '') {
477
-				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";
478
-				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";
572
+				if ($limit) {
573
+					$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";
574
+				} else {
575
+					$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";
576
+				}
479 577
 				try {
480 578
 					$sth = $this->db->prepare($query);
481 579
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -483,7 +581,9 @@  discard block
 block discarded – undo
483 581
 					echo "error : ".$e->getMessage();
484 582
 				}
485 583
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486
-			} else $all = array();
584
+			} else {
585
+				$all = array();
586
+			}
487 587
 		}
488 588
 		if (empty($all)) {
489 589
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -502,7 +602,9 @@  discard block
 block discarded – undo
502 602
 	}
503 603
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
504 604
 		global $globalStatsFilters;
505
-		if ($filter_name == '') $filter_name = $this->filter_name;
605
+		if ($filter_name == '') {
606
+			$filter_name = $this->filter_name;
607
+		}
506 608
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
507 609
 			$Spotter = new Spotter($this->db);
508 610
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -511,8 +613,11 @@  discard block
 block discarded – undo
511 613
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
512 614
 			}
513 615
 			if ($year == '' && $month == '') {
514
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
515
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
616
+				if ($limit) {
617
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
618
+				} else {
619
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
620
+				}
516 621
 				 try {
517 622
 					$sth = $this->db->prepare($query);
518 623
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -520,11 +625,16 @@  discard block
 block discarded – undo
520 625
 					echo "error : ".$e->getMessage();
521 626
 				}
522 627
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
523
-			} else $all = array();
628
+			} else {
629
+				$all = array();
630
+			}
524 631
 		} else {
525 632
 			if ($year == '' && $month == '') {
526
-				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";
527
-				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";
633
+				if ($limit) {
634
+					$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";
635
+				} else {
636
+					$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";
637
+				}
528 638
 				 try {
529 639
 					$sth = $this->db->prepare($query);
530 640
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -532,7 +642,9 @@  discard block
 block discarded – undo
532 642
 					echo "error : ".$e->getMessage();
533 643
 				}
534 644
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
535
-			} else $all = array();
645
+			} else {
646
+				$all = array();
647
+			}
536 648
 		}
537 649
 		if (empty($all)) {
538 650
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -551,7 +663,9 @@  discard block
 block discarded – undo
551 663
 	}
552 664
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
553 665
 		$Connection = new Connection($this->db);
554
-		if ($filter_name == '') $filter_name = $this->filter_name;
666
+		if ($filter_name == '') {
667
+			$filter_name = $this->filter_name;
668
+		}
555 669
 		if ($Connection->tableExists('countries')) {
556 670
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
557 671
 				$Spotter = new Spotter($this->db);
@@ -561,8 +675,11 @@  discard block
 block discarded – undo
561 675
 					foreach ($airlines as $airline) {
562 676
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
563 677
 					}
564
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
565
-					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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
678
+					if ($limit) {
679
+						$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
680
+					} else {
681
+						$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
682
+					}
566 683
 					 try {
567 684
 						$sth = $this->db->prepare($query);
568 685
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -571,11 +688,16 @@  discard block
 block discarded – undo
571 688
 					}
572 689
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
573 690
 					return $all;
574
-				} else return array();
691
+				} else {
692
+					return array();
693
+				}
575 694
 			} else {
576 695
 				if ($year == '' && $month == '') {
577
-					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";
578
-					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";
696
+					if ($limit) {
697
+						$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";
698
+					} else {
699
+						$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";
700
+					}
579 701
 					 try {
580 702
 						$sth = $this->db->prepare($query);
581 703
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -584,20 +706,29 @@  discard block
 block discarded – undo
584 706
 					}
585 707
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
586 708
 					return $all;
587
-				} else return array();
709
+				} else {
710
+					return array();
711
+				}
588 712
 			}
589 713
 			$Spotter = new Spotter($this->db);
590 714
 			return $Spotter->countAllFlightOverCountries($limit);
591
-		} else return array();
715
+		} else {
716
+			return array();
717
+		}
592 718
 	}
593 719
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
594 720
 		$Connection = new Connection($this->db);
595
-		if ($filter_name == '') $filter_name = $this->filter_name;
721
+		if ($filter_name == '') {
722
+			$filter_name = $this->filter_name;
723
+		}
596 724
 		if ($Connection->tableExists('countries')) {
597 725
 			$all = array();
598 726
 			if ($year == '' && $month == '') {
599
-				if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
600
-				else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
727
+				if ($limit) {
728
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
729
+				} else {
730
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
731
+				}
601 732
 				 try {
602 733
 					$sth = $this->db->prepare($query);
603 734
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -615,17 +746,24 @@  discard block
 block discarded – undo
615 746
 				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
616 747
 			}
617 748
 			return $all;
618
-		} else return array();
749
+		} else {
750
+			return array();
751
+		}
619 752
 	}
620 753
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
621 754
 		global $globalStatsFilters;
622 755
 		$Connection = new Connection($this->db);
623
-		if ($filter_name == '') $filter_name = $this->filter_name;
756
+		if ($filter_name == '') {
757
+			$filter_name = $this->filter_name;
758
+		}
624 759
 		if ($Connection->tableExists('countries')) {
625 760
 			$all = array();
626 761
 			if ($year == '' && $month == '') {
627
-				if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
628
-				else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
762
+				if ($limit) {
763
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
764
+				} else {
765
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
766
+				}
629 767
 				 try {
630 768
 					$sth = $this->db->prepare($query);
631 769
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -644,14 +782,21 @@  discard block
 block discarded – undo
644 782
 				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
645 783
 			}
646 784
 			return $all;
647
-		} else return array();
785
+		} else {
786
+			return array();
787
+		}
648 788
 	}
649 789
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
650 790
 		global $globalStatsFilters;
651
-		if ($filter_name == '') $filter_name = $this->filter_name;
791
+		if ($filter_name == '') {
792
+			$filter_name = $this->filter_name;
793
+		}
652 794
 		if ($year == '' && $month == '') {
653
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
654
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
795
+			if ($limit) {
796
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
797
+			} else {
798
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
799
+			}
655 800
 			try {
656 801
 				$sth = $this->db->prepare($query);
657 802
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -659,7 +804,9 @@  discard block
 block discarded – undo
659 804
 				echo "error : ".$e->getMessage();
660 805
 			}
661 806
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
662
-		} else $all = array();
807
+		} else {
808
+			$all = array();
809
+		}
663 810
 		if (empty($all)) {
664 811
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
665 812
 			if ($filter_name != '') {
@@ -674,7 +821,9 @@  discard block
 block discarded – undo
674 821
 
675 822
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
676 823
 		global $globalStatsFilters;
677
-		if ($filter_name == '') $filter_name = $this->filter_name;
824
+		if ($filter_name == '') {
825
+			$filter_name = $this->filter_name;
826
+		}
678 827
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
679 828
 			$Spotter = new Spotter($this->db);
680 829
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -683,8 +832,11 @@  discard block
 block discarded – undo
683 832
 				foreach ($airlines as $airline) {
684 833
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
685 834
 				}
686
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
687
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
835
+				if ($limit) {
836
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
837
+				} else {
838
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
839
+				}
688 840
 				try {
689 841
 					$sth = $this->db->prepare($query);
690 842
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -692,11 +844,16 @@  discard block
 block discarded – undo
692 844
 					echo "error : ".$e->getMessage();
693 845
 				}
694 846
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-			} else $all = array();
847
+			} else {
848
+				$all = array();
849
+			}
696 850
 		} else {
697 851
 			if ($year == '' && $month == '') {
698
-				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";
699
-				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";
852
+				if ($limit) {
853
+					$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";
854
+				} else {
855
+					$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";
856
+				}
700 857
 				try {
701 858
 					$sth = $this->db->prepare($query);
702 859
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -704,7 +861,9 @@  discard block
 block discarded – undo
704 861
 					echo "error : ".$e->getMessage();
705 862
 				}
706 863
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
707
-			} else $all = array();
864
+			} else {
865
+				$all = array();
866
+			}
708 867
 		}
709 868
 		if (empty($all)) {
710 869
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -723,7 +882,9 @@  discard block
 block discarded – undo
723 882
 	}
724 883
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
725 884
 		global $globalStatsFilters;
726
-		if ($filter_name == '') $filter_name = $this->filter_name;
885
+		if ($filter_name == '') {
886
+			$filter_name = $this->filter_name;
887
+		}
727 888
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
728 889
 			$Spotter = new Spotter($this->db);
729 890
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -732,8 +893,11 @@  discard block
 block discarded – undo
732 893
 				foreach ($airlines as $airline) {
733 894
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
734 895
 				}
735
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
736
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
896
+				if ($limit) {
897
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
898
+				} else {
899
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
900
+				}
737 901
 				try {
738 902
 					$sth = $this->db->prepare($query);
739 903
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -741,11 +905,16 @@  discard block
 block discarded – undo
741 905
 					echo "error : ".$e->getMessage();
742 906
 				}
743 907
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
744
-			} else $all = array();
908
+			} else {
909
+				$all = array();
910
+			}
745 911
 		} else {
746 912
 			if ($year == '' && $month == '') {
747
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
748
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
913
+				if ($limit) {
914
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
915
+				} else {
916
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
917
+				}
749 918
 				try {
750 919
 					$sth = $this->db->prepare($query);
751 920
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -753,7 +922,9 @@  discard block
 block discarded – undo
753 922
 					echo "error : ".$e->getMessage();
754 923
 				}
755 924
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
756
-			} else $all = array();
925
+			} else {
926
+				$all = array();
927
+			}
757 928
 		}
758 929
 		if (empty($all)) {
759 930
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -778,7 +949,9 @@  discard block
 block discarded – undo
778 949
 				$icao = $value['airport_departure_icao'];
779 950
 				if (isset($all[$icao])) {
780 951
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
781
-				} else $all[$icao] = $value;
952
+				} else {
953
+					$all[$icao] = $value;
954
+				}
782 955
 			}
783 956
 			$count = array();
784 957
 			foreach ($all as $key => $row) {
@@ -790,7 +963,9 @@  discard block
 block discarded – undo
790 963
 	}
791 964
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
792 965
 		global $globalStatsFilters;
793
-		if ($filter_name == '') $filter_name = $this->filter_name;
966
+		if ($filter_name == '') {
967
+			$filter_name = $this->filter_name;
968
+		}
794 969
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
795 970
 			$Spotter = new Spotter($this->db);
796 971
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -799,8 +974,11 @@  discard block
 block discarded – undo
799 974
 				foreach ($airlines as $airline) {
800 975
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
801 976
 				}
802
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
803
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
977
+				if ($limit) {
978
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
979
+				} else {
980
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
981
+				}
804 982
 				try {
805 983
 					$sth = $this->db->prepare($query);
806 984
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -808,11 +986,16 @@  discard block
 block discarded – undo
808 986
 					echo "error : ".$e->getMessage();
809 987
 				}
810 988
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
811
-			} else $all = array();
989
+			} else {
990
+				$all = array();
991
+			}
812 992
 		} else {
813 993
 			if ($year == '' && $month == '') {
814
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
815
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
994
+				if ($limit) {
995
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
996
+				} else {
997
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
998
+				}
816 999
 				try {
817 1000
 					$sth = $this->db->prepare($query);
818 1001
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -820,7 +1003,9 @@  discard block
 block discarded – undo
820 1003
 					echo "error : ".$e->getMessage();
821 1004
 				}
822 1005
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
823
-			} else $all = array();
1006
+			} else {
1007
+				$all = array();
1008
+			}
824 1009
 		}
825 1010
 		if (empty($all)) {
826 1011
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -845,7 +1030,9 @@  discard block
 block discarded – undo
845 1030
 				$icao = $value['airport_arrival_icao'];
846 1031
 				if (isset($all[$icao])) {
847 1032
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
848
-				} else $all[$icao] = $value;
1033
+				} else {
1034
+					$all[$icao] = $value;
1035
+				}
849 1036
 			}
850 1037
 			$count = array();
851 1038
 			foreach ($all as $key => $row) {
@@ -857,7 +1044,9 @@  discard block
 block discarded – undo
857 1044
 	}
858 1045
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
859 1046
 		global $globalDBdriver, $globalStatsFilters;
860
-		if ($filter_name == '') $filter_name = $this->filter_name;
1047
+		if ($filter_name == '') {
1048
+			$filter_name = $this->filter_name;
1049
+		}
861 1050
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
862 1051
 			$Spotter = new Spotter($this->db);
863 1052
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -866,20 +1055,32 @@  discard block
 block discarded – undo
866 1055
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
867 1056
 			}
868 1057
 			if ($globalDBdriver == 'mysql') {
869
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
870
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1058
+				if ($limit) {
1059
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1060
+				} else {
1061
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1062
+				}
871 1063
 			} else {
872
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1064
+				if ($limit) {
1065
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1066
+				} else {
1067
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1068
+				}
874 1069
 			}
875 1070
 			$query_data = array(':filter_name' => $filter_name);
876 1071
 		} else {
877 1072
 			if ($globalDBdriver == 'mysql') {
878
-				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";
879
-				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";
1073
+				if ($limit) {
1074
+					$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";
1075
+				} else {
1076
+					$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";
1077
+				}
880 1078
 			} else {
881
-				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";
882
-				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";
1079
+				if ($limit) {
1080
+					$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";
1081
+				} else {
1082
+					$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";
1083
+				}
883 1084
 			}
884 1085
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
885 1086
 		}
@@ -907,13 +1108,21 @@  discard block
 block discarded – undo
907 1108
 
908 1109
 	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
909 1110
 		global $globalDBdriver, $globalStatsFilters;
910
-		if ($filter_name == '') $filter_name = $this->filter_name;
1111
+		if ($filter_name == '') {
1112
+			$filter_name = $this->filter_name;
1113
+		}
911 1114
 		if ($globalDBdriver == 'mysql') {
912
-			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 = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
913
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1115
+			if ($limit) {
1116
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1117
+			} else {
1118
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'marine_bymonth' AND filter_name = :filter_name";
1119
+			}
914 1120
 		} else {
915
-			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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
916
-			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 = 'marine_bymonth' AND filter_name = :filter_name";
1121
+			if ($limit) {
1122
+				$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 = 'marine_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1123
+			} else {
1124
+				$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 = 'marine_bymonth' AND filter_name = :filter_name";
1125
+			}
917 1126
 		}
918 1127
 		$query_data = array(':filter_name' => $filter_name);
919 1128
 		try {
@@ -936,13 +1145,21 @@  discard block
 block discarded – undo
936 1145
 
937 1146
 	public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') {
938 1147
 		global $globalDBdriver, $globalStatsFilters;
939
-		if ($filter_name == '') $filter_name = $this->filter_name;
1148
+		if ($filter_name == '') {
1149
+			$filter_name = $this->filter_name;
1150
+		}
940 1151
 		if ($globalDBdriver == 'mysql') {
941
-			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 = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
942
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name";
1152
+			if ($limit) {
1153
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND filter_name = :filter_name";
1154
+			} else {
1155
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'tracker_bymonth' AND filter_name = :filter_name";
1156
+			}
943 1157
 		} else {
944
-			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 = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
945
-			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 = 'tracker_bymonth' AND filter_name = :filter_name";
1158
+			if ($limit) {
1159
+				$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 = 'tracker_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND filter_name = :filter_name";
1160
+			} else {
1161
+				$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 = 'tracker_bymonth' AND filter_name = :filter_name";
1162
+			}
946 1163
 		}
947 1164
 		$query_data = array(':filter_name' => $filter_name);
948 1165
 		try {
@@ -965,7 +1182,9 @@  discard block
 block discarded – undo
965 1182
 	
966 1183
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
967 1184
 		global $globalStatsFilters;
968
-		if ($filter_name == '') $filter_name = $this->filter_name;
1185
+		if ($filter_name == '') {
1186
+			$filter_name = $this->filter_name;
1187
+		}
969 1188
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
970 1189
 			$Spotter = new Spotter($this->db);
971 1190
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1002,7 +1221,9 @@  discard block
 block discarded – undo
1002 1221
 	}
1003 1222
 	public function countAllMarineDatesLastMonth($filter_name = '') {
1004 1223
 		global $globalStatsFilters;
1005
-		if ($filter_name == '') $filter_name = $this->filter_name;
1224
+		if ($filter_name == '') {
1225
+			$filter_name = $this->filter_name;
1226
+		}
1006 1227
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND filter_name = :filter_name";
1007 1228
 		$query_data = array(':filter_name' => $filter_name);
1008 1229
 		try {
@@ -1024,7 +1245,9 @@  discard block
 block discarded – undo
1024 1245
 	}
1025 1246
 	public function countAllTrackerDatesLastMonth($filter_name = '') {
1026 1247
 		global $globalStatsFilters;
1027
-		if ($filter_name == '') $filter_name = $this->filter_name;
1248
+		if ($filter_name == '') {
1249
+			$filter_name = $this->filter_name;
1250
+		}
1028 1251
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND filter_name = :filter_name";
1029 1252
 		$query_data = array(':filter_name' => $filter_name);
1030 1253
 		try {
@@ -1046,7 +1269,9 @@  discard block
 block discarded – undo
1046 1269
 	}
1047 1270
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
1048 1271
 		global $globalDBdriver, $globalStatsFilters;
1049
-		if ($filter_name == '') $filter_name = $this->filter_name;
1272
+		if ($filter_name == '') {
1273
+			$filter_name = $this->filter_name;
1274
+		}
1050 1275
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1051 1276
 			$Spotter = new Spotter($this->db);
1052 1277
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1091,7 +1316,9 @@  discard block
 block discarded – undo
1091 1316
 	}
1092 1317
 	public function countAllMarineDatesLast7Days($filter_name = '') {
1093 1318
 		global $globalDBdriver, $globalStatsFilters;
1094
-		if ($filter_name == '') $filter_name = $this->filter_name;
1319
+		if ($filter_name == '') {
1320
+			$filter_name = $this->filter_name;
1321
+		}
1095 1322
 		if ($globalDBdriver == 'mysql') {
1096 1323
 			$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'month' AND marine_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1097 1324
 		} else {
@@ -1117,7 +1344,9 @@  discard block
 block discarded – undo
1117 1344
 	}
1118 1345
 	public function countAllTrackerDatesLast7Days($filter_name = '') {
1119 1346
 		global $globalDBdriver, $globalStatsFilters;
1120
-		if ($filter_name == '') $filter_name = $this->filter_name;
1347
+		if ($filter_name == '') {
1348
+			$filter_name = $this->filter_name;
1349
+		}
1121 1350
 		if ($globalDBdriver == 'mysql') {
1122 1351
 			$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'month' AND tracker_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND filter_name = :filter_name";
1123 1352
 		} else {
@@ -1143,7 +1372,9 @@  discard block
 block discarded – undo
1143 1372
 	}
1144 1373
 	public function countAllDates($stats_airline = '',$filter_name = '') {
1145 1374
 		global $globalStatsFilters;
1146
-		if ($filter_name == '') $filter_name = $this->filter_name;
1375
+		if ($filter_name == '') {
1376
+			$filter_name = $this->filter_name;
1377
+		}
1147 1378
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1148 1379
 			$Spotter = new Spotter($this->db);
1149 1380
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1180,7 +1411,9 @@  discard block
 block discarded – undo
1180 1411
 	}
1181 1412
 	public function countAllDatesMarine($filter_name = '') {
1182 1413
 		global $globalStatsFilters;
1183
-		if ($filter_name == '') $filter_name = $this->filter_name;
1414
+		if ($filter_name == '') {
1415
+			$filter_name = $this->filter_name;
1416
+		}
1184 1417
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1185 1418
 		$query_data = array(':filter_name' => $filter_name);
1186 1419
 		try {
@@ -1202,7 +1435,9 @@  discard block
 block discarded – undo
1202 1435
 	}
1203 1436
 	public function countAllDatesTracker($filter_name = '') {
1204 1437
 		global $globalStatsFilters;
1205
-		if ($filter_name == '') $filter_name = $this->filter_name;
1438
+		if ($filter_name == '') {
1439
+			$filter_name = $this->filter_name;
1440
+		}
1206 1441
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1207 1442
 		$query_data = array(':filter_name' => $filter_name);
1208 1443
 		try {
@@ -1224,7 +1459,9 @@  discard block
 block discarded – undo
1224 1459
 	}
1225 1460
 	public function countAllDatesByAirlines($filter_name = '') {
1226 1461
 		global $globalStatsFilters;
1227
-		if ($filter_name == '') $filter_name = $this->filter_name;
1462
+		if ($filter_name == '') {
1463
+			$filter_name = $this->filter_name;
1464
+		}
1228 1465
 		$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";
1229 1466
 		$query_data = array('filter_name' => $filter_name);
1230 1467
 		try {
@@ -1246,7 +1483,9 @@  discard block
 block discarded – undo
1246 1483
 	}
1247 1484
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1248 1485
 		global $globalStatsFilters, $globalDBdriver;
1249
-		if ($filter_name == '') $filter_name = $this->filter_name;
1486
+		if ($filter_name == '') {
1487
+			$filter_name = $this->filter_name;
1488
+		}
1250 1489
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1251 1490
 			$Spotter = new Spotter($this->db);
1252 1491
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1331,7 +1570,9 @@  discard block
 block discarded – undo
1331 1570
 	}
1332 1571
 	public function countAllMilitaryMonths($filter_name = '') {
1333 1572
 		global $globalStatsFilters;
1334
-		if ($filter_name == '') $filter_name = $this->filter_name;
1573
+		if ($filter_name == '') {
1574
+			$filter_name = $this->filter_name;
1575
+		}
1335 1576
 		$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";
1336 1577
 		try {
1337 1578
 			$sth = $this->db->prepare($query);
@@ -1352,7 +1593,9 @@  discard block
 block discarded – undo
1352 1593
 	}
1353 1594
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1354 1595
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1355
-		if ($filter_name == '') $filter_name = $this->filter_name;
1596
+		if ($filter_name == '') {
1597
+			$filter_name = $this->filter_name;
1598
+		}
1356 1599
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1357 1600
 			$Spotter = new Spotter($this->db);
1358 1601
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1360,12 +1603,18 @@  discard block
 block discarded – undo
1360 1603
 			foreach ($airlines as $airline) {
1361 1604
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1362 1605
 			}
1363
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1364
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1606
+			if ($limit) {
1607
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1608
+			} else {
1609
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1610
+			}
1365 1611
 			$query_data = array(':filter_name' => $filter_name);
1366 1612
 		} else {
1367
-			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";
1368
-			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";
1613
+			if ($limit) {
1614
+				$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";
1615
+			} else {
1616
+				$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";
1617
+			}
1369 1618
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1370 1619
 		}
1371 1620
 		if ($orderby == 'hour') {
@@ -1375,7 +1624,9 @@  discard block
 block discarded – undo
1375 1624
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1376 1625
 			}
1377 1626
 		}
1378
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1627
+		if ($orderby == 'count') {
1628
+			$query .= " ORDER BY hour_count DESC";
1629
+		}
1379 1630
 		try {
1380 1631
 			$sth = $this->db->prepare($query);
1381 1632
 			$sth->execute($query_data);
@@ -1399,9 +1650,14 @@  discard block
 block discarded – undo
1399 1650
 	}
1400 1651
 	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1401 1652
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1402
-		if ($filter_name == '') $filter_name = $this->filter_name;
1403
-		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1404
-		else $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1653
+		if ($filter_name == '') {
1654
+			$filter_name = $this->filter_name;
1655
+		}
1656
+		if ($limit) {
1657
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1658
+		} else {
1659
+			$query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
1660
+		}
1405 1661
 		$query_data = array(':filter_name' => $filter_name);
1406 1662
 		if ($orderby == 'hour') {
1407 1663
 			if ($globalDBdriver == 'mysql') {
@@ -1410,7 +1666,9 @@  discard block
 block discarded – undo
1410 1666
 				$query .= " ORDER BY CAST(marine_date AS integer) ASC";
1411 1667
 			}
1412 1668
 		}
1413
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1669
+		if ($orderby == 'count') {
1670
+			$query .= " ORDER BY hour_count DESC";
1671
+		}
1414 1672
 		try {
1415 1673
 			$sth = $this->db->prepare($query);
1416 1674
 			$sth->execute($query_data);
@@ -1430,9 +1688,14 @@  discard block
 block discarded – undo
1430 1688
 	}
1431 1689
 	public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') {
1432 1690
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1433
-		if ($filter_name == '') $filter_name = $this->filter_name;
1434
-		if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1435
-		else $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1691
+		if ($filter_name == '') {
1692
+			$filter_name = $this->filter_name;
1693
+		}
1694
+		if ($limit) {
1695
+			$query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1696
+		} else {
1697
+			$query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
1698
+		}
1436 1699
 		$query_data = array(':filter_name' => $filter_name);
1437 1700
 		if ($orderby == 'hour') {
1438 1701
 			if ($globalDBdriver == 'mysql') {
@@ -1441,7 +1704,9 @@  discard block
 block discarded – undo
1441 1704
 				$query .= " ORDER BY CAST(tracker_date AS integer) ASC";
1442 1705
 			}
1443 1706
 		}
1444
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1707
+		if ($orderby == 'count') {
1708
+			$query .= " ORDER BY hour_count DESC";
1709
+		}
1445 1710
 		try {
1446 1711
 			$sth = $this->db->prepare($query);
1447 1712
 			$sth->execute($query_data);
@@ -1461,8 +1726,12 @@  discard block
 block discarded – undo
1461 1726
 	}
1462 1727
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1463 1728
 		global $globalStatsFilters;
1464
-		if ($filter_name == '') $filter_name = $this->filter_name;
1465
-		if ($year == '') $year = date('Y');
1729
+		if ($filter_name == '') {
1730
+			$filter_name = $this->filter_name;
1731
+		}
1732
+		if ($year == '') {
1733
+			$year = date('Y');
1734
+		}
1466 1735
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1467 1736
 		if (empty($all)) {
1468 1737
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1481,8 +1750,12 @@  discard block
 block discarded – undo
1481 1750
 	}
1482 1751
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1483 1752
 		global $globalStatsFilters;
1484
-		if ($filter_name == '') $filter_name = $this->filter_name;
1485
-		if ($year == '') $year = date('Y');
1753
+		if ($filter_name == '') {
1754
+			$filter_name = $this->filter_name;
1755
+		}
1756
+		if ($year == '') {
1757
+			$year = date('Y');
1758
+		}
1486 1759
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1487 1760
 		if (empty($all)) {
1488 1761
 			$filters = array('year' => $year,'month' => $month);
@@ -1497,8 +1770,12 @@  discard block
 block discarded – undo
1497 1770
 	}
1498 1771
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1499 1772
 		global $globalStatsFilters;
1500
-		if ($filter_name == '') $filter_name = $this->filter_name;
1501
-		if ($year == '') $year = date('Y');
1773
+		if ($filter_name == '') {
1774
+			$filter_name = $this->filter_name;
1775
+		}
1776
+		if ($year == '') {
1777
+			$year = date('Y');
1778
+		}
1502 1779
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1503 1780
 		if (empty($all)) {
1504 1781
 			$filters = array('year' => $year,'month' => $month);
@@ -1513,8 +1790,12 @@  discard block
 block discarded – undo
1513 1790
 	}
1514 1791
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1515 1792
 		global $globalStatsFilters;
1516
-		if ($filter_name == '') $filter_name = $this->filter_name;
1517
-		if ($year == '') $year = date('Y');
1793
+		if ($filter_name == '') {
1794
+			$filter_name = $this->filter_name;
1795
+		}
1796
+		if ($year == '') {
1797
+			$year = date('Y');
1798
+		}
1518 1799
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1519 1800
 		if (empty($all)) {
1520 1801
 			$filters = array();
@@ -1530,8 +1811,12 @@  discard block
 block discarded – undo
1530 1811
 	}
1531 1812
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1532 1813
 		global $globalStatsFilters;
1533
-		if ($filter_name == '') $filter_name = $this->filter_name;
1534
-		if ($year == '') $year = date('Y');
1814
+		if ($filter_name == '') {
1815
+			$filter_name = $this->filter_name;
1816
+		}
1817
+		if ($year == '') {
1818
+			$year = date('Y');
1819
+		}
1535 1820
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1536 1821
 		if (empty($all)) {
1537 1822
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1550,7 +1835,9 @@  discard block
 block discarded – undo
1550 1835
 	}
1551 1836
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1552 1837
 		global $globalStatsFilters;
1553
-		if ($filter_name == '') $filter_name = $this->filter_name;
1838
+		if ($filter_name == '') {
1839
+			$filter_name = $this->filter_name;
1840
+		}
1554 1841
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1555 1842
 			$Spotter = new Spotter($this->db);
1556 1843
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1568,7 +1855,9 @@  discard block
 block discarded – undo
1568 1855
 				}
1569 1856
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1570 1857
 				$all = $result[0]['nb'];
1571
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1858
+			} else {
1859
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1860
+			}
1572 1861
 		} else {
1573 1862
 			if ($year == '' && $month == '') {
1574 1863
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1580,7 +1869,9 @@  discard block
 block discarded – undo
1580 1869
 				}
1581 1870
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1582 1871
 				$all = $result[0]['nb'];
1583
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1872
+			} else {
1873
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1874
+			}
1584 1875
 		}
1585 1876
 		if (empty($all)) {
1586 1877
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1599,7 +1890,9 @@  discard block
 block discarded – undo
1599 1890
 	}
1600 1891
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1601 1892
 		global $globalStatsFilters;
1602
-		if ($filter_name == '') $filter_name = $this->filter_name;
1893
+		if ($filter_name == '') {
1894
+			$filter_name = $this->filter_name;
1895
+		}
1603 1896
 		if ($year == '' && $month == '') {
1604 1897
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1605 1898
 			try {
@@ -1610,7 +1903,9 @@  discard block
 block discarded – undo
1610 1903
 			}
1611 1904
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1612 1905
 			$all = $result[0]['nb_airline'];
1613
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1906
+		} else {
1907
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1908
+		}
1614 1909
 		if (empty($all)) {
1615 1910
 			$filters = array();
1616 1911
 			$filters = array('year' => $year,'month' => $month);
@@ -1625,7 +1920,9 @@  discard block
 block discarded – undo
1625 1920
 	}
1626 1921
 	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1627 1922
 		global $globalStatsFilters;
1628
-		if ($filter_name == '') $filter_name = $this->filter_name;
1923
+		if ($filter_name == '') {
1924
+			$filter_name = $this->filter_name;
1925
+		}
1629 1926
 		$all = array();
1630 1927
 		if ($year == '' && $month == '') {
1631 1928
 			$query = "SELECT COUNT(*) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name";
@@ -1652,7 +1949,9 @@  discard block
 block discarded – undo
1652 1949
 	}
1653 1950
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1654 1951
 		global $globalStatsFilters;
1655
-		if ($filter_name == '') $filter_name = $this->filter_name;
1952
+		if ($filter_name == '') {
1953
+			$filter_name = $this->filter_name;
1954
+		}
1656 1955
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1657 1956
 			$Spotter = new Spotter($this->db);
1658 1957
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1707,7 +2006,9 @@  discard block
 block discarded – undo
1707 2006
 	}
1708 2007
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1709 2008
 		global $globalStatsFilters;
1710
-		if ($filter_name == '') $filter_name = $this->filter_name;
2009
+		if ($filter_name == '') {
2010
+			$filter_name = $this->filter_name;
2011
+		}
1711 2012
 		//if ($year == '') $year = date('Y');
1712 2013
 		if ($year == '' && $month == '') {
1713 2014
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1736,7 +2037,9 @@  discard block
 block discarded – undo
1736 2037
 	}
1737 2038
 
1738 2039
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1739
-		if ($filter_name == '') $filter_name = $this->filter_name;
2040
+		if ($filter_name == '') {
2041
+			$filter_name = $this->filter_name;
2042
+		}
1740 2043
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1741 2044
 			$Spotter = new Spotter($this->db);
1742 2045
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1760,7 +2063,9 @@  discard block
 block discarded – undo
1760 2063
 		return $all;
1761 2064
 	}
1762 2065
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1763
-		if ($filter_name == '') $filter_name = $this->filter_name;
2066
+		if ($filter_name == '') {
2067
+			$filter_name = $this->filter_name;
2068
+		}
1764 2069
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1765 2070
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1766 2071
 		try {
@@ -1773,7 +2078,9 @@  discard block
 block discarded – undo
1773 2078
 		return $all;
1774 2079
 	}
1775 2080
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1776
-		if ($filter_name == '') $filter_name = $this->filter_name;
2081
+		if ($filter_name == '') {
2082
+			$filter_name = $this->filter_name;
2083
+		}
1777 2084
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1778 2085
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1779 2086
 		try {
@@ -1784,7 +2091,9 @@  discard block
 block discarded – undo
1784 2091
 		}
1785 2092
 	}
1786 2093
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1787
-		if ($filter_name == '') $filter_name = $this->filter_name;
2094
+		if ($filter_name == '') {
2095
+			$filter_name = $this->filter_name;
2096
+		}
1788 2097
 		global $globalArchiveMonths, $globalDBdriver;
1789 2098
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1790 2099
 			$Spotter = new Spotter($this->db);
@@ -1840,7 +2149,9 @@  discard block
 block discarded – undo
1840 2149
 	}
1841 2150
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1842 2151
 		global $globalArchiveMonths, $globalDBdriver;
1843
-		if ($filter_name == '') $filter_name = $this->filter_name;
2152
+		if ($filter_name == '') {
2153
+			$filter_name = $this->filter_name;
2154
+		}
1844 2155
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1845 2156
 			$Spotter = new Spotter($this->db);
1846 2157
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1873,7 +2184,9 @@  discard block
 block discarded – undo
1873 2184
 	}
1874 2185
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1875 2186
 		global $globalArchiveMonths, $globalDBdriver;
1876
-		if ($filter_name == '') $filter_name = $this->filter_name;
2187
+		if ($filter_name == '') {
2188
+			$filter_name = $this->filter_name;
2189
+		}
1877 2190
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1878 2191
 			$Spotter = new Spotter($this->db);
1879 2192
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1904,7 +2217,9 @@  discard block
 block discarded – undo
1904 2217
 	}
1905 2218
 	public function getStatsAirlineTotal($filter_name = '') {
1906 2219
 		global $globalArchiveMonths, $globalDBdriver;
1907
-		if ($filter_name == '') $filter_name = $this->filter_name;
2220
+		if ($filter_name == '') {
2221
+			$filter_name = $this->filter_name;
2222
+		}
1908 2223
 		if ($globalDBdriver == 'mysql') {
1909 2224
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1910 2225
 		} else {
@@ -1921,7 +2236,9 @@  discard block
 block discarded – undo
1921 2236
 	}
1922 2237
 	public function getStatsOwnerTotal($filter_name = '') {
1923 2238
 		global $globalArchiveMonths, $globalDBdriver;
1924
-		if ($filter_name == '') $filter_name = $this->filter_name;
2239
+		if ($filter_name == '') {
2240
+			$filter_name = $this->filter_name;
2241
+		}
1925 2242
 		if ($globalDBdriver == 'mysql') {
1926 2243
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1927 2244
 		} else {
@@ -1938,7 +2255,9 @@  discard block
 block discarded – undo
1938 2255
 	}
1939 2256
 	public function getStatsOwner($owner_name,$filter_name = '') {
1940 2257
 		global $globalArchiveMonths, $globalDBdriver;
1941
-		if ($filter_name == '') $filter_name = $this->filter_name;
2258
+		if ($filter_name == '') {
2259
+			$filter_name = $this->filter_name;
2260
+		}
1942 2261
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1943 2262
 		try {
1944 2263
 			$sth = $this->db->prepare($query);
@@ -1947,12 +2266,17 @@  discard block
 block discarded – undo
1947 2266
 			echo "error : ".$e->getMessage();
1948 2267
 		}
1949 2268
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1950
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1951
-		else return 0;
2269
+		if (isset($all[0]['cnt'])) {
2270
+			return $all[0]['cnt'];
2271
+		} else {
2272
+			return 0;
2273
+		}
1952 2274
 	}
1953 2275
 	public function getStatsPilotTotal($filter_name = '') {
1954 2276
 		global $globalArchiveMonths, $globalDBdriver;
1955
-		if ($filter_name == '') $filter_name = $this->filter_name;
2277
+		if ($filter_name == '') {
2278
+			$filter_name = $this->filter_name;
2279
+		}
1956 2280
 		if ($globalDBdriver == 'mysql') {
1957 2281
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1958 2282
 		} else {
@@ -1969,7 +2293,9 @@  discard block
 block discarded – undo
1969 2293
 	}
1970 2294
 	public function getStatsPilot($pilot,$filter_name = '') {
1971 2295
 		global $globalArchiveMonths, $globalDBdriver;
1972
-		if ($filter_name == '') $filter_name = $this->filter_name;
2296
+		if ($filter_name == '') {
2297
+			$filter_name = $this->filter_name;
2298
+		}
1973 2299
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1974 2300
 		try {
1975 2301
 			$sth = $this->db->prepare($query);
@@ -1978,13 +2304,18 @@  discard block
 block discarded – undo
1978 2304
 			echo "error : ".$e->getMessage();
1979 2305
 		}
1980 2306
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1981
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1982
-		else return 0;
2307
+		if (isset($all[0]['cnt'])) {
2308
+			return $all[0]['cnt'];
2309
+		} else {
2310
+			return 0;
2311
+		}
1983 2312
 	}
1984 2313
 
1985 2314
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1986 2315
 		global $globalDBdriver;
1987
-		if ($filter_name == '') $filter_name = $this->filter_name;
2316
+		if ($filter_name == '') {
2317
+			$filter_name = $this->filter_name;
2318
+		}
1988 2319
 		if ($globalDBdriver == 'mysql') {
1989 2320
 			$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";
1990 2321
 		} else {
@@ -2000,7 +2331,9 @@  discard block
 block discarded – undo
2000 2331
 	}
2001 2332
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
2002 2333
 		global $globalDBdriver;
2003
-		if ($filter_name == '') $filter_name = $this->filter_name;
2334
+		if ($filter_name == '') {
2335
+			$filter_name = $this->filter_name;
2336
+		}
2004 2337
 		if ($globalDBdriver == 'mysql') {
2005 2338
 			$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";
2006 2339
 		} else {
@@ -2519,27 +2852,37 @@  discard block
 block discarded – undo
2519 2852
 		date_default_timezone_set('UTC');
2520 2853
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2521 2854
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2522
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2855
+			if ($globalDebug) {
2856
+				echo '!!! Update Marine stats !!!'."\n";
2857
+			}
2523 2858
 			if (isset($last_update[0]['value'])) {
2524 2859
 				$last_update_day = $last_update[0]['value'];
2525
-			} else $last_update_day = '2012-12-12 12:12:12';
2860
+			} else {
2861
+				$last_update_day = '2012-12-12 12:12:12';
2862
+			}
2526 2863
 			$reset = false;
2527 2864
 			$Marine = new Marine($this->db);
2528 2865
 			$filtername = 'marine';
2529 2866
 			if ($Connection->tableExists('countries')) {
2530
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2867
+				if ($globalDebug) {
2868
+					echo 'Count all vessels by countries...'."\n";
2869
+				}
2531 2870
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2532 2871
 				foreach ($alldata as $number) {
2533 2872
 					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2534 2873
 				}
2535 2874
 			}
2536
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2875
+			if ($globalDebug) {
2876
+				echo 'Count all vessels by months...'."\n";
2877
+			}
2537 2878
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2538 2879
 			$filter_last_month = array('since_date' => $last_month);
2539 2880
 			$alldata = $Marine->countAllMonths($filter_last_month);
2540 2881
 			$lastyear = false;
2541 2882
 			foreach ($alldata as $number) {
2542
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2883
+				if ($number['year_name'] != date('Y')) {
2884
+					$lastyear = true;
2885
+				}
2543 2886
 				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2544 2887
 			}
2545 2888
 			echo 'Marine data...'."\n";
@@ -2569,7 +2912,9 @@  discard block
 block discarded – undo
2569 2912
 			foreach ($alldata as $number) {
2570 2913
 				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2571 2914
 			}
2572
-			if ($globalDebug) echo 'Count all types...'."\n";
2915
+			if ($globalDebug) {
2916
+				echo 'Count all types...'."\n";
2917
+			}
2573 2918
 			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2574 2919
 			foreach ($alldata as $number) {
2575 2920
 				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
@@ -2581,26 +2926,36 @@  discard block
 block discarded – undo
2581 2926
 		}
2582 2927
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2583 2928
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2584
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2929
+			if ($globalDebug) {
2930
+				echo '!!! Update tracker stats !!!'."\n";
2931
+			}
2585 2932
 			if (isset($last_update[0]['value'])) {
2586 2933
 				$last_update_day = $last_update[0]['value'];
2587
-			} else $last_update_day = '2012-12-12 12:12:12';
2934
+			} else {
2935
+				$last_update_day = '2012-12-12 12:12:12';
2936
+			}
2588 2937
 			$reset = false;
2589 2938
 			$Tracker = new Tracker($this->db);
2590 2939
 			if ($Connection->tableExists('countries')) {
2591
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2940
+				if ($globalDebug) {
2941
+					echo 'Count all trackers by countries...'."\n";
2942
+				}
2592 2943
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2593 2944
 				foreach ($alldata as $number) {
2594 2945
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2595 2946
 				}
2596 2947
 			}
2597
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2948
+			if ($globalDebug) {
2949
+				echo 'Count all vessels by months...'."\n";
2950
+			}
2598 2951
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2599 2952
 			$filter_last_month = array('since_date' => $last_month);
2600 2953
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2601 2954
 			$lastyear = false;
2602 2955
 			foreach ($alldata as $number) {
2603
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2956
+				if ($number['year_name'] != date('Y')) {
2957
+					$lastyear = true;
2958
+				}
2604 2959
 				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2605 2960
 			}
2606 2961
 			echo 'Tracker data...'."\n";
@@ -2630,7 +2985,9 @@  discard block
 block discarded – undo
2630 2985
 			foreach ($alldata as $number) {
2631 2986
 				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2632 2987
 			}
2633
-			if ($globalDebug) echo 'Count all types...'."\n";
2988
+			if ($globalDebug) {
2989
+				echo 'Count all types...'."\n";
2990
+			}
2634 2991
 			$alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day);
2635 2992
 			foreach ($alldata as $number) {
2636 2993
 				$this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset);
@@ -2642,10 +2999,14 @@  discard block
 block discarded – undo
2642 2999
 
2643 3000
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2644 3001
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2645
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
3002
+			if ($globalDebug) {
3003
+				echo '!!! Update aicraft stats !!!'."\n";
3004
+			}
2646 3005
 			if (isset($last_update[0]['value'])) {
2647 3006
 				$last_update_day = $last_update[0]['value'];
2648
-			} else $last_update_day = '2012-12-12 12:12:12';
3007
+			} else {
3008
+				$last_update_day = '2012-12-12 12:12:12';
3009
+			}
2649 3010
 			$reset = false;
2650 3011
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2651 3012
 			if ($globalStatsResetYear) {
@@ -2654,43 +3015,63 @@  discard block
 block discarded – undo
2654 3015
 			}
2655 3016
 			$Spotter = new Spotter($this->db);
2656 3017
 
2657
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
3018
+			if ($globalDebug) {
3019
+				echo 'Count all aircraft types...'."\n";
3020
+			}
2658 3021
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2659 3022
 			foreach ($alldata as $number) {
2660 3023
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2661 3024
 			}
2662
-			if ($globalDebug) echo 'Count all airlines...'."\n";
3025
+			if ($globalDebug) {
3026
+				echo 'Count all airlines...'."\n";
3027
+			}
2663 3028
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2664 3029
 			foreach ($alldata as $number) {
2665 3030
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2666 3031
 			}
2667
-			if ($globalDebug) echo 'Count all registrations...'."\n";
3032
+			if ($globalDebug) {
3033
+				echo 'Count all registrations...'."\n";
3034
+			}
2668 3035
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2669 3036
 			foreach ($alldata as $number) {
2670 3037
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2671 3038
 			}
2672
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
3039
+			if ($globalDebug) {
3040
+				echo 'Count all callsigns...'."\n";
3041
+			}
2673 3042
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2674 3043
 			foreach ($alldata as $number) {
2675 3044
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2676 3045
 			}
2677
-			if ($globalDebug) echo 'Count all owners...'."\n";
3046
+			if ($globalDebug) {
3047
+				echo 'Count all owners...'."\n";
3048
+			}
2678 3049
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2679 3050
 			foreach ($alldata as $number) {
2680 3051
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2681 3052
 			}
2682
-			if ($globalDebug) echo 'Count all pilots...'."\n";
3053
+			if ($globalDebug) {
3054
+				echo 'Count all pilots...'."\n";
3055
+			}
2683 3056
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2684 3057
 			foreach ($alldata as $number) {
2685
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
3058
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
3059
+					$number['pilot_id'] = $number['pilot_name'];
3060
+				}
2686 3061
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2687 3062
 			}
2688 3063
 			
2689
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
3064
+			if ($globalDebug) {
3065
+				echo 'Count all departure airports...'."\n";
3066
+			}
2690 3067
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2691
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
3068
+			if ($globalDebug) {
3069
+				echo 'Count all detected departure airports...'."\n";
3070
+			}
2692 3071
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2693
-			if ($globalDebug) echo 'Order departure airports...'."\n";
3072
+			if ($globalDebug) {
3073
+				echo 'Order departure airports...'."\n";
3074
+			}
2694 3075
 			$alldata = array();
2695 3076
 			foreach ($pall as $value) {
2696 3077
 				$icao = $value['airport_departure_icao'];
@@ -2700,7 +3081,9 @@  discard block
 block discarded – undo
2700 3081
 				$icao = $value['airport_departure_icao'];
2701 3082
 				if (isset($alldata[$icao])) {
2702 3083
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2703
-				} else $alldata[$icao] = $value;
3084
+				} else {
3085
+					$alldata[$icao] = $value;
3086
+				}
2704 3087
 			}
2705 3088
 			$count = array();
2706 3089
 			foreach ($alldata as $key => $row) {
@@ -2710,11 +3093,17 @@  discard block
 block discarded – undo
2710 3093
 			foreach ($alldata as $number) {
2711 3094
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
2712 3095
 			}
2713
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
3096
+			if ($globalDebug) {
3097
+				echo 'Count all arrival airports...'."\n";
3098
+			}
2714 3099
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2715
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
3100
+			if ($globalDebug) {
3101
+				echo 'Count all detected arrival airports...'."\n";
3102
+			}
2716 3103
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2717
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
3104
+			if ($globalDebug) {
3105
+				echo 'Order arrival airports...'."\n";
3106
+			}
2718 3107
 			$alldata = array();
2719 3108
 			foreach ($pall as $value) {
2720 3109
 				$icao = $value['airport_arrival_icao'];
@@ -2724,7 +3113,9 @@  discard block
 block discarded – undo
2724 3113
 				$icao = $value['airport_arrival_icao'];
2725 3114
 				if (isset($alldata[$icao])) {
2726 3115
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2727
-				} else $alldata[$icao] = $value;
3116
+				} else {
3117
+					$alldata[$icao] = $value;
3118
+				}
2728 3119
 			}
2729 3120
 			$count = array();
2730 3121
 			foreach ($alldata as $key => $row) {
@@ -2735,7 +3126,9 @@  discard block
 block discarded – undo
2735 3126
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
2736 3127
 			}
2737 3128
 			if ($Connection->tableExists('countries')) {
2738
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
3129
+				if ($globalDebug) {
3130
+					echo 'Count all flights by countries...'."\n";
3131
+				}
2739 3132
 				//$SpotterArchive = new SpotterArchive();
2740 3133
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2741 3134
 				$Spotter = new Spotter($this->db);
@@ -2746,7 +3139,9 @@  discard block
 block discarded – undo
2746 3139
 			}
2747 3140
 			
2748 3141
 			if (isset($globalAccidents) && $globalAccidents) {
2749
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
3142
+				if ($globalDebug) {
3143
+					echo 'Count fatalities stats...'."\n";
3144
+				}
2750 3145
 				$Accident = new Accident($this->db);
2751 3146
 				$this->deleteStatsByType('fatalities_byyear');
2752 3147
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2762,48 +3157,68 @@  discard block
 block discarded – undo
2762 3157
 
2763 3158
 			// Add by month using getstat if month finish...
2764 3159
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2765
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
3160
+			if ($globalDebug) {
3161
+				echo 'Count all flights by months...'."\n";
3162
+			}
2766 3163
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2767 3164
 			$filter_last_month = array('since_date' => $last_month);
2768 3165
 			$Spotter = new Spotter($this->db);
2769 3166
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2770 3167
 			$lastyear = false;
2771 3168
 			foreach ($alldata as $number) {
2772
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3169
+				if ($number['year_name'] != date('Y')) {
3170
+					$lastyear = true;
3171
+				}
2773 3172
 				$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'])));
2774 3173
 			}
2775
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
3174
+			if ($globalDebug) {
3175
+				echo 'Count all military flights by months...'."\n";
3176
+			}
2776 3177
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2777 3178
 			foreach ($alldata as $number) {
2778 3179
 				$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'])));
2779 3180
 			}
2780
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
3181
+			if ($globalDebug) {
3182
+				echo 'Count all owners by months...'."\n";
3183
+			}
2781 3184
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2782 3185
 			foreach ($alldata as $number) {
2783 3186
 				$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'])));
2784 3187
 			}
2785
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
3188
+			if ($globalDebug) {
3189
+				echo 'Count all pilots by months...'."\n";
3190
+			}
2786 3191
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2787 3192
 			foreach ($alldata as $number) {
2788 3193
 				$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'])));
2789 3194
 			}
2790
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
3195
+			if ($globalDebug) {
3196
+				echo 'Count all airlines by months...'."\n";
3197
+			}
2791 3198
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2792 3199
 			foreach ($alldata as $number) {
2793 3200
 				$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'])));
2794 3201
 			}
2795
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3202
+			if ($globalDebug) {
3203
+				echo 'Count all aircrafts by months...'."\n";
3204
+			}
2796 3205
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2797 3206
 			foreach ($alldata as $number) {
2798 3207
 				$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'])));
2799 3208
 			}
2800
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3209
+			if ($globalDebug) {
3210
+				echo 'Count all real arrivals by months...'."\n";
3211
+			}
2801 3212
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2802 3213
 			foreach ($alldata as $number) {
2803 3214
 				$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'])));
2804 3215
 			}
2805
-			if ($globalDebug) echo 'Airports data...'."\n";
2806
-			if ($globalDebug) echo '...Departure'."\n";
3216
+			if ($globalDebug) {
3217
+				echo 'Airports data...'."\n";
3218
+			}
3219
+			if ($globalDebug) {
3220
+				echo '...Departure'."\n";
3221
+			}
2807 3222
 			$this->deleteStatAirport('daily');
2808 3223
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2809 3224
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2921,7 +3336,9 @@  discard block
 block discarded – undo
2921 3336
 			// Count by airlines
2922 3337
 			echo '--- Stats by airlines ---'."\n";
2923 3338
 			if ($Connection->tableExists('countries')) {
2924
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
3339
+				if ($globalDebug) {
3340
+					echo 'Count all flights by countries by airlines...'."\n";
3341
+				}
2925 3342
 				$SpotterArchive = new SpotterArchive($this->db);
2926 3343
 				//$Spotter = new Spotter($this->db);
2927 3344
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2930,37 +3347,53 @@  discard block
 block discarded – undo
2930 3347
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2931 3348
 				}
2932 3349
 			}
2933
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
3350
+			if ($globalDebug) {
3351
+				echo 'Count all aircraft types by airlines...'."\n";
3352
+			}
2934 3353
 			$Spotter = new Spotter($this->db);
2935 3354
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2936 3355
 			foreach ($alldata as $number) {
2937 3356
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2938 3357
 			}
2939
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
3358
+			if ($globalDebug) {
3359
+				echo 'Count all aircraft registrations by airlines...'."\n";
3360
+			}
2940 3361
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2941 3362
 			foreach ($alldata as $number) {
2942 3363
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2943 3364
 			}
2944
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
3365
+			if ($globalDebug) {
3366
+				echo 'Count all callsigns by airlines...'."\n";
3367
+			}
2945 3368
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2946 3369
 			foreach ($alldata as $number) {
2947 3370
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2948 3371
 			}
2949
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
3372
+			if ($globalDebug) {
3373
+				echo 'Count all owners by airlines...'."\n";
3374
+			}
2950 3375
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2951 3376
 			foreach ($alldata as $number) {
2952 3377
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2953 3378
 			}
2954
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
3379
+			if ($globalDebug) {
3380
+				echo 'Count all pilots by airlines...'."\n";
3381
+			}
2955 3382
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2956 3383
 			foreach ($alldata as $number) {
2957 3384
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2958 3385
 			}
2959
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
3386
+			if ($globalDebug) {
3387
+				echo 'Count all departure airports by airlines...'."\n";
3388
+			}
2960 3389
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2961
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
3390
+			if ($globalDebug) {
3391
+				echo 'Count all detected departure airports by airlines...'."\n";
3392
+			}
2962 3393
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2963
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
3394
+			if ($globalDebug) {
3395
+				echo 'Order detected departure airports by airlines...'."\n";
3396
+			}
2964 3397
 			//$alldata = array();
2965 3398
 			foreach ($dall as $value) {
2966 3399
 				$icao = $value['airport_departure_icao'];
@@ -2981,11 +3414,17 @@  discard block
 block discarded – undo
2981 3414
 			foreach ($alldata as $number) {
2982 3415
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
2983 3416
 			}
2984
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3417
+			if ($globalDebug) {
3418
+				echo 'Count all arrival airports by airlines...'."\n";
3419
+			}
2985 3420
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2986
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3421
+			if ($globalDebug) {
3422
+				echo 'Count all detected arrival airports by airlines...'."\n";
3423
+			}
2987 3424
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2988
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3425
+			if ($globalDebug) {
3426
+				echo 'Order arrival airports by airlines...'."\n";
3427
+			}
2989 3428
 			//$alldata = array();
2990 3429
 			foreach ($dall as $value) {
2991 3430
 				$icao = $value['airport_arrival_icao'];
@@ -3004,37 +3443,53 @@  discard block
 block discarded – undo
3004 3443
 			}
3005 3444
 			$alldata = $pall;
3006 3445
 			foreach ($alldata as $number) {
3007
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
3446
+				if ($number['airline_icao'] != '') {
3447
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
3448
+				}
3449
+			}
3450
+			if ($globalDebug) {
3451
+				echo 'Count all flights by months by airlines...'."\n";
3008 3452
 			}
3009
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
3010 3453
 			$Spotter = new Spotter($this->db);
3011 3454
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
3012 3455
 			$lastyear = false;
3013 3456
 			foreach ($alldata as $number) {
3014
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3457
+				if ($number['year_name'] != date('Y')) {
3458
+					$lastyear = true;
3459
+				}
3015 3460
 				$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']);
3016 3461
 			}
3017
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3462
+			if ($globalDebug) {
3463
+				echo 'Count all owners by months by airlines...'."\n";
3464
+			}
3018 3465
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
3019 3466
 			foreach ($alldata as $number) {
3020 3467
 				$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']);
3021 3468
 			}
3022
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3469
+			if ($globalDebug) {
3470
+				echo 'Count all pilots by months by airlines...'."\n";
3471
+			}
3023 3472
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
3024 3473
 			foreach ($alldata as $number) {
3025 3474
 				$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']);
3026 3475
 			}
3027
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3476
+			if ($globalDebug) {
3477
+				echo 'Count all aircrafts by months by airlines...'."\n";
3478
+			}
3028 3479
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
3029 3480
 			foreach ($alldata as $number) {
3030 3481
 				$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']);
3031 3482
 			}
3032
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3483
+			if ($globalDebug) {
3484
+				echo 'Count all real arrivals by months by airlines...'."\n";
3485
+			}
3033 3486
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
3034 3487
 			foreach ($alldata as $number) {
3035 3488
 				$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']);
3036 3489
 			}
3037
-			if ($globalDebug) echo '...Departure'."\n";
3490
+			if ($globalDebug) {
3491
+				echo '...Departure'."\n";
3492
+			}
3038 3493
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
3039 3494
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
3040 3495
 			foreach ($dall as $value) {
@@ -3057,7 +3512,9 @@  discard block
 block discarded – undo
3057 3512
 			foreach ($alldata as $number) {
3058 3513
 				$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']);
3059 3514
 			}
3060
-			if ($globalDebug) echo '...Arrival'."\n";
3515
+			if ($globalDebug) {
3516
+				echo '...Arrival'."\n";
3517
+			}
3061 3518
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
3062 3519
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
3063 3520
 			foreach ($dall as $value) {
@@ -3081,13 +3538,19 @@  discard block
 block discarded – undo
3081 3538
 				$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']);
3082 3539
 			}
3083 3540
 
3084
-			if ($globalDebug) echo 'Flights data...'."\n";
3085
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3541
+			if ($globalDebug) {
3542
+				echo 'Flights data...'."\n";
3543
+			}
3544
+			if ($globalDebug) {
3545
+				echo '-> countAllDatesLastMonth...'."\n";
3546
+			}
3086 3547
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
3087 3548
 			foreach ($alldata as $number) {
3088 3549
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
3089 3550
 			}
3090
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3551
+			if ($globalDebug) {
3552
+				echo '-> countAllDates...'."\n";
3553
+			}
3091 3554
 			//$previousdata = $this->countAllDatesByAirlines();
3092 3555
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
3093 3556
 			$values = array();
@@ -3100,14 +3563,18 @@  discard block
 block discarded – undo
3100 3563
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
3101 3564
 			}
3102 3565
 			
3103
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3566
+			if ($globalDebug) {
3567
+				echo '-> countAllHours...'."\n";
3568
+			}
3104 3569
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
3105 3570
 			foreach ($alldata as $number) {
3106 3571
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
3107 3572
 			}
3108 3573
 
3109 3574
 			// Stats by filters
3110
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3575
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3576
+				$globalStatsFilters = array();
3577
+			}
3111 3578
 			foreach ($globalStatsFilters as $name => $filter) {
3112 3579
 				if (!empty($filter)) {
3113 3580
 					//$filter_name = $filter['name'];
@@ -3115,7 +3582,9 @@  discard block
 block discarded – undo
3115 3582
 					$reset = false;
3116 3583
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
3117 3584
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
3118
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3585
+						if ($globalDebug) {
3586
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3587
+						}
3119 3588
 						$this->deleteOldStats($filter_name);
3120 3589
 						unset($last_update);
3121 3590
 					}
@@ -3132,39 +3601,55 @@  discard block
 block discarded – undo
3132 3601
 						$reset = true;
3133 3602
 					}
3134 3603
 					// Count by filter
3135
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3604
+					if ($globalDebug) {
3605
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3606
+					}
3136 3607
 					$Spotter = new Spotter($this->db);
3137
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3608
+					if ($globalDebug) {
3609
+						echo 'Count all aircraft types...'."\n";
3610
+					}
3138 3611
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
3139 3612
 					foreach ($alldata as $number) {
3140 3613
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
3141 3614
 					}
3142
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3615
+					if ($globalDebug) {
3616
+						echo 'Count all airlines...'."\n";
3617
+					}
3143 3618
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3144 3619
 					foreach ($alldata as $number) {
3145 3620
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3146 3621
 					}
3147
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3622
+					if ($globalDebug) {
3623
+						echo 'Count all aircraft registrations...'."\n";
3624
+					}
3148 3625
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3149 3626
 					foreach ($alldata as $number) {
3150 3627
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3151 3628
 					}
3152
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3629
+					if ($globalDebug) {
3630
+						echo 'Count all callsigns...'."\n";
3631
+					}
3153 3632
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3154 3633
 					foreach ($alldata as $number) {
3155 3634
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3156 3635
 					}
3157
-					if ($globalDebug) echo 'Count all owners...'."\n";
3636
+					if ($globalDebug) {
3637
+						echo 'Count all owners...'."\n";
3638
+					}
3158 3639
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3159 3640
 					foreach ($alldata as $number) {
3160 3641
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3161 3642
 					}
3162
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3643
+					if ($globalDebug) {
3644
+						echo 'Count all pilots...'."\n";
3645
+					}
3163 3646
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3164 3647
 					foreach ($alldata as $number) {
3165 3648
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3166 3649
 					}
3167
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3650
+					if ($globalDebug) {
3651
+						echo 'Count departure airports...'."\n";
3652
+					}
3168 3653
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3169 3654
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3170 3655
 					$alldata = array();
@@ -3176,7 +3661,9 @@  discard block
 block discarded – undo
3176 3661
 						$icao = $value['airport_departure_icao'];
3177 3662
 						if (isset($alldata[$icao])) {
3178 3663
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
3179
-						} else $alldata[$icao] = $value;
3664
+						} else {
3665
+							$alldata[$icao] = $value;
3666
+						}
3180 3667
 					}
3181 3668
 					$count = array();
3182 3669
 					foreach ($alldata as $key => $row) {
@@ -3186,7 +3673,9 @@  discard block
 block discarded – undo
3186 3673
 					foreach ($alldata as $number) {
3187 3674
 						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
3188 3675
 					}
3189
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3676
+					if ($globalDebug) {
3677
+						echo 'Count all arrival airports...'."\n";
3678
+					}
3190 3679
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3191 3680
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3192 3681
 					$alldata = array();
@@ -3198,7 +3687,9 @@  discard block
 block discarded – undo
3198 3687
 						$icao = $value['airport_arrival_icao'];
3199 3688
 						if (isset($alldata[$icao])) {
3200 3689
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
3201
-						} else $alldata[$icao] = $value;
3690
+						} else {
3691
+							$alldata[$icao] = $value;
3692
+						}
3202 3693
 					}
3203 3694
 					$count = array();
3204 3695
 					foreach ($alldata as $key => $row) {
@@ -3208,35 +3699,49 @@  discard block
 block discarded – undo
3208 3699
 					foreach ($alldata as $number) {
3209 3700
 						echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
3210 3701
 					}
3211
-					if ($globalDebug) echo 'Count all months...'."\n";
3702
+					if ($globalDebug) {
3703
+						echo 'Count all months...'."\n";
3704
+					}
3212 3705
 					$Spotter = new Spotter($this->db);
3213 3706
 					$alldata = $Spotter->countAllMonths($filter);
3214 3707
 					$lastyear = false;
3215 3708
 					foreach ($alldata as $number) {
3216
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3709
+						if ($number['year_name'] != date('Y')) {
3710
+							$lastyear = true;
3711
+						}
3217 3712
 						$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);
3218 3713
 					}
3219
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3714
+					if ($globalDebug) {
3715
+						echo 'Count all owners by months...'."\n";
3716
+					}
3220 3717
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3221 3718
 					foreach ($alldata as $number) {
3222 3719
 						$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);
3223 3720
 					}
3224
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3721
+					if ($globalDebug) {
3722
+						echo 'Count all pilots by months...'."\n";
3723
+					}
3225 3724
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3226 3725
 					foreach ($alldata as $number) {
3227 3726
 						$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);
3228 3727
 					}
3229
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3728
+					if ($globalDebug) {
3729
+						echo 'Count all military by months...'."\n";
3730
+					}
3230 3731
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3231 3732
 					foreach ($alldata as $number) {
3232 3733
 						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3233 3734
 					}
3234
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3735
+					if ($globalDebug) {
3736
+						echo 'Count all aircrafts by months...'."\n";
3737
+					}
3235 3738
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3236 3739
 				    	foreach ($alldata as $number) {
3237 3740
 			    			$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);
3238 3741
 					}
3239
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3742
+					if ($globalDebug) {
3743
+						echo 'Count all real arrivals by months...'."\n";
3744
+					}
3240 3745
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3241 3746
 					foreach ($alldata as $number) {
3242 3747
 						$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);
Please login to merge, or discard this patch.
require/class.Source.php 3 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		try {
17 17
 			$sth = $this->db->prepare($query);
18 18
 			$sth->execute($query_values);
19
-		} catch(PDOException $e) {
19
+		} catch (PDOException $e) {
20 20
 			return "error : ".$e->getMessage();
21 21
 		}
22 22
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 		try {
30 30
 			$sth = $this->db->prepare($query);
31 31
 			$sth->execute($query_values);
32
-		} catch(PDOException $e) {
32
+		} catch (PDOException $e) {
33 33
 			return "error : ".$e->getMessage();
34 34
 		}
35 35
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
36 36
 		return $all;
37 37
 	}
38 38
 
39
-	public function getLocationInfobyNameType($name,$type) {
39
+	public function getLocationInfobyNameType($name, $type) {
40 40
 		$query = "SELECT * FROM source_location WHERE name = :name AND type = :type";
41
-		$query_values = array(':name' => $name,':type' => $type);
41
+		$query_values = array(':name' => $name, ':type' => $type);
42 42
 		try {
43 43
 			$sth = $this->db->prepare($query);
44 44
 			$sth->execute($query_values);
45
-		} catch(PDOException $e) {
45
+		} catch (PDOException $e) {
46 46
 			return "error : ".$e->getMessage();
47 47
 		}
48 48
 		$all = $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($query_values);
58
-		} catch(PDOException $e) {
58
+		} catch (PDOException $e) {
59 59
 			return "error : ".$e->getMessage();
60 60
 		}
61 61
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	public function getLocationInfoByType($type, $coord = array(), $limit = false) {
66 66
 		$query = "SELECT * FROM source_location WHERE type = :type";
67 67
 		if (is_array($coord) && !empty($coord)) {
68
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
69
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
70
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
71
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
68
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
69
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
70
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
71
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
72 72
 			$query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0";
73 73
 		}
74 74
 		$query .= " ORDER BY last_seen DESC";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		try {
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute($query_values);
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error : ".$e->getMessage();
82 82
 		}
83 83
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		try {
91 91
 			$sth = $this->db->prepare($query);
92 92
 			$sth->execute($query_values);
93
-		} catch(PDOException $e) {
93
+		} catch (PDOException $e) {
94 94
 			return "error : ".$e->getMessage();
95 95
 		}
96 96
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -103,56 +103,56 @@  discard block
 block discarded – undo
103 103
 		try {
104 104
 			$sth = $this->db->prepare($query);
105 105
 			$sth->execute($query_values);
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109 109
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
110 110
 		return $all;
111 111
 	}
112 112
 
113
-	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') {
113
+	public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
114 114
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
115 115
 		$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)";
116
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
116
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
117 117
 		try {
118 118
 			$sth = $this->db->prepare($query);
119 119
 			$sth->execute($query_values);
120
-		} catch(PDOException $e) {
120
+		} catch (PDOException $e) {
121 121
 			echo "error : ".$e->getMessage();
122 122
 		}
123 123
 	}
124 124
 
125
-	public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') {
125
+	public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
126 126
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
127 127
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source";
128
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
128
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
129 129
 		try {
130 130
 			$sth = $this->db->prepare($query);
131 131
 			$sth->execute($query_values);
132
-		} catch(PDOException $e) {
132
+		} catch (PDOException $e) {
133 133
 			return "error : ".$e->getMessage();
134 134
 		}
135 135
 	}
136 136
 
137
-	public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') {
137
+	public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') {
138 138
 		$query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source";
139
-		$query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description);
139
+		$query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description);
140 140
 		try {
141 141
 			$sth = $this->db->prepare($query);
142 142
 			$sth->execute($query_values);
143
-		} catch(PDOException $e) {
143
+		} catch (PDOException $e) {
144 144
 			return "error : ".$e->getMessage();
145 145
 		}
146 146
 	}
147 147
 
148
-	public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') {
148
+	public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') {
149 149
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
150 150
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id";
151
-		$query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
151
+		$query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
152 152
 		try {
153 153
 			$sth = $this->db->prepare($query);
154 154
 			$sth->execute($query_values);
155
-		} catch(PDOException $e) {
155
+		} catch (PDOException $e) {
156 156
 			echo "error : ".$e->getMessage();
157 157
 		}
158 158
 	}
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute($query_values);
166
-		} catch(PDOException $e) {
166
+		} catch (PDOException $e) {
167 167
 			return "error : ".$e->getMessage();
168 168
 		}
169 169
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		try {
175 175
 			$sth = $this->db->prepare($query);
176 176
 			$sth->execute($query_values);
177
-		} catch(PDOException $e) {
177
+		} catch (PDOException $e) {
178 178
 			return "error : ".$e->getMessage();
179 179
 		}
180 180
 	}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		try {
186 186
 			$sth = $this->db->prepare($query);
187 187
 			$sth->execute($query_values);
188
-		} catch(PDOException $e) {
188
+		} catch (PDOException $e) {
189 189
 			return "error : ".$e->getMessage();
190 190
 		}
191 191
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		try {
196 196
 			$sth = $this->db->prepare($query);
197 197
 			$sth->execute();
198
-		} catch(PDOException $e) {
198
+		} catch (PDOException $e) {
199 199
 			return "error : ".$e->getMessage();
200 200
 		}
201 201
 	}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		try {
225 225
 			$sth = $this->db->prepare($query);
226 226
 			$sth->execute(array(':type' => $type));
227
-		} catch(PDOException $e) {
227
+		} catch (PDOException $e) {
228 228
 			return "error";
229 229
 		}
230 230
 		return "success";
Please login to merge, or discard this patch.
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -110,6 +110,12 @@  discard block
 block discarded – undo
110 110
 		return $all;
111 111
 	}
112 112
 
113
+	/**
114
+	 * @param string $name
115
+	 * @param string $city
116
+	 * @param string $country
117
+	 * @param string $source
118
+	 */
113 119
 	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') {
114 120
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
115 121
 		$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)";
@@ -168,6 +174,9 @@  discard block
 block discarded – undo
168 174
 		}
169 175
 	}
170 176
 
177
+	/**
178
+	 * @param string $type
179
+	 */
171 180
 	public function deleteLocationByType($type) {
172 181
 		$query = "DELETE FROM source_location WHERE type = :type";
173 182
 		$query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 	public function __construct($dbc = null) {
8 8
 		$Connection = new Connection($dbc);
9 9
 		$this->db = $Connection->db;
10
-		if ($this->db === null) die('Error: No DB connection. (Source)');
10
+		if ($this->db === null) {
11
+			die('Error: No DB connection. (Source)');
12
+		}
11 13
 	}
12 14
 
13 15
 	public function getAllLocationInfo() {
@@ -72,7 +74,9 @@  discard block
 block discarded – undo
72 74
 			$query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0";
73 75
 		}
74 76
 		$query .= " ORDER BY last_seen DESC";
75
-		if ($limit) $query .= " LIMIT 400";
77
+		if ($limit) {
78
+			$query .= " LIMIT 400";
79
+		}
76 80
 		$query_values = array(':type' => $type);
77 81
 		try {
78 82
 			$sth = $this->db->prepare($query);
@@ -111,7 +115,9 @@  discard block
 block discarded – undo
111 115
 	}
112 116
 
113 117
 	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') {
114
-		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
118
+		if ($last_seen == '') {
119
+			$last_seen = date('Y-m-d H:i:s');
120
+		}
115 121
 		$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)";
116 122
 		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
117 123
 		try {
@@ -123,7 +129,9 @@  discard block
 block discarded – undo
123 129
 	}
124 130
 
125 131
 	public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') {
126
-		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
132
+		if ($last_seen == '') {
133
+			$last_seen = date('Y-m-d H:i:s');
134
+		}
127 135
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source";
128 136
 		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
129 137
 		try {
@@ -146,7 +154,9 @@  discard block
 block discarded – undo
146 154
 	}
147 155
 
148 156
 	public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') {
149
-		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
157
+		if ($last_seen == '') {
158
+			$last_seen = date('Y-m-d H:i:s');
159
+		}
150 160
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id";
151 161
 		$query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
152 162
 		try {
Please login to merge, or discard this patch.
location-geojson.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,9 @@
 block discarded – undo
79 79
 		$output .= '"type": "'.$spotter_item['type'].'",';
80 80
 		if ($spotter_item['type'] == 'wx') {
81 81
 			$weather = json_decode($spotter_item['description'],true);
82
-			if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
82
+			if (isset($weather['temp'])) {
83
+				$output.= '"temp": "'.$weather['temp'].'",';
84
+			}
83 85
 		}
84 86
 		$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
85 87
 		$output .= '},';
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,40 +14,40 @@
 block discarded – undo
14 14
 	{
15 15
 		$coords = explode(',',$_GET['coord']);
16 16
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
17
-		    || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
17
+			|| (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
18 18
 			//$spotter_array = $Source->getAllLocationInfo();
19 19
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords));
20 20
 		}
21 21
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
22
-		    || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
22
+			|| (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
23 23
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords));
24 24
 		}
25 25
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
26
-		    || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
26
+			|| (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
27 27
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords));
28 28
 		}
29 29
 		
30 30
 		if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') 
31
-		    || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
31
+			|| (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
32 32
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true));
33 33
 		}
34 34
 		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
35 35
 	} else {
36 36
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
37
-		    || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
37
+			|| (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
38 38
 			//$spotter_array = $Source->getAllLocationInfo();
39 39
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
40 40
 		}
41 41
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
42
-		    || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
42
+			|| (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
43 43
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
44 44
 		}
45 45
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
46
-		    || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
46
+			|| (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
47 47
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
48 48
 		}
49 49
 		if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') 
50
-		    || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
50
+			|| (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
51 51
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',array(),true));
52 52
 		}
53 53
 		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,52 +12,52 @@  discard block
 block discarded – undo
12 12
 if (!isset($globalDemo)) {
13 13
 	if (isset($_GET['coord'])) 
14 14
 	{
15
-		$coords = explode(',',$_GET['coord']);
15
+		$coords = explode(',', $_GET['coord']);
16 16
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
17 17
 		    || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
18 18
 			//$spotter_array = $Source->getAllLocationInfo();
19
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords));
19
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs', $coords));
20 20
 		}
21 21
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
22 22
 		    || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
23
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords));
23
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx', $coords));
24 24
 		}
25 25
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
26 26
 		    || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
27
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords));
27
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning', $coords));
28 28
 		}
29 29
 		
30 30
 		if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') 
31 31
 		    || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
32
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true));
32
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('fires', $coords, true));
33 33
 		}
34
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
34
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType(''));
35 35
 	} else {
36 36
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
37 37
 		    || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
38 38
 			//$spotter_array = $Source->getAllLocationInfo();
39
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
39
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs'));
40 40
 		}
41 41
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
42 42
 		    || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
43
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
43
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx'));
44 44
 		}
45 45
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
46 46
 		    || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
47
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
47
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning'));
48 48
 		}
49 49
 		if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') 
50 50
 		    || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
51
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',array(),true));
51
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('fires', array(), true));
52 52
 		}
53
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
53
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType(''));
54 54
 	}
55 55
 }
56 56
 
57 57
 $output = '{"type": "FeatureCollection","features": [';
58 58
 if (!empty($spotter_array) && count($spotter_array) > 0)
59 59
 {
60
-	foreach($spotter_array as $spotter_item)
60
+	foreach ($spotter_array as $spotter_item)
61 61
 	{
62 62
 		date_default_timezone_set('UTC');
63 63
 		$output .= '{"type": "Feature",';
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 		$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
77 77
 		$output .= '"type": "'.$spotter_item['type'].'",';
78 78
 		if ($spotter_item['type'] == 'wx') {
79
-			$weather = json_decode($spotter_item['description'],true);
80
-			if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
79
+			$weather = json_decode($spotter_item['description'], true);
80
+			if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",';
81 81
 		}
82 82
 		$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
83 83
 		$output .= '},';
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		$output .= '}';
88 88
 		$output .= '},';
89 89
 	}
90
-	$output  = substr($output, 0, -1);
90
+	$output = substr($output, 0, -1);
91 91
 }
92 92
 $output .= ']}';
93 93
 print $output;
Please login to merge, or discard this patch.
install/class.update_db.php 4 patches
Doc Comments   +48 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@  discard block
 block discarded – undo
10 10
 class update_db {
11 11
 	public static $db_sqlite;
12 12
 
13
+	/**
14
+	 * @param string $file
15
+	 */
13 16
 	public static function download($url, $file, $referer = '') {
14 17
 		global $globalProxy, $globalForceIPv4;
15 18
 		$fp = fopen($file, 'w');
@@ -34,6 +37,9 @@  discard block
 block discarded – undo
34 37
 		fclose($fp);
35 38
 	}
36 39
 
40
+	/**
41
+	 * @param string $in_file
42
+	 */
37 43
 	public static function gunzip($in_file,$out_file_name = '') {
38 44
 		//echo $in_file.' -> '.$out_file_name."\n";
39 45
 		$buffer_size = 4096; // read 4kb at a time
@@ -55,6 +61,9 @@  discard block
 block discarded – undo
55 61
 		}
56 62
 	}
57 63
 
64
+	/**
65
+	 * @param string $in_file
66
+	 */
58 67
 	public static function unzip($in_file) {
59 68
 		if ($in_file != '' && file_exists($in_file)) {
60 69
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -76,6 +85,9 @@  discard block
 block discarded – undo
76 85
 		}
77 86
 	}
78 87
 	
88
+	/**
89
+	 * @param string $database_file
90
+	 */
79 91
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 92
 		global $globalDebug, $globalTransaction;
81 93
 		//$query = 'TRUNCATE TABLE routes';
@@ -118,6 +130,10 @@  discard block
 block discarded – undo
118 130
 		}
119 131
                 return '';
120 132
 	}
133
+
134
+	/**
135
+	 * @param string $database_file
136
+	 */
121 137
 	public static function retrieve_route_oneworld($database_file) {
122 138
 		global $globalDebug, $globalTransaction;
123 139
 		//$query = 'TRUNCATE TABLE routes';
@@ -159,6 +175,9 @@  discard block
 block discarded – undo
159 175
                 return '';
160 176
 	}
161 177
 	
178
+	/**
179
+	 * @param string $database_file
180
+	 */
162 181
 	public static function retrieve_route_skyteam($database_file) {
163 182
 		global $globalDebug, $globalTransaction;
164 183
 		//$query = 'TRUNCATE TABLE routes';
@@ -201,6 +220,10 @@  discard block
 block discarded – undo
201 220
 		}
202 221
                 return '';
203 222
 	}
223
+
224
+	/**
225
+	 * @param string $database_file
226
+	 */
204 227
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
205 228
 		global $globalTransaction;
206 229
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -267,6 +290,9 @@  discard block
 block discarded – undo
267 290
 		return '';
268 291
 	}
269 292
 
293
+	/**
294
+	 * @param string $database_file
295
+	 */
270 296
 	public static function retrieve_modes_flarmnet($database_file) {
271 297
 		global $globalTransaction;
272 298
 		$Common = new Common();
@@ -337,6 +363,9 @@  discard block
 block discarded – undo
337 363
 		return '';
338 364
 	}
339 365
 
366
+	/**
367
+	 * @param string $database_file
368
+	 */
340 369
 	public static function retrieve_modes_ogn($database_file) {
341 370
 		global $globalTransaction;
342 371
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -406,6 +435,9 @@  discard block
 block discarded – undo
406 435
 		return '';
407 436
 	}
408 437
 
438
+	/**
439
+	 * @param string $database_file
440
+	 */
409 441
 	public static function retrieve_owner($database_file,$country = 'F') {
410 442
 		global $globalTransaction, $globalMasterSource;
411 443
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -1393,6 +1425,10 @@  discard block
 block discarded – undo
1393 1425
 		return '';
1394 1426
         }
1395 1427
 
1428
+	/**
1429
+	 * @param string $filename
1430
+	 * @param string $tletype
1431
+	 */
1396 1432
 	public static function tle($filename,$tletype) {
1397 1433
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1398 1434
 		global $tmp_dir, $globalTransaction;
@@ -1442,6 +1478,9 @@  discard block
 block discarded – undo
1442 1478
 		return '';
1443 1479
         }
1444 1480
 
1481
+	/**
1482
+	 * @param string $filename
1483
+	 */
1445 1484
 	public static function satellite_ucsdb($filename) {
1446 1485
 		global $tmp_dir, $globalTransaction;
1447 1486
 		$query = "DELETE FROM satellite";
@@ -1488,6 +1527,9 @@  discard block
 block discarded – undo
1488 1527
 		return '';
1489 1528
 	}
1490 1529
 
1530
+	/**
1531
+	 * @param string $filename
1532
+	 */
1491 1533
 	public static function satellite_celestrak($filename) {
1492 1534
 		global $tmp_dir, $globalTransaction;
1493 1535
 		$satcat_sources = array(
@@ -1815,6 +1857,9 @@  discard block
 block discarded – undo
1815 1857
 
1816 1858
 	}
1817 1859
 */
1860
+	/**
1861
+	 * @param string $filename
1862
+	 */
1818 1863
 	public static function waypoints($filename) {
1819 1864
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1820 1865
 		global $tmp_dir, $globalTransaction;
@@ -1883,6 +1928,9 @@  discard block
 block discarded – undo
1883 1928
 		}
1884 1929
 	}
1885 1930
 
1931
+	/**
1932
+	 * @param string $filename
1933
+	 */
1886 1934
 	public static function ivao_airlines($filename) {
1887 1935
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1888 1936
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -85,38 +85,38 @@  discard block
 block discarded – undo
85 85
 		try {
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88
-                        $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
90
-                        return "error : ".$e->getMessage();
91
-                }
88
+						$sth->execute(array(':source' => $database_file));
89
+				} catch(PDOException $e) {
90
+						return "error : ".$e->getMessage();
91
+				}
92 92
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
94
-    		update_db::connect_sqlite($database_file);
93
+			if ($globalDebug) echo " - Add routes to DB -";
94
+			update_db::connect_sqlite($database_file);
95 95
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
96 96
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
97 97
 		try {
98
-                        $sth = update_db::$db_sqlite->prepare($query);
99
-                        $sth->execute();
100
-                } catch(PDOException $e) {
101
-                        return "error : ".$e->getMessage();
102
-                }
98
+						$sth = update_db::$db_sqlite->prepare($query);
99
+						$sth->execute();
100
+				} catch(PDOException $e) {
101
+						return "error : ".$e->getMessage();
102
+				}
103 103
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
104 104
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
105 105
 		$Connection = new Connection();
106 106
 		$sth_dest = $Connection->db->prepare($query_dest);
107 107
 		try {
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
109
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111 111
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
112 112
 				$sth_dest->execute($query_dest_values);
113
-            		}
113
+					}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115 115
 		} catch(PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
119
-                return '';
119
+				return '';
120 120
 	}
121 121
 	public static function retrieve_route_oneworld($database_file) {
122 122
 		global $globalDebug, $globalTransaction;
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 		try {
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130
-                        $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
132
-                        return "error : ".$e->getMessage();
133
-                }
130
+						$sth->execute(array(':source' => 'oneworld'));
131
+				} catch(PDOException $e) {
132
+						return "error : ".$e->getMessage();
133
+				}
134 134
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
135
+			if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138 138
 		if ($fh = fopen($database_file,"r")) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			}
157 157
 			if ($globalTransaction) $Connection->db->commit();
158 158
 		}
159
-                return '';
159
+				return '';
160 160
 	}
161 161
 	
162 162
 	public static function retrieve_route_skyteam($database_file) {
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 		try {
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171
-                        $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
173
-                        return "error : ".$e->getMessage();
174
-                }
171
+						$sth->execute(array(':source' => 'skyteam'));
172
+				} catch(PDOException $e) {
173
+						return "error : ".$e->getMessage();
174
+				}
175 175
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
176
+			if ($globalDebug) echo " - Add routes to DB -";
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
201 201
 		}
202
-                return '';
202
+				return '';
203 203
 	}
204 204
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
205 205
 		global $globalTransaction;
@@ -208,27 +208,27 @@  discard block
 block discarded – undo
208 208
 		try {
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211
-                        $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
213
-                        return "error : ".$e->getMessage();
214
-                }
211
+						$sth->execute(array(':source' => $database_file));
212
+				} catch(PDOException $e) {
213
+						return "error : ".$e->getMessage();
214
+				}
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
216 216
 		try {
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219
-                        $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
219
+						$sth->execute(array(':source' => $database_file));
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 
224
-    		update_db::connect_sqlite($database_file);
224
+			update_db::connect_sqlite($database_file);
225 225
 		$query = 'select * from Aircraft';
226 226
 		try {
227
-                        $sth = update_db::$db_sqlite->prepare($query);
228
-                        $sth->execute();
229
-                } catch(PDOException $e) {
230
-                        return "error : ".$e->getMessage();
231
-                }
227
+						$sth = update_db::$db_sqlite->prepare($query);
228
+						$sth->execute();
229
+				} catch(PDOException $e) {
230
+						return "error : ".$e->getMessage();
231
+				}
232 232
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
233 233
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
234 234
 		
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 240
 		try {
241 241
 			if ($globalTransaction) $Connection->db->beginTransaction();
242
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
242
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 243
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246 246
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
250
-				    $sth_dest_owner->execute($query_dest_owner_values);
249
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
250
+					$sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252
-            		}
252
+					}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254 254
 		} catch(PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 		try {
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263
-                        $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
265
-                        return "error : ".$e->getMessage();
266
-                }
263
+						$sth->execute(array(':source' => $database_file));
264
+				} catch(PDOException $e) {
265
+						return "error : ".$e->getMessage();
266
+				}
267 267
 		return '';
268 268
 	}
269 269
 
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 		try {
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278
-                        $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
280
-                        return "error : ".$e->getMessage();
281
-                }
278
+						$sth->execute(array(':source' => $database_file));
279
+				} catch(PDOException $e) {
280
+						return "error : ".$e->getMessage();
281
+				}
282 282
 		
283 283
 		if ($fh = fopen($database_file,"r")) {
284 284
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -288,26 +288,26 @@  discard block
 block discarded – undo
288 288
 			$sth_dest = $Connection->db->prepare($query_dest);
289 289
 			try {
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291
-            			while (!feof($fh)) {
292
-            				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
291
+						while (!feof($fh)) {
292
+							$values = array();
293
+							$line = $Common->hex2str(fgets($fh,9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
298
-            				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
300
-            				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303
-            				$sth_search = $Connection->db->prepare($query_search);
295
+							$values['ModeS'] = substr($line,0,6);
296
+							$values['Registration'] = trim(substr($line,69,6));
297
+							$aircraft_name = trim(substr($line,48,6));
298
+							// Check if we can find ICAO, else set it to GLID
299
+							$aircraft_name_split = explode(' ',$aircraft_name);
300
+							$search_more = '';
301
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303
+							$sth_search = $Connection->db->prepare($query_search);
304 304
 					try {
305
-                                    		$sth_search->execute();
306
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
307
-	            				//if (count($result) > 0) {
308
-	            				if (isset($result['icao']) && $result['icao'] != '') {
309
-	            				    $values['ICAOTypeCode'] = $result['icao'];
310
-	            				} 
305
+											$sth_search->execute();
306
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
307
+								//if (count($result) > 0) {
308
+								if (isset($result['icao']) && $result['icao'] != '') {
309
+									$values['ICAOTypeCode'] = $result['icao'];
310
+								} 
311 311
 					} catch(PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 		try {
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333
-                        $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
335
-                        return "error : ".$e->getMessage();
336
-                }
333
+						$sth->execute(array(':source' => $database_file));
334
+				} catch(PDOException $e) {
335
+						return "error : ".$e->getMessage();
336
+				}
337 337
 		return '';
338 338
 	}
339 339
 
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 		try {
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347
-                        $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
349
-                        return "error : ".$e->getMessage();
350
-                }
347
+						$sth->execute(array(':source' => $database_file));
348
+				} catch(PDOException $e) {
349
+						return "error : ".$e->getMessage();
350
+				}
351 351
 		
352 352
 		if ($fh = fopen($database_file,"r")) {
353 353
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360 360
 				$tmp = fgetcsv($fh,9999,',',"'");
361
-            			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
361
+						while (!feof($fh)) {
362
+							$line = fgetcsv($fh,9999,',',"'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
366
-            				$values['ModeS'] = $line[1];
367
-            				$values['Registration'] = $line[3];
368
-            				$values['ICAOTypeCode'] = '';
369
-            				$aircraft_name = $line[2];
370
-            				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
372
-            				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375
-            				$sth_search = $Connection->db->prepare($query_search);
366
+							$values['ModeS'] = $line[1];
367
+							$values['Registration'] = $line[3];
368
+							$values['ICAOTypeCode'] = '';
369
+							$aircraft_name = $line[2];
370
+							// Check if we can find ICAO, else set it to GLID
371
+							$aircraft_name_split = explode(' ',$aircraft_name);
372
+							$search_more = '';
373
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375
+							$sth_search = $Connection->db->prepare($query_search);
376 376
 					try {
377
-                                    		$sth_search->execute();
378
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
377
+											$sth_search->execute();
378
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380 380
 					} catch(PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 		try {
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402
-                        $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
404
-                        return "error : ".$e->getMessage();
405
-                }
402
+						$sth->execute(array(':source' => $database_file));
403
+				} catch(PDOException $e) {
404
+						return "error : ".$e->getMessage();
405
+				}
406 406
 		return '';
407 407
 	}
408 408
 
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 		try {
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416
-                        $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
418
-                        return "error : ".$e->getMessage();
419
-                }
416
+						$sth->execute(array(':source' => $database_file));
417
+				} catch(PDOException $e) {
418
+						return "error : ".$e->getMessage();
419
+				}
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422 422
 		if ($fh = fopen($database_file,"r")) {
423 423
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
425
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
426 426
 		        
427 427
 			$Connection = new Connection();
428 428
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -430,126 +430,126 @@  discard block
 block discarded – undo
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432 432
 				$tmp = fgetcsv($fh,9999,',','"');
433
-            			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
435
-            				$values = array();
436
-            				//print_r($line);
437
-            				if ($country == 'F') {
438
-            				    $values['registration'] = $line[0];
439
-            				    $values['base'] = $line[4];
440
-            				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
443
-					    $values['cancel'] = $line[7];
433
+						while (!feof($fh)) {
434
+							$line = fgetcsv($fh,9999,',','"');
435
+							$values = array();
436
+							//print_r($line);
437
+							if ($country == 'F') {
438
+								$values['registration'] = $line[0];
439
+								$values['base'] = $line[4];
440
+								$values['owner'] = $line[5];
441
+								if ($line[6] == '') $values['date_first_reg'] = null;
442
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
443
+						$values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[0];
447
-            				    $values['base'] = $line[3];
448
-            				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
451
-					    $values['cancel'] = '';
452
-					    $values['modes'] = $line[7];
453
-					    $values['icao'] = $line[8];
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[0];
447
+								$values['base'] = $line[3];
448
+								$values['owner'] = $line[2];
449
+								if ($line[1] == '') $values['date_first_reg'] = null;
450
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
451
+						$values['cancel'] = '';
452
+						$values['modes'] = $line[7];
453
+						$values['icao'] = $line[8];
454 454
 					    
455 455
 					} elseif ($country == 'HB') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[0];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    $values['date_first_reg'] = null;
461
-					    $values['cancel'] = '';
462
-					    $values['modes'] = $line[4];
463
-					    $values['icao'] = $line[7];
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[0];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								$values['date_first_reg'] = null;
461
+						$values['cancel'] = '';
462
+						$values['modes'] = $line[4];
463
+						$values['icao'] = $line[7];
464 464
 					} elseif ($country == 'OK') {
465
-					    // TODO : add modeS & reg to aircraft_modes
466
-            				    $values['registration'] = $line[3];
467
-            				    $values['base'] = null;
468
-            				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
471
-					    $values['cancel'] = '';
465
+						// TODO : add modeS & reg to aircraft_modes
466
+								$values['registration'] = $line[3];
467
+								$values['base'] = null;
468
+								$values['owner'] = $line[5];
469
+								if ($line[18] == '') $values['date_first_reg'] = null;
470
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
471
+						$values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473
-					    // TODO : add modeS & reg to aircraft_modes
474
-            				    $values['registration'] = $line[0];
475
-            				    $values['base'] = null;
476
-            				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
479
-
480
-					    $values['cancel'] = $line[39];
473
+						// TODO : add modeS & reg to aircraft_modes
474
+								$values['registration'] = $line[0];
475
+								$values['base'] = null;
476
+								$values['owner'] = $line[12];
477
+								if ($line[28] == '') $values['date_first_reg'] = null;
478
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
479
+
480
+						$values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
482
-            				    $values['registration'] = $line[0];
483
-            				    $values['base'] = null;
484
-            				    $values['owner'] = $line[4];
485
-            				    $values['date_first_reg'] = null;
486
-					    $values['cancel'] = '';
482
+								$values['registration'] = $line[0];
483
+								$values['base'] = null;
484
+								$values['owner'] = $line[4];
485
+								$values['date_first_reg'] = null;
486
+						$values['cancel'] = '';
487 487
 					} elseif ($country == 'CC') {
488
-            				    $values['registration'] = $line[0];
489
-            				    $values['base'] = null;
490
-            				    $values['owner'] = $line[6];
491
-            				    $values['date_first_reg'] = null;
492
-					    $values['cancel'] = '';
488
+								$values['registration'] = $line[0];
489
+								$values['base'] = null;
490
+								$values['owner'] = $line[6];
491
+								$values['date_first_reg'] = null;
492
+						$values['cancel'] = '';
493 493
 					} elseif ($country == 'HJ') {
494
-            				    $values['registration'] = $line[0];
495
-            				    $values['base'] = null;
496
-            				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
-					    $values['cancel'] = '';
494
+								$values['registration'] = $line[0];
495
+								$values['base'] = null;
496
+								$values['owner'] = $line[8];
497
+								if ($line[7] == '') $values['date_first_reg'] = null;
498
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
+						$values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501
-            				    $values['registration'] = $line[0];
502
-            				    $values['base'] = null;
503
-            				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
-					    $values['cancel'] = $line[7];
501
+								$values['registration'] = $line[0];
502
+								$values['base'] = null;
503
+								$values['owner'] = $line[4];
504
+								if ($line[6] == '') $values['date_first_reg'] = null;
505
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+						$values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508
-            				    $values['registration'] = $line[0];
509
-            				    $values['base'] = null;
510
-            				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
513
-					    $values['cancel'] = '';
508
+								$values['registration'] = $line[0];
509
+								$values['base'] = null;
510
+								$values['owner'] = $line[4];
511
+								if ($line[5] == '') $values['date_first_reg'] = null;
512
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
513
+						$values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515
-            				    $values['registration'] = $line[0];
516
-            				    $values['base'] = null;
517
-            				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
520
-					    $values['cancel'] = '';
515
+								$values['registration'] = $line[0];
516
+								$values['base'] = null;
517
+								$values['owner'] = $line[3];
518
+								if ($line[7] == '') $values['date_first_reg'] = null;
519
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
520
+						$values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522
-            				    $values['registration'] = $line[0];
523
-            				    $values['base'] = null;
524
-            				    $values['owner'] = $line[3];
525
-            				    $values['date_first_reg'] = null;
526
-					    $values['cancel'] = '';
527
-					    $values['modes'] = $line[5];
528
-					    $values['icao'] = $line[9];
522
+								$values['registration'] = $line[0];
523
+								$values['base'] = null;
524
+								$values['owner'] = $line[3];
525
+								$values['date_first_reg'] = null;
526
+						$values['cancel'] = '';
527
+						$values['modes'] = $line[5];
528
+						$values['icao'] = $line[9];
529 529
 					} elseif ($country == 'M') {
530
-            				    $values['registration'] = $line[0];
531
-            				    $values['base'] = null;
532
-            				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
535
-					    $values['modes'] = $line[4];
536
-					    $values['icao'] = $line[10];
530
+								$values['registration'] = $line[0];
531
+								$values['base'] = null;
532
+								$values['owner'] = $line[6];
533
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
535
+						$values['modes'] = $line[4];
536
+						$values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538
-            				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
540
-					    $values['modes'] = $line[5];
541
-					    $values['icao'] = $line[6];
538
+								$values['registration'] = $line[0];
539
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
540
+						$values['modes'] = $line[5];
541
+						$values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543
-            				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
545
-					    $values['modes'] = $line[4];
546
-					    $values['icao'] = $line[5];
543
+								$values['registration'] = $line[0];
544
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
545
+						$values['modes'] = $line[4];
546
+						$values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
548
-            				    $values['registration'] = $line[0];
549
-            				    $values['base'] = null;
550
-            				    $values['owner'] = $line[3];
551
-            				    $values['date_first_reg'] = null;
552
-					    $values['cancel'] = '';
548
+								$values['registration'] = $line[0];
549
+								$values['base'] = null;
550
+								$values['owner'] = $line[3];
551
+								$values['date_first_reg'] = null;
552
+						$values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555 555
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
                         return "error : ".$e->getMessage();
683 683
                 }
684 684
                 */
685
-                /*
685
+				/*
686 686
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
687 687
 		try {
688 688
 			$Connection = new Connection();
@@ -927,10 +927,10 @@  discard block
 block discarded – undo
927 927
 		try {
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930
-                        $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
932
-                        return "error : ".$e->getMessage();
933
-                }
930
+						$sth->execute(array(':source' => 'translation.csv'));
931
+				} catch(PDOException $e) {
932
+						return "error : ".$e->getMessage();
933
+				}
934 934
 
935 935
 		
936 936
 		//update_db::unzip($out_file);
@@ -949,21 +949,21 @@  discard block
 block discarded – undo
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
952
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
953
-                                                //echo substr($operator, 0, 2)."\n";;
954
-                                                if (count($airline_array) > 0) {
952
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
953
+												//echo substr($operator, 0, 2)."\n";;
954
+												if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956 956
 							$operator = $airline_array[0]['icao'].substr($operator,2);
957
-                                                }
958
-                                        }
957
+												}
958
+										}
959 959
 					
960 960
 					$operator_correct = $data[3];
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963
-                                                if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
965
-                                            	}
966
-                                        }
962
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963
+												if (count($airline_array) > 0) {
964
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
965
+												}
966
+										}
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 			//$Connection->db->commit();
978 978
 		}
979 979
 		return '';
980
-        }
980
+		}
981 981
 	
982 982
 	public static function translation_fam() {
983 983
 		global $tmp_dir, $globalTransaction;
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 			//$Connection->db->commit();
1016 1016
 		}
1017 1017
 		return '';
1018
-        }
1018
+		}
1019 1019
 
1020 1020
 	/*
1021 1021
 	* This function use FAA public data.
@@ -1027,19 +1027,19 @@  discard block
 block discarded – undo
1027 1027
 		try {
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030
-                        $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1032
-                        return "error : ".$e->getMessage();
1033
-                }
1030
+						$sth->execute(array(':source' => 'website_faa'));
1031
+				} catch(PDOException $e) {
1032
+						return "error : ".$e->getMessage();
1033
+				}
1034 1034
 
1035 1035
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1036 1036
 		try {
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039
-                        $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1041
-                        return "error : ".$e->getMessage();
1042
-                }
1039
+						$sth->execute(array(':source' => 'website_faa'));
1040
+				} catch(PDOException $e) {
1041
+						return "error : ".$e->getMessage();
1042
+				}
1043 1043
 
1044 1044
 		$delimiter = ",";
1045 1045
 		$mfr = array();
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 		}
1208 1208
 		*/
1209 1209
 		return '';
1210
-        }
1210
+		}
1211 1211
         
1212 1212
 	public static function owner_fam() {
1213 1213
 		global $tmp_dir, $globalTransaction;
@@ -1215,10 +1215,10 @@  discard block
 block discarded – undo
1215 1215
 		try {
1216 1216
 			$Connection = new Connection();
1217 1217
 			$sth = $Connection->db->prepare($query);
1218
-                        $sth->execute(array(':source' => 'website_fam'));
1219
-                } catch(PDOException $e) {
1220
-                        return "error : ".$e->getMessage();
1221
-                }
1218
+						$sth->execute(array(':source' => 'website_fam'));
1219
+				} catch(PDOException $e) {
1220
+						return "error : ".$e->getMessage();
1221
+				}
1222 1222
 
1223 1223
 		$delimiter = "\t";
1224 1224
 		$Connection = new Connection();
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 			if ($globalTransaction) $Connection->db->commit();
1245 1245
 		}
1246 1246
 		return '';
1247
-        }
1247
+		}
1248 1248
 
1249 1249
 	public static function routes_fam() {
1250 1250
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 			if ($globalTransaction) $Connection->db->commit();
1287 1287
 		}
1288 1288
 		return '';
1289
-        }
1289
+		}
1290 1290
 
1291 1291
 	public static function marine_identity_fam() {
1292 1292
 		global $tmp_dir, $globalTransaction;
@@ -1294,10 +1294,10 @@  discard block
 block discarded – undo
1294 1294
 		try {
1295 1295
 			$Connection = new Connection();
1296 1296
 			$sth = $Connection->db->prepare($query);
1297
-                        $sth->execute();
1298
-                } catch(PDOException $e) {
1299
-                        return "error : ".$e->getMessage();
1300
-                }
1297
+						$sth->execute();
1298
+				} catch(PDOException $e) {
1299
+						return "error : ".$e->getMessage();
1300
+				}
1301 1301
 
1302 1302
 		
1303 1303
 		//update_db::unzip($out_file);
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 			if ($globalTransaction) $Connection->db->commit();
1328 1328
 		}
1329 1329
 		return '';
1330
-        }
1330
+		}
1331 1331
 
1332 1332
 	public static function satellite_fam() {
1333 1333
 		global $tmp_dir, $globalTransaction;
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 			if ($globalTransaction) $Connection->db->commit();
1399 1399
 		}
1400 1400
 		return '';
1401
-        }
1401
+		}
1402 1402
 
1403 1403
 	public static function tle($filename,$tletype) {
1404 1404
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1409,10 +1409,10 @@  discard block
 block discarded – undo
1409 1409
 		try {
1410 1410
 			$Connection = new Connection();
1411 1411
 			$sth = $Connection->db->prepare($query);
1412
-                        $sth->execute(array(':source' => $filename));
1413
-                } catch(PDOException $e) {
1414
-                        return "error : ".$e->getMessage();
1415
-                }
1412
+						$sth->execute(array(':source' => $filename));
1413
+				} catch(PDOException $e) {
1414
+						return "error : ".$e->getMessage();
1415
+				}
1416 1416
 		
1417 1417
 		$Connection = new Connection();
1418 1418
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 			//$Connection->db->commit();
1448 1448
 		}
1449 1449
 		return '';
1450
-        }
1450
+		}
1451 1451
 
1452 1452
 	public static function satellite_ucsdb($filename) {
1453 1453
 		global $tmp_dir, $globalTransaction;
@@ -1706,11 +1706,11 @@  discard block
 block discarded – undo
1706 1706
 							try {
1707 1707
 								$sth = $Connection->db->prepare($query);
1708 1708
 								$sth->execute(array(
1709
-								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710
-								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711
-								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713
-								    )
1709
+									':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710
+									':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711
+									':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
+									':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713
+									)
1714 1714
 								);
1715 1715
 							} catch(PDOException $e) {
1716 1716
 								return "error : ".$e->getMessage();
@@ -1734,13 +1734,13 @@  discard block
 block discarded – undo
1734 1734
 			//$Connection->db->commit();
1735 1735
 		}
1736 1736
 		return '';
1737
-        }
1737
+		}
1738 1738
 
1739 1739
 	/**
1740
-        * Convert a HTML table to an array
1741
-        * @param String $data HTML page
1742
-        * @return Array array of the tables in HTML page
1743
-        */
1740
+	 * Convert a HTML table to an array
1741
+	 * @param String $data HTML page
1742
+	 * @return Array array of the tables in HTML page
1743
+	 */
1744 1744
 /*
1745 1745
         private static function table2array($data) {
1746 1746
                 $html = str_get_html($data);
@@ -1770,11 +1770,11 @@  discard block
 block discarded – undo
1770 1770
                 return(array_filter($tabledata));
1771 1771
         }
1772 1772
 */
1773
-       /**
1774
-        * Get data from form result
1775
-        * @param String $url form URL
1776
-        * @return String the result
1777
-        */
1773
+	   /**
1774
+	    * Get data from form result
1775
+	    * @param String $url form URL
1776
+	    * @return String the result
1777
+	    */
1778 1778
 /*
1779 1779
         private static function getData($url) {
1780 1780
                 $ch = curl_init();
@@ -1924,7 +1924,7 @@  discard block
 block discarded – undo
1924 1924
 			if ($globalTransaction) $Connection->db->commit();
1925 1925
 		}
1926 1926
 		return '';
1927
-        }
1927
+		}
1928 1928
 	
1929 1929
 	public static function update_airspace() {
1930 1930
 		global $tmp_dir, $globalDBdriver;
@@ -1934,11 +1934,11 @@  discard block
 block discarded – undo
1934 1934
 			$query = 'DROP TABLE airspace';
1935 1935
 			try {
1936 1936
 				$sth = $Connection->db->prepare($query);
1937
-                    		$sth->execute();
1938
-	                } catch(PDOException $e) {
1937
+							$sth->execute();
1938
+					} catch(PDOException $e) {
1939 1939
 				return "error : ".$e->getMessage();
1940
-	                }
1941
-	        }
1940
+					}
1941
+			}
1942 1942
 
1943 1943
 
1944 1944
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -2003,10 +2003,10 @@  discard block
 block discarded – undo
2003 2003
 			$query = 'DROP TABLE countries';
2004 2004
 			try {
2005 2005
 				$sth = $Connection->db->prepare($query);
2006
-            	        	$sth->execute();
2007
-	                } catch(PDOException $e) {
2008
-    	                	echo "error : ".$e->getMessage();
2009
-	                }
2006
+							$sth->execute();
2007
+					} catch(PDOException $e) {
2008
+							echo "error : ".$e->getMessage();
2009
+					}
2010 2010
 		}
2011 2011
 		if ($globalDBdriver == 'mysql') {
2012 2012
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2465,7 +2465,7 @@  discard block
 block discarded – undo
2465 2465
 						$error = update_db::airlines_fam();
2466 2466
 						update_db::insert_airlines_version($airlines_md5);
2467 2467
 					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2468
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2468
+				} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2469 2469
 			} elseif ($globalDebug) echo "No update.";
2470 2470
 		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2471 2471
 		if ($error != '') {
@@ -2956,10 +2956,10 @@  discard block
 block discarded – undo
2956 2956
 		try {
2957 2957
 			$Connection = new Connection();
2958 2958
 			$sth = $Connection->db->prepare($query);
2959
-                        $sth->execute();
2960
-                } catch(PDOException $e) {
2961
-                        return "error : ".$e->getMessage();
2962
-                }
2959
+						$sth->execute();
2960
+				} catch(PDOException $e) {
2961
+						return "error : ".$e->getMessage();
2962
+				}
2963 2963
 
2964 2964
 		$error = '';
2965 2965
 		if ($globalDebug) echo "Notam : Download...";
@@ -3015,8 +3015,8 @@  discard block
 block discarded – undo
3015 3015
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3016 3016
 					$data['permanent'] = 0;
3017 3017
 				} else {
3018
-				    $data['date_end'] = NULL;
3019
-				    $data['permanent'] = 1;
3018
+					$data['date_end'] = NULL;
3019
+					$data['permanent'] = 1;
3020 3020
 				}
3021 3021
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3022 3022
 				$NOTAM = new NOTAM();
@@ -3090,13 +3090,13 @@  discard block
 block discarded – undo
3090 3090
 		try {
3091 3091
 			$Connection = new Connection();
3092 3092
 			$sth = $Connection->db->prepare($query);
3093
-                        $sth->execute();
3094
-                } catch(PDOException $e) {
3095
-                        return "error : ".$e->getMessage();
3096
-                }
3097
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3098
-                if ($row['nb'] > 0) return false;
3099
-                else return true;
3093
+						$sth->execute();
3094
+				} catch(PDOException $e) {
3095
+						return "error : ".$e->getMessage();
3096
+				}
3097
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3098
+				if ($row['nb'] > 0) return false;
3099
+				else return true;
3100 3100
 	}
3101 3101
 
3102 3102
 	public static function insert_last_update() {
@@ -3105,10 +3105,10 @@  discard block
 block discarded – undo
3105 3105
 		try {
3106 3106
 			$Connection = new Connection();
3107 3107
 			$sth = $Connection->db->prepare($query);
3108
-                        $sth->execute();
3109
-                } catch(PDOException $e) {
3110
-                        return "error : ".$e->getMessage();
3111
-                }
3108
+						$sth->execute();
3109
+				} catch(PDOException $e) {
3110
+						return "error : ".$e->getMessage();
3111
+				}
3112 3112
 	}
3113 3113
 
3114 3114
 	public static function check_airspace_version($version) {
@@ -3116,13 +3116,13 @@  discard block
 block discarded – undo
3116 3116
 		try {
3117 3117
 			$Connection = new Connection();
3118 3118
 			$sth = $Connection->db->prepare($query);
3119
-                        $sth->execute(array(':version' => $version));
3120
-                } catch(PDOException $e) {
3121
-                        return "error : ".$e->getMessage();
3122
-                }
3123
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3124
-                if ($row['nb'] > 0) return true;
3125
-                else return false;
3119
+						$sth->execute(array(':version' => $version));
3120
+				} catch(PDOException $e) {
3121
+						return "error : ".$e->getMessage();
3122
+				}
3123
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3124
+				if ($row['nb'] > 0) return true;
3125
+				else return false;
3126 3126
 	}
3127 3127
 
3128 3128
 	public static function check_geoid_version($version) {
@@ -3130,13 +3130,13 @@  discard block
 block discarded – undo
3130 3130
 		try {
3131 3131
 			$Connection = new Connection();
3132 3132
 			$sth = $Connection->db->prepare($query);
3133
-                        $sth->execute(array(':version' => $version));
3134
-                } catch(PDOException $e) {
3135
-                        return "error : ".$e->getMessage();
3136
-                }
3137
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3138
-                if ($row['nb'] > 0) return true;
3139
-                else return false;
3133
+						$sth->execute(array(':version' => $version));
3134
+				} catch(PDOException $e) {
3135
+						return "error : ".$e->getMessage();
3136
+				}
3137
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3138
+				if ($row['nb'] > 0) return true;
3139
+				else return false;
3140 3140
 	}
3141 3141
 
3142 3142
 	public static function check_marine_identity_version($version) {
@@ -3237,10 +3237,10 @@  discard block
 block discarded – undo
3237 3237
 		try {
3238 3238
 			$Connection = new Connection();
3239 3239
 			$sth = $Connection->db->prepare($query);
3240
-                        $sth->execute(array(':version' => $version));
3241
-                } catch(PDOException $e) {
3242
-                        return "error : ".$e->getMessage();
3243
-                }
3240
+						$sth->execute(array(':version' => $version));
3241
+				} catch(PDOException $e) {
3242
+						return "error : ".$e->getMessage();
3243
+				}
3244 3244
 	}
3245 3245
 
3246 3246
 	public static function insert_marine_identity_version($version) {
@@ -3277,13 +3277,13 @@  discard block
 block discarded – undo
3277 3277
 		try {
3278 3278
 			$Connection = new Connection();
3279 3279
 			$sth = $Connection->db->prepare($query);
3280
-                        $sth->execute();
3281
-                } catch(PDOException $e) {
3282
-                        return "error : ".$e->getMessage();
3283
-                }
3284
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3285
-                if ($row['nb'] > 0) return false;
3286
-                else return true;
3280
+						$sth->execute();
3281
+				} catch(PDOException $e) {
3282
+						return "error : ".$e->getMessage();
3283
+				}
3284
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3285
+				if ($row['nb'] > 0) return false;
3286
+				else return true;
3287 3287
 	}
3288 3288
 
3289 3289
 	public static function insert_last_notam_update() {
@@ -3292,10 +3292,10 @@  discard block
 block discarded – undo
3292 3292
 		try {
3293 3293
 			$Connection = new Connection();
3294 3294
 			$sth = $Connection->db->prepare($query);
3295
-                        $sth->execute();
3296
-                } catch(PDOException $e) {
3297
-                        return "error : ".$e->getMessage();
3298
-                }
3295
+						$sth->execute();
3296
+				} catch(PDOException $e) {
3297
+						return "error : ".$e->getMessage();
3298
+				}
3299 3299
 	}
3300 3300
 
3301 3301
 	public static function check_last_airspace_update() {
@@ -3308,13 +3308,13 @@  discard block
 block discarded – undo
3308 3308
 		try {
3309 3309
 			$Connection = new Connection();
3310 3310
 			$sth = $Connection->db->prepare($query);
3311
-                        $sth->execute();
3312
-                } catch(PDOException $e) {
3313
-                        return "error : ".$e->getMessage();
3314
-                }
3315
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3316
-                if ($row['nb'] > 0) return false;
3317
-                else return true;
3311
+						$sth->execute();
3312
+				} catch(PDOException $e) {
3313
+						return "error : ".$e->getMessage();
3314
+				}
3315
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3316
+				if ($row['nb'] > 0) return false;
3317
+				else return true;
3318 3318
 	}
3319 3319
 
3320 3320
 	public static function insert_last_airspace_update() {
@@ -3323,10 +3323,10 @@  discard block
 block discarded – undo
3323 3323
 		try {
3324 3324
 			$Connection = new Connection();
3325 3325
 			$sth = $Connection->db->prepare($query);
3326
-                        $sth->execute();
3327
-                } catch(PDOException $e) {
3328
-                        return "error : ".$e->getMessage();
3329
-                }
3326
+						$sth->execute();
3327
+				} catch(PDOException $e) {
3328
+						return "error : ".$e->getMessage();
3329
+				}
3330 3330
 	}
3331 3331
 
3332 3332
 	public static function check_last_geoid_update() {
@@ -3339,13 +3339,13 @@  discard block
 block discarded – undo
3339 3339
 		try {
3340 3340
 			$Connection = new Connection();
3341 3341
 			$sth = $Connection->db->prepare($query);
3342
-                        $sth->execute();
3343
-                } catch(PDOException $e) {
3344
-                        return "error : ".$e->getMessage();
3345
-                }
3346
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3347
-                if ($row['nb'] > 0) return false;
3348
-                else return true;
3342
+						$sth->execute();
3343
+				} catch(PDOException $e) {
3344
+						return "error : ".$e->getMessage();
3345
+				}
3346
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3347
+				if ($row['nb'] > 0) return false;
3348
+				else return true;
3349 3349
 	}
3350 3350
 
3351 3351
 	public static function insert_last_geoid_update() {
@@ -3354,10 +3354,10 @@  discard block
 block discarded – undo
3354 3354
 		try {
3355 3355
 			$Connection = new Connection();
3356 3356
 			$sth = $Connection->db->prepare($query);
3357
-                        $sth->execute();
3358
-                } catch(PDOException $e) {
3359
-                        return "error : ".$e->getMessage();
3360
-                }
3357
+						$sth->execute();
3358
+				} catch(PDOException $e) {
3359
+						return "error : ".$e->getMessage();
3360
+				}
3361 3361
 	}
3362 3362
 
3363 3363
 	public static function check_last_owner_update() {
@@ -3463,13 +3463,13 @@  discard block
 block discarded – undo
3463 3463
 		try {
3464 3464
 			$Connection = new Connection();
3465 3465
 			$sth = $Connection->db->prepare($query);
3466
-                        $sth->execute();
3467
-                } catch(PDOException $e) {
3468
-                        return "error : ".$e->getMessage();
3469
-                }
3470
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3471
-                if ($row['nb'] > 0) return false;
3472
-                else return true;
3466
+						$sth->execute();
3467
+				} catch(PDOException $e) {
3468
+						return "error : ".$e->getMessage();
3469
+				}
3470
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3471
+				if ($row['nb'] > 0) return false;
3472
+				else return true;
3473 3473
 	}
3474 3474
 
3475 3475
 	public static function insert_last_schedules_update() {
@@ -3649,10 +3649,10 @@  discard block
 block discarded – undo
3649 3649
 		try {
3650 3650
 			$Connection = new Connection();
3651 3651
 			$sth = $Connection->db->prepare($query);
3652
-                        $sth->execute();
3653
-                } catch(PDOException $e) {
3654
-                        return "error : ".$e->getMessage();
3655
-                }
3652
+						$sth->execute();
3653
+				} catch(PDOException $e) {
3654
+						return "error : ".$e->getMessage();
3655
+				}
3656 3656
 	}
3657 3657
 	public static function delete_duplicateowner() {
3658 3658
 		global $globalDBdriver;
@@ -3664,10 +3664,10 @@  discard block
 block discarded – undo
3664 3664
 		try {
3665 3665
 			$Connection = new Connection();
3666 3666
 			$sth = $Connection->db->prepare($query);
3667
-                        $sth->execute();
3668
-                } catch(PDOException $e) {
3669
-                        return "error : ".$e->getMessage();
3670
-                }
3667
+						$sth->execute();
3668
+				} catch(PDOException $e) {
3669
+						return "error : ".$e->getMessage();
3670
+				}
3671 3671
 	}
3672 3672
 	
3673 3673
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		$ch = curl_init();
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
19
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
19
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
20 20
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
21 21
 			}
22 22
 		}
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
 		fclose($fp);
35 35
 	}
36 36
 
37
-	public static function gunzip($in_file,$out_file_name = '') {
37
+	public static function gunzip($in_file, $out_file_name = '') {
38 38
 		//echo $in_file.' -> '.$out_file_name."\n";
39 39
 		$buffer_size = 4096; // read 4kb at a time
40 40
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
41 41
 		if ($in_file != '' && file_exists($in_file)) {
42 42
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
43
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
44
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
45 45
 			else {
46 46
 				echo 'gzopen not available';
47 47
 				die;
48 48
 			}
49 49
 			$out_file = fopen($out_file_name, 'wb'); 
50
-			while(!gzeof($file)) {
50
+			while (!gzeof($file)) {
51 51
 				fwrite($out_file, gzread($file, $buffer_size));
52 52
 			}  
53 53
 			fclose($out_file);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		try {
72 72
 			self::$db_sqlite = new PDO('sqlite:'.$database);
73 73
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
74
-		} catch(PDOException $e) {
74
+		} catch (PDOException $e) {
75 75
 			return "error : ".$e->getMessage();
76 76
 		}
77 77
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88 88
                         $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
89
+                } catch (PDOException $e) {
90 90
                         return "error : ".$e->getMessage();
91 91
                 }
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		try {
98 98
                         $sth = update_db::$db_sqlite->prepare($query);
99 99
                         $sth->execute();
100
-                } catch(PDOException $e) {
100
+                } catch (PDOException $e) {
101 101
                         return "error : ".$e->getMessage();
102 102
                 }
103 103
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109 109
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
112 112
 				$sth_dest->execute($query_dest_values);
113 113
             		}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115
-		} catch(PDOException $e) {
115
+		} catch (PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
@@ -128,26 +128,26 @@  discard block
 block discarded – undo
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130 130
                         $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
131
+                } catch (PDOException $e) {
132 132
                         return "error : ".$e->getMessage();
133 133
                 }
134 134
 
135 135
     		if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138
-		if ($fh = fopen($database_file,"r")) {
138
+		if ($fh = fopen($database_file, "r")) {
139 139
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
140 140
 			$Connection = new Connection();
141 141
 			$sth_dest = $Connection->db->prepare($query_dest);
142 142
 			if ($globalTransaction) $Connection->db->beginTransaction();
143 143
 			while (!feof($fh)) {
144
-				$line = fgetcsv($fh,9999,',');
144
+				$line = fgetcsv($fh, 9999, ',');
145 145
 				if ($line[0] != '') {
146 146
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
147 147
 						try {
148
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
148
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
149 149
 							$sth_dest->execute($query_dest_values);
150
-						} catch(PDOException $e) {
150
+						} catch (PDOException $e) {
151 151
 							if ($globalTransaction) $Connection->db->rollBack(); 
152 152
 							return "error : ".$e->getMessage();
153 153
 						}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171 171
                         $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
172
+                } catch (PDOException $e) {
173 173
                         return "error : ".$e->getMessage();
174 174
                 }
175 175
 
@@ -177,24 +177,24 @@  discard block
 block discarded – undo
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
180
-		if ($fh = fopen($database_file,"r")) {
180
+		if ($fh = fopen($database_file, "r")) {
181 181
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
182 182
 			$Connection = new Connection();
183 183
 			$sth_dest = $Connection->db->prepare($query_dest);
184 184
 			try {
185 185
 				if ($globalTransaction) $Connection->db->beginTransaction();
186 186
 				while (!feof($fh)) {
187
-					$line = fgetcsv($fh,9999,',');
187
+					$line = fgetcsv($fh, 9999, ',');
188 188
 					if ($line[0] != '') {
189
-						$datebe = explode('  -  ',$line[2]);
189
+						$datebe = explode('  -  ', $line[2]);
190 190
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
191
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
191
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
192 192
 							$sth_dest->execute($query_dest_values);
193 193
 						}
194 194
 					}
195 195
 				}
196 196
 				if ($globalTransaction) $Connection->db->commit();
197
-			} catch(PDOException $e) {
197
+			} catch (PDOException $e) {
198 198
 				if ($globalTransaction) $Connection->db->rollBack(); 
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211 211
                         $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
212
+                } catch (PDOException $e) {
213 213
                         return "error : ".$e->getMessage();
214 214
                 }
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219 219
                         $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		try {
227 227
                         $sth = update_db::$db_sqlite->prepare($query);
228 228
                         $sth->execute();
229
-                } catch(PDOException $e) {
229
+                } catch (PDOException $e) {
230 230
                         return "error : ".$e->getMessage();
231 231
                 }
232 232
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
246
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
247 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
249
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
250 250
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252 252
             		}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254
-		} catch(PDOException $e) {
254
+		} catch (PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
256 256
 		}
257 257
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263 263
                         $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
264
+                } catch (PDOException $e) {
265 265
                         return "error : ".$e->getMessage();
266 266
                 }
267 267
 		return '';
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278 278
                         $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
279
+                } catch (PDOException $e) {
280 280
                         return "error : ".$e->getMessage();
281 281
                 }
282 282
 		
283
-		if ($fh = fopen($database_file,"r")) {
283
+		if ($fh = fopen($database_file, "r")) {
284 284
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
285 285
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
286 286
 		
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291 291
             			while (!feof($fh)) {
292 292
             				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
293
+            				$line = $Common->hex2str(fgets($fh, 9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
295
+            				$values['ModeS'] = substr($line, 0, 6);
296
+            				$values['Registration'] = trim(substr($line, 69, 6));
297
+            				$aircraft_name = trim(substr($line, 48, 6));
298 298
             				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
299
+            				$aircraft_name_split = explode(' ', $aircraft_name);
300 300
             				$search_more = '';
301 301
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302 302
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	            				if (isset($result['icao']) && $result['icao'] != '') {
309 309
 	            				    $values['ICAOTypeCode'] = $result['icao'];
310 310
 	            				} 
311
-					} catch(PDOException $e) {
311
+					} catch (PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
314 314
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
315 315
 					// Add data to db
316 316
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 317
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
318
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
318
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
319 319
 						//print_r($query_dest_values);
320 320
 						$sth_dest->execute($query_dest_values);
321 321
 					}
322 322
 				}
323 323
 				if ($globalTransaction) $Connection->db->commit();
324
-			} catch(PDOException $e) {
324
+			} catch (PDOException $e) {
325 325
 				return "error : ".$e->getMessage();
326 326
 			}
327 327
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333 333
                         $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
334
+                } catch (PDOException $e) {
335 335
                         return "error : ".$e->getMessage();
336 336
                 }
337 337
 		return '';
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347 347
                         $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
348
+                } catch (PDOException $e) {
349 349
                         return "error : ".$e->getMessage();
350 350
                 }
351 351
 		
352
-		if ($fh = fopen($database_file,"r")) {
352
+		if ($fh = fopen($database_file, "r")) {
353 353
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
354 354
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
355 355
 		
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 			$sth_dest = $Connection->db->prepare($query_dest);
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360
-				$tmp = fgetcsv($fh,9999,',',"'");
360
+				$tmp = fgetcsv($fh, 9999, ',', "'");
361 361
             			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
362
+            				$line = fgetcsv($fh, 9999, ',', "'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
             				$values['ICAOTypeCode'] = '';
369 369
             				$aircraft_name = $line[2];
370 370
             				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
371
+            				$aircraft_name_split = explode(' ', $aircraft_name);
372 372
             				$search_more = '';
373 373
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374 374
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -377,20 +377,20 @@  discard block
 block discarded – undo
377 377
                                     		$sth_search->execute();
378 378
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379 379
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380
-					} catch(PDOException $e) {
380
+					} catch (PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
383 383
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
384 384
 					// Add data to db
385 385
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
386 386
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
387
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
387
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
388 388
 						//print_r($query_dest_values);
389 389
 						$sth_dest->execute($query_dest_values);
390 390
 					}
391 391
 				}
392 392
 				if ($globalTransaction) $Connection->db->commit();
393
-			} catch(PDOException $e) {
393
+			} catch (PDOException $e) {
394 394
 				return "error : ".$e->getMessage();
395 395
 			}
396 396
 		}
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402 402
                         $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
403
+                } catch (PDOException $e) {
404 404
                         return "error : ".$e->getMessage();
405 405
                 }
406 406
 		return '';
407 407
 	}
408 408
 
409
-	public static function retrieve_owner($database_file,$country = 'F') {
409
+	public static function retrieve_owner($database_file, $country = 'F') {
410 410
 		global $globalTransaction, $globalMasterSource;
411 411
 		//$query = 'TRUNCATE TABLE aircraft_modes';
412 412
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416 416
                         $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
417
+                } catch (PDOException $e) {
418 418
                         return "error : ".$e->getMessage();
419 419
                 }
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422
-		if ($fh = fopen($database_file,"r")) {
422
+		if ($fh = fopen($database_file, "r")) {
423 423
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425 425
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 			$sth_modes = $Connection->db->prepare($query_modes);
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432
-				$tmp = fgetcsv($fh,9999,',','"');
432
+				$tmp = fgetcsv($fh, 9999, ',', '"');
433 433
             			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
434
+            				$line = fgetcsv($fh, 9999, ',', '"');
435 435
             				$values = array();
436 436
             				//print_r($line);
437 437
             				if ($country == 'F') {
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             				    $values['base'] = $line[4];
440 440
             				    $values['owner'] = $line[5];
441 441
             				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
442
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
443 443
 					    $values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445 445
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             				    $values['base'] = $line[3];
448 448
             				    $values['owner'] = $line[2];
449 449
             				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
450
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
451 451
 					    $values['cancel'] = '';
452 452
 					    $values['modes'] = $line[7];
453 453
 					    $values['icao'] = $line[8];
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             				    $values['base'] = null;
468 468
             				    $values['owner'] = $line[5];
469 469
             				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
470
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
471 471
 					    $values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473 473
 					    // TODO : add modeS & reg to aircraft_modes
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
             				    $values['base'] = null;
476 476
             				    $values['owner'] = $line[12];
477 477
             				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
478
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
479 479
 
480 480
 					    $values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -495,28 +495,28 @@  discard block
 block discarded – undo
495 495
             				    $values['base'] = null;
496 496
             				    $values['owner'] = $line[8];
497 497
             				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
498
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
499 499
 					    $values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501 501
             				    $values['registration'] = $line[0];
502 502
             				    $values['base'] = null;
503 503
             				    $values['owner'] = $line[4];
504 504
             				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
505
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
506 506
 					    $values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508 508
             				    $values['registration'] = $line[0];
509 509
             				    $values['base'] = null;
510 510
             				    $values['owner'] = $line[4];
511 511
             				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
512
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
513 513
 					    $values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515 515
             				    $values['registration'] = $line[0];
516 516
             				    $values['base'] = null;
517 517
             				    $values['owner'] = $line[3];
518 518
             				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
519
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
520 520
 					    $values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522 522
             				    $values['registration'] = $line[0];
@@ -530,18 +530,18 @@  discard block
 block discarded – undo
530 530
             				    $values['registration'] = $line[0];
531 531
             				    $values['base'] = null;
532 532
             				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
533
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
534
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
535 535
 					    $values['modes'] = $line[4];
536 536
 					    $values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538 538
             				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
539
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
540 540
 					    $values['modes'] = $line[5];
541 541
 					    $values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543 543
             				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
544
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
545 545
 					    $values['modes'] = $line[4];
546 546
 					    $values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -552,17 +552,17 @@  discard block
 block discarded – undo
552 552
 					    $values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
555
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
556 556
 						$sth_dest->execute($query_dest_values);
557 557
 					}
558 558
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
559 559
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
560
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
560
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
561 561
 						$sth_modes->execute($query_modes_values);
562 562
 					}
563 563
 				}
564 564
 				if ($globalTransaction) $Connection->db->commit();
565
-			} catch(PDOException $e) {
565
+			} catch (PDOException $e) {
566 566
 				return "error : ".$e->getMessage();
567 567
 			}
568 568
 		}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		if ($globalTransaction) $Connection->db->beginTransaction();
701 701
   
702 702
 		$i = 0;
703
-		while($row = sparql_fetch_array($result))
703
+		while ($row = sparql_fetch_array($result))
704 704
 		{
705 705
 			if ($i >= 1) {
706 706
 			//print_r($row);
@@ -720,33 +720,33 @@  discard block
 block discarded – undo
720 720
 				$row['image'] = '';
721 721
 				$row['image_thumb'] = '';
722 722
 			} else {
723
-				$image = str_replace(' ','_',$row['image']);
723
+				$image = str_replace(' ', '_', $row['image']);
724 724
 				$digest = md5($image);
725
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
726
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
727
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
728
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
725
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
726
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
727
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
728
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
729 729
 			}
730 730
 			
731
-			$country = explode('-',$row['country']);
731
+			$country = explode('-', $row['country']);
732 732
 			$row['country'] = $country[0];
733 733
 			
734 734
 			$row['type'] = trim($row['type']);
735
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
735
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
736 736
 				$row['type'] = 'military';
737 737
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
738 738
 				$row['type'] = 'small_airport';
739 739
 			}
740 740
 			
741
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
742
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
741
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
742
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
743 743
 			//print_r($query_dest_values);
744 744
 			
745 745
 			if ($row['icao'] != '') {
746 746
 				try {
747 747
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
748 748
 					$sth->execute(array(':icao' => $row['icao']));
749
-				} catch(PDOException $e) {
749
+				} catch (PDOException $e) {
750 750
 					return "error : ".$e->getMessage();
751 751
 				}
752 752
 					if ($sth->fetchColumn() > 0) {
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
755 755
 						try {
756 756
 							$sth = $Connection->db->prepare($query);
757
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
758
-						} catch(PDOException $e) {
757
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
758
+						} catch (PDOException $e) {
759 759
 							return "error : ".$e->getMessage();
760 760
 						}
761 761
 						echo $row['icao'].' : '.$row['type']."\n";
762 762
 					} else {
763 763
 						try {
764 764
 							$sth_dest->execute($query_dest_values);
765
-						} catch(PDOException $e) {
765
+						} catch (PDOException $e) {
766 766
 							return "error : ".$e->getMessage();
767 767
 						}
768 768
 					}
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		echo "Download data from ourairports.com...\n";
814 814
 		$delimiter = ',';
815 815
 		$out_file = $tmp_dir.'airports.csv';
816
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
816
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
817 817
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
818 818
 		echo "Add data from ourairports.com...\n";
819 819
 
@@ -824,33 +824,33 @@  discard block
 block discarded – undo
824 824
 			//$Connection->db->beginTransaction();
825 825
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 826
 			{
827
-				if(!$header) $header = $row;
827
+				if (!$header) $header = $row;
828 828
 				else {
829 829
 					$data = array();
830 830
 					$data = array_combine($header, $row);
831 831
 					try {
832 832
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
833 833
 						$sth->execute(array(':icao' => $data['ident']));
834
-					} catch(PDOException $e) {
834
+					} catch (PDOException $e) {
835 835
 						return "error : ".$e->getMessage();
836 836
 					}
837 837
 					if ($sth->fetchColumn() > 0) {
838 838
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
839 839
 						try {
840 840
 							$sth = $Connection->db->prepare($query);
841
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
842
-						} catch(PDOException $e) {
841
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
842
+						} catch (PDOException $e) {
843 843
 							return "error : ".$e->getMessage();
844 844
 						}
845 845
 					} else {
846 846
 						if ($data['gps_code'] == $data['ident']) {
847 847
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
848 848
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
849
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
849
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
850 850
 						try {
851 851
 							$sth = $Connection->db->prepare($query);
852 852
 							$sth->execute($query_values);
853
-						} catch(PDOException $e) {
853
+						} catch (PDOException $e) {
854 854
 							return "error : ".$e->getMessage();
855 855
 						}
856 856
 						$i++;
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		
866 866
 		echo "Download data from another free database...\n";
867 867
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
868
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
869 869
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
870 870
 		update_db::unzip($out_file);
871 871
 		$header = NULL;
@@ -877,15 +877,15 @@  discard block
 block discarded – undo
877 877
 			//$Connection->db->beginTransaction();
878 878
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 879
 			{
880
-				if(!$header) $header = $row;
880
+				if (!$header) $header = $row;
881 881
 				else {
882 882
 					$data = $row;
883 883
 
884 884
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
885 885
 					try {
886 886
 						$sth = $Connection->db->prepare($query);
887
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
888
-					} catch(PDOException $e) {
887
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
888
+					} catch (PDOException $e) {
889 889
 						return "error : ".$e->getMessage();
890 890
 					}
891 891
 				}
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 		try {
900 900
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
901 901
 			$sth->execute();
902
-		} catch(PDOException $e) {
902
+		} catch (PDOException $e) {
903 903
 			return "error : ".$e->getMessage();
904 904
 		}
905 905
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
906 906
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
907 907
 			try {
908 908
 				$sth2 = $Connection->db->prepare($query2);
909
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
910
-			} catch(PDOException $e) {
909
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
910
+			} catch (PDOException $e) {
911 911
 				return "error : ".$e->getMessage();
912 912
 			}
913 913
 		}
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930 930
                         $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
931
+                } catch (PDOException $e) {
932 932
                         return "error : ".$e->getMessage();
933 933
                 }
934 934
 
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
946 946
 			{
947 947
 				$i++;
948
-				if($i > 12) {
948
+				if ($i > 12) {
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
                                                 //echo substr($operator, 0, 2)."\n";;
954 954
                                                 if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956
-							$operator = $airline_array[0]['icao'].substr($operator,2);
956
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
957 957
                                                 }
958 958
                                         }
959 959
 					
@@ -961,14 +961,14 @@  discard block
 block discarded – undo
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962 962
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963 963
                                                 if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
964
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
965 965
                                             	}
966 966
                                         }
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
970
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
-					} catch(PDOException $e) {
970
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
+					} catch (PDOException $e) {
972 972
 						return "error : ".$e->getMessage();
973 973
 					}
974 974
 				}
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 			$Connection = new Connection();
987 987
 			$sth = $Connection->db->prepare($query);
988 988
 			$sth->execute(array(':source' => 'website_fam'));
989
-		} catch(PDOException $e) {
989
+		} catch (PDOException $e) {
990 990
 			return "error : ".$e->getMessage();
991 991
 		}
992 992
 		//update_db::unzip($out_file);
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
1005 1005
 					try {
1006 1006
 						$sth = $Connection->db->prepare($query);
1007
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
-					} catch(PDOException $e) {
1007
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
+					} catch (PDOException $e) {
1009 1009
 						return "error : ".$e->getMessage();
1010 1010
 					}
1011 1011
 				}
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030 1030
                         $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1031
+                } catch (PDOException $e) {
1032 1032
                         return "error : ".$e->getMessage();
1033 1033
                 }
1034 1034
 
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039 1039
                         $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1040
+                } catch (PDOException $e) {
1041 1041
                         return "error : ".$e->getMessage();
1042 1042
                 }
1043 1043
 
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1055 1055
 					try {
1056 1056
 						$sths = $Connection->db->prepare($query_search);
1057
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1058
-					} catch(PDOException $e) {
1057
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1058
+					} catch (PDOException $e) {
1059 1059
 						return "error s : ".$e->getMessage();
1060 1060
 					}
1061 1061
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
 							//}
1069 1069
 						try {
1070 1070
 							$sthi = $Connection->db->prepare($queryi);
1071
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1072
-						} catch(PDOException $e) {
1071
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1072
+						} catch (PDOException $e) {
1073 1073
 							return "error u : ".$e->getMessage();
1074 1074
 						}
1075 1075
 					} else {
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 						try {
1078 1078
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1079 1079
 							$sthsm->execute(array(':mfr' => $data[2]));
1080
-						} catch(PDOException $e) {
1080
+						} catch (PDOException $e) {
1081 1081
 							return "error mfr : ".$e->getMessage();
1082 1082
 						}
1083 1083
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1088
 							try {
1089 1089
 								$sthf = $Connection->db->prepare($queryf);
1090
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1091
-							} catch(PDOException $e) {
1090
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1091
+							} catch (PDOException $e) {
1092 1092
 								return "error f : ".$e->getMessage();
1093 1093
 							}
1094 1094
 						}
@@ -1098,13 +1098,13 @@  discard block
 block discarded – undo
1098 1098
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1099
 						try {
1100 1100
 							$sth = $Connection->db->prepare($query);
1101
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1102
-						} catch(PDOException $e) {
1101
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1102
+						} catch (PDOException $e) {
1103 1103
 							return "error i : ".$e->getMessage();
1104 1104
 						}
1105 1105
 					}
1106 1106
 				}
1107
-				if ($i % 90 == 0) {
1107
+				if ($i%90 == 0) {
1108 1108
 					if ($globalTransaction) $Connection->db->commit();
1109 1109
 					if ($globalTransaction) $Connection->db->beginTransaction();
1110 1110
 				}
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			$Connection = new Connection();
1124 1124
 			$sth = $Connection->db->prepare($query);
1125 1125
 			$sth->execute(array(':source' => 'website_fam'));
1126
-		} catch(PDOException $e) {
1126
+		} catch (PDOException $e) {
1127 1127
 			return "error : ".$e->getMessage();
1128 1128
 		}
1129 1129
 		$delimiter = "\t";
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1140
 					try {
1141 1141
 						$sth = $Connection->db->prepare($query);
1142
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1143
-					} catch(PDOException $e) {
1142
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1143
+					} catch (PDOException $e) {
1144 1144
 						return "error : ".$e->getMessage();
1145 1145
 					}
1146 1146
 				}
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
 		try {
1173 1173
 			$sth = $Connection->db->prepare($query);
1174 1174
 			$sth->execute();
1175
-		} catch(PDOException $e) {
1175
+		} catch (PDOException $e) {
1176 1176
 			return "error : ".$e->getMessage();
1177 1177
 		}
1178 1178
 		$delimiter = "\t";
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1188
 					try {
1189 1189
 						$sth = $Connection->db->prepare($query);
1190
-						$sth->execute(array(':name' => $data[0],':alias' => $data[1],':iata' => $data[2],':icao' => $data[3], ':callsign' => $data[4],':country' => $data[5],':active' => $data[6],':type' => $data[7],':home' => $data[8],':wikipedia_link' => $data[9],':alliance' => $data[10],':ban_eu' => $data[11]));
1191
-					} catch(PDOException $e) {
1190
+						$sth->execute(array(':name' => $data[0], ':alias' => $data[1], ':iata' => $data[2], ':icao' => $data[3], ':callsign' => $data[4], ':country' => $data[5], ':active' => $data[6], ':type' => $data[7], ':home' => $data[8], ':wikipedia_link' => $data[9], ':alliance' => $data[10], ':ban_eu' => $data[11]));
1191
+					} catch (PDOException $e) {
1192 1192
 						return "error : ".$e->getMessage();
1193 1193
 					}
1194 1194
 				}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 			$Connection = new Connection();
1217 1217
 			$sth = $Connection->db->prepare($query);
1218 1218
                         $sth->execute(array(':source' => 'website_fam'));
1219
-                } catch(PDOException $e) {
1219
+                } catch (PDOException $e) {
1220 1220
                         return "error : ".$e->getMessage();
1221 1221
                 }
1222 1222
 
@@ -1232,8 +1232,8 @@  discard block
 block discarded – undo
1232 1232
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1233 1233
 					try {
1234 1234
 						$sth = $Connection->db->prepare($query);
1235
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1236
-					} catch(PDOException $e) {
1235
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1236
+					} catch (PDOException $e) {
1237 1237
 						//print_r($data);
1238 1238
 						return "error : ".$e->getMessage();
1239 1239
 					}
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 			$Connection = new Connection();
1254 1254
 			$sth = $Connection->db->prepare($query);
1255 1255
 			$sth->execute(array(':source' => 'website_fam'));
1256
-		} catch(PDOException $e) {
1256
+		} catch (PDOException $e) {
1257 1257
 			return "error : ".$e->getMessage();
1258 1258
 		}
1259 1259
 		$delimiter = "\t";
@@ -1269,13 +1269,13 @@  discard block
 block discarded – undo
1269 1269
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1270 1270
 					try {
1271 1271
 						$sth = $Connection->db->prepare($query);
1272
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1273
-					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1272
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1273
+					} catch (PDOException $e) {
1274
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1275 1275
 						die();
1276 1276
 					}
1277 1277
 				}
1278
-				if ($globalTransaction && $i % 2000 == 0) {
1278
+				if ($globalTransaction && $i%2000 == 0) {
1279 1279
 					$Connection->db->commit();
1280 1280
 					if ($globalDebug) echo '.';
1281 1281
 					$Connection->db->beginTransaction();
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 			$Connection = new Connection();
1296 1296
 			$sth = $Connection->db->prepare($query);
1297 1297
                         $sth->execute();
1298
-                } catch(PDOException $e) {
1298
+                } catch (PDOException $e) {
1299 1299
                         return "error : ".$e->getMessage();
1300 1300
                 }
1301 1301
 
@@ -1316,8 +1316,8 @@  discard block
 block discarded – undo
1316 1316
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1317 1317
 					try {
1318 1318
 						$sth = $Connection->db->prepare($query);
1319
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1320
-					} catch(PDOException $e) {
1319
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1320
+					} catch (PDOException $e) {
1321 1321
 						return "error : ".$e->getMessage();
1322 1322
 					}
1323 1323
 				}
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
 			$Connection = new Connection();
1337 1337
 			$sth = $Connection->db->prepare($query);
1338 1338
 			$sth->execute();
1339
-		} catch(PDOException $e) {
1339
+		} catch (PDOException $e) {
1340 1340
 			return "error : ".$e->getMessage();
1341 1341
 		}
1342 1342
 		$delimiter = "\t";
@@ -1353,8 +1353,8 @@  discard block
 block discarded – undo
1353 1353
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1354 1354
 					try {
1355 1355
 						$sth = $Connection->db->prepare($query);
1356
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1357
-					} catch(PDOException $e) {
1356
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1357
+					} catch (PDOException $e) {
1358 1358
 						return "error : ".$e->getMessage();
1359 1359
 					}
1360 1360
 				}
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 			$Connection = new Connection();
1374 1374
 			$sth = $Connection->db->prepare($query);
1375 1375
 			$sth->execute();
1376
-		} catch(PDOException $e) {
1376
+		} catch (PDOException $e) {
1377 1377
 			return "error : ".$e->getMessage();
1378 1378
 		}
1379 1379
 
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
 					try {
1390 1390
 						$sth = $Connection->db->prepare($query);
1391 1391
 						$sth->execute(array(':icao' => $icao));
1392
-					} catch(PDOException $e) {
1392
+					} catch (PDOException $e) {
1393 1393
 						return "error : ".$e->getMessage();
1394 1394
 					}
1395 1395
 				}
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		return '';
1401 1401
         }
1402 1402
 
1403
-	public static function tle($filename,$tletype) {
1403
+	public static function tle($filename, $tletype) {
1404 1404
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1405 1405
 		global $tmp_dir, $globalTransaction;
1406 1406
 		//$Spotter = new Spotter();
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 			$Connection = new Connection();
1411 1411
 			$sth = $Connection->db->prepare($query);
1412 1412
                         $sth->execute(array(':source' => $filename));
1413
-                } catch(PDOException $e) {
1413
+                } catch (PDOException $e) {
1414 1414
                         return "error : ".$e->getMessage();
1415 1415
                 }
1416 1416
 		
@@ -1435,8 +1435,8 @@  discard block
 block discarded – undo
1435 1435
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1436 1436
 					try {
1437 1437
 						$sth = $Connection->db->prepare($query);
1438
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1439
-					} catch(PDOException $e) {
1438
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1439
+					} catch (PDOException $e) {
1440 1440
 						return "error : ".$e->getMessage();
1441 1441
 					}
1442 1442
 
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 			$Connection = new Connection();
1457 1457
 			$sth = $Connection->db->prepare($query);
1458 1458
 			$sth->execute(array(':source' => $filename));
1459
-		} catch(PDOException $e) {
1459
+		} catch (PDOException $e) {
1460 1460
 			return "error : ".$e->getMessage();
1461 1461
 		}
1462 1462
 		
@@ -1466,13 +1466,13 @@  discard block
 block discarded – undo
1466 1466
 			$i = 0;
1467 1467
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1468 1468
 			//$Connection->db->beginTransaction();
1469
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1469
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1470 1470
 			{
1471 1471
 				if ($i > 0 && $data[0] != '') {
1472 1472
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1473
-					$period = str_replace(',','',$data[14]);
1474
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1475
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1473
+					$period = str_replace(',', '', $data[14]);
1474
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1475
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1476 1476
 					else $launch_date = NULL;
1477 1477
 					$data = array_map(function($value) {
1478 1478
 						return trim($value) === '' ? null : $value;
@@ -1482,8 +1482,8 @@  discard block
 block discarded – undo
1482 1482
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1483 1483
 					try {
1484 1484
 						$sth = $Connection->db->prepare($query);
1485
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',','',$data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',','',$data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+',','),'',$data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',','-1900',' (BOL)',' (EOL)'),'',$data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',',' (BOL)',' (EOL)'),'',$data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20],':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1486
-					} catch(PDOException $e) {
1485
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',', '', $data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',', '', $data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+', ','), '', $data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',', '-1900', ' (BOL)', ' (EOL)'), '', $data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',', ' (BOL)', ' (EOL)'), '', $data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20], ':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1486
+					} catch (PDOException $e) {
1487 1487
 						return "error : ".$e->getMessage();
1488 1488
 					}
1489 1489
 				}
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1524 1524
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1525 1525
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1526
-			'EST' => array('country' => 'Estonia','owner' => ''),
1526
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1527 1527
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1528 1528
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1529 1529
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1647,10 +1647,10 @@  discard block
 block discarded – undo
1647 1647
 			{
1648 1648
 				if ($data != '') {
1649 1649
 				$result = array();
1650
-				$result['cospar'] = trim(substr($data,0,11));
1651
-				$result['norad'] = trim(substr($data,13,6));
1652
-				$result['operational'] = trim(substr($data,21,1));
1653
-				$result['name'] = trim(substr($data,23,24));
1650
+				$result['cospar'] = trim(substr($data, 0, 11));
1651
+				$result['norad'] = trim(substr($data, 13, 6));
1652
+				$result['operational'] = trim(substr($data, 21, 1));
1653
+				$result['name'] = trim(substr($data, 23, 24));
1654 1654
 				/*
1655 1655
 				    * R/B(1) = Rocket body, first stage
1656 1656
 				    * R/B(2) = Rocket body, second stage
@@ -1662,29 +1662,29 @@  discard block
 block discarded – undo
1662 1662
 				    * An ampersand (&) indicates two or more objects are attached
1663 1663
 				*/
1664 1664
 				
1665
-				$owner_code = trim(substr($data,49,5));
1665
+				$owner_code = trim(substr($data, 49, 5));
1666 1666
 				
1667 1667
 				if (!isset($satcat_sources[$owner_code])) {
1668 1668
 					echo $data;
1669 1669
 					echo 'owner_code: '.$owner_code."\n";
1670 1670
 				}
1671
-				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1672
-					echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1671
+				if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1672
+					echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n";
1673 1673
 				}
1674 1674
 				
1675
-				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
1675
+				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1676 1676
 					$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1677 1677
 					$result['owner'] = $satcat_sources[$owner_code]['owner'];
1678
-					$result['launch_date'] = trim(substr($data,56,10));
1679
-					$launch_site_code = trim(substr($data,68,5));
1678
+					$result['launch_date'] = trim(substr($data, 56, 10));
1679
+					$launch_site_code = trim(substr($data, 68, 5));
1680 1680
 					$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1681
-					$result['lifetime'] = trim(substr($data,75,10));
1682
-					$result['period'] = trim(substr($data,87,7));
1683
-					$result['inclination'] = trim(substr($data,96,5));
1684
-					$result['apogee'] = trim(substr($data,103,6));
1685
-					$result['perigee'] = trim(substr($data,111,6));
1681
+					$result['lifetime'] = trim(substr($data, 75, 10));
1682
+					$result['period'] = trim(substr($data, 87, 7));
1683
+					$result['inclination'] = trim(substr($data, 96, 5));
1684
+					$result['apogee'] = trim(substr($data, 103, 6));
1685
+					$result['perigee'] = trim(substr($data, 111, 6));
1686 1686
 					//$result['radarcross'] = trim(substr($data,119,8));
1687
-					$result['status'] = trim(substr($data,129,3));
1687
+					$result['status'] = trim(substr($data, 129, 3));
1688 1688
 					//print_r($result);
1689 1689
 					$result = array_map(function($value) {
1690 1690
 						return trim($value) === '' ? null : $value;
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
 							$sth = $Connection->db->prepare($query);
1698 1698
 							$sth->execute(array(':cospar' => $result['cospar']));
1699 1699
 							$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1700
-						} catch(PDOException $e) {
1700
+						} catch (PDOException $e) {
1701 1701
 							return "error : ".$e->getMessage();
1702 1702
 						}
1703 1703
 						if (empty($exist)) {
@@ -1709,10 +1709,10 @@  discard block
 block discarded – undo
1709 1709
 								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710 1710
 								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711 1711
 								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1712
+								    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713 1713
 								    )
1714 1714
 								);
1715
-							} catch(PDOException $e) {
1715
+							} catch (PDOException $e) {
1716 1716
 								return "error : ".$e->getMessage();
1717 1717
 							}
1718 1718
 						} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1720,8 +1720,8 @@  discard block
 block discarded – undo
1720 1720
 							try {
1721 1721
 								$Connection = new Connection();
1722 1722
 								$sth = $Connection->db->prepare($query);
1723
-								$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1724
-							} catch(PDOException $e) {
1723
+								$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1724
+							} catch (PDOException $e) {
1725 1725
 								return "error : ".$e->getMessage();
1726 1726
 							}
1727 1727
 						}
@@ -1840,13 +1840,13 @@  discard block
 block discarded – undo
1840 1840
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1841 1841
 			{
1842 1842
 				$i++;
1843
-				if($i > 3 && count($row) > 2) {
1843
+				if ($i > 3 && count($row) > 2) {
1844 1844
 					$data = array_values(array_filter($row));
1845 1845
 					$cntdata = count($data);
1846 1846
 					if ($cntdata > 10) {
1847 1847
 						$value = $data[9];
1848 1848
 						
1849
-						for ($i =10;$i < $cntdata;$i++) {
1849
+						for ($i = 10; $i < $cntdata; $i++) {
1850 1850
 							$value .= ' '.$data[$i];
1851 1851
 						}
1852 1852
 						$data[9] = $value;
@@ -1856,8 +1856,8 @@  discard block
 block discarded – undo
1856 1856
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1857 1857
 						try {
1858 1858
 							$sth = $Connection->db->prepare($query);
1859
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1860
-						} catch(PDOException $e) {
1859
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1860
+						} catch (PDOException $e) {
1861 1861
 							return "error : ".$e->getMessage();
1862 1862
 						}
1863 1863
 					}
@@ -1874,16 +1874,16 @@  discard block
 block discarded – undo
1874 1874
 		require_once(dirname(__FILE__).'/../require/class.Source.php');
1875 1875
 		$delimiter = ',';
1876 1876
 		$Common = new Common();
1877
-		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv');
1877
+		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv');
1878 1878
 		$Connection = new Connection();
1879 1879
 		$Source = new Source();
1880 1880
 		$Source->deleteLocationByType('fires');
1881 1881
 		$i = 0;
1882
-		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1883
-			while (($row = fgetcsv($handle,1000)) !== false) {
1882
+		if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) {
1883
+			while (($row = fgetcsv($handle, 1000)) !== false) {
1884 1884
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1885
-					$description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]);
1886
-					$Source->addLocation('',$row[0],$row[1],null,'','','fires','fire.png','fires',0,0,$row[5].' '.substr($row[6],0,2).':'.substr($row[6],2,2),json_encode($description));
1885
+					$description = array('bright_t14' => $row[2], 'scan' => $row[3], 'track' => $row[4], 'sat' => $row[7], 'confidence' => $row[8], 'version' => $row[9], 'bright_t15' => $row[10], 'frp' => $row[11], 'daynight' => $row[12]);
1886
+					$Source->addLocation('', $row[0], $row[1], null, '', '', 'fires', 'fire.png', 'fires', 0, 0, $row[5].' '.substr($row[6], 0, 2).':'.substr($row[6], 2, 2), json_encode($description));
1887 1887
 				}
1888 1888
 				$i++;
1889 1889
 			}
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
 			$Connection = new Connection();
1900 1900
 			$sth = $Connection->db->prepare($query);
1901 1901
 			$sth->execute();
1902
-		} catch(PDOException $e) {
1902
+		} catch (PDOException $e) {
1903 1903
 			return "error : ".$e->getMessage();
1904 1904
 		}
1905 1905
 		$header = NULL;
@@ -1910,12 +1910,12 @@  discard block
 block discarded – undo
1910 1910
 			if ($globalTransaction) $Connection->db->beginTransaction();
1911 1911
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1912 1912
 			{
1913
-				if(count($row) > 1) {
1913
+				if (count($row) > 1) {
1914 1914
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1915 1915
 					try {
1916 1916
 						$sth = $Connection->db->prepare($query);
1917
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1918
-					} catch(PDOException $e) {
1917
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1918
+					} catch (PDOException $e) {
1919 1919
 						return "error : ".$e->getMessage();
1920 1920
 					}
1921 1921
 				}
@@ -1935,21 +1935,21 @@  discard block
 block discarded – undo
1935 1935
 			try {
1936 1936
 				$sth = $Connection->db->prepare($query);
1937 1937
                     		$sth->execute();
1938
-	                } catch(PDOException $e) {
1938
+	                } catch (PDOException $e) {
1939 1939
 				return "error : ".$e->getMessage();
1940 1940
 	                }
1941 1941
 	        }
1942 1942
 
1943 1943
 
1944
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1944
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1945 1945
 		else {
1946
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1946
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1947 1947
 			$query = "CREATE EXTENSION postgis";
1948
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1948
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1949 1949
 			try {
1950 1950
 				$sth = $Connection->db->prepare($query);
1951 1951
 				$sth->execute();
1952
-			} catch(PDOException $e) {
1952
+			} catch (PDOException $e) {
1953 1953
 				return "error : ".$e->getMessage();
1954 1954
 			}
1955 1955
 		}
@@ -1962,13 +1962,13 @@  discard block
 block discarded – undo
1962 1962
 		include_once('class.create_db.php');
1963 1963
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1964 1964
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1965
-		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1965
+		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5');
1966 1966
 		$error = '';
1967 1967
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
1968
-			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1968
+			$notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1969 1969
 			$notam_md5 = $notam_md5_file[0];
1970 1970
 			if (!update_db::check_notam_version($notam_md5)) {
1971
-				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1971
+				update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1972 1972
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
1973 1973
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1974 1974
 						if ($globalDebug) echo "Gunzip...";
@@ -2004,14 +2004,14 @@  discard block
 block discarded – undo
2004 2004
 			try {
2005 2005
 				$sth = $Connection->db->prepare($query);
2006 2006
             	        	$sth->execute();
2007
-	                } catch(PDOException $e) {
2007
+	                } catch (PDOException $e) {
2008 2008
     	                	echo "error : ".$e->getMessage();
2009 2009
 	                }
2010 2010
 		}
2011 2011
 		if ($globalDBdriver == 'mysql') {
2012
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
2012
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
2013 2013
 		} else {
2014
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
2014
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
2015 2015
 		}
2016 2016
 		$error = create_db::import_file($tmp_dir.'countries.sql');
2017 2017
 		return $error;
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
 //		update_db::unzip($tmp_dir.'AptNav.zip');
2025 2025
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
2026 2026
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
2027
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
2027
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
2028 2028
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
2029 2029
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
2030 2030
 		return $error;
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2046 2046
 				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2047 2047
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2048
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2048
+					if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2049 2049
 				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2050 2050
 			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2051 2051
 		} else $error = "ZIP module not loaded but required for IVAO.";
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
 		global $tmp_dir, $globalDebug;
2060 2060
 		$error = '';
2061 2061
 		if ($globalDebug) echo "Routes : Download...";
2062
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2062
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
2063 2063
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2064 2064
 			if ($globalDebug) echo "Gunzip...";
2065 2065
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -2075,7 +2075,7 @@  discard block
 block discarded – undo
2075 2075
 		global $tmp_dir, $globalDebug;
2076 2076
 		$error = '';
2077 2077
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
2078
-		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2078
+		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
2079 2079
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2080 2080
 			if ($globalDebug) echo "Gunzip...";
2081 2081
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
 		global $tmp_dir, $globalDebug;
2092 2092
 		$error = '';
2093 2093
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
2094
-		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2094
+		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
2095 2095
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2096 2096
 			if ($globalDebug) echo "Gunzip...";
2097 2097
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
 */
2120 2120
 		if ($globalDebug) echo "Modes : Download...";
2121 2121
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2122
-		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2122
+		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2123 2123
 
2124 2124
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2125 2125
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
 	public static function update_ModeS_faa() {
2140 2140
 		global $tmp_dir, $globalDebug;
2141 2141
 		if ($globalDebug) echo "Modes FAA: Download...";
2142
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2142
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2143 2143
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2144 2144
 			if ($globalDebug) echo "Unzip...";
2145 2145
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
 	public static function update_ModeS_flarm() {
2156 2156
 		global $tmp_dir, $globalDebug;
2157 2157
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2158
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2158
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2159 2159
 		if (file_exists($tmp_dir.'data.fln')) {
2160 2160
 			if ($globalDebug) echo "Add to DB...";
2161 2161
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2169,7 +2169,7 @@  discard block
 block discarded – undo
2169 2169
 	public static function update_ModeS_ogn() {
2170 2170
 		global $tmp_dir, $globalDebug;
2171 2171
 		if ($globalDebug) echo "Modes OGN: Download...";
2172
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2172
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2173 2173
 		if (file_exists($tmp_dir.'ogn.csv')) {
2174 2174
 			if ($globalDebug) echo "Add to DB...";
2175 2175
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2184,201 +2184,201 @@  discard block
 block discarded – undo
2184 2184
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2185 2185
 		
2186 2186
 		if ($globalDebug) echo "Owner France: Download...";
2187
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2187
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2188 2188
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2189 2189
 			if ($globalDebug) echo "Add to DB...";
2190
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2190
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2191 2191
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2192 2192
 		if ($error != '') {
2193 2193
 			return $error;
2194 2194
 		} elseif ($globalDebug) echo "Done\n";
2195 2195
 		
2196 2196
 		if ($globalDebug) echo "Owner Ireland: Download...";
2197
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2197
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2198 2198
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2199 2199
 			if ($globalDebug) echo "Add to DB...";
2200
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2200
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2201 2201
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2202 2202
 		if ($error != '') {
2203 2203
 			return $error;
2204 2204
 		} elseif ($globalDebug) echo "Done\n";
2205 2205
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2206
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2206
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2207 2207
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2208 2208
 			if ($globalDebug) echo "Add to DB...";
2209
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2209
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2210 2210
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2211 2211
 		if ($error != '') {
2212 2212
 			return $error;
2213 2213
 		} elseif ($globalDebug) echo "Done\n";
2214 2214
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2215
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2215
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2216 2216
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2217 2217
 			if ($globalDebug) echo "Add to DB...";
2218
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2218
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2219 2219
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2220 2220
 		if ($error != '') {
2221 2221
 			return $error;
2222 2222
 		} elseif ($globalDebug) echo "Done\n";
2223 2223
 		if ($globalDebug) echo "Owner Australia: Download...";
2224
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2224
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2225 2225
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2226 2226
 			if ($globalDebug) echo "Add to DB...";
2227
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2227
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2228 2228
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2229 2229
 		if ($error != '') {
2230 2230
 			return $error;
2231 2231
 		} elseif ($globalDebug) echo "Done\n";
2232 2232
 		if ($globalDebug) echo "Owner Austria: Download...";
2233
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2233
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2234 2234
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2235 2235
 			if ($globalDebug) echo "Add to DB...";
2236
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2236
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2237 2237
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2238 2238
 		if ($error != '') {
2239 2239
 			return $error;
2240 2240
 		} elseif ($globalDebug) echo "Done\n";
2241 2241
 		if ($globalDebug) echo "Owner Chile: Download...";
2242
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2242
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2243 2243
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2244 2244
 			if ($globalDebug) echo "Add to DB...";
2245
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2245
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2246 2246
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2247 2247
 		if ($error != '') {
2248 2248
 			return $error;
2249 2249
 		} elseif ($globalDebug) echo "Done\n";
2250 2250
 		if ($globalDebug) echo "Owner Colombia: Download...";
2251
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2251
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2252 2252
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2253 2253
 			if ($globalDebug) echo "Add to DB...";
2254
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2254
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2255 2255
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2256 2256
 		if ($error != '') {
2257 2257
 			return $error;
2258 2258
 		} elseif ($globalDebug) echo "Done\n";
2259 2259
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2260
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2260
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2261 2261
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2262 2262
 			if ($globalDebug) echo "Add to DB...";
2263
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2263
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2264 2264
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2265 2265
 		if ($error != '') {
2266 2266
 			return $error;
2267 2267
 		} elseif ($globalDebug) echo "Done\n";
2268 2268
 		if ($globalDebug) echo "Owner Brazil: Download...";
2269
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2269
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2270 2270
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2271 2271
 			if ($globalDebug) echo "Add to DB...";
2272
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2272
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2273 2273
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2274 2274
 		if ($error != '') {
2275 2275
 			return $error;
2276 2276
 		} elseif ($globalDebug) echo "Done\n";
2277 2277
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2278
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2278
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2279 2279
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2280 2280
 			if ($globalDebug) echo "Add to DB...";
2281
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2281
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2282 2282
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2283 2283
 		if ($error != '') {
2284 2284
 			return $error;
2285 2285
 		} elseif ($globalDebug) echo "Done\n";
2286 2286
 		if ($globalDebug) echo "Owner Croatia: Download...";
2287
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2287
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2288 2288
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2289 2289
 			if ($globalDebug) echo "Add to DB...";
2290
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2290
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2291 2291
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2292 2292
 		if ($error != '') {
2293 2293
 			return $error;
2294 2294
 		} elseif ($globalDebug) echo "Done\n";
2295 2295
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2296
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2296
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2297 2297
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2298 2298
 			if ($globalDebug) echo "Add to DB...";
2299
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2299
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2300 2300
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2301 2301
 		if ($error != '') {
2302 2302
 			return $error;
2303 2303
 		} elseif ($globalDebug) echo "Done\n";
2304 2304
 		if ($globalDebug) echo "Owner Maldives: Download...";
2305
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2305
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2306 2306
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2307 2307
 			if ($globalDebug) echo "Add to DB...";
2308
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2308
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2309 2309
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2310 2310
 		if ($error != '') {
2311 2311
 			return $error;
2312 2312
 		} elseif ($globalDebug) echo "Done\n";
2313 2313
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2314
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2314
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2315 2315
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2316 2316
 			if ($globalDebug) echo "Add to DB...";
2317
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2317
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2318 2318
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2319 2319
 		if ($error != '') {
2320 2320
 			return $error;
2321 2321
 		} elseif ($globalDebug) echo "Done\n";
2322 2322
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2323
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2323
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2324 2324
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2325 2325
 			if ($globalDebug) echo "Add to DB...";
2326
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2326
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2327 2327
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2328 2328
 		if ($error != '') {
2329 2329
 			return $error;
2330 2330
 		} elseif ($globalDebug) echo "Done\n";
2331 2331
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2332
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2332
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2333 2333
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2334 2334
 			if ($globalDebug) echo "Add to DB...";
2335
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2335
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2336 2336
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2337 2337
 		if ($error != '') {
2338 2338
 			return $error;
2339 2339
 		} elseif ($globalDebug) echo "Done\n";
2340 2340
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2341
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2341
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2342 2342
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2343 2343
 			if ($globalDebug) echo "Add to DB...";
2344
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2344
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2345 2345
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2346 2346
 		if ($error != '') {
2347 2347
 			return $error;
2348 2348
 		} elseif ($globalDebug) echo "Done\n";
2349 2349
 		if ($globalDebug) echo "Owner Iceland: Download...";
2350
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2350
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2351 2351
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2352 2352
 			if ($globalDebug) echo "Add to DB...";
2353
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2353
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2354 2354
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2355 2355
 		if ($error != '') {
2356 2356
 			return $error;
2357 2357
 		} elseif ($globalDebug) echo "Done\n";
2358 2358
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2359
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2359
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2360 2360
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2361 2361
 			if ($globalDebug) echo "Add to DB...";
2362
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2362
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2363 2363
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2364 2364
 		if ($error != '') {
2365 2365
 			return $error;
2366 2366
 		} elseif ($globalDebug) echo "Done\n";
2367 2367
 		if ($globalMasterSource) {
2368 2368
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2369
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2369
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2370 2370
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2371 2371
 				if ($globalDebug) echo "Add to DB...";
2372
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2372
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2373 2373
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2374 2374
 			if ($error != '') {
2375 2375
 				return $error;
2376 2376
 			} elseif ($globalDebug) echo "Done\n";
2377 2377
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2378
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2378
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2379 2379
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2380 2380
 				if ($globalDebug) echo "Add to DB...";
2381
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2381
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2382 2382
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2383 2383
 			if ($error != '') {
2384 2384
 				return $error;
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
 		global $tmp_dir, $globalDebug;
2392 2392
 		$error = '';
2393 2393
 		if ($globalDebug) echo "Translation : Download...";
2394
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2394
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2395 2395
 		if (file_exists($tmp_dir.'translation.zip')) {
2396 2396
 			if ($globalDebug) echo "Unzip...";
2397 2397
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2408,10 +2408,10 @@  discard block
 block discarded – undo
2408 2408
 		global $tmp_dir, $globalDebug;
2409 2409
 		$error = '';
2410 2410
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2411
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2412
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2411
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2412
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5');
2413 2413
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2414
-			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2414
+			$translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2415 2415
 			$translation_md5 = $translation_md5_file[0];
2416 2416
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2417 2417
 				if ($globalDebug) echo "Gunzip...";
@@ -2429,10 +2429,10 @@  discard block
 block discarded – undo
2429 2429
 		global $tmp_dir, $globalDebug;
2430 2430
 		$error = '';
2431 2431
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2432
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2433
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2432
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2433
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5');
2434 2434
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2435
-			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2435
+			$modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2436 2436
 			$modes_md5 = $modes_md5_file[0];
2437 2437
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2438 2438
 				if ($globalDebug) echo "Gunzip...";
@@ -2451,12 +2451,12 @@  discard block
 block discarded – undo
2451 2451
 		global $tmp_dir, $globalDebug;
2452 2452
 		$error = '';
2453 2453
 		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2454
-		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2454
+		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5');
2455 2455
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2456
-			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2456
+			$airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2457 2457
 			$airlines_md5 = $airlines_md5_file[0];
2458 2458
 			if (!update_db::check_airlines_version($airlines_md5)) {
2459
-				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2459
+				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz');
2460 2460
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2461 2461
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2462 2462
 						if ($globalDebug) echo "Gunzip...";
@@ -2481,14 +2481,14 @@  discard block
 block discarded – undo
2481 2481
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2482 2482
 		$error = '';
2483 2483
 		if ($globalOwner === TRUE) {
2484
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2485
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2484
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2485
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2486 2486
 		} else {
2487
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2488
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2487
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2488
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2489 2489
 		}
2490 2490
 		if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) {
2491
-			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2491
+			$owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2492 2492
 			$owners_md5 = $owners_md5_file[0];
2493 2493
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2494 2494
 				if ($globalDebug) echo "Gunzip...";
@@ -2505,10 +2505,10 @@  discard block
 block discarded – undo
2505 2505
 	public static function update_routes_fam() {
2506 2506
 		global $tmp_dir, $globalDebug;
2507 2507
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2508
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2509
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2508
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2509
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5');
2510 2510
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2511
-			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2511
+			$routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2512 2512
 			$routes_md5 = $routes_md5_file[0];
2513 2513
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2514 2514
 				if ($globalDebug) echo "Gunzip...";
@@ -2524,13 +2524,13 @@  discard block
 block discarded – undo
2524 2524
 	}
2525 2525
 	public static function update_marine_identity_fam() {
2526 2526
 		global $tmp_dir, $globalDebug;
2527
-		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2527
+		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2528 2528
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2529
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2529
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2530 2530
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2531 2531
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2532 2532
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2533
-				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2533
+				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2534 2534
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2535 2535
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2536 2536
 						if ($globalDebug) echo "Gunzip...";
@@ -2552,13 +2552,13 @@  discard block
 block discarded – undo
2552 2552
 
2553 2553
 	public static function update_satellite_fam() {
2554 2554
 		global $tmp_dir, $globalDebug;
2555
-		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2555
+		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2556 2556
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2557
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2557
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2558 2558
 			$satellite_md5 = $satellite_md5_file[0];
2559 2559
 			if (!update_db::check_satellite_version($satellite_md5)) {
2560 2560
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2561
-				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2561
+				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2562 2562
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2563 2563
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2564 2564
 						if ($globalDebug) echo "Gunzip...";
@@ -2580,7 +2580,7 @@  discard block
 block discarded – undo
2580 2580
 	public static function update_banned_fam() {
2581 2581
 		global $tmp_dir, $globalDebug;
2582 2582
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2583
-		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2583
+		update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2584 2584
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2585 2585
 			//if ($globalDebug) echo "Gunzip...";
2586 2586
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2599,18 +2599,18 @@  discard block
 block discarded – undo
2599 2599
 		$error = '';
2600 2600
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2601 2601
 		if ($globalDBdriver == 'mysql') {
2602
-			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2602
+			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2603 2603
 		} else {
2604
-			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2604
+			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2605 2605
 		}
2606 2606
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2607
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2607
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2608 2608
 			$airspace_md5 = $airspace_md5_file[0];
2609 2609
 			if (!update_db::check_airspace_version($airspace_md5)) {
2610 2610
 				if ($globalDBdriver == 'mysql') {
2611
-					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2611
+					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2612 2612
 				} else {
2613
-					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2613
+					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2614 2614
 				}
2615 2615
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2616 2616
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
@@ -2623,7 +2623,7 @@  discard block
 block discarded – undo
2623 2623
 							try {
2624 2624
 								$sth = $Connection->db->prepare($query);
2625 2625
 								$sth->execute();
2626
-							} catch(PDOException $e) {
2626
+							} catch (PDOException $e) {
2627 2627
 								return "error : ".$e->getMessage();
2628 2628
 							}
2629 2629
 						}
@@ -2643,16 +2643,16 @@  discard block
 block discarded – undo
2643 2643
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2644 2644
 		$error = '';
2645 2645
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2646
-		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2646
+		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2647 2647
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2648
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2648
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2649 2649
 			$geoid_md5 = $geoid_md5_file[0];
2650 2650
 			if (!update_db::check_geoid_version($geoid_md5)) {
2651
-				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2651
+				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2652 2652
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2653 2653
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2654 2654
 						if ($globalDebug) echo "Gunzip...";
2655
-						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2655
+						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2656 2656
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2657 2657
 							update_db::insert_geoid_version($geoid_md5);
2658 2658
 						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
@@ -2669,15 +2669,15 @@  discard block
 block discarded – undo
2669 2669
 	public static function update_tle() {
2670 2670
 		global $tmp_dir, $globalDebug;
2671 2671
 		if ($globalDebug) echo "Download TLE : Download...";
2672
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2673
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2674
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2672
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2673
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2674
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt', 'visual.txt', 'sarsat.txt', 'argos.txt', 'ses.txt', 'iridium-NEXT.txt', 'beidou.txt');
2675 2675
 		foreach ($alltle as $filename) {
2676 2676
 			if ($globalDebug) echo "downloading ".$filename.'...';
2677
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2677
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2678 2678
 			if (file_exists($tmp_dir.$filename)) {
2679 2679
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2680
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2680
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2681 2681
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2682 2682
 			if ($error != '') {
2683 2683
 				echo $error."\n";
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
 	public static function update_ucsdb() {
2690 2690
 		global $tmp_dir, $globalDebug;
2691 2691
 		if ($globalDebug) echo "Download UCS DB : Download...";
2692
-		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2692
+		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt', $tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2693 2693
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2694 2694
 			if ($globalDebug) echo "Add to DB...";
2695 2695
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
@@ -2703,7 +2703,7 @@  discard block
 block discarded – undo
2703 2703
 	public static function update_celestrak() {
2704 2704
 		global $tmp_dir, $globalDebug;
2705 2705
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2706
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2706
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2707 2707
 		if (file_exists($tmp_dir.'satcat.txt')) {
2708 2708
 			if ($globalDebug) echo "Add to DB...";
2709 2709
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2718,63 +2718,63 @@  discard block
 block discarded – undo
2718 2718
 		global $tmp_dir, $globalDebug;
2719 2719
 		$error = '';
2720 2720
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2721
-		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2721
+		update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2722 2722
 		if (file_exists($tmp_dir.'models.md5sum')) {
2723 2723
 			if ($globalDebug) echo "Check files...\n";
2724 2724
 			$newmodelsdb = array();
2725
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2726
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2725
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2726
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2727 2727
 					$model = trim($row[2]);
2728 2728
 					$newmodelsdb[$model] = trim($row[0]);
2729 2729
 				}
2730 2730
 			}
2731 2731
 			$modelsdb = array();
2732 2732
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2733
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2734
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2733
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2734
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2735 2735
 						$model = trim($row[2]);
2736 2736
 						$modelsdb[$model] = trim($row[0]);
2737 2737
 					}
2738 2738
 				}
2739 2739
 			}
2740
-			$diff = array_diff($newmodelsdb,$modelsdb);
2740
+			$diff = array_diff($newmodelsdb, $modelsdb);
2741 2741
 			foreach ($diff as $key => $value) {
2742 2742
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2743
-				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2743
+				update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2744 2744
 				
2745 2745
 			}
2746
-			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2746
+			update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2747 2747
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2748 2748
 		if ($error != '') {
2749 2749
 			return $error;
2750 2750
 		} elseif ($globalDebug) echo "Done\n";
2751 2751
 		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
2752
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2752
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum');
2753 2753
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2754 2754
 			if ($globalDebug) echo "Check files...\n";
2755 2755
 			$newmodelsdb = array();
2756
-			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2757
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2756
+			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) {
2757
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2758 2758
 					$model = trim($row[2]);
2759 2759
 					$newmodelsdb[$model] = trim($row[0]);
2760 2760
 				}
2761 2761
 			}
2762 2762
 			$modelsdb = array();
2763 2763
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) {
2764
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) {
2765
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2764
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) {
2765
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2766 2766
 						$model = trim($row[2]);
2767 2767
 						$modelsdb[$model] = trim($row[0]);
2768 2768
 					}
2769 2769
 				}
2770 2770
 			}
2771
-			$diff = array_diff($newmodelsdb,$modelsdb);
2771
+			$diff = array_diff($newmodelsdb, $modelsdb);
2772 2772
 			foreach ($diff as $key => $value) {
2773 2773
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2774
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2774
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key);
2775 2775
 				
2776 2776
 			}
2777
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2777
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum');
2778 2778
 		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
2779 2779
 		if ($error != '') {
2780 2780
 			return $error;
@@ -2786,32 +2786,32 @@  discard block
 block discarded – undo
2786 2786
 		global $tmp_dir, $globalDebug;
2787 2787
 		$error = '';
2788 2788
 		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
2789
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2789
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum');
2790 2790
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2791 2791
 			if ($globalDebug) echo "Check files...\n";
2792 2792
 			$newmodelsdb = array();
2793
-			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2794
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2793
+			if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) {
2794
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2795 2795
 					$model = trim($row[2]);
2796 2796
 					$newmodelsdb[$model] = trim($row[0]);
2797 2797
 				}
2798 2798
 			}
2799 2799
 			$modelsdb = array();
2800 2800
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) {
2801
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) {
2802
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2801
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) {
2802
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2803 2803
 						$model = trim($row[2]);
2804 2804
 						$modelsdb[$model] = trim($row[0]);
2805 2805
 					}
2806 2806
 				}
2807 2807
 			}
2808
-			$diff = array_diff($newmodelsdb,$modelsdb);
2808
+			$diff = array_diff($newmodelsdb, $modelsdb);
2809 2809
 			foreach ($diff as $key => $value) {
2810 2810
 				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
2811
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2811
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2812 2812
 				
2813 2813
 			}
2814
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2814
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2815 2815
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2816 2816
 		if ($error != '') {
2817 2817
 			return $error;
@@ -2823,32 +2823,32 @@  discard block
 block discarded – undo
2823 2823
 		global $tmp_dir, $globalDebug;
2824 2824
 		$error = '';
2825 2825
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2826
-		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2826
+		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2827 2827
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2828 2828
 			if ($globalDebug) echo "Check files...\n";
2829 2829
 			$newmodelsdb = array();
2830
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2831
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2830
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2831
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2832 2832
 					$model = trim($row[2]);
2833 2833
 					$newmodelsdb[$model] = trim($row[0]);
2834 2834
 				}
2835 2835
 			}
2836 2836
 			$modelsdb = array();
2837 2837
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2838
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2839
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2838
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2839
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2840 2840
 						$model = trim($row[2]);
2841 2841
 						$modelsdb[$model] = trim($row[0]);
2842 2842
 					}
2843 2843
 				}
2844 2844
 			}
2845
-			$diff = array_diff($newmodelsdb,$modelsdb);
2845
+			$diff = array_diff($newmodelsdb, $modelsdb);
2846 2846
 			foreach ($diff as $key => $value) {
2847 2847
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2848
-				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2848
+				update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2849 2849
 				
2850 2850
 			}
2851
-			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2851
+			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2852 2852
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2853 2853
 		if ($error != '') {
2854 2854
 			return $error;
@@ -2860,32 +2860,32 @@  discard block
 block discarded – undo
2860 2860
 		global $tmp_dir, $globalDebug;
2861 2861
 		$error = '';
2862 2862
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2863
-		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2863
+		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2864 2864
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2865 2865
 			if ($globalDebug) echo "Check files...\n";
2866 2866
 			$newmodelsdb = array();
2867
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2868
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2867
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2868
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2869 2869
 					$model = trim($row[2]);
2870 2870
 					$newmodelsdb[$model] = trim($row[0]);
2871 2871
 				}
2872 2872
 			}
2873 2873
 			$modelsdb = array();
2874 2874
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2875
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2876
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2875
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2876
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2877 2877
 						$model = trim($row[2]);
2878 2878
 						$modelsdb[$model] = trim($row[0]);
2879 2879
 					}
2880 2880
 				}
2881 2881
 			}
2882
-			$diff = array_diff($newmodelsdb,$modelsdb);
2882
+			$diff = array_diff($newmodelsdb, $modelsdb);
2883 2883
 			foreach ($diff as $key => $value) {
2884 2884
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2885
-				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2885
+				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2886 2886
 				
2887 2887
 			}
2888
-			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2888
+			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2889 2889
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2890 2890
 		if ($error != '') {
2891 2891
 			return $error;
@@ -2897,8 +2897,8 @@  discard block
 block discarded – undo
2897 2897
 		global $tmp_dir, $globalDebug;
2898 2898
 		date_default_timezone_set('UTC');
2899 2899
 		$Common = new Common();
2900
-		$data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes','post',array('X-Requested-With: XMLHttpRequest','Accept: application/json, text/javascript, */*; q=0.01','Host: www4.icao.int','Origin: https://www.icao.int','Content-Length: 0'),'','','https://www.icao.int/publications/DOC8643/Pages/Search.aspx',60);
2901
-		$all = json_decode($data,true);
2900
+		$data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes', 'post', array('X-Requested-With: XMLHttpRequest', 'Accept: application/json, text/javascript, */*; q=0.01', 'Host: www4.icao.int', 'Origin: https://www.icao.int', 'Content-Length: 0'), '', '', 'https://www.icao.int/publications/DOC8643/Pages/Search.aspx', 60);
2901
+		$all = json_decode($data, true);
2902 2902
 		$Connection = new Connection();
2903 2903
 		$querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao";
2904 2904
 		$sth = $Connection->db->prepare($querychk);
@@ -2910,8 +2910,8 @@  discard block
 block discarded – undo
2910 2910
 		foreach ($all as $model) {
2911 2911
 			$icao = $model['Designator'];
2912 2912
 			if (!isset($allicao[$icao])) {
2913
-				$aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png';
2914
-				$allicao[$icao] = array(':icao' => $icao,':type' => $model['ModelFullName'],':manufacturer' => $model['ManufacturerCode'],':aircraft_shadow' => $aircraft_shadow,':aircraft_description' => $model['AircraftDescription'],':engine_type' => $model['EngineType'],':engine_count' => $model['EngineCount'],':wake_category' => $model['WTC']);
2913
+				$aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png';
2914
+				$allicao[$icao] = array(':icao' => $icao, ':type' => $model['ModelFullName'], ':manufacturer' => $model['ManufacturerCode'], ':aircraft_shadow' => $aircraft_shadow, ':aircraft_description' => $model['AircraftDescription'], ':engine_type' => $model['EngineType'], ':engine_count' => $model['EngineCount'], ':wake_category' => $model['WTC']);
2915 2915
 			} else {
2916 2916
 				$allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName'];
2917 2917
 			}
@@ -2923,9 +2923,9 @@  discard block
 block discarded – undo
2923 2923
 				if ($exist[0]['nb'] == 0) {
2924 2924
 					$sthins->execute($airdata);
2925 2925
 				} else {
2926
-					$sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao));
2926
+					$sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao));
2927 2927
 				}
2928
-			} catch(PDOException $e) {
2928
+			} catch (PDOException $e) {
2929 2929
 				return "error : ".$e->getMessage();
2930 2930
 			}
2931 2931
 		}
@@ -2957,23 +2957,23 @@  discard block
 block discarded – undo
2957 2957
 			$Connection = new Connection();
2958 2958
 			$sth = $Connection->db->prepare($query);
2959 2959
                         $sth->execute();
2960
-                } catch(PDOException $e) {
2960
+                } catch (PDOException $e) {
2961 2961
                         return "error : ".$e->getMessage();
2962 2962
                 }
2963 2963
 
2964 2964
 		$error = '';
2965 2965
 		if ($globalDebug) echo "Notam : Download...";
2966
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2966
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2967 2967
 		if (file_exists($tmp_dir.'notam.rss')) {
2968
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2968
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2969 2969
 			foreach ($notams['channel']['item'] as $notam) {
2970
-				$title = explode(':',$notam['title']);
2970
+				$title = explode(':', $notam['title']);
2971 2971
 				$data['ref'] = trim($title[0]);
2972 2972
 				unset($title[0]);
2973
-				$data['title'] = trim(implode(':',$title));
2974
-				$description = strip_tags($notam['description'],'<pre>');
2975
-				preg_match(':^(.*?)<pre>:',$description,$match);
2976
-				$q = explode('/',$match[1]);
2973
+				$data['title'] = trim(implode(':', $title));
2974
+				$description = strip_tags($notam['description'], '<pre>');
2975
+				preg_match(':^(.*?)<pre>:', $description, $match);
2976
+				$q = explode('/', $match[1]);
2977 2977
 				$data['fir'] = $q[0];
2978 2978
 				$data['code'] = $q[1];
2979 2979
 				$ifrvfr = $q[2];
@@ -2989,30 +2989,30 @@  discard block
 block discarded – undo
2989 2989
 				$data['lower_limit'] = $q[5];
2990 2990
 				$data['upper_limit'] = $q[6];
2991 2991
 				$latlonrad = $q[7];
2992
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2993
-				$latitude = $Common->convertDec($las,'latitude');
2994
-				$longitude = $Common->convertDec($lns,'longitude');
2992
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2993
+				$latitude = $Common->convertDec($las, 'latitude');
2994
+				$longitude = $Common->convertDec($lns, 'longitude');
2995 2995
 				if ($lac == 'S') $latitude = '-'.$latitude;
2996 2996
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2997 2997
 				$data['center_latitude'] = $latitude;
2998 2998
 				$data['center_longitude'] = $longitude;
2999 2999
 				$data['radius'] = intval($radius);
3000 3000
 				
3001
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
3001
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
3002 3002
 				$data['text'] = $match[1];
3003
-				preg_match(':</pre>(.*?)$:',$description,$match);
3003
+				preg_match(':</pre>(.*?)$:', $description, $match);
3004 3004
 				$fromto = $match[1];
3005
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
3005
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
3006 3006
 				$fromall = trim($match[1]);
3007
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
3007
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
3008 3008
 				$from = trim($match[1]);
3009
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
3010
-				preg_match('#TO:(.*?)$#',$fromto,$match);
3009
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
3010
+				preg_match('#TO:(.*?)$#', $fromto, $match);
3011 3011
 				$toall = trim($match[1]);
3012
-				if (!preg_match(':Permanent:',$toall)) {
3013
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
3012
+				if (!preg_match(':Permanent:', $toall)) {
3013
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
3014 3014
 					$to = trim($match[1]);
3015
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3015
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
3016 3016
 					$data['permanent'] = 0;
3017 3017
 				} else {
3018 3018
 				    $data['date_end'] = NULL;
@@ -3020,7 +3020,7 @@  discard block
 block discarded – undo
3020 3020
 				}
3021 3021
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3022 3022
 				$NOTAM = new NOTAM();
3023
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
3023
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
3024 3024
 				unset($data);
3025 3025
 			} 
3026 3026
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -3043,16 +3043,16 @@  discard block
 block discarded – undo
3043 3043
 				$Connection = new Connection();
3044 3044
 				$sth = $Connection->db->prepare($query);
3045 3045
 				$sth->execute();
3046
-			} catch(PDOException $e) {
3046
+			} catch (PDOException $e) {
3047 3047
 				return "error : ".$e->getMessage();
3048 3048
 			}
3049 3049
 		}
3050 3050
 		$Common = new Common();
3051 3051
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3052
-		$airspace_json = json_decode($airspace_lst,true);
3052
+		$airspace_json = json_decode($airspace_lst, true);
3053 3053
 		foreach ($airspace_json['records'] as $airspace) {
3054 3054
 			if ($globalDebug) echo $airspace['name']."...\n";
3055
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3055
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
3056 3056
 			if (file_exists($tmp_dir.$airspace['name'])) {
3057 3057
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
3058 3058
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -3074,7 +3074,7 @@  discard block
 block discarded – undo
3074 3074
 				$Connection = new Connection();
3075 3075
 				$sth = $Connection->db->prepare($query);
3076 3076
 				$sth->execute(array(':new' => $new, ':old' => $old));
3077
-			} catch(PDOException $e) {
3077
+			} catch (PDOException $e) {
3078 3078
 				return "error : ".$e->getMessage();
3079 3079
 			}
3080 3080
 		}
@@ -3091,7 +3091,7 @@  discard block
 block discarded – undo
3091 3091
 			$Connection = new Connection();
3092 3092
 			$sth = $Connection->db->prepare($query);
3093 3093
                         $sth->execute();
3094
-                } catch(PDOException $e) {
3094
+                } catch (PDOException $e) {
3095 3095
                         return "error : ".$e->getMessage();
3096 3096
                 }
3097 3097
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3106,7 +3106,7 @@  discard block
 block discarded – undo
3106 3106
 			$Connection = new Connection();
3107 3107
 			$sth = $Connection->db->prepare($query);
3108 3108
                         $sth->execute();
3109
-                } catch(PDOException $e) {
3109
+                } catch (PDOException $e) {
3110 3110
                         return "error : ".$e->getMessage();
3111 3111
                 }
3112 3112
 	}
@@ -3117,7 +3117,7 @@  discard block
 block discarded – undo
3117 3117
 			$Connection = new Connection();
3118 3118
 			$sth = $Connection->db->prepare($query);
3119 3119
                         $sth->execute(array(':version' => $version));
3120
-                } catch(PDOException $e) {
3120
+                } catch (PDOException $e) {
3121 3121
                         return "error : ".$e->getMessage();
3122 3122
                 }
3123 3123
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3131,7 +3131,7 @@  discard block
 block discarded – undo
3131 3131
 			$Connection = new Connection();
3132 3132
 			$sth = $Connection->db->prepare($query);
3133 3133
                         $sth->execute(array(':version' => $version));
3134
-                } catch(PDOException $e) {
3134
+                } catch (PDOException $e) {
3135 3135
                         return "error : ".$e->getMessage();
3136 3136
                 }
3137 3137
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3145,7 +3145,7 @@  discard block
 block discarded – undo
3145 3145
 			$Connection = new Connection();
3146 3146
 			$sth = $Connection->db->prepare($query);
3147 3147
 			$sth->execute(array(':version' => $version));
3148
-		} catch(PDOException $e) {
3148
+		} catch (PDOException $e) {
3149 3149
 			return "error : ".$e->getMessage();
3150 3150
 		}
3151 3151
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3159,7 +3159,7 @@  discard block
 block discarded – undo
3159 3159
 			$Connection = new Connection();
3160 3160
 			$sth = $Connection->db->prepare($query);
3161 3161
 			$sth->execute(array(':version' => $version));
3162
-		} catch(PDOException $e) {
3162
+		} catch (PDOException $e) {
3163 3163
 			return "error : ".$e->getMessage();
3164 3164
 		}
3165 3165
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
 			$Connection = new Connection();
3174 3174
 			$sth = $Connection->db->prepare($query);
3175 3175
 			$sth->execute(array(':version' => $version));
3176
-		} catch(PDOException $e) {
3176
+		} catch (PDOException $e) {
3177 3177
 			return "error : ".$e->getMessage();
3178 3178
 		}
3179 3179
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
 			$Connection = new Connection();
3188 3188
 			$sth = $Connection->db->prepare($query);
3189 3189
 			$sth->execute(array(':version' => $version));
3190
-		} catch(PDOException $e) {
3190
+		} catch (PDOException $e) {
3191 3191
 			return "error : ".$e->getMessage();
3192 3192
 		}
3193 3193
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3202,7 +3202,7 @@  discard block
 block discarded – undo
3202 3202
 			$Connection = new Connection();
3203 3203
 			$sth = $Connection->db->prepare($query);
3204 3204
 			$sth->execute(array(':version' => $version));
3205
-		} catch(PDOException $e) {
3205
+		} catch (PDOException $e) {
3206 3206
 			return "error : ".$e->getMessage();
3207 3207
 		}
3208 3208
 	}
@@ -3214,7 +3214,7 @@  discard block
 block discarded – undo
3214 3214
 			$Connection = new Connection();
3215 3215
 			$sth = $Connection->db->prepare($query);
3216 3216
 			$sth->execute(array(':version' => $version));
3217
-		} catch(PDOException $e) {
3217
+		} catch (PDOException $e) {
3218 3218
 			return "error : ".$e->getMessage();
3219 3219
 		}
3220 3220
 	}
@@ -3226,7 +3226,7 @@  discard block
 block discarded – undo
3226 3226
 			$Connection = new Connection();
3227 3227
 			$sth = $Connection->db->prepare($query);
3228 3228
 			$sth->execute(array(':version' => $version));
3229
-		} catch(PDOException $e) {
3229
+		} catch (PDOException $e) {
3230 3230
 			return "error : ".$e->getMessage();
3231 3231
 		}
3232 3232
 	}
@@ -3238,7 +3238,7 @@  discard block
 block discarded – undo
3238 3238
 			$Connection = new Connection();
3239 3239
 			$sth = $Connection->db->prepare($query);
3240 3240
                         $sth->execute(array(':version' => $version));
3241
-                } catch(PDOException $e) {
3241
+                } catch (PDOException $e) {
3242 3242
                         return "error : ".$e->getMessage();
3243 3243
                 }
3244 3244
 	}
@@ -3250,7 +3250,7 @@  discard block
 block discarded – undo
3250 3250
 			$Connection = new Connection();
3251 3251
 			$sth = $Connection->db->prepare($query);
3252 3252
 			$sth->execute(array(':version' => $version));
3253
-		} catch(PDOException $e) {
3253
+		} catch (PDOException $e) {
3254 3254
 			return "error : ".$e->getMessage();
3255 3255
 		}
3256 3256
 	}
@@ -3262,7 +3262,7 @@  discard block
 block discarded – undo
3262 3262
 			$Connection = new Connection();
3263 3263
 			$sth = $Connection->db->prepare($query);
3264 3264
 			$sth->execute(array(':version' => $version));
3265
-		} catch(PDOException $e) {
3265
+		} catch (PDOException $e) {
3266 3266
 			return "error : ".$e->getMessage();
3267 3267
 		}
3268 3268
 	}
@@ -3278,7 +3278,7 @@  discard block
 block discarded – undo
3278 3278
 			$Connection = new Connection();
3279 3279
 			$sth = $Connection->db->prepare($query);
3280 3280
                         $sth->execute();
3281
-                } catch(PDOException $e) {
3281
+                } catch (PDOException $e) {
3282 3282
                         return "error : ".$e->getMessage();
3283 3283
                 }
3284 3284
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3293,7 +3293,7 @@  discard block
 block discarded – undo
3293 3293
 			$Connection = new Connection();
3294 3294
 			$sth = $Connection->db->prepare($query);
3295 3295
                         $sth->execute();
3296
-                } catch(PDOException $e) {
3296
+                } catch (PDOException $e) {
3297 3297
                         return "error : ".$e->getMessage();
3298 3298
                 }
3299 3299
 	}
@@ -3309,7 +3309,7 @@  discard block
 block discarded – undo
3309 3309
 			$Connection = new Connection();
3310 3310
 			$sth = $Connection->db->prepare($query);
3311 3311
                         $sth->execute();
3312
-                } catch(PDOException $e) {
3312
+                } catch (PDOException $e) {
3313 3313
                         return "error : ".$e->getMessage();
3314 3314
                 }
3315 3315
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3324,7 +3324,7 @@  discard block
 block discarded – undo
3324 3324
 			$Connection = new Connection();
3325 3325
 			$sth = $Connection->db->prepare($query);
3326 3326
                         $sth->execute();
3327
-                } catch(PDOException $e) {
3327
+                } catch (PDOException $e) {
3328 3328
                         return "error : ".$e->getMessage();
3329 3329
                 }
3330 3330
 	}
@@ -3340,7 +3340,7 @@  discard block
 block discarded – undo
3340 3340
 			$Connection = new Connection();
3341 3341
 			$sth = $Connection->db->prepare($query);
3342 3342
                         $sth->execute();
3343
-                } catch(PDOException $e) {
3343
+                } catch (PDOException $e) {
3344 3344
                         return "error : ".$e->getMessage();
3345 3345
                 }
3346 3346
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3355,7 +3355,7 @@  discard block
 block discarded – undo
3355 3355
 			$Connection = new Connection();
3356 3356
 			$sth = $Connection->db->prepare($query);
3357 3357
                         $sth->execute();
3358
-                } catch(PDOException $e) {
3358
+                } catch (PDOException $e) {
3359 3359
                         return "error : ".$e->getMessage();
3360 3360
                 }
3361 3361
 	}
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
 			$Connection = new Connection();
3372 3372
 			$sth = $Connection->db->prepare($query);
3373 3373
 			$sth->execute();
3374
-		} catch(PDOException $e) {
3374
+		} catch (PDOException $e) {
3375 3375
 			return "error : ".$e->getMessage();
3376 3376
 		}
3377 3377
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3386,7 +3386,7 @@  discard block
 block discarded – undo
3386 3386
 			$Connection = new Connection();
3387 3387
 			$sth = $Connection->db->prepare($query);
3388 3388
 			$sth->execute();
3389
-		} catch(PDOException $e) {
3389
+		} catch (PDOException $e) {
3390 3390
 			return "error : ".$e->getMessage();
3391 3391
 		}
3392 3392
 	}
@@ -3402,7 +3402,7 @@  discard block
 block discarded – undo
3402 3402
 			$Connection = new Connection();
3403 3403
 			$sth = $Connection->db->prepare($query);
3404 3404
 			$sth->execute();
3405
-		} catch(PDOException $e) {
3405
+		} catch (PDOException $e) {
3406 3406
 			return "error : ".$e->getMessage();
3407 3407
 		}
3408 3408
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3417,7 +3417,7 @@  discard block
 block discarded – undo
3417 3417
 			$Connection = new Connection();
3418 3418
 			$sth = $Connection->db->prepare($query);
3419 3419
 			$sth->execute();
3420
-		} catch(PDOException $e) {
3420
+		} catch (PDOException $e) {
3421 3421
 			return "error : ".$e->getMessage();
3422 3422
 		}
3423 3423
 	}
@@ -3433,7 +3433,7 @@  discard block
 block discarded – undo
3433 3433
 			$Connection = new Connection();
3434 3434
 			$sth = $Connection->db->prepare($query);
3435 3435
 			$sth->execute();
3436
-		} catch(PDOException $e) {
3436
+		} catch (PDOException $e) {
3437 3437
 			return "error : ".$e->getMessage();
3438 3438
 		}
3439 3439
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3448,7 +3448,7 @@  discard block
 block discarded – undo
3448 3448
 			$Connection = new Connection();
3449 3449
 			$sth = $Connection->db->prepare($query);
3450 3450
 			$sth->execute();
3451
-		} catch(PDOException $e) {
3451
+		} catch (PDOException $e) {
3452 3452
 			return "error : ".$e->getMessage();
3453 3453
 		}
3454 3454
 	}
@@ -3464,7 +3464,7 @@  discard block
 block discarded – undo
3464 3464
 			$Connection = new Connection();
3465 3465
 			$sth = $Connection->db->prepare($query);
3466 3466
                         $sth->execute();
3467
-                } catch(PDOException $e) {
3467
+                } catch (PDOException $e) {
3468 3468
                         return "error : ".$e->getMessage();
3469 3469
                 }
3470 3470
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3479,7 +3479,7 @@  discard block
 block discarded – undo
3479 3479
 			$Connection = new Connection();
3480 3480
 			$sth = $Connection->db->prepare($query);
3481 3481
 			$sth->execute();
3482
-		} catch(PDOException $e) {
3482
+		} catch (PDOException $e) {
3483 3483
 			return "error : ".$e->getMessage();
3484 3484
 		}
3485 3485
 	}
@@ -3495,7 +3495,7 @@  discard block
 block discarded – undo
3495 3495
 			$Connection = new Connection();
3496 3496
 			$sth = $Connection->db->prepare($query);
3497 3497
 			$sth->execute();
3498
-		} catch(PDOException $e) {
3498
+		} catch (PDOException $e) {
3499 3499
 			return "error : ".$e->getMessage();
3500 3500
 		}
3501 3501
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3510,7 +3510,7 @@  discard block
 block discarded – undo
3510 3510
 			$Connection = new Connection();
3511 3511
 			$sth = $Connection->db->prepare($query);
3512 3512
 			$sth->execute();
3513
-		} catch(PDOException $e) {
3513
+		} catch (PDOException $e) {
3514 3514
 			return "error : ".$e->getMessage();
3515 3515
 		}
3516 3516
 	}
@@ -3526,7 +3526,7 @@  discard block
 block discarded – undo
3526 3526
 			$Connection = new Connection();
3527 3527
 			$sth = $Connection->db->prepare($query);
3528 3528
 			$sth->execute();
3529
-		} catch(PDOException $e) {
3529
+		} catch (PDOException $e) {
3530 3530
 			return "error : ".$e->getMessage();
3531 3531
 		}
3532 3532
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
 			$Connection = new Connection();
3542 3542
 			$sth = $Connection->db->prepare($query);
3543 3543
 			$sth->execute();
3544
-		} catch(PDOException $e) {
3544
+		} catch (PDOException $e) {
3545 3545
 			return "error : ".$e->getMessage();
3546 3546
 		}
3547 3547
 	}
@@ -3557,7 +3557,7 @@  discard block
 block discarded – undo
3557 3557
 			$Connection = new Connection();
3558 3558
 			$sth = $Connection->db->prepare($query);
3559 3559
 			$sth->execute();
3560
-		} catch(PDOException $e) {
3560
+		} catch (PDOException $e) {
3561 3561
 			return "error : ".$e->getMessage();
3562 3562
 		}
3563 3563
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
 			$Connection = new Connection();
3573 3573
 			$sth = $Connection->db->prepare($query);
3574 3574
 			$sth->execute();
3575
-		} catch(PDOException $e) {
3575
+		} catch (PDOException $e) {
3576 3576
 			return "error : ".$e->getMessage();
3577 3577
 		}
3578 3578
 	}
@@ -3588,7 +3588,7 @@  discard block
 block discarded – undo
3588 3588
 			$Connection = new Connection();
3589 3589
 			$sth = $Connection->db->prepare($query);
3590 3590
 			$sth->execute();
3591
-		} catch(PDOException $e) {
3591
+		} catch (PDOException $e) {
3592 3592
 			return "error : ".$e->getMessage();
3593 3593
 		}
3594 3594
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3607,7 +3607,7 @@  discard block
 block discarded – undo
3607 3607
 			$Connection = new Connection();
3608 3608
 			$sth = $Connection->db->prepare($query);
3609 3609
 			$sth->execute();
3610
-		} catch(PDOException $e) {
3610
+		} catch (PDOException $e) {
3611 3611
 			return "error : ".$e->getMessage();
3612 3612
 		}
3613 3613
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3622,7 +3622,7 @@  discard block
 block discarded – undo
3622 3622
 			$Connection = new Connection();
3623 3623
 			$sth = $Connection->db->prepare($query);
3624 3624
 			$sth->execute();
3625
-		} catch(PDOException $e) {
3625
+		} catch (PDOException $e) {
3626 3626
 			return "error : ".$e->getMessage();
3627 3627
 		}
3628 3628
 	}
@@ -3634,7 +3634,7 @@  discard block
 block discarded – undo
3634 3634
 			$Connection = new Connection();
3635 3635
 			$sth = $Connection->db->prepare($query);
3636 3636
 			$sth->execute();
3637
-		} catch(PDOException $e) {
3637
+		} catch (PDOException $e) {
3638 3638
 			return "error : ".$e->getMessage();
3639 3639
 		}
3640 3640
 	}
@@ -3650,7 +3650,7 @@  discard block
 block discarded – undo
3650 3650
 			$Connection = new Connection();
3651 3651
 			$sth = $Connection->db->prepare($query);
3652 3652
                         $sth->execute();
3653
-                } catch(PDOException $e) {
3653
+                } catch (PDOException $e) {
3654 3654
                         return "error : ".$e->getMessage();
3655 3655
                 }
3656 3656
 	}
@@ -3665,7 +3665,7 @@  discard block
 block discarded – undo
3665 3665
 			$Connection = new Connection();
3666 3666
 			$sth = $Connection->db->prepare($query);
3667 3667
                         $sth->execute();
3668
-                } catch(PDOException $e) {
3668
+                } catch (PDOException $e) {
3669 3669
                         return "error : ".$e->getMessage();
3670 3670
                 }
3671 3671
 	}
Please login to merge, or discard this patch.
Braces   +1160 added lines, -402 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 27
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28 28
 		curl_setopt($ch, CURLOPT_TIMEOUT, 200);
29
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
29
+		if ($referer != '') {
30
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
31
+		}
30 32
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
31 33
 		curl_setopt($ch, CURLOPT_FILE, $fp);
32 34
 		curl_exec($ch);
@@ -37,12 +39,16 @@  discard block
 block discarded – undo
37 39
 	public static function gunzip($in_file,$out_file_name = '') {
38 40
 		//echo $in_file.' -> '.$out_file_name."\n";
39 41
 		$buffer_size = 4096; // read 4kb at a time
40
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
42
+		if ($out_file_name == '') {
43
+			$out_file_name = str_replace('.gz', '', $in_file);
44
+		}
41 45
 		if ($in_file != '' && file_exists($in_file)) {
42 46
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
45
-			else {
47
+			if (function_exists('gzopen')) {
48
+				$file = gzopen($in_file,'rb');
49
+			} elseif (function_exists('gzopen64')) {
50
+				$file = gzopen64($in_file,'rb');
51
+			} else {
46 52
 				echo 'gzopen not available';
47 53
 				die;
48 54
 			}
@@ -63,8 +69,12 @@  discard block
 block discarded – undo
63 69
 			if ($res === TRUE) {
64 70
 				$zip->extractTo($path);
65 71
 				$zip->close();
66
-			} else return false;
67
-		} else return false;
72
+			} else {
73
+				return false;
74
+			}
75
+		} else {
76
+			return false;
77
+		}
68 78
 	}
69 79
 	
70 80
 	public static function connect_sqlite($database) {
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 90
 		global $globalDebug, $globalTransaction;
81 91
 		//$query = 'TRUNCATE TABLE routes';
82
-		if ($globalDebug) echo " - Delete previous routes from DB -";
92
+		if ($globalDebug) {
93
+			echo " - Delete previous routes from DB -";
94
+		}
83 95
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
84 96
 		$Connection = new Connection();
85 97
 		try {
@@ -90,7 +102,9 @@  discard block
 block discarded – undo
90 102
                         return "error : ".$e->getMessage();
91 103
                 }
92 104
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
105
+    		if ($globalDebug) {
106
+    			echo " - Add routes to DB -";
107
+    		}
94 108
     		update_db::connect_sqlite($database_file);
95 109
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
96 110
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -105,15 +119,21 @@  discard block
 block discarded – undo
105 119
 		$Connection = new Connection();
106 120
 		$sth_dest = $Connection->db->prepare($query_dest);
107 121
 		try {
108
-			if ($globalTransaction) $Connection->db->beginTransaction();
122
+			if ($globalTransaction) {
123
+				$Connection->db->beginTransaction();
124
+			}
109 125
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 126
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111 127
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
112 128
 				$sth_dest->execute($query_dest_values);
113 129
             		}
114
-			if ($globalTransaction) $Connection->db->commit();
130
+			if ($globalTransaction) {
131
+				$Connection->db->commit();
132
+			}
115 133
 		} catch(PDOException $e) {
116
-			if ($globalTransaction) $Connection->db->rollBack(); 
134
+			if ($globalTransaction) {
135
+				$Connection->db->rollBack();
136
+			}
117 137
 			return "error : ".$e->getMessage();
118 138
 		}
119 139
                 return '';
@@ -121,7 +141,9 @@  discard block
 block discarded – undo
121 141
 	public static function retrieve_route_oneworld($database_file) {
122 142
 		global $globalDebug, $globalTransaction;
123 143
 		//$query = 'TRUNCATE TABLE routes';
124
-		if ($globalDebug) echo " - Delete previous routes from DB -";
144
+		if ($globalDebug) {
145
+			echo " - Delete previous routes from DB -";
146
+		}
125 147
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
126 148
 		$Connection = new Connection();
127 149
 		try {
@@ -132,14 +154,18 @@  discard block
 block discarded – undo
132 154
                         return "error : ".$e->getMessage();
133 155
                 }
134 156
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
157
+    		if ($globalDebug) {
158
+    			echo " - Add routes to DB -";
159
+    		}
136 160
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 161
 		$Spotter = new Spotter();
138 162
 		if ($fh = fopen($database_file,"r")) {
139 163
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
140 164
 			$Connection = new Connection();
141 165
 			$sth_dest = $Connection->db->prepare($query_dest);
142
-			if ($globalTransaction) $Connection->db->beginTransaction();
166
+			if ($globalTransaction) {
167
+				$Connection->db->beginTransaction();
168
+			}
143 169
 			while (!feof($fh)) {
144 170
 				$line = fgetcsv($fh,9999,',');
145 171
 				if ($line[0] != '') {
@@ -148,13 +174,17 @@  discard block
 block discarded – undo
148 174
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
149 175
 							$sth_dest->execute($query_dest_values);
150 176
 						} catch(PDOException $e) {
151
-							if ($globalTransaction) $Connection->db->rollBack(); 
177
+							if ($globalTransaction) {
178
+								$Connection->db->rollBack();
179
+							}
152 180
 							return "error : ".$e->getMessage();
153 181
 						}
154 182
 					}
155 183
 				}
156 184
 			}
157
-			if ($globalTransaction) $Connection->db->commit();
185
+			if ($globalTransaction) {
186
+				$Connection->db->commit();
187
+			}
158 188
 		}
159 189
                 return '';
160 190
 	}
@@ -162,7 +192,9 @@  discard block
 block discarded – undo
162 192
 	public static function retrieve_route_skyteam($database_file) {
163 193
 		global $globalDebug, $globalTransaction;
164 194
 		//$query = 'TRUNCATE TABLE routes';
165
-		if ($globalDebug) echo " - Delete previous routes from DB -";
195
+		if ($globalDebug) {
196
+			echo " - Delete previous routes from DB -";
197
+		}
166 198
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
167 199
 		$Connection = new Connection();
168 200
 		try {
@@ -173,7 +205,9 @@  discard block
 block discarded – undo
173 205
                         return "error : ".$e->getMessage();
174 206
                 }
175 207
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
208
+    		if ($globalDebug) {
209
+    			echo " - Add routes to DB -";
210
+    		}
177 211
 
178 212
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 213
 		$Spotter = new Spotter();
@@ -182,7 +216,9 @@  discard block
 block discarded – undo
182 216
 			$Connection = new Connection();
183 217
 			$sth_dest = $Connection->db->prepare($query_dest);
184 218
 			try {
185
-				if ($globalTransaction) $Connection->db->beginTransaction();
219
+				if ($globalTransaction) {
220
+					$Connection->db->beginTransaction();
221
+				}
186 222
 				while (!feof($fh)) {
187 223
 					$line = fgetcsv($fh,9999,',');
188 224
 					if ($line[0] != '') {
@@ -193,9 +229,13 @@  discard block
 block discarded – undo
193 229
 						}
194 230
 					}
195 231
 				}
196
-				if ($globalTransaction) $Connection->db->commit();
232
+				if ($globalTransaction) {
233
+					$Connection->db->commit();
234
+				}
197 235
 			} catch(PDOException $e) {
198
-				if ($globalTransaction) $Connection->db->rollBack(); 
236
+				if ($globalTransaction) {
237
+					$Connection->db->rollBack();
238
+				}
199 239
 				return "error : ".$e->getMessage();
200 240
 			}
201 241
 		}
@@ -238,11 +278,16 @@  discard block
 block discarded – undo
238 278
 		$sth_dest = $Connection->db->prepare($query_dest);
239 279
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 280
 		try {
241
-			if ($globalTransaction) $Connection->db->beginTransaction();
281
+			if ($globalTransaction) {
282
+				$Connection->db->beginTransaction();
283
+			}
242 284
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 285
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244
-				if ($values['UserString4'] == 'M') $type = 'military';
245
-				else $type = null;
286
+				if ($values['UserString4'] == 'M') {
287
+					$type = 'military';
288
+				} else {
289
+					$type = null;
290
+				}
246 291
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 292
 				$sth_dest->execute($query_dest_values);
248 293
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -250,7 +295,9 @@  discard block
 block discarded – undo
250 295
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 296
 				}
252 297
             		}
253
-			if ($globalTransaction) $Connection->db->commit();
298
+			if ($globalTransaction) {
299
+				$Connection->db->commit();
300
+			}
254 301
 		} catch(PDOException $e) {
255 302
 			return "error : ".$e->getMessage();
256 303
 		}
@@ -287,7 +334,9 @@  discard block
 block discarded – undo
287 334
 			$Connection = new Connection();
288 335
 			$sth_dest = $Connection->db->prepare($query_dest);
289 336
 			try {
290
-				if ($globalTransaction) $Connection->db->beginTransaction();
337
+				if ($globalTransaction) {
338
+					$Connection->db->beginTransaction();
339
+				}
291 340
             			while (!feof($fh)) {
292 341
             				$values = array();
293 342
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -298,7 +347,9 @@  discard block
 block discarded – undo
298 347
             				// Check if we can find ICAO, else set it to GLID
299 348
             				$aircraft_name_split = explode(' ',$aircraft_name);
300 349
             				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
350
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
351
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
352
+            				}
302 353
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303 354
             				$sth_search = $Connection->db->prepare($query_search);
304 355
 					try {
@@ -311,7 +362,9 @@  discard block
 block discarded – undo
311 362
 					} catch(PDOException $e) {
312 363
 						return "error : ".$e->getMessage();
313 364
 					}
314
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
365
+					if (!isset($values['ICAOTypeCode'])) {
366
+						$values['ICAOTypeCode'] = 'GLID';
367
+					}
315 368
 					// Add data to db
316 369
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 370
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -320,7 +373,9 @@  discard block
 block discarded – undo
320 373
 						$sth_dest->execute($query_dest_values);
321 374
 					}
322 375
 				}
323
-				if ($globalTransaction) $Connection->db->commit();
376
+				if ($globalTransaction) {
377
+					$Connection->db->commit();
378
+				}
324 379
 			} catch(PDOException $e) {
325 380
 				return "error : ".$e->getMessage();
326 381
 			}
@@ -356,7 +411,9 @@  discard block
 block discarded – undo
356 411
 			$Connection = new Connection();
357 412
 			$sth_dest = $Connection->db->prepare($query_dest);
358 413
 			try {
359
-				if ($globalTransaction) $Connection->db->beginTransaction();
414
+				if ($globalTransaction) {
415
+					$Connection->db->beginTransaction();
416
+				}
360 417
 				$tmp = fgetcsv($fh,9999,',',"'");
361 418
             			while (!feof($fh)) {
362 419
             				$line = fgetcsv($fh,9999,',',"'");
@@ -370,13 +427,17 @@  discard block
 block discarded – undo
370 427
             				// Check if we can find ICAO, else set it to GLID
371 428
             				$aircraft_name_split = explode(' ',$aircraft_name);
372 429
             				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
430
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
431
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
432
+            				}
374 433
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375 434
             				$sth_search = $Connection->db->prepare($query_search);
376 435
 					try {
377 436
                                     		$sth_search->execute();
378 437
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
438
+	            				if (isset($result['icao']) && $result['icao'] != '') {
439
+	            					$values['ICAOTypeCode'] = $result['icao'];
440
+	            				}
380 441
 					} catch(PDOException $e) {
381 442
 						return "error : ".$e->getMessage();
382 443
 					}
@@ -389,7 +450,9 @@  discard block
 block discarded – undo
389 450
 						$sth_dest->execute($query_dest_values);
390 451
 					}
391 452
 				}
392
-				if ($globalTransaction) $Connection->db->commit();
453
+				if ($globalTransaction) {
454
+					$Connection->db->commit();
455
+				}
393 456
 			} catch(PDOException $e) {
394 457
 				return "error : ".$e->getMessage();
395 458
 			}
@@ -428,7 +491,9 @@  discard block
 block discarded – undo
428 491
 			$sth_dest = $Connection->db->prepare($query_dest);
429 492
 			$sth_modes = $Connection->db->prepare($query_modes);
430 493
 			try {
431
-				if ($globalTransaction) $Connection->db->beginTransaction();
494
+				if ($globalTransaction) {
495
+					$Connection->db->beginTransaction();
496
+				}
432 497
 				$tmp = fgetcsv($fh,9999,',','"');
433 498
             			while (!feof($fh)) {
434 499
             				$line = fgetcsv($fh,9999,',','"');
@@ -438,16 +503,22 @@  discard block
 block discarded – undo
438 503
             				    $values['registration'] = $line[0];
439 504
             				    $values['base'] = $line[4];
440 505
             				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+            				    if ($line[6] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
510
+					    }
443 511
 					    $values['cancel'] = $line[7];
444 512
 					} elseif ($country == 'EI') {
445 513
 					    // TODO : add modeS & reg to aircraft_modes
446 514
             				    $values['registration'] = $line[0];
447 515
             				    $values['base'] = $line[3];
448 516
             				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
517
+            				    if ($line[1] == '') {
518
+            				    	$values['date_first_reg'] = null;
519
+            				    } else {
520
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
521
+					    }
451 522
 					    $values['cancel'] = '';
452 523
 					    $values['modes'] = $line[7];
453 524
 					    $values['icao'] = $line[8];
@@ -466,16 +537,22 @@  discard block
 block discarded – undo
466 537
             				    $values['registration'] = $line[3];
467 538
             				    $values['base'] = null;
468 539
             				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
540
+            				    if ($line[18] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
544
+					    }
471 545
 					    $values['cancel'] = '';
472 546
 					} elseif ($country == 'VH') {
473 547
 					    // TODO : add modeS & reg to aircraft_modes
474 548
             				    $values['registration'] = $line[0];
475 549
             				    $values['base'] = null;
476 550
             				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
551
+            				    if ($line[28] == '') {
552
+            				    	$values['date_first_reg'] = null;
553
+            				    } else {
554
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
555
+					    }
479 556
 
480 557
 					    $values['cancel'] = $line[39];
481 558
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -494,29 +571,41 @@  discard block
 block discarded – undo
494 571
             				    $values['registration'] = $line[0];
495 572
             				    $values['base'] = null;
496 573
             				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
574
+            				    if ($line[7] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
578
+					    }
499 579
 					    $values['cancel'] = '';
500 580
 					} elseif ($country == 'PP') {
501 581
             				    $values['registration'] = $line[0];
502 582
             				    $values['base'] = null;
503 583
             				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
584
+            				    if ($line[6] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
588
+					    }
506 589
 					    $values['cancel'] = $line[7];
507 590
 					} elseif ($country == 'E7') {
508 591
             				    $values['registration'] = $line[0];
509 592
             				    $values['base'] = null;
510 593
             				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
594
+            				    if ($line[5] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
598
+					    }
513 599
 					    $values['cancel'] = '';
514 600
 					} elseif ($country == '8Q') {
515 601
             				    $values['registration'] = $line[0];
516 602
             				    $values['base'] = null;
517 603
             				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
604
+            				    if ($line[7] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
608
+					    }
520 609
 					    $values['cancel'] = '';
521 610
 					} elseif ($country == 'ZK') {
522 611
             				    $values['registration'] = $line[0];
@@ -561,7 +650,9 @@  discard block
 block discarded – undo
561 650
 						$sth_modes->execute($query_modes_values);
562 651
 					}
563 652
 				}
564
-				if ($globalTransaction) $Connection->db->commit();
653
+				if ($globalTransaction) {
654
+					$Connection->db->commit();
655
+				}
565 656
 			} catch(PDOException $e) {
566 657
 				return "error : ".$e->getMessage();
567 658
 			}
@@ -697,25 +788,45 @@  discard block
 block discarded – undo
697 788
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
698 789
 		$Connection = new Connection();
699 790
 		$sth_dest = $Connection->db->prepare($query_dest);
700
-		if ($globalTransaction) $Connection->db->beginTransaction();
791
+		if ($globalTransaction) {
792
+			$Connection->db->beginTransaction();
793
+		}
701 794
   
702 795
 		$i = 0;
703 796
 		while($row = sparql_fetch_array($result))
704 797
 		{
705 798
 			if ($i >= 1) {
706 799
 			//print_r($row);
707
-			if (!isset($row['iata'])) $row['iata'] = '';
708
-			if (!isset($row['icao'])) $row['icao'] = '';
709
-			if (!isset($row['type'])) $row['type'] = '';
710
-			if (!isset($row['altitude'])) $row['altitude'] = '';
800
+			if (!isset($row['iata'])) {
801
+				$row['iata'] = '';
802
+			}
803
+			if (!isset($row['icao'])) {
804
+				$row['icao'] = '';
805
+			}
806
+			if (!isset($row['type'])) {
807
+				$row['type'] = '';
808
+			}
809
+			if (!isset($row['altitude'])) {
810
+				$row['altitude'] = '';
811
+			}
711 812
 			if (isset($row['city_bis'])) {
712 813
 				$row['city'] = $row['city_bis'];
713 814
 			}
714
-			if (!isset($row['city'])) $row['city'] = '';
715
-			if (!isset($row['country'])) $row['country'] = '';
716
-			if (!isset($row['homepage'])) $row['homepage'] = '';
717
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
718
-			if (!isset($row['name'])) continue;
815
+			if (!isset($row['city'])) {
816
+				$row['city'] = '';
817
+			}
818
+			if (!isset($row['country'])) {
819
+				$row['country'] = '';
820
+			}
821
+			if (!isset($row['homepage'])) {
822
+				$row['homepage'] = '';
823
+			}
824
+			if (!isset($row['wikipedia_page'])) {
825
+				$row['wikipedia_page'] = '';
826
+			}
827
+			if (!isset($row['name'])) {
828
+				continue;
829
+			}
719 830
 			if (!isset($row['image'])) {
720 831
 				$row['image'] = '';
721 832
 				$row['image_thumb'] = '';
@@ -771,7 +882,9 @@  discard block
 block discarded – undo
771 882
 
772 883
 			$i++;
773 884
 		}
774
-		if ($globalTransaction) $Connection->db->commit();
885
+		if ($globalTransaction) {
886
+			$Connection->db->commit();
887
+		}
775 888
 		/*
776 889
 		echo "Delete duplicate rows...\n";
777 890
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -814,7 +927,9 @@  discard block
 block discarded – undo
814 927
 		$delimiter = ',';
815 928
 		$out_file = $tmp_dir.'airports.csv';
816 929
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
817
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
930
+		if (!file_exists($out_file) || !is_readable($out_file)) {
931
+			return FALSE;
932
+		}
818 933
 		echo "Add data from ourairports.com...\n";
819 934
 
820 935
 		$header = NULL;
@@ -824,8 +939,9 @@  discard block
 block discarded – undo
824 939
 			//$Connection->db->beginTransaction();
825 940
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 941
 			{
827
-				if(!$header) $header = $row;
828
-				else {
942
+				if(!$header) {
943
+					$header = $row;
944
+				} else {
829 945
 					$data = array();
830 946
 					$data = array_combine($header, $row);
831 947
 					try {
@@ -866,7 +982,9 @@  discard block
 block discarded – undo
866 982
 		echo "Download data from another free database...\n";
867 983
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868 984
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
869
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
985
+		if (!file_exists($out_file) || !is_readable($out_file)) {
986
+			return FALSE;
987
+		}
870 988
 		update_db::unzip($out_file);
871 989
 		$header = NULL;
872 990
 		echo "Add data from another free database...\n";
@@ -877,8 +995,9 @@  discard block
 block discarded – undo
877 995
 			//$Connection->db->beginTransaction();
878 996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 997
 			{
880
-				if(!$header) $header = $row;
881
-				else {
998
+				if(!$header) {
999
+					$header = $row;
1000
+				} else {
882 1001
 					$data = $row;
883 1002
 
884 1003
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1047,7 +1166,9 @@  discard block
 block discarded – undo
1047 1166
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1048 1167
 		{
1049 1168
 			$i = 0;
1050
-			if ($globalTransaction) $Connection->db->beginTransaction();
1169
+			if ($globalTransaction) {
1170
+				$Connection->db->beginTransaction();
1171
+			}
1051 1172
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1052 1173
 			{
1053 1174
 				if ($i > 0) {
@@ -1060,7 +1181,9 @@  discard block
 block discarded – undo
1060 1181
 					}
1061 1182
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1062 1183
 					if (!empty($result_search)) {
1063
-						if ($globalDebug) echo '.';
1184
+						if ($globalDebug) {
1185
+							echo '.';
1186
+						}
1064 1187
 							//if ($globalDBdriver == 'mysql') {
1065 1188
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1066 1189
 							//} else {
@@ -1082,8 +1205,12 @@  discard block
 block discarded – undo
1082 1205
 						}
1083 1206
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1084 1207
 						if (!empty($result_search_mfr)) {
1085
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1086
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1208
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1209
+								$data[16] = $data[23];
1210
+							}
1211
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1212
+								$data[16] = $data[15];
1213
+							}
1087 1214
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1215
 							try {
1089 1216
 								$sthf = $Connection->db->prepare($queryf);
@@ -1094,7 +1221,9 @@  discard block
 block discarded – undo
1094 1221
 						}
1095 1222
 					}
1096 1223
 					if (strtotime($data[29]) > time()) {
1097
-						if ($globalDebug) echo 'i';
1224
+						if ($globalDebug) {
1225
+							echo 'i';
1226
+						}
1098 1227
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1228
 						try {
1100 1229
 							$sth = $Connection->db->prepare($query);
@@ -1105,13 +1234,19 @@  discard block
 block discarded – undo
1105 1234
 					}
1106 1235
 				}
1107 1236
 				if ($i % 90 == 0) {
1108
-					if ($globalTransaction) $Connection->db->commit();
1109
-					if ($globalTransaction) $Connection->db->beginTransaction();
1237
+					if ($globalTransaction) {
1238
+						$Connection->db->commit();
1239
+					}
1240
+					if ($globalTransaction) {
1241
+						$Connection->db->beginTransaction();
1242
+					}
1110 1243
 				}
1111 1244
 				$i++;
1112 1245
 			}
1113 1246
 			fclose($handle);
1114
-			if ($globalTransaction) $Connection->db->commit();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->commit();
1249
+			}
1115 1250
 		}
1116 1251
 		return '';
1117 1252
 	}
@@ -1131,11 +1266,15 @@  discard block
 block discarded – undo
1131 1266
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1132 1267
 		{
1133 1268
 			$i = 0;
1134
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1135 1272
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1136 1273
 			{
1137 1274
 				if ($i > 0) {
1138
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1275
+					if ($data[1] == 'NULL') {
1276
+						$data[1] = $data[0];
1277
+					}
1139 1278
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1279
 					try {
1141 1280
 						$sth = $Connection->db->prepare($query);
@@ -1147,7 +1286,9 @@  discard block
 block discarded – undo
1147 1286
 				$i++;
1148 1287
 			}
1149 1288
 			fclose($handle);
1150
-			if ($globalTransaction) $Connection->db->commit();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->commit();
1291
+			}
1151 1292
 		}
1152 1293
 		return '';
1153 1294
 	}
@@ -1179,11 +1320,15 @@  discard block
 block discarded – undo
1179 1320
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1180 1321
 		{
1181 1322
 			$i = 0;
1182
-			if ($globalTransaction) $Connection->db->beginTransaction();
1323
+			if ($globalTransaction) {
1324
+				$Connection->db->beginTransaction();
1325
+			}
1183 1326
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1184 1327
 			{
1185 1328
 				if ($i > 0) {
1186
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1329
+					if ($data[1] == 'NULL') {
1330
+						$data[1] = $data[0];
1331
+					}
1187 1332
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1333
 					try {
1189 1334
 						$sth = $Connection->db->prepare($query);
@@ -1195,7 +1340,9 @@  discard block
 block discarded – undo
1195 1340
 				$i++;
1196 1341
 			}
1197 1342
 			fclose($handle);
1198
-			if ($globalTransaction) $Connection->db->commit();
1343
+			if ($globalTransaction) {
1344
+				$Connection->db->commit();
1345
+			}
1199 1346
 		}
1200 1347
 		/*
1201 1348
 		$query = "UNLOCK TABLES";
@@ -1225,7 +1372,9 @@  discard block
 block discarded – undo
1225 1372
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1226 1373
 		{
1227 1374
 			$i = 0;
1228
-			if ($globalTransaction) $Connection->db->beginTransaction();
1375
+			if ($globalTransaction) {
1376
+				$Connection->db->beginTransaction();
1377
+			}
1229 1378
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1230 1379
 			{
1231 1380
 				if ($i > 0) {
@@ -1241,7 +1390,9 @@  discard block
 block discarded – undo
1241 1390
 				$i++;
1242 1391
 			}
1243 1392
 			fclose($handle);
1244
-			if ($globalTransaction) $Connection->db->commit();
1393
+			if ($globalTransaction) {
1394
+				$Connection->db->commit();
1395
+			}
1245 1396
 		}
1246 1397
 		return '';
1247 1398
         }
@@ -1261,7 +1412,9 @@  discard block
 block discarded – undo
1261 1412
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1262 1413
 		{
1263 1414
 			$i = 0;
1264
-			if ($globalTransaction) $Connection->db->beginTransaction();
1415
+			if ($globalTransaction) {
1416
+				$Connection->db->beginTransaction();
1417
+			}
1265 1418
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1266 1419
 			{
1267 1420
 				if ($i > 0) {
@@ -1271,19 +1424,25 @@  discard block
 block discarded – undo
1271 1424
 						$sth = $Connection->db->prepare($query);
1272 1425
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1273 1426
 					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1427
+						if ($globalDebug) {
1428
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1429
+						}
1275 1430
 						die();
1276 1431
 					}
1277 1432
 				}
1278 1433
 				if ($globalTransaction && $i % 2000 == 0) {
1279 1434
 					$Connection->db->commit();
1280
-					if ($globalDebug) echo '.';
1435
+					if ($globalDebug) {
1436
+						echo '.';
1437
+					}
1281 1438
 					$Connection->db->beginTransaction();
1282 1439
 				}
1283 1440
 				$i++;
1284 1441
 			}
1285 1442
 			fclose($handle);
1286
-			if ($globalTransaction) $Connection->db->commit();
1443
+			if ($globalTransaction) {
1444
+				$Connection->db->commit();
1445
+			}
1287 1446
 		}
1288 1447
 		return '';
1289 1448
         }
@@ -1308,7 +1467,9 @@  discard block
 block discarded – undo
1308 1467
 			$i = 0;
1309 1468
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1310 1469
 			//$Connection->db->beginTransaction();
1311
-			if ($globalTransaction) $Connection->db->beginTransaction();
1470
+			if ($globalTransaction) {
1471
+				$Connection->db->beginTransaction();
1472
+			}
1312 1473
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1313 1474
 			{
1314 1475
 				if ($i > 0) {
@@ -1324,7 +1485,9 @@  discard block
 block discarded – undo
1324 1485
 				$i++;
1325 1486
 			}
1326 1487
 			fclose($handle);
1327
-			if ($globalTransaction) $Connection->db->commit();
1488
+			if ($globalTransaction) {
1489
+				$Connection->db->commit();
1490
+			}
1328 1491
 		}
1329 1492
 		return '';
1330 1493
         }
@@ -1344,7 +1507,9 @@  discard block
 block discarded – undo
1344 1507
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1345 1508
 		{
1346 1509
 			$i = 0;
1347
-			if ($globalTransaction) $Connection->db->beginTransaction();
1510
+			if ($globalTransaction) {
1511
+				$Connection->db->beginTransaction();
1512
+			}
1348 1513
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1349 1514
 			{
1350 1515
 				if ($i > 0) {
@@ -1361,7 +1526,9 @@  discard block
 block discarded – undo
1361 1526
 				$i++;
1362 1527
 			}
1363 1528
 			fclose($handle);
1364
-			if ($globalTransaction) $Connection->db->commit();
1529
+			if ($globalTransaction) {
1530
+				$Connection->db->commit();
1531
+			}
1365 1532
 		}
1366 1533
 		return '';
1367 1534
 	}
@@ -1380,7 +1547,9 @@  discard block
 block discarded – undo
1380 1547
 		$Connection = new Connection();
1381 1548
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1382 1549
 		{
1383
-			if ($globalTransaction) $Connection->db->beginTransaction();
1550
+			if ($globalTransaction) {
1551
+				$Connection->db->beginTransaction();
1552
+			}
1384 1553
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1385 1554
 			{
1386 1555
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1395,7 +1564,9 @@  discard block
 block discarded – undo
1395 1564
 				}
1396 1565
 			}
1397 1566
 			fclose($handle);
1398
-			if ($globalTransaction) $Connection->db->commit();
1567
+			if ($globalTransaction) {
1568
+				$Connection->db->commit();
1569
+			}
1399 1570
 		}
1400 1571
 		return '';
1401 1572
         }
@@ -1471,9 +1642,14 @@  discard block
 block discarded – undo
1471 1642
 				if ($i > 0 && $data[0] != '') {
1472 1643
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1473 1644
 					$period = str_replace(',','',$data[14]);
1474
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1475
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1476
-					else $launch_date = NULL;
1645
+					if (!empty($period) && strpos($period,'days')) {
1646
+						$period = str_replace(' days','',$period)*24*60;
1647
+					}
1648
+					if ($data[18] != '') {
1649
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1650
+					} else {
1651
+						$launch_date = NULL;
1652
+					}
1477 1653
 					$data = array_map(function($value) {
1478 1654
 						return trim($value) === '' ? null : $value;
1479 1655
 					}, $data);
@@ -1836,7 +2012,9 @@  discard block
 block discarded – undo
1836 2012
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1837 2013
 		{
1838 2014
 			$i = 0;
1839
-			if ($globalTransaction) $Connection->db->beginTransaction();
2015
+			if ($globalTransaction) {
2016
+				$Connection->db->beginTransaction();
2017
+			}
1840 2018
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1841 2019
 			{
1842 2020
 				$i++;
@@ -1864,7 +2042,9 @@  discard block
 block discarded – undo
1864 2042
 				}
1865 2043
 			}
1866 2044
 			fclose($handle);
1867
-			if ($globalTransaction) $Connection->db->commit();
2045
+			if ($globalTransaction) {
2046
+				$Connection->db->commit();
2047
+			}
1868 2048
 		}
1869 2049
 		return '';
1870 2050
 	}
@@ -1907,7 +2087,9 @@  discard block
 block discarded – undo
1907 2087
 		$Connection = new Connection();
1908 2088
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1909 2089
 		{
1910
-			if ($globalTransaction) $Connection->db->beginTransaction();
2090
+			if ($globalTransaction) {
2091
+				$Connection->db->beginTransaction();
2092
+			}
1911 2093
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1912 2094
 			{
1913 2095
 				if(count($row) > 1) {
@@ -1921,7 +2103,9 @@  discard block
 block discarded – undo
1921 2103
 				}
1922 2104
 			}
1923 2105
 			fclose($handle);
1924
-			if ($globalTransaction) $Connection->db->commit();
2106
+			if ($globalTransaction) {
2107
+				$Connection->db->commit();
2108
+			}
1925 2109
 		}
1926 2110
 		return '';
1927 2111
         }
@@ -1941,8 +2125,9 @@  discard block
 block discarded – undo
1941 2125
 	        }
1942 2126
 
1943 2127
 
1944
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1945
-		else {
2128
+		if ($globalDBdriver == 'mysql') {
2129
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2130
+		} else {
1946 2131
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1947 2132
 			$query = "CREATE EXTENSION postgis";
1948 2133
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1961,7 +2146,9 @@  discard block
 block discarded – undo
1961 2146
 		global $tmp_dir, $globalDebug;
1962 2147
 		include_once('class.create_db.php');
1963 2148
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1964
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2149
+		if ($globalDebug) {
2150
+			echo "NOTAM from FlightAirMap website : Download...";
2151
+		}
1965 2152
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1966 2153
 		$error = '';
1967 2154
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -1971,20 +2158,34 @@  discard block
 block discarded – undo
1971 2158
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1972 2159
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
1973 2160
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1974
-						if ($globalDebug) echo "Gunzip...";
2161
+						if ($globalDebug) {
2162
+							echo "Gunzip...";
2163
+						}
1975 2164
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
1976
-						if ($globalDebug) echo "Add to DB...";
2165
+						if ($globalDebug) {
2166
+							echo "Add to DB...";
2167
+						}
1977 2168
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
1978 2169
 						$NOTAM = new NOTAM();
1979 2170
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1980 2171
 						update_db::insert_notam_version($notam_md5);
1981
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
1982
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1983
-			} elseif ($globalDebug) echo "No new version.";
1984
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2172
+					} else {
2173
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2174
+					}
2175
+				} else {
2176
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2177
+				}
2178
+			} elseif ($globalDebug) {
2179
+				echo "No new version.";
2180
+			}
2181
+		} else {
2182
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2183
+		}
1985 2184
 		if ($error != '') {
1986 2185
 			return $error;
1987
-		} elseif ($globalDebug) echo "Done\n";
2186
+		} elseif ($globalDebug) {
2187
+			echo "Done\n";
2188
+		}
1988 2189
 		return '';
1989 2190
 	}
1990 2191
 
@@ -2039,68 +2240,114 @@  discard block
 block discarded – undo
2039 2240
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
2040 2241
 		if (extension_loaded('zip')) {
2041 2242
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
2042
-				if ($globalDebug) echo "Unzip...";
2243
+				if ($globalDebug) {
2244
+					echo "Unzip...";
2245
+				}
2043 2246
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
2044
-				if ($globalDebug) echo "Add to DB...";
2247
+				if ($globalDebug) {
2248
+					echo "Add to DB...";
2249
+				}
2045 2250
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2046
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2251
+				if ($globalDebug) {
2252
+					echo "Copy airlines logos to airlines images directory...";
2253
+				}
2047 2254
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2048
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2049
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2050
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2051
-		} else $error = "ZIP module not loaded but required for IVAO.";
2255
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2256
+						$error = "Failed to copy airlines logo.";
2257
+					}
2258
+				} else {
2259
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2260
+				}
2261
+			} else {
2262
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2263
+			}
2264
+		} else {
2265
+			$error = "ZIP module not loaded but required for IVAO.";
2266
+		}
2052 2267
 		if ($error != '') {
2053 2268
 			return $error;
2054
-		} elseif ($globalDebug) echo "Done\n";
2269
+		} elseif ($globalDebug) {
2270
+			echo "Done\n";
2271
+		}
2055 2272
 		return '';
2056 2273
 	}
2057 2274
 
2058 2275
 	public static function update_routes() {
2059 2276
 		global $tmp_dir, $globalDebug;
2060 2277
 		$error = '';
2061
-		if ($globalDebug) echo "Routes : Download...";
2278
+		if ($globalDebug) {
2279
+			echo "Routes : Download...";
2280
+		}
2062 2281
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2063 2282
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2064
-			if ($globalDebug) echo "Gunzip...";
2283
+			if ($globalDebug) {
2284
+				echo "Gunzip...";
2285
+			}
2065 2286
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2066
-			if ($globalDebug) echo "Add to DB...";
2287
+			if ($globalDebug) {
2288
+				echo "Add to DB...";
2289
+			}
2067 2290
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2068
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2291
+		} else {
2292
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2293
+		}
2069 2294
 		if ($error != '') {
2070 2295
 			return $error;
2071
-		} elseif ($globalDebug) echo "Done\n";
2296
+		} elseif ($globalDebug) {
2297
+			echo "Done\n";
2298
+		}
2072 2299
 		return '';
2073 2300
 	}
2074 2301
 	public static function update_oneworld() {
2075 2302
 		global $tmp_dir, $globalDebug;
2076 2303
 		$error = '';
2077
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2304
+		if ($globalDebug) {
2305
+			echo "Schedules Oneworld : Download...";
2306
+		}
2078 2307
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2079 2308
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2080
-			if ($globalDebug) echo "Gunzip...";
2309
+			if ($globalDebug) {
2310
+				echo "Gunzip...";
2311
+			}
2081 2312
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2082
-			if ($globalDebug) echo "Add to DB...";
2313
+			if ($globalDebug) {
2314
+				echo "Add to DB...";
2315
+			}
2083 2316
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2084
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2317
+		} else {
2318
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2319
+		}
2085 2320
 		if ($error != '') {
2086 2321
 			return $error;
2087
-		} elseif ($globalDebug) echo "Done\n";
2322
+		} elseif ($globalDebug) {
2323
+			echo "Done\n";
2324
+		}
2088 2325
 		return '';
2089 2326
 	}
2090 2327
 	public static function update_skyteam() {
2091 2328
 		global $tmp_dir, $globalDebug;
2092 2329
 		$error = '';
2093
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2330
+		if ($globalDebug) {
2331
+			echo "Schedules Skyteam : Download...";
2332
+		}
2094 2333
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2095 2334
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2096
-			if ($globalDebug) echo "Gunzip...";
2335
+			if ($globalDebug) {
2336
+				echo "Gunzip...";
2337
+			}
2097 2338
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2098
-			if ($globalDebug) echo "Add to DB...";
2339
+			if ($globalDebug) {
2340
+				echo "Add to DB...";
2341
+			}
2099 2342
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2100
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2343
+		} else {
2344
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2345
+		}
2101 2346
 		if ($error != '') {
2102 2347
 			return $error;
2103
-		} elseif ($globalDebug) echo "Done\n";
2348
+		} elseif ($globalDebug) {
2349
+			echo "Done\n";
2350
+		}
2104 2351
 		return '';
2105 2352
 	}
2106 2353
 	public static function update_ModeS() {
@@ -2117,340 +2364,590 @@  discard block
 block discarded – undo
2117 2364
 			exit;
2118 2365
 		} elseif ($globalDebug) echo "Done\n";
2119 2366
 */
2120
-		if ($globalDebug) echo "Modes : Download...";
2121
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2367
+		if ($globalDebug) {
2368
+			echo "Modes : Download...";
2369
+		}
2370
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2122 2371
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2123 2372
 
2124 2373
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2125 2374
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2126
-			if ($globalDebug) echo "Unzip...";
2127
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2375
+			if ($globalDebug) {
2376
+				echo "Unzip...";
2377
+			}
2378
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2128 2379
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2129
-			if ($globalDebug) echo "Add to DB...";
2380
+			if ($globalDebug) {
2381
+				echo "Add to DB...";
2382
+			}
2130 2383
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2131 2384
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2132
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2385
+		} else {
2386
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2387
+		}
2133 2388
 		if ($error != '') {
2134 2389
 			return $error;
2135
-		} elseif ($globalDebug) echo "Done\n";
2390
+		} elseif ($globalDebug) {
2391
+			echo "Done\n";
2392
+		}
2136 2393
 		return '';
2137 2394
 	}
2138 2395
 
2139 2396
 	public static function update_ModeS_faa() {
2140 2397
 		global $tmp_dir, $globalDebug;
2141
-		if ($globalDebug) echo "Modes FAA: Download...";
2398
+		if ($globalDebug) {
2399
+			echo "Modes FAA: Download...";
2400
+		}
2142 2401
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2143 2402
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2144
-			if ($globalDebug) echo "Unzip...";
2403
+			if ($globalDebug) {
2404
+				echo "Unzip...";
2405
+			}
2145 2406
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2146
-			if ($globalDebug) echo "Add to DB...";
2407
+			if ($globalDebug) {
2408
+				echo "Add to DB...";
2409
+			}
2147 2410
 			$error = update_db::modes_faa();
2148
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2411
+		} else {
2412
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2413
+		}
2149 2414
 		if ($error != '') {
2150 2415
 			return $error;
2151
-		} elseif ($globalDebug) echo "Done\n";
2416
+		} elseif ($globalDebug) {
2417
+			echo "Done\n";
2418
+		}
2152 2419
 		return '';
2153 2420
 	}
2154 2421
 
2155 2422
 	public static function update_ModeS_flarm() {
2156 2423
 		global $tmp_dir, $globalDebug;
2157
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2424
+		if ($globalDebug) {
2425
+			echo "Modes Flarmnet: Download...";
2426
+		}
2158 2427
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2159 2428
 		if (file_exists($tmp_dir.'data.fln')) {
2160
-			if ($globalDebug) echo "Add to DB...";
2429
+			if ($globalDebug) {
2430
+				echo "Add to DB...";
2431
+			}
2161 2432
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2162
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2433
+		} else {
2434
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2435
+		}
2163 2436
 		if ($error != '') {
2164 2437
 			return $error;
2165
-		} elseif ($globalDebug) echo "Done\n";
2438
+		} elseif ($globalDebug) {
2439
+			echo "Done\n";
2440
+		}
2166 2441
 		return '';
2167 2442
 	}
2168 2443
 
2169 2444
 	public static function update_ModeS_ogn() {
2170 2445
 		global $tmp_dir, $globalDebug;
2171
-		if ($globalDebug) echo "Modes OGN: Download...";
2446
+		if ($globalDebug) {
2447
+			echo "Modes OGN: Download...";
2448
+		}
2172 2449
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2173 2450
 		if (file_exists($tmp_dir.'ogn.csv')) {
2174
-			if ($globalDebug) echo "Add to DB...";
2451
+			if ($globalDebug) {
2452
+				echo "Add to DB...";
2453
+			}
2175 2454
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2176
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2455
+		} else {
2456
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2457
+		}
2177 2458
 		if ($error != '') {
2178 2459
 			return $error;
2179
-		} elseif ($globalDebug) echo "Done\n";
2460
+		} elseif ($globalDebug) {
2461
+			echo "Done\n";
2462
+		}
2180 2463
 		return '';
2181 2464
 	}
2182 2465
 
2183 2466
 	public static function update_owner() {
2184 2467
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2185 2468
 		
2186
-		if ($globalDebug) echo "Owner France: Download...";
2469
+		if ($globalDebug) {
2470
+			echo "Owner France: Download...";
2471
+		}
2187 2472
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2188 2473
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2189
-			if ($globalDebug) echo "Add to DB...";
2474
+			if ($globalDebug) {
2475
+				echo "Add to DB...";
2476
+			}
2190 2477
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2191
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2478
+		} else {
2479
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2480
+		}
2192 2481
 		if ($error != '') {
2193 2482
 			return $error;
2194
-		} elseif ($globalDebug) echo "Done\n";
2483
+		} elseif ($globalDebug) {
2484
+			echo "Done\n";
2485
+		}
2195 2486
 		
2196
-		if ($globalDebug) echo "Owner Ireland: Download...";
2487
+		if ($globalDebug) {
2488
+			echo "Owner Ireland: Download...";
2489
+		}
2197 2490
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2198 2491
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2199
-			if ($globalDebug) echo "Add to DB...";
2492
+			if ($globalDebug) {
2493
+				echo "Add to DB...";
2494
+			}
2200 2495
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2201
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2496
+		} else {
2497
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2498
+		}
2202 2499
 		if ($error != '') {
2203 2500
 			return $error;
2204
-		} elseif ($globalDebug) echo "Done\n";
2205
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2501
+		} elseif ($globalDebug) {
2502
+			echo "Done\n";
2503
+		}
2504
+		if ($globalDebug) {
2505
+			echo "Owner Switzerland: Download...";
2506
+		}
2206 2507
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2207 2508
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2208
-			if ($globalDebug) echo "Add to DB...";
2509
+			if ($globalDebug) {
2510
+				echo "Add to DB...";
2511
+			}
2209 2512
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2210
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2513
+		} else {
2514
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2515
+		}
2211 2516
 		if ($error != '') {
2212 2517
 			return $error;
2213
-		} elseif ($globalDebug) echo "Done\n";
2214
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2518
+		} elseif ($globalDebug) {
2519
+			echo "Done\n";
2520
+		}
2521
+		if ($globalDebug) {
2522
+			echo "Owner Czech Republic: Download...";
2523
+		}
2215 2524
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2216 2525
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2217
-			if ($globalDebug) echo "Add to DB...";
2526
+			if ($globalDebug) {
2527
+				echo "Add to DB...";
2528
+			}
2218 2529
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2219
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2530
+		} else {
2531
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2532
+		}
2220 2533
 		if ($error != '') {
2221 2534
 			return $error;
2222
-		} elseif ($globalDebug) echo "Done\n";
2223
-		if ($globalDebug) echo "Owner Australia: Download...";
2535
+		} elseif ($globalDebug) {
2536
+			echo "Done\n";
2537
+		}
2538
+		if ($globalDebug) {
2539
+			echo "Owner Australia: Download...";
2540
+		}
2224 2541
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2225 2542
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2226
-			if ($globalDebug) echo "Add to DB...";
2543
+			if ($globalDebug) {
2544
+				echo "Add to DB...";
2545
+			}
2227 2546
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2228
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2547
+		} else {
2548
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2549
+		}
2229 2550
 		if ($error != '') {
2230 2551
 			return $error;
2231
-		} elseif ($globalDebug) echo "Done\n";
2232
-		if ($globalDebug) echo "Owner Austria: Download...";
2552
+		} elseif ($globalDebug) {
2553
+			echo "Done\n";
2554
+		}
2555
+		if ($globalDebug) {
2556
+			echo "Owner Austria: Download...";
2557
+		}
2233 2558
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2234 2559
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2235
-			if ($globalDebug) echo "Add to DB...";
2560
+			if ($globalDebug) {
2561
+				echo "Add to DB...";
2562
+			}
2236 2563
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2237
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2564
+		} else {
2565
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2566
+		}
2238 2567
 		if ($error != '') {
2239 2568
 			return $error;
2240
-		} elseif ($globalDebug) echo "Done\n";
2241
-		if ($globalDebug) echo "Owner Chile: Download...";
2569
+		} elseif ($globalDebug) {
2570
+			echo "Done\n";
2571
+		}
2572
+		if ($globalDebug) {
2573
+			echo "Owner Chile: Download...";
2574
+		}
2242 2575
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2243 2576
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2244
-			if ($globalDebug) echo "Add to DB...";
2577
+			if ($globalDebug) {
2578
+				echo "Add to DB...";
2579
+			}
2245 2580
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2246
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2581
+		} else {
2582
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2583
+		}
2247 2584
 		if ($error != '') {
2248 2585
 			return $error;
2249
-		} elseif ($globalDebug) echo "Done\n";
2250
-		if ($globalDebug) echo "Owner Colombia: Download...";
2586
+		} elseif ($globalDebug) {
2587
+			echo "Done\n";
2588
+		}
2589
+		if ($globalDebug) {
2590
+			echo "Owner Colombia: Download...";
2591
+		}
2251 2592
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2252 2593
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2253
-			if ($globalDebug) echo "Add to DB...";
2594
+			if ($globalDebug) {
2595
+				echo "Add to DB...";
2596
+			}
2254 2597
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2255
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2598
+		} else {
2599
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2600
+		}
2256 2601
 		if ($error != '') {
2257 2602
 			return $error;
2258
-		} elseif ($globalDebug) echo "Done\n";
2259
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2603
+		} elseif ($globalDebug) {
2604
+			echo "Done\n";
2605
+		}
2606
+		if ($globalDebug) {
2607
+			echo "Owner Bosnia Herzegobina: Download...";
2608
+		}
2260 2609
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2261 2610
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2262
-			if ($globalDebug) echo "Add to DB...";
2611
+			if ($globalDebug) {
2612
+				echo "Add to DB...";
2613
+			}
2263 2614
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2264
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2615
+		} else {
2616
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2617
+		}
2265 2618
 		if ($error != '') {
2266 2619
 			return $error;
2267
-		} elseif ($globalDebug) echo "Done\n";
2268
-		if ($globalDebug) echo "Owner Brazil: Download...";
2620
+		} elseif ($globalDebug) {
2621
+			echo "Done\n";
2622
+		}
2623
+		if ($globalDebug) {
2624
+			echo "Owner Brazil: Download...";
2625
+		}
2269 2626
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2270 2627
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2271
-			if ($globalDebug) echo "Add to DB...";
2628
+			if ($globalDebug) {
2629
+				echo "Add to DB...";
2630
+			}
2272 2631
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2273
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2632
+		} else {
2633
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2634
+		}
2274 2635
 		if ($error != '') {
2275 2636
 			return $error;
2276
-		} elseif ($globalDebug) echo "Done\n";
2277
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2637
+		} elseif ($globalDebug) {
2638
+			echo "Done\n";
2639
+		}
2640
+		if ($globalDebug) {
2641
+			echo "Owner Cayman Islands: Download...";
2642
+		}
2278 2643
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2279 2644
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2280
-			if ($globalDebug) echo "Add to DB...";
2645
+			if ($globalDebug) {
2646
+				echo "Add to DB...";
2647
+			}
2281 2648
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2282
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2649
+		} else {
2650
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2651
+		}
2283 2652
 		if ($error != '') {
2284 2653
 			return $error;
2285
-		} elseif ($globalDebug) echo "Done\n";
2286
-		if ($globalDebug) echo "Owner Croatia: Download...";
2654
+		} elseif ($globalDebug) {
2655
+			echo "Done\n";
2656
+		}
2657
+		if ($globalDebug) {
2658
+			echo "Owner Croatia: Download...";
2659
+		}
2287 2660
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2288 2661
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2289
-			if ($globalDebug) echo "Add to DB...";
2662
+			if ($globalDebug) {
2663
+				echo "Add to DB...";
2664
+			}
2290 2665
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2291
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2666
+		} else {
2667
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2668
+		}
2292 2669
 		if ($error != '') {
2293 2670
 			return $error;
2294
-		} elseif ($globalDebug) echo "Done\n";
2295
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2671
+		} elseif ($globalDebug) {
2672
+			echo "Done\n";
2673
+		}
2674
+		if ($globalDebug) {
2675
+			echo "Owner Luxembourg: Download...";
2676
+		}
2296 2677
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2297 2678
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2298
-			if ($globalDebug) echo "Add to DB...";
2679
+			if ($globalDebug) {
2680
+				echo "Add to DB...";
2681
+			}
2299 2682
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2300
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2683
+		} else {
2684
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2685
+		}
2301 2686
 		if ($error != '') {
2302 2687
 			return $error;
2303
-		} elseif ($globalDebug) echo "Done\n";
2304
-		if ($globalDebug) echo "Owner Maldives: Download...";
2688
+		} elseif ($globalDebug) {
2689
+			echo "Done\n";
2690
+		}
2691
+		if ($globalDebug) {
2692
+			echo "Owner Maldives: Download...";
2693
+		}
2305 2694
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2306 2695
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2307
-			if ($globalDebug) echo "Add to DB...";
2696
+			if ($globalDebug) {
2697
+				echo "Add to DB...";
2698
+			}
2308 2699
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2309
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2700
+		} else {
2701
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2702
+		}
2310 2703
 		if ($error != '') {
2311 2704
 			return $error;
2312
-		} elseif ($globalDebug) echo "Done\n";
2313
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2705
+		} elseif ($globalDebug) {
2706
+			echo "Done\n";
2707
+		}
2708
+		if ($globalDebug) {
2709
+			echo "Owner New Zealand: Download...";
2710
+		}
2314 2711
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2315 2712
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2316
-			if ($globalDebug) echo "Add to DB...";
2713
+			if ($globalDebug) {
2714
+				echo "Add to DB...";
2715
+			}
2317 2716
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2318
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2717
+		} else {
2718
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2719
+		}
2319 2720
 		if ($error != '') {
2320 2721
 			return $error;
2321
-		} elseif ($globalDebug) echo "Done\n";
2322
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2722
+		} elseif ($globalDebug) {
2723
+			echo "Done\n";
2724
+		}
2725
+		if ($globalDebug) {
2726
+			echo "Owner Papua New Guinea: Download...";
2727
+		}
2323 2728
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2324 2729
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2325
-			if ($globalDebug) echo "Add to DB...";
2730
+			if ($globalDebug) {
2731
+				echo "Add to DB...";
2732
+			}
2326 2733
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2327
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2734
+		} else {
2735
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2736
+		}
2328 2737
 		if ($error != '') {
2329 2738
 			return $error;
2330
-		} elseif ($globalDebug) echo "Done\n";
2331
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2739
+		} elseif ($globalDebug) {
2740
+			echo "Done\n";
2741
+		}
2742
+		if ($globalDebug) {
2743
+			echo "Owner Slovakia: Download...";
2744
+		}
2332 2745
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2333 2746
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2334
-			if ($globalDebug) echo "Add to DB...";
2747
+			if ($globalDebug) {
2748
+				echo "Add to DB...";
2749
+			}
2335 2750
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2336
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2751
+		} else {
2752
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2753
+		}
2337 2754
 		if ($error != '') {
2338 2755
 			return $error;
2339
-		} elseif ($globalDebug) echo "Done\n";
2340
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2756
+		} elseif ($globalDebug) {
2757
+			echo "Done\n";
2758
+		}
2759
+		if ($globalDebug) {
2760
+			echo "Owner Ecuador: Download...";
2761
+		}
2341 2762
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2342 2763
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2343
-			if ($globalDebug) echo "Add to DB...";
2764
+			if ($globalDebug) {
2765
+				echo "Add to DB...";
2766
+			}
2344 2767
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2345
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2768
+		} else {
2769
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2770
+		}
2346 2771
 		if ($error != '') {
2347 2772
 			return $error;
2348
-		} elseif ($globalDebug) echo "Done\n";
2349
-		if ($globalDebug) echo "Owner Iceland: Download...";
2773
+		} elseif ($globalDebug) {
2774
+			echo "Done\n";
2775
+		}
2776
+		if ($globalDebug) {
2777
+			echo "Owner Iceland: Download...";
2778
+		}
2350 2779
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2351 2780
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2352
-			if ($globalDebug) echo "Add to DB...";
2781
+			if ($globalDebug) {
2782
+				echo "Add to DB...";
2783
+			}
2353 2784
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2354
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2785
+		} else {
2786
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2787
+		}
2355 2788
 		if ($error != '') {
2356 2789
 			return $error;
2357
-		} elseif ($globalDebug) echo "Done\n";
2358
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2790
+		} elseif ($globalDebug) {
2791
+			echo "Done\n";
2792
+		}
2793
+		if ($globalDebug) {
2794
+			echo "Owner Isle of Man: Download...";
2795
+		}
2359 2796
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2360 2797
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2361
-			if ($globalDebug) echo "Add to DB...";
2798
+			if ($globalDebug) {
2799
+				echo "Add to DB...";
2800
+			}
2362 2801
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2363
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2802
+		} else {
2803
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2804
+		}
2364 2805
 		if ($error != '') {
2365 2806
 			return $error;
2366
-		} elseif ($globalDebug) echo "Done\n";
2807
+		} elseif ($globalDebug) {
2808
+			echo "Done\n";
2809
+		}
2367 2810
 		if ($globalMasterSource) {
2368
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2811
+			if ($globalDebug) {
2812
+				echo "ModeS Netherlands: Download...";
2813
+			}
2369 2814
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2370 2815
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2371
-				if ($globalDebug) echo "Add to DB...";
2816
+				if ($globalDebug) {
2817
+					echo "Add to DB...";
2818
+				}
2372 2819
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2373
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2820
+			} else {
2821
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2822
+			}
2374 2823
 			if ($error != '') {
2375 2824
 				return $error;
2376
-			} elseif ($globalDebug) echo "Done\n";
2377
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2825
+			} elseif ($globalDebug) {
2826
+				echo "Done\n";
2827
+			}
2828
+			if ($globalDebug) {
2829
+				echo "ModeS Denmark: Download...";
2830
+			}
2378 2831
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2379 2832
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2380
-				if ($globalDebug) echo "Add to DB...";
2833
+				if ($globalDebug) {
2834
+					echo "Add to DB...";
2835
+				}
2381 2836
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2382
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2837
+			} else {
2838
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2839
+			}
2383 2840
 			if ($error != '') {
2384 2841
 				return $error;
2385
-			} elseif ($globalDebug) echo "Done\n";
2386
-		} elseif ($globalDebug) echo "Done\n";
2842
+			} elseif ($globalDebug) {
2843
+				echo "Done\n";
2844
+			}
2845
+		} elseif ($globalDebug) {
2846
+			echo "Done\n";
2847
+		}
2387 2848
 		return '';
2388 2849
 	}
2389 2850
 
2390 2851
 	public static function update_translation() {
2391 2852
 		global $tmp_dir, $globalDebug;
2392 2853
 		$error = '';
2393
-		if ($globalDebug) echo "Translation : Download...";
2854
+		if ($globalDebug) {
2855
+			echo "Translation : Download...";
2856
+		}
2394 2857
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2395 2858
 		if (file_exists($tmp_dir.'translation.zip')) {
2396
-			if ($globalDebug) echo "Unzip...";
2859
+			if ($globalDebug) {
2860
+				echo "Unzip...";
2861
+			}
2397 2862
 			update_db::unzip($tmp_dir.'translation.zip');
2398
-			if ($globalDebug) echo "Add to DB...";
2863
+			if ($globalDebug) {
2864
+				echo "Add to DB...";
2865
+			}
2399 2866
 			$error = update_db::translation();
2400
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2867
+		} else {
2868
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2869
+		}
2401 2870
 		if ($error != '') {
2402 2871
 			return $error;
2403
-		} elseif ($globalDebug) echo "Done\n";
2872
+		} elseif ($globalDebug) {
2873
+			echo "Done\n";
2874
+		}
2404 2875
 		return '';
2405 2876
 	}
2406 2877
 
2407 2878
 	public static function update_translation_fam() {
2408 2879
 		global $tmp_dir, $globalDebug;
2409 2880
 		$error = '';
2410
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2881
+		if ($globalDebug) {
2882
+			echo "Translation from FlightAirMap website : Download...";
2883
+		}
2411 2884
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2412 2885
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2413 2886
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2414 2887
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2415 2888
 			$translation_md5 = $translation_md5_file[0];
2416 2889
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2417
-				if ($globalDebug) echo "Gunzip...";
2890
+				if ($globalDebug) {
2891
+					echo "Gunzip...";
2892
+				}
2418 2893
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2419
-				if ($globalDebug) echo "Add to DB...";
2894
+				if ($globalDebug) {
2895
+					echo "Add to DB...";
2896
+				}
2420 2897
 				$error = update_db::translation_fam();
2421
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2422
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2898
+			} else {
2899
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2900
+			}
2901
+		} else {
2902
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2903
+		}
2423 2904
 		if ($error != '') {
2424 2905
 			return $error;
2425
-		} elseif ($globalDebug) echo "Done\n";
2906
+		} elseif ($globalDebug) {
2907
+			echo "Done\n";
2908
+		}
2426 2909
 		return '';
2427 2910
 	}
2428 2911
 	public static function update_ModeS_fam() {
2429 2912
 		global $tmp_dir, $globalDebug;
2430 2913
 		$error = '';
2431
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2914
+		if ($globalDebug) {
2915
+			echo "ModeS from FlightAirMap website : Download...";
2916
+		}
2432 2917
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2433 2918
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2434 2919
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2435 2920
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2436 2921
 			$modes_md5 = $modes_md5_file[0];
2437 2922
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2438
-				if ($globalDebug) echo "Gunzip...";
2923
+				if ($globalDebug) {
2924
+					echo "Gunzip...";
2925
+				}
2439 2926
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2440
-				if ($globalDebug) echo "Add to DB...";
2927
+				if ($globalDebug) {
2928
+					echo "Add to DB...";
2929
+				}
2441 2930
 				$error = update_db::modes_fam();
2442
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2443
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2931
+			} else {
2932
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2933
+			}
2934
+		} else {
2935
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2936
+		}
2444 2937
 		if ($error != '') {
2445 2938
 			return $error;
2446
-		} elseif ($globalDebug) echo "Done\n";
2939
+		} elseif ($globalDebug) {
2940
+			echo "Done\n";
2941
+		}
2447 2942
 		return '';
2448 2943
 	}
2449 2944
 
2450 2945
 	public static function update_airlines_fam() {
2451 2946
 		global $tmp_dir, $globalDebug;
2452 2947
 		$error = '';
2453
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2948
+		if ($globalDebug) {
2949
+			echo "Airlines from FlightAirMap website : Download...";
2950
+		}
2454 2951
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2455 2952
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2456 2953
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2459,26 +2956,42 @@  discard block
 block discarded – undo
2459 2956
 				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2460 2957
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2461 2958
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2462
-						if ($globalDebug) echo "Gunzip...";
2959
+						if ($globalDebug) {
2960
+							echo "Gunzip...";
2961
+						}
2463 2962
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2464
-						if ($globalDebug) echo "Add to DB...";
2963
+						if ($globalDebug) {
2964
+							echo "Add to DB...";
2965
+						}
2465 2966
 						$error = update_db::airlines_fam();
2466 2967
 						update_db::insert_airlines_version($airlines_md5);
2467
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2468
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2469
-			} elseif ($globalDebug) echo "No update.";
2470
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2968
+					} else {
2969
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2970
+					}
2971
+			    } else {
2972
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2973
+			    }
2974
+			} elseif ($globalDebug) {
2975
+				echo "No update.";
2976
+			}
2977
+		} else {
2978
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2979
+		}
2471 2980
 		if ($error != '') {
2472 2981
 			return $error;
2473 2982
 		} else {
2474
-			if ($globalDebug) echo "Done\n";
2983
+			if ($globalDebug) {
2984
+				echo "Done\n";
2985
+			}
2475 2986
 		}
2476 2987
 		return '';
2477 2988
 	}
2478 2989
 
2479 2990
 	public static function update_owner_fam() {
2480 2991
 		global $tmp_dir, $globalDebug, $globalOwner;
2481
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2992
+		if ($globalDebug) {
2993
+			echo "owner from FlightAirMap website : Download...";
2994
+		}
2482 2995
 		$error = '';
2483 2996
 		if ($globalOwner === TRUE) {
2484 2997
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
@@ -2491,35 +3004,57 @@  discard block
 block discarded – undo
2491 3004
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2492 3005
 			$owners_md5 = $owners_md5_file[0];
2493 3006
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2494
-				if ($globalDebug) echo "Gunzip...";
3007
+				if ($globalDebug) {
3008
+					echo "Gunzip...";
3009
+				}
2495 3010
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2496
-				if ($globalDebug) echo "Add to DB...";
3011
+				if ($globalDebug) {
3012
+					echo "Add to DB...";
3013
+				}
2497 3014
 				$error = update_db::owner_fam();
2498
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2499
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3015
+			} else {
3016
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
3017
+			}
3018
+		} else {
3019
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3020
+		}
2500 3021
 		if ($error != '') {
2501 3022
 			return $error;
2502
-		} elseif ($globalDebug) echo "Done\n";
3023
+		} elseif ($globalDebug) {
3024
+			echo "Done\n";
3025
+		}
2503 3026
 		return '';
2504 3027
 	}
2505 3028
 	public static function update_routes_fam() {
2506 3029
 		global $tmp_dir, $globalDebug;
2507
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
3030
+		if ($globalDebug) {
3031
+			echo "Routes from FlightAirMap website : Download...";
3032
+		}
2508 3033
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2509 3034
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2510 3035
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2511 3036
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2512 3037
 			$routes_md5 = $routes_md5_file[0];
2513 3038
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2514
-				if ($globalDebug) echo "Gunzip...";
3039
+				if ($globalDebug) {
3040
+					echo "Gunzip...";
3041
+				}
2515 3042
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2516
-				if ($globalDebug) echo "Add to DB...";
3043
+				if ($globalDebug) {
3044
+					echo "Add to DB...";
3045
+				}
2517 3046
 				$error = update_db::routes_fam();
2518
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2519
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3047
+			} else {
3048
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
3049
+			}
3050
+		} else {
3051
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3052
+		}
2520 3053
 		if ($error != '') {
2521 3054
 			return $error;
2522
-		} elseif ($globalDebug) echo "Done\n";
3055
+		} elseif ($globalDebug) {
3056
+			echo "Done\n";
3057
+		}
2523 3058
 		return '';
2524 3059
 	}
2525 3060
 	public static function update_marine_identity_fam() {
@@ -2529,21 +3064,33 @@  discard block
 block discarded – undo
2529 3064
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2530 3065
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2531 3066
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2532
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3067
+				if ($globalDebug) {
3068
+					echo "Marine identity from FlightAirMap website : Download...";
3069
+				}
2533 3070
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2534 3071
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2535 3072
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2536
-						if ($globalDebug) echo "Gunzip...";
3073
+						if ($globalDebug) {
3074
+							echo "Gunzip...";
3075
+						}
2537 3076
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2538
-						if ($globalDebug) echo "Add to DB...";
3077
+						if ($globalDebug) {
3078
+							echo "Add to DB...";
3079
+						}
2539 3080
 						$error = update_db::marine_identity_fam();
2540
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2541
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3081
+					} else {
3082
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3083
+					}
3084
+				} else {
3085
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3086
+				}
2542 3087
 				if ($error != '') {
2543 3088
 					return $error;
2544 3089
 				} else {
2545 3090
 					update_db::insert_marine_identity_version($marine_identity_md5);
2546
-					if ($globalDebug) echo "Done\n";
3091
+					if ($globalDebug) {
3092
+						echo "Done\n";
3093
+					}
2547 3094
 				}
2548 3095
 			}
2549 3096
 		}
@@ -2557,21 +3104,33 @@  discard block
 block discarded – undo
2557 3104
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2558 3105
 			$satellite_md5 = $satellite_md5_file[0];
2559 3106
 			if (!update_db::check_satellite_version($satellite_md5)) {
2560
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3107
+				if ($globalDebug) {
3108
+					echo "Satellite from FlightAirMap website : Download...";
3109
+				}
2561 3110
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2562 3111
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2563 3112
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2564
-						if ($globalDebug) echo "Gunzip...";
3113
+						if ($globalDebug) {
3114
+							echo "Gunzip...";
3115
+						}
2565 3116
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2566
-						if ($globalDebug) echo "Add to DB...";
3117
+						if ($globalDebug) {
3118
+							echo "Add to DB...";
3119
+						}
2567 3120
 						$error = update_db::satellite_fam();
2568
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2569
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3121
+					} else {
3122
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3123
+					}
3124
+				} else {
3125
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3126
+				}
2570 3127
 				if ($error != '') {
2571 3128
 					return $error;
2572 3129
 				} else {
2573 3130
 					update_db::insert_satellite_version($satellite_md5);
2574
-					if ($globalDebug) echo "Done\n";
3131
+					if ($globalDebug) {
3132
+						echo "Done\n";
3133
+					}
2575 3134
 				}
2576 3135
 			}
2577 3136
 		}
@@ -2579,17 +3138,25 @@  discard block
 block discarded – undo
2579 3138
 	}
2580 3139
 	public static function update_banned_fam() {
2581 3140
 		global $tmp_dir, $globalDebug;
2582
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3141
+		if ($globalDebug) {
3142
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3143
+		}
2583 3144
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2584 3145
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2585 3146
 			//if ($globalDebug) echo "Gunzip...";
2586 3147
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2587
-			if ($globalDebug) echo "Add to DB...";
3148
+			if ($globalDebug) {
3149
+				echo "Add to DB...";
3150
+			}
2588 3151
 			$error = update_db::banned_fam();
2589
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3152
+		} else {
3153
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3154
+		}
2590 3155
 		if ($error != '') {
2591 3156
 			return $error;
2592
-		} elseif ($globalDebug) echo "Done\n";
3157
+		} elseif ($globalDebug) {
3158
+			echo "Done\n";
3159
+		}
2593 3160
 		return '';
2594 3161
 	}
2595 3162
 
@@ -2597,7 +3164,9 @@  discard block
 block discarded – undo
2597 3164
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2598 3165
 		include_once('class.create_db.php');
2599 3166
 		$error = '';
2600
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3167
+		if ($globalDebug) {
3168
+			echo "Airspace from FlightAirMap website : Download...";
3169
+		}
2601 3170
 		if ($globalDBdriver == 'mysql') {
2602 3171
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2603 3172
 		} else {
@@ -2614,9 +3183,13 @@  discard block
 block discarded – undo
2614 3183
 				}
2615 3184
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2616 3185
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2617
-						if ($globalDebug) echo "Gunzip...";
3186
+						if ($globalDebug) {
3187
+							echo "Gunzip...";
3188
+						}
2618 3189
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2619
-						if ($globalDebug) echo "Add to DB...";
3190
+						if ($globalDebug) {
3191
+							echo "Add to DB...";
3192
+						}
2620 3193
 						$Connection = new Connection();
2621 3194
 						if ($Connection->tableExists('airspace')) {
2622 3195
 							$query = 'DROP TABLE airspace';
@@ -2629,20 +3202,30 @@  discard block
 block discarded – undo
2629 3202
 						}
2630 3203
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2631 3204
 						update_db::insert_airspace_version($airspace_md5);
2632
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2633
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3205
+					} else {
3206
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3207
+					}
3208
+				} else {
3209
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3210
+				}
2634 3211
 			}
2635
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3212
+		} else {
3213
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3214
+		}
2636 3215
 		if ($error != '') {
2637 3216
 			return $error;
2638
-		} elseif ($globalDebug) echo "Done\n";
3217
+		} elseif ($globalDebug) {
3218
+			echo "Done\n";
3219
+		}
2639 3220
 		return '';
2640 3221
 	}
2641 3222
 
2642 3223
 	public static function update_geoid_fam() {
2643 3224
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2644 3225
 		$error = '';
2645
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3226
+		if ($globalDebug) {
3227
+			echo "Geoid from FlightAirMap website : Download...";
3228
+		}
2646 3229
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2647 3230
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2648 3231
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2651,76 +3234,120 @@  discard block
 block discarded – undo
2651 3234
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2652 3235
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2653 3236
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2654
-						if ($globalDebug) echo "Gunzip...";
3237
+						if ($globalDebug) {
3238
+							echo "Gunzip...";
3239
+						}
2655 3240
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2656 3241
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2657 3242
 							update_db::insert_geoid_version($geoid_md5);
2658
-						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
2659
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2660
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2661
-			} elseif ($globalDebug) echo 'No new version'."\n";
2662
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3243
+						} else {
3244
+							$error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
3245
+						}
3246
+					} else {
3247
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3248
+					}
3249
+				} else {
3250
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3251
+				}
3252
+			} elseif ($globalDebug) {
3253
+				echo 'No new version'."\n";
3254
+			}
3255
+		} else {
3256
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3257
+		}
2663 3258
 		if ($error != '') {
2664 3259
 			return $error;
2665
-		} elseif ($globalDebug) echo "Done\n";
3260
+		} elseif ($globalDebug) {
3261
+			echo "Done\n";
3262
+		}
2666 3263
 		return '';
2667 3264
 	}
2668 3265
 
2669 3266
 	public static function update_tle() {
2670 3267
 		global $tmp_dir, $globalDebug;
2671
-		if ($globalDebug) echo "Download TLE : Download...";
3268
+		if ($globalDebug) {
3269
+			echo "Download TLE : Download...";
3270
+		}
2672 3271
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2673 3272
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2674 3273
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2675 3274
 		foreach ($alltle as $filename) {
2676
-			if ($globalDebug) echo "downloading ".$filename.'...';
3275
+			if ($globalDebug) {
3276
+				echo "downloading ".$filename.'...';
3277
+			}
2677 3278
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2678 3279
 			if (file_exists($tmp_dir.$filename)) {
2679
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3280
+				if ($globalDebug) {
3281
+					echo "Add to DB ".$filename."...";
3282
+				}
2680 3283
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2681
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3284
+			} else {
3285
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3286
+			}
2682 3287
 			if ($error != '') {
2683 3288
 				echo $error."\n";
2684
-			} elseif ($globalDebug) echo "Done\n";
3289
+			} elseif ($globalDebug) {
3290
+				echo "Done\n";
3291
+			}
2685 3292
 		}
2686 3293
 		return '';
2687 3294
 	}
2688 3295
 
2689 3296
 	public static function update_ucsdb() {
2690 3297
 		global $tmp_dir, $globalDebug;
2691
-		if ($globalDebug) echo "Download UCS DB : Download...";
3298
+		if ($globalDebug) {
3299
+			echo "Download UCS DB : Download...";
3300
+		}
2692 3301
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2693 3302
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2694
-			if ($globalDebug) echo "Add to DB...";
3303
+			if ($globalDebug) {
3304
+				echo "Add to DB...";
3305
+			}
2695 3306
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2696
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3307
+		} else {
3308
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3309
+		}
2697 3310
 		if ($error != '') {
2698 3311
 			echo $error."\n";
2699
-		} elseif ($globalDebug) echo "Done\n";
3312
+		} elseif ($globalDebug) {
3313
+			echo "Done\n";
3314
+		}
2700 3315
 		return '';
2701 3316
 	}
2702 3317
 
2703 3318
 	public static function update_celestrak() {
2704 3319
 		global $tmp_dir, $globalDebug;
2705
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3320
+		if ($globalDebug) {
3321
+			echo "Download Celestrak DB : Download...";
3322
+		}
2706 3323
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2707 3324
 		if (file_exists($tmp_dir.'satcat.txt')) {
2708
-			if ($globalDebug) echo "Add to DB...";
3325
+			if ($globalDebug) {
3326
+				echo "Add to DB...";
3327
+			}
2709 3328
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2710
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3329
+		} else {
3330
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3331
+		}
2711 3332
 		if ($error != '') {
2712 3333
 			echo $error."\n";
2713
-		} elseif ($globalDebug) echo "Done\n";
3334
+		} elseif ($globalDebug) {
3335
+			echo "Done\n";
3336
+		}
2714 3337
 		return '';
2715 3338
 	}
2716 3339
 
2717 3340
 	public static function update_models() {
2718 3341
 		global $tmp_dir, $globalDebug;
2719 3342
 		$error = '';
2720
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3343
+		if ($globalDebug) {
3344
+			echo "Models from FlightAirMap website : Download...";
3345
+		}
2721 3346
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2722 3347
 		if (file_exists($tmp_dir.'models.md5sum')) {
2723
-			if ($globalDebug) echo "Check files...\n";
3348
+			if ($globalDebug) {
3349
+				echo "Check files...\n";
3350
+			}
2724 3351
 			$newmodelsdb = array();
2725 3352
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2726 3353
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2739,19 +3366,29 @@  discard block
 block discarded – undo
2739 3366
 			}
2740 3367
 			$diff = array_diff($newmodelsdb,$modelsdb);
2741 3368
 			foreach ($diff as $key => $value) {
2742
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3369
+				if ($globalDebug) {
3370
+					echo 'Downloading model '.$key.' ...'."\n";
3371
+				}
2743 3372
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2744 3373
 				
2745 3374
 			}
2746 3375
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2747
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3376
+		} else {
3377
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3378
+		}
2748 3379
 		if ($error != '') {
2749 3380
 			return $error;
2750
-		} elseif ($globalDebug) echo "Done\n";
2751
-		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
3381
+		} elseif ($globalDebug) {
3382
+			echo "Done\n";
3383
+		}
3384
+		if ($globalDebug) {
3385
+			echo "glTF 2.0 Models from FlightAirMap website : Download...";
3386
+		}
2752 3387
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2753 3388
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2754
-			if ($globalDebug) echo "Check files...\n";
3389
+			if ($globalDebug) {
3390
+				echo "Check files...\n";
3391
+			}
2755 3392
 			$newmodelsdb = array();
2756 3393
 			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2757 3394
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2770,25 +3407,35 @@  discard block
 block discarded – undo
2770 3407
 			}
2771 3408
 			$diff = array_diff($newmodelsdb,$modelsdb);
2772 3409
 			foreach ($diff as $key => $value) {
2773
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3410
+				if ($globalDebug) {
3411
+					echo 'Downloading model '.$key.' ...'."\n";
3412
+				}
2774 3413
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2775 3414
 				
2776 3415
 			}
2777 3416
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2778
-		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3417
+		} else {
3418
+			$error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3419
+		}
2779 3420
 		if ($error != '') {
2780 3421
 			return $error;
2781
-		} elseif ($globalDebug) echo "Done\n";
3422
+		} elseif ($globalDebug) {
3423
+			echo "Done\n";
3424
+		}
2782 3425
 		return '';
2783 3426
 	}
2784 3427
 
2785 3428
 	public static function update_liveries() {
2786 3429
 		global $tmp_dir, $globalDebug;
2787 3430
 		$error = '';
2788
-		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
3431
+		if ($globalDebug) {
3432
+			echo "Liveries from FlightAirMap website : Download...";
3433
+		}
2789 3434
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2790 3435
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2791
-			if ($globalDebug) echo "Check files...\n";
3436
+			if ($globalDebug) {
3437
+				echo "Check files...\n";
3438
+			}
2792 3439
 			$newmodelsdb = array();
2793 3440
 			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2794 3441
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2807,25 +3454,35 @@  discard block
 block discarded – undo
2807 3454
 			}
2808 3455
 			$diff = array_diff($newmodelsdb,$modelsdb);
2809 3456
 			foreach ($diff as $key => $value) {
2810
-				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
3457
+				if ($globalDebug) {
3458
+					echo 'Downloading liveries '.$key.' ...'."\n";
3459
+				}
2811 3460
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2812 3461
 				
2813 3462
 			}
2814 3463
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2815
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3464
+		} else {
3465
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3466
+		}
2816 3467
 		if ($error != '') {
2817 3468
 			return $error;
2818
-		} elseif ($globalDebug) echo "Done\n";
3469
+		} elseif ($globalDebug) {
3470
+			echo "Done\n";
3471
+		}
2819 3472
 		return '';
2820 3473
 	}
2821 3474
 
2822 3475
 	public static function update_space_models() {
2823 3476
 		global $tmp_dir, $globalDebug;
2824 3477
 		$error = '';
2825
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3478
+		if ($globalDebug) {
3479
+			echo "Space models from FlightAirMap website : Download...";
3480
+		}
2826 3481
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2827 3482
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2828
-			if ($globalDebug) echo "Check files...\n";
3483
+			if ($globalDebug) {
3484
+				echo "Check files...\n";
3485
+			}
2829 3486
 			$newmodelsdb = array();
2830 3487
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2831 3488
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2844,25 +3501,35 @@  discard block
 block discarded – undo
2844 3501
 			}
2845 3502
 			$diff = array_diff($newmodelsdb,$modelsdb);
2846 3503
 			foreach ($diff as $key => $value) {
2847
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3504
+				if ($globalDebug) {
3505
+					echo 'Downloading space model '.$key.' ...'."\n";
3506
+				}
2848 3507
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2849 3508
 				
2850 3509
 			}
2851 3510
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2852
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3511
+		} else {
3512
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3513
+		}
2853 3514
 		if ($error != '') {
2854 3515
 			return $error;
2855
-		} elseif ($globalDebug) echo "Done\n";
3516
+		} elseif ($globalDebug) {
3517
+			echo "Done\n";
3518
+		}
2856 3519
 		return '';
2857 3520
 	}
2858 3521
 
2859 3522
 	public static function update_vehicules_models() {
2860 3523
 		global $tmp_dir, $globalDebug;
2861 3524
 		$error = '';
2862
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3525
+		if ($globalDebug) {
3526
+			echo "Vehicules models from FlightAirMap website : Download...";
3527
+		}
2863 3528
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2864 3529
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2865
-			if ($globalDebug) echo "Check files...\n";
3530
+			if ($globalDebug) {
3531
+				echo "Check files...\n";
3532
+			}
2866 3533
 			$newmodelsdb = array();
2867 3534
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2868 3535
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2881,15 +3548,21 @@  discard block
 block discarded – undo
2881 3548
 			}
2882 3549
 			$diff = array_diff($newmodelsdb,$modelsdb);
2883 3550
 			foreach ($diff as $key => $value) {
2884
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3551
+				if ($globalDebug) {
3552
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3553
+				}
2885 3554
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2886 3555
 				
2887 3556
 			}
2888 3557
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2889
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3558
+		} else {
3559
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3560
+		}
2890 3561
 		if ($error != '') {
2891 3562
 			return $error;
2892
-		} elseif ($globalDebug) echo "Done\n";
3563
+		} elseif ($globalDebug) {
3564
+			echo "Done\n";
3565
+		}
2893 3566
 		return '';
2894 3567
 	}
2895 3568
 
@@ -2962,7 +3635,9 @@  discard block
 block discarded – undo
2962 3635
                 }
2963 3636
 
2964 3637
 		$error = '';
2965
-		if ($globalDebug) echo "Notam : Download...";
3638
+		if ($globalDebug) {
3639
+			echo "Notam : Download...";
3640
+		}
2966 3641
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2967 3642
 		if (file_exists($tmp_dir.'notam.rss')) {
2968 3643
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2977,14 +3652,30 @@  discard block
 block discarded – undo
2977 3652
 				$data['fir'] = $q[0];
2978 3653
 				$data['code'] = $q[1];
2979 3654
 				$ifrvfr = $q[2];
2980
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2981
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2982
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2983
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2984
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2985
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2986
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2987
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3655
+				if ($ifrvfr == 'IV') {
3656
+					$data['rules'] = 'IFR/VFR';
3657
+				}
3658
+				if ($ifrvfr == 'I') {
3659
+					$data['rules'] = 'IFR';
3660
+				}
3661
+				if ($ifrvfr == 'V') {
3662
+					$data['rules'] = 'VFR';
3663
+				}
3664
+				if ($q[4] == 'A') {
3665
+					$data['scope'] = 'Airport warning';
3666
+				}
3667
+				if ($q[4] == 'E') {
3668
+					$data['scope'] = 'Enroute warning';
3669
+				}
3670
+				if ($q[4] == 'W') {
3671
+					$data['scope'] = 'Navigation warning';
3672
+				}
3673
+				if ($q[4] == 'AE') {
3674
+					$data['scope'] = 'Airport/Enroute warning';
3675
+				}
3676
+				if ($q[4] == 'AW') {
3677
+					$data['scope'] = 'Airport/Navigation warning';
3678
+				}
2988 3679
 				//$data['scope'] = $q[4];
2989 3680
 				$data['lower_limit'] = $q[5];
2990 3681
 				$data['upper_limit'] = $q[6];
@@ -2992,8 +3683,12 @@  discard block
 block discarded – undo
2992 3683
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2993 3684
 				$latitude = $Common->convertDec($las,'latitude');
2994 3685
 				$longitude = $Common->convertDec($lns,'longitude');
2995
-				if ($lac == 'S') $latitude = '-'.$latitude;
2996
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3686
+				if ($lac == 'S') {
3687
+					$latitude = '-'.$latitude;
3688
+				}
3689
+				if ($lnc == 'W') {
3690
+					$longitude = '-'.$longitude;
3691
+				}
2997 3692
 				$data['center_latitude'] = $latitude;
2998 3693
 				$data['center_longitude'] = $longitude;
2999 3694
 				$data['radius'] = intval($radius);
@@ -3023,10 +3718,14 @@  discard block
 block discarded – undo
3023 3718
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
3024 3719
 				unset($data);
3025 3720
 			} 
3026
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3721
+		} else {
3722
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3723
+		}
3027 3724
 		if ($error != '') {
3028 3725
 			return $error;
3029
-		} elseif ($globalDebug) echo "Done\n";
3726
+		} elseif ($globalDebug) {
3727
+			echo "Done\n";
3728
+		}
3030 3729
 		return '';
3031 3730
 	}
3032 3731
 	
@@ -3051,7 +3750,9 @@  discard block
 block discarded – undo
3051 3750
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3052 3751
 		$airspace_json = json_decode($airspace_lst,true);
3053 3752
 		foreach ($airspace_json['records'] as $airspace) {
3054
-			if ($globalDebug) echo $airspace['name']."...\n";
3753
+			if ($globalDebug) {
3754
+				echo $airspace['name']."...\n";
3755
+			}
3055 3756
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3056 3757
 			if (file_exists($tmp_dir.$airspace['name'])) {
3057 3758
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -3095,8 +3796,11 @@  discard block
 block discarded – undo
3095 3796
                         return "error : ".$e->getMessage();
3096 3797
                 }
3097 3798
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3098
-                if ($row['nb'] > 0) return false;
3099
-                else return true;
3799
+                if ($row['nb'] > 0) {
3800
+                	return false;
3801
+                } else {
3802
+                	return true;
3803
+                }
3100 3804
 	}
3101 3805
 
3102 3806
 	public static function insert_last_update() {
@@ -3121,8 +3825,11 @@  discard block
 block discarded – undo
3121 3825
                         return "error : ".$e->getMessage();
3122 3826
                 }
3123 3827
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3124
-                if ($row['nb'] > 0) return true;
3125
-                else return false;
3828
+                if ($row['nb'] > 0) {
3829
+                	return true;
3830
+                } else {
3831
+                	return false;
3832
+                }
3126 3833
 	}
3127 3834
 
3128 3835
 	public static function check_geoid_version($version) {
@@ -3135,8 +3842,11 @@  discard block
 block discarded – undo
3135 3842
                         return "error : ".$e->getMessage();
3136 3843
                 }
3137 3844
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3138
-                if ($row['nb'] > 0) return true;
3139
-                else return false;
3845
+                if ($row['nb'] > 0) {
3846
+                	return true;
3847
+                } else {
3848
+                	return false;
3849
+                }
3140 3850
 	}
3141 3851
 
3142 3852
 	public static function check_marine_identity_version($version) {
@@ -3149,8 +3859,11 @@  discard block
 block discarded – undo
3149 3859
 			return "error : ".$e->getMessage();
3150 3860
 		}
3151 3861
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3152
-		if ($row['nb'] > 0) return true;
3153
-		else return false;
3862
+		if ($row['nb'] > 0) {
3863
+			return true;
3864
+		} else {
3865
+			return false;
3866
+		}
3154 3867
 	}
3155 3868
 
3156 3869
 	public static function check_satellite_version($version) {
@@ -3163,8 +3876,11 @@  discard block
 block discarded – undo
3163 3876
 			return "error : ".$e->getMessage();
3164 3877
 		}
3165 3878
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3166
-		if ($row['nb'] > 0) return true;
3167
-		else return false;
3879
+		if ($row['nb'] > 0) {
3880
+			return true;
3881
+		} else {
3882
+			return false;
3883
+		}
3168 3884
 	}
3169 3885
 
3170 3886
 	public static function check_airlines_version($version) {
@@ -3177,8 +3893,11 @@  discard block
 block discarded – undo
3177 3893
 			return "error : ".$e->getMessage();
3178 3894
 		}
3179 3895
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3180
-		if ($row['nb'] > 0) return true;
3181
-		else return false;
3896
+		if ($row['nb'] > 0) {
3897
+			return true;
3898
+		} else {
3899
+			return false;
3900
+		}
3182 3901
 	}
3183 3902
 
3184 3903
 	public static function check_notam_version($version) {
@@ -3191,8 +3910,11 @@  discard block
 block discarded – undo
3191 3910
 			return "error : ".$e->getMessage();
3192 3911
 		}
3193 3912
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3194
-		if ($row['nb'] > 0) return true;
3195
-		else return false;
3913
+		if ($row['nb'] > 0) {
3914
+			return true;
3915
+		} else {
3916
+			return false;
3917
+		}
3196 3918
 	}
3197 3919
 
3198 3920
 	public static function insert_airlines_version($version) {
@@ -3282,8 +4004,11 @@  discard block
 block discarded – undo
3282 4004
                         return "error : ".$e->getMessage();
3283 4005
                 }
3284 4006
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3285
-                if ($row['nb'] > 0) return false;
3286
-                else return true;
4007
+                if ($row['nb'] > 0) {
4008
+                	return false;
4009
+                } else {
4010
+                	return true;
4011
+                }
3287 4012
 	}
3288 4013
 
3289 4014
 	public static function insert_last_notam_update() {
@@ -3313,8 +4038,11 @@  discard block
 block discarded – undo
3313 4038
                         return "error : ".$e->getMessage();
3314 4039
                 }
3315 4040
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3316
-                if ($row['nb'] > 0) return false;
3317
-                else return true;
4041
+                if ($row['nb'] > 0) {
4042
+                	return false;
4043
+                } else {
4044
+                	return true;
4045
+                }
3318 4046
 	}
3319 4047
 
3320 4048
 	public static function insert_last_airspace_update() {
@@ -3344,8 +4072,11 @@  discard block
 block discarded – undo
3344 4072
                         return "error : ".$e->getMessage();
3345 4073
                 }
3346 4074
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3347
-                if ($row['nb'] > 0) return false;
3348
-                else return true;
4075
+                if ($row['nb'] > 0) {
4076
+                	return false;
4077
+                } else {
4078
+                	return true;
4079
+                }
3349 4080
 	}
3350 4081
 
3351 4082
 	public static function insert_last_geoid_update() {
@@ -3375,8 +4106,11 @@  discard block
 block discarded – undo
3375 4106
 			return "error : ".$e->getMessage();
3376 4107
 		}
3377 4108
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3378
-		if ($row['nb'] > 0) return false;
3379
-		else return true;
4109
+		if ($row['nb'] > 0) {
4110
+			return false;
4111
+		} else {
4112
+			return true;
4113
+		}
3380 4114
 	}
3381 4115
 
3382 4116
 	public static function insert_last_owner_update() {
@@ -3406,8 +4140,11 @@  discard block
 block discarded – undo
3406 4140
 			return "error : ".$e->getMessage();
3407 4141
 		}
3408 4142
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3409
-		if ($row['nb'] > 0) return false;
3410
-		else return true;
4143
+		if ($row['nb'] > 0) {
4144
+			return false;
4145
+		} else {
4146
+			return true;
4147
+		}
3411 4148
 	}
3412 4149
 
3413 4150
 	public static function insert_last_fires_update() {
@@ -3437,8 +4174,11 @@  discard block
 block discarded – undo
3437 4174
 			return "error : ".$e->getMessage();
3438 4175
 		}
3439 4176
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3440
-		if ($row['nb'] > 0) return false;
3441
-		else return true;
4177
+		if ($row['nb'] > 0) {
4178
+			return false;
4179
+		} else {
4180
+			return true;
4181
+		}
3442 4182
 	}
3443 4183
 
3444 4184
 	public static function insert_last_airlines_update() {
@@ -3468,8 +4208,11 @@  discard block
 block discarded – undo
3468 4208
                         return "error : ".$e->getMessage();
3469 4209
                 }
3470 4210
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3471
-                if ($row['nb'] > 0) return false;
3472
-                else return true;
4211
+                if ($row['nb'] > 0) {
4212
+                	return false;
4213
+                } else {
4214
+                	return true;
4215
+                }
3473 4216
 	}
3474 4217
 
3475 4218
 	public static function insert_last_schedules_update() {
@@ -3499,8 +4242,11 @@  discard block
 block discarded – undo
3499 4242
 			return "error : ".$e->getMessage();
3500 4243
 		}
3501 4244
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3502
-		if ($row['nb'] > 0) return false;
3503
-		else return true;
4245
+		if ($row['nb'] > 0) {
4246
+			return false;
4247
+		} else {
4248
+			return true;
4249
+		}
3504 4250
 	}
3505 4251
 
3506 4252
 	public static function insert_last_tle_update() {
@@ -3530,8 +4276,11 @@  discard block
 block discarded – undo
3530 4276
 			return "error : ".$e->getMessage();
3531 4277
 		}
3532 4278
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3533
-		if ($row['nb'] > 0) return false;
3534
-		else return true;
4279
+		if ($row['nb'] > 0) {
4280
+			return false;
4281
+		} else {
4282
+			return true;
4283
+		}
3535 4284
 	}
3536 4285
 
3537 4286
 	public static function insert_last_ucsdb_update() {
@@ -3561,8 +4310,11 @@  discard block
 block discarded – undo
3561 4310
 			return "error : ".$e->getMessage();
3562 4311
 		}
3563 4312
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3564
-		if ($row['nb'] > 0) return false;
3565
-		else return true;
4313
+		if ($row['nb'] > 0) {
4314
+			return false;
4315
+		} else {
4316
+			return true;
4317
+		}
3566 4318
 	}
3567 4319
 
3568 4320
 	public static function insert_last_celestrak_update() {
@@ -3592,8 +4344,11 @@  discard block
 block discarded – undo
3592 4344
 			return "error : ".$e->getMessage();
3593 4345
 		}
3594 4346
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3595
-		if ($row['nb'] > 0) return false;
3596
-		else return true;
4347
+		if ($row['nb'] > 0) {
4348
+			return false;
4349
+		} else {
4350
+			return true;
4351
+		}
3597 4352
 	}
3598 4353
 
3599 4354
 	public static function check_last_satellite_update() {
@@ -3611,8 +4366,11 @@  discard block
 block discarded – undo
3611 4366
 			return "error : ".$e->getMessage();
3612 4367
 		}
3613 4368
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3614
-		if ($row['nb'] > 0) return false;
3615
-		else return true;
4369
+		if ($row['nb'] > 0) {
4370
+			return false;
4371
+		} else {
4372
+			return true;
4373
+		}
3616 4374
 	}
3617 4375
 
3618 4376
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.