Completed
Push — master ( d53e0e...462fd9 )
by Yannick
06:21
created
statistics-pilot.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
           function drawChart() {
31 31
             var data = google.visualization.arrayToDataTable([
32 32
             	["'._("Pilot").'", "'._("# of times").'"], ';
33
-            	$pilot_data = '';
33
+				$pilot_data = '';
34 34
 		foreach($pilot_array as $pilot_item)
35 35
 		{
36 36
 			$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
37 37
 		}
38 38
 		$pilot_data = substr($pilot_data, 0, -1);
39 39
 		print $pilot_data;
40
-            print ']);
40
+			print ']);
41 41
     
42 42
             var options = {
43 43
             	chartArea: {"width": "80%", "height": "60%"},
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11 11
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13
-setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
13
+setcookie('stats_airline_icao', $airline_icao, time() + 60*60*24, '/');
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 require_once('header.php');
17 17
 include('statistics-sub-menu.php');
18 18
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	</div>
23 23
 	<p>'._("Below are the <strong>Top 10</strong> most common pilot.").'</p>';
24 24
 	  
25
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
25
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
26 26
 	print '<div id="chart" class="chart" width="100%"></div>
27 27
       	<script> 
28 28
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
             var data = google.visualization.arrayToDataTable([
32 32
             	["'._("Pilot").'", "'._("# of times").'"], ';
33 33
             	$pilot_data = '';
34
-		foreach($pilot_array as $pilot_item)
34
+		foreach ($pilot_array as $pilot_item)
35 35
 		{
36 36
 			$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
37 37
 		}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	print '</thead>';
65 65
 	print '<tbody>';
66 66
 	$i = 1;
67
-	foreach($pilot_array as $pilot_item)
67
+	foreach ($pilot_array as $pilot_item)
68 68
 	{
69 69
 		print '<tr>';
70 70
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,11 +5,15 @@
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12
-}
13
+    if (isset($globalFilter['airline'])) {
14
+    	$airline_icao = $globalFilter['airline'][0];
15
+    }
16
+    }
13 17
 setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/');
14 18
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 19
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
require/class.METAR.php 3 patches
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -7,109 +7,109 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 	
41 41
 	public function __construct($dbc = null) {
42
-                $Connection = new Connection($dbc);
43
-                $this->db = $Connection->db;
44
-        }
42
+				$Connection = new Connection($dbc);
43
+				$this->db = $Connection->db;
44
+		}
45 45
 
46
-       public static function check_last_update() {
47
-    		global $globalDBdriver;
48
-    		if ($globalDBdriver == 'mysql') {
46
+	   public static function check_last_update() {
47
+			global $globalDBdriver;
48
+			if ($globalDBdriver == 'mysql') {
49 49
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
50 50
 		} else {
51 51
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'";
52 52
 		}
53
-                try {
54
-                        $Connection = new Connection();
55
-                        $sth = $Connection->db->prepare($query);
56
-                        $sth->execute();
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
64
-        }
53
+				try {
54
+						$Connection = new Connection();
55
+						$sth = $Connection->db->prepare($query);
56
+						$sth->execute();
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
61
+				$sth->closeCursor();
62
+				if ($row['nb'] > 0) return false;
63
+				else return true;
64
+		}
65 65
 
66
-        public static function insert_last_update() {
67
-                $query = "DELETE FROM config WHERE name = 'last_update_metar';
66
+		public static function insert_last_update() {
67
+				$query = "DELETE FROM config WHERE name = 'last_update_metar';
68 68
                         INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());";
69
-                try {
70
-                        $Connection = new Connection();
71
-                        $sth = $Connection->db->prepare($query);
72
-                        $sth->execute();
73
-                } catch(PDOException $e) {
74
-                        return "error : ".$e->getMessage();
75
-                }
76
-        }
69
+				try {
70
+						$Connection = new Connection();
71
+						$sth = $Connection->db->prepare($query);
72
+						$sth->execute();
73
+				} catch(PDOException $e) {
74
+						return "error : ".$e->getMessage();
75
+				}
76
+		}
77 77
 
78 78
 
79 79
         
80
-        public function parse($data) {
81
-    		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
-    		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
-    		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
86
-    		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
-    		$result = array();
91
-    		$result['location'] = $pieces[$pos];
92
-    		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
95
-    		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
97
-    			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
101
-    			// Wind Speed
102
-    			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
80
+		public function parse($data) {
81
+			//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
+			$codes = implode('|', array_keys($this->texts));
83
+			$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
+			//$pieces = explode(' ',$data);
85
+			$pieces = preg_split('/\s/',$data);
86
+			$pos = 0;
87
+			if ($pieces[0] == 'METAR') $pos++;
88
+			elseif ($pieces[0] == 'SPECI') $pos++;
89
+			if (strlen($pieces[$pos]) != 4) $pos++;
90
+			$result = array();
91
+			$result['location'] = $pieces[$pos];
92
+			$pos++;
93
+			$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
+			$result['time'] = substr($pieces[$pos],2,4);
95
+			$c = count($pieces);
96
+			for($pos++; $pos < $c; $pos++) {
97
+				$piece = $pieces[$pos];
98
+				if ($piece == 'RMK') break;
99
+				if ($piece == 'AUTO') $result['auto'] = true;
100
+				if ($piece == 'COR') $result['correction'] = true;
101
+				// Wind Speed
102
+				if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
+					$result['wind']['direction'] = (float)$matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
105
+					if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
+					elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
+					elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108 108
 				$result['wind']['gust'] = (float)$matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110 110
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111 111
 				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
112
-    			}
112
+				}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
115 115
     				$result['wind_direction'] = (float)$matches[1];
@@ -126,35 +126,35 @@  discard block
 block discarded – undo
126 126
     				}
127 127
     			}
128 128
     			*/
129
-    			// Temperature
130
-    			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
129
+				// Temperature
130
+				if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
+					$temp = (float)$matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133 133
 					$temp = ((float)substr($matches[1], 1)) * -1;
134 134
 				}
135
-    				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
135
+					$result['temperature'] = $temp;
136
+					$dew = (float)$matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138 138
 					$dew = ((float)substr($matches[2], 1)) * -1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141
-    			}
142
-    			// QNH
143
-    			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
-    			// #^(Q|A)(////|[0-9]{4})( )#
145
-    				if ($matches[1] == 'Q') {
146
-    					// hPa
147
-    					$result['QNH'] = $matches[2];
148
-    				} else {
149
-    					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151 141
 				}
152
-    				/*
142
+				// QNH
143
+				if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
+				// #^(Q|A)(////|[0-9]{4})( )#
145
+					if ($matches[1] == 'Q') {
146
+						// hPa
147
+						$result['QNH'] = $matches[2];
148
+					} else {
149
+						// inHg
150
+						$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151
+				}
152
+					/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
154 154
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
155 155
     				*/
156
-    			}
157
-                     /*
156
+				}
157
+					 /*
158 158
     			// Wind Direction
159 159
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
160 160
     				$result['wind_direction'] = $matches[1];
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     				$result['speed_variable'] = $matches[1];
166 166
     			}
167 167
     			*/
168
-    			// Visibility
169
-    			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
-    				if (isset($matches[3]) && strlen($matches[3]) > 0) {
168
+				// Visibility
169
+				if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
+					if (isset($matches[3]) && strlen($matches[3]) > 0) {
171 171
 					$result['visibility'] = (float)$matches[3] * 1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 					$result['visibility'] = '> 10000';
181 181
 					$result['weather'] = "CAVOK";
182 182
 				}
183
-    			}
184
-    			// Cloud Coverage
185
-    			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
-    				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
-    				$type = $matches[1];
188
-    				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
-    				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
-    				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
-    				$result['cloud'][] = $cloud;
201
-    			}
202
-    			// RVR
203
-    			 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
-    				$rvr = array();
183
+				}
184
+				// Cloud Coverage
185
+				if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
+					//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
+					$type = $matches[1];
188
+					$cloud = array();
189
+					if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
+					elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
+					elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
+					elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
+					elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
+					elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
+					elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
+					elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
+					$cloud['type_code'] = $type;
198
+					$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
+					$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
+					$result['cloud'][] = $cloud;
201
+				}
202
+				// RVR
203
+				 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
+					$rvr = array();
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
@@ -210,33 +210,33 @@  discard block
 block discarded – undo
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
213
-    			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
-    			if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
-    				//print_r($matches);
216
-    				// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
-    				$result['RVR']['runway'] = $matches[1];
218
-        			$result['RVR']['deposits'] = $matches[2];
219
-        			$result['RVR']['extent'] = $matches[3];
220
-        			$result['RVR']['depth'] = $matches[4];
221
-        			$result['RVR']['friction'] = $matches[5];
222
-    			}
223
-    			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
-    				//echo $piece;
225
-    				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
213
+				//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
+				if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
+					//print_r($matches);
216
+					// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
+					$result['RVR']['runway'] = $matches[1];
218
+					$result['RVR']['deposits'] = $matches[2];
219
+					$result['RVR']['extent'] = $matches[3];
220
+					$result['RVR']['depth'] = $matches[4];
221
+					$result['RVR']['friction'] = $matches[5];
222
+				}
223
+				if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
+					//echo $piece;
225
+					//print_r($matches);
226
+					if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+					else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
232
-					    'unit' => $matches[5] ? 'FT' : 'M'
230
+						'from' => (float)$matches[2],
231
+						'to'   => (float)$matches[4],
232
+						'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
235 235
 				$result['RVR'] = $matches[1];
236 236
 				$result['RVR_range'] = $range;
237
-    			}
238
-    			// Weather
239
-    			if (preg_match($regWeather, $piece, $matches)) {
237
+				}
238
+				// Weather
239
+				if (preg_match($regWeather, $piece, $matches)) {
240 240
 				$text = Array();
241 241
 				switch ($matches[1]) {
242 242
 					case '+':
@@ -259,35 +259,35 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261 261
 				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
262
-    			}
263
-    		}
264
-    		return $result;
262
+				}
263
+			}
264
+			return $result;
265 265
         
266
-        }
266
+		}
267 267
         
268 268
 	public function getMETAR($icao) {
269
-    		global $globalMETARcycle, $globalDBdriver;
270
-    		if (isset($globalMETARcycle) && $globalMETARcycle) {
271
-            		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
-                } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
-                }
276
-                $query_values = array(':icao' => $icao);
277
-                 try {
278
-                        $sth = $this->db->prepare($query);
279
-                        $sth->execute($query_values);
280
-                } catch(PDOException $e) {
281
-                        return "error : ".$e->getMessage();
282
-                }
283
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
-                if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
-            		$all = $this->downloadMETAR($icao);
286
-                }
287
-                return $all;
288
-        }
269
+			global $globalMETARcycle, $globalDBdriver;
270
+			if (isset($globalMETARcycle) && $globalMETARcycle) {
271
+					$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
+				} else {
273
+					if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
+					else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
+				}
276
+				$query_values = array(':icao' => $icao);
277
+				 try {
278
+						$sth = $this->db->prepare($query);
279
+						$sth->execute($query_values);
280
+				} catch(PDOException $e) {
281
+						return "error : ".$e->getMessage();
282
+				}
283
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
+					$all = $this->downloadMETAR($icao);
286
+				}
287
+				return $all;
288
+		}
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+	   public function addMETAR($location,$metar,$date) {
291 291
 		global $globalDBdriver;
292 292
 		$date = date('Y-m-d H:i:s',strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
@@ -295,106 +295,106 @@  discard block
 block discarded – undo
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
-                 try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute($query_values);
302
-                } catch(PDOException $e) {
303
-                        return "error : ".$e->getMessage();
304
-                }
305
-        }
298
+				$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
+				 try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute($query_values);
302
+				} catch(PDOException $e) {
303
+						return "error : ".$e->getMessage();
304
+				}
305
+		}
306 306
 
307
-       public function deleteMETAR($id) {
308
-                $query = "DELETE FROM metar WHERE id = :id";
309
-                $query_values = array(':id' => $id);
310
-                 try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute($query_values);
313
-                } catch(PDOException $e) {
314
-                        return "error : ".$e->getMessage();
315
-                }
316
-        }
317
-       public function deleteAllMETARLocation() {
318
-                $query = "DELETE FROM metar";
319
-                 try {
320
-                        $sth = $this->db->prepare($query);
321
-                        $sth->execute();
322
-                } catch(PDOException $e) {
323
-                        return "error : ".$e->getMessage();
324
-                }
325
-        }
307
+	   public function deleteMETAR($id) {
308
+				$query = "DELETE FROM metar WHERE id = :id";
309
+				$query_values = array(':id' => $id);
310
+				 try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute($query_values);
313
+				} catch(PDOException $e) {
314
+						return "error : ".$e->getMessage();
315
+				}
316
+		}
317
+	   public function deleteAllMETARLocation() {
318
+				$query = "DELETE FROM metar";
319
+				 try {
320
+						$sth = $this->db->prepare($query);
321
+						$sth->execute();
322
+				} catch(PDOException $e) {
323
+						return "error : ".$e->getMessage();
324
+				}
325
+		}
326 326
         
327
-        public function addMETARCycle() {
328
-    		global $globalDebug, $globalIVAO, $globalTransaction;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
-    		date_default_timezone_set("UTC");
331
-    		$Common = new Common();
332
-    		if (isset($globalIVAO) && $globalIVAO) {
333
-        		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
327
+		public function addMETARCycle() {
328
+			global $globalDebug, $globalIVAO, $globalTransaction;
329
+			if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
+			date_default_timezone_set("UTC");
331
+			$Common = new Common();
332
+			if (isset($globalIVAO) && $globalIVAO) {
333
+				//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334 334
 			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
-    		} else {
335
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
+			} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338 338
 			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
-    		}
341
-    		if ($handle) {
339
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
+			}
341
+			if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344
-    			//foreach(explode("\n",$cycle) as $line) {
345
-    			if ($globalTransaction) $this->db->beginTransaction();
346
-	    		while(($line = fgets($handle,4096)) !== false) {
344
+				//foreach(explode("\n",$cycle) as $line) {
345
+				if ($globalTransaction) $this->db->beginTransaction();
346
+				while(($line = fgets($handle,4096)) !== false) {
347 347
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
348 348
 					$date = $line;
349
-    				} elseif ($line != '') {
350
-    				    //$this->parse($line);
351
-    				    if ($date == '') $date = date('Y/m/d H:m');
352
-        			    $pos = 0;
353
-        			    $pieces = preg_split('/\s/',$line);
354
-        			    if ($pieces[0] == 'METAR') $pos++;
355
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
356
-		        	    $location = $pieces[$pos];
357
-        	        	    echo $this->addMETAR($location,$line,$date);
358
-    				}
359
-    			}
360
-    			fclose($handle);
361
-    			if ($globalTransaction) $this->db->commit();
362
-    		}
363
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
349
+					} elseif ($line != '') {
350
+						//$this->parse($line);
351
+						if ($date == '') $date = date('Y/m/d H:m');
352
+						$pos = 0;
353
+						$pieces = preg_split('/\s/',$line);
354
+						if ($pieces[0] == 'METAR') $pos++;
355
+						if (strlen($pieces[$pos]) != 4) $pos++;
356
+						$location = $pieces[$pos];
357
+							echo $this->addMETAR($location,$line,$date);
358
+					}
359
+				}
360
+				fclose($handle);
361
+				if ($globalTransaction) $this->db->commit();
362
+			}
363
+			if (isset($globalDebug) && $globalDebug) echo "Done\n";
364 364
         
365
-        }
366
-        public function downloadMETAR($icao) {
367
-    		global $globalMETARurl;
368
-    		if ($globalMETARurl == '') return array();
369
-    		date_default_timezone_set("UTC");
370
-    		$Common = new Common();
371
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
372
-    		$cycle = $Common->getData($url);
373
-    		$date = '';
374
-    		foreach(explode("\n",$cycle) as $line) {
375
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
376
-    				//echo "date : ".$line."\n";
377
-    				$date = $line;
378
-    			} 
379
-    			if ($line != '') {
380
-    			    //$this->parse($line);
381
-    			    //echo $line;
382
-    			    if ($date == '') $date = date('Y/m/d H:m');
383
-    			    $pos = 0;
384
-    			    $pieces = preg_split('/\s/',$line);
385
-    			    if ($pieces[0] == 'METAR') $pos++;
386
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
387
-	        	    $location = $pieces[$pos];
388
-	        	    if (strlen($location == 4)) {
389
-	        		$this->addMETAR($location,$line,$date);
390
-	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
-	        	    } else return array();
392
-    			}
393
-    			//echo $line."\n";
394
-    		}
395
-    		return array();
365
+		}
366
+		public function downloadMETAR($icao) {
367
+			global $globalMETARurl;
368
+			if ($globalMETARurl == '') return array();
369
+			date_default_timezone_set("UTC");
370
+			$Common = new Common();
371
+			$url = str_replace('{icao}',$icao,$globalMETARurl);
372
+			$cycle = $Common->getData($url);
373
+			$date = '';
374
+			foreach(explode("\n",$cycle) as $line) {
375
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
376
+					//echo "date : ".$line."\n";
377
+					$date = $line;
378
+				} 
379
+				if ($line != '') {
380
+					//$this->parse($line);
381
+					//echo $line;
382
+					if ($date == '') $date = date('Y/m/d H:m');
383
+					$pos = 0;
384
+					$pieces = preg_split('/\s/',$line);
385
+					if ($pieces[0] == 'METAR') $pos++;
386
+					if (strlen($pieces[$pos]) != 4) $pos++;
387
+					$location = $pieces[$pos];
388
+					if (strlen($location == 4)) {
389
+					$this->addMETAR($location,$line,$date);
390
+					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
+					} else return array();
392
+				}
393
+				//echo $line."\n";
394
+			}
395
+			return array();
396 396
         
397
-        }
397
+		}
398 398
 }
399 399
 /*
400 400
 $METAR = new METAR();
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $Connection = new Connection();
71 71
                         $sth = $Connection->db->prepare($query);
72 72
                         $sth->execute();
73
-                } catch(PDOException $e) {
73
+                } catch (PDOException $e) {
74 74
                         return "error : ".$e->getMessage();
75 75
                 }
76 76
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         public function parse($data) {
81 81
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82 82
     		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
84 84
     		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
85
+    		$pieces = preg_split('/\s/', $data);
86 86
     		$pos = 0;
87 87
     		if ($pieces[0] == 'METAR') $pos++;
88 88
     		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     		$result = array();
91 91
     		$result['location'] = $pieces[$pos];
92 92
     		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
93
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
94
+    		$result['time'] = substr($pieces[$pos], 2, 4);
95 95
     		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
96
+    		for ($pos++; $pos < $c; $pos++) {
97 97
     			$piece = $pieces[$pos];
98 98
     			if ($piece == 'RMK') break;
99 99
     			if ($piece == 'AUTO') $result['auto'] = true;
100 100
     			if ($piece == 'COR') $result['correction'] = true;
101 101
     			// Wind Speed
102 102
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
103
+    				$result['wind']['direction'] = (float) $matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108
-				$result['wind']['gust'] = (float)$matches[3];
105
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
106
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
107
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
108
+				$result['wind']['gust'] = (float) $matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
111
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
112 112
     			}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
     			*/
129 129
     			// Temperature
130 130
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
131
+    				$temp = (float) $matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133
-					$temp = ((float)substr($matches[1], 1)) * -1;
133
+					$temp = ((float) substr($matches[1], 1))*-1;
134 134
 				}
135 135
     				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
136
+    				$dew = (float) $matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138
-					$dew = ((float)substr($matches[2], 1)) * -1;
138
+					$dew = ((float) substr($matches[2], 1))*-1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141 141
     			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     					$result['QNH'] = $matches[2];
148 148
     				} else {
149 149
     					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
150
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
151 151
 				}
152 152
     				/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     			// Visibility
169 169
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170 170
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
171
-					$result['visibility'] = (float)$matches[3] * 1609.34;
171
+					$result['visibility'] = (float) $matches[3]*1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
174 174
 						$result['visibility'] = '> 10000';
175 175
 					} else {
176
-						$result['visibility'] = (float)$matches[1];
176
+						$result['visibility'] = (float) $matches[1];
177 177
 					}
178 178
 				}
179 179
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196 196
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197 197
     				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
199 199
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200 200
     				$result['cloud'][] = $cloud;
201 201
     			}
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
208
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
209
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
208
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
209
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 224
     				//echo $piece;
225 225
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
226
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
230
+					    'from' => (float) $matches[2],
231
+					    'to'   => (float) $matches[4],
232 232
 					    'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                  try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute($query_values);
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         return "error : ".$e->getMessage();
282 282
                 }
283 283
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
                 return $all;
288 288
         }
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+       public function addMETAR($location, $metar, $date) {
291 291
 		global $globalDBdriver;
292
-		$date = date('Y-m-d H:i:s',strtotime($date));
292
+		$date = date('Y-m-d H:i:s', strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
298
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
299 299
                  try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute($query_values);
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                  try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute($query_values);
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         return "error : ".$e->getMessage();
315 315
                 }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321 321
                         $sth->execute();
322
-                } catch(PDOException $e) {
322
+                } catch (PDOException $e) {
323 323
                         return "error : ".$e->getMessage();
324 324
                 }
325 325
         }
@@ -331,30 +331,30 @@  discard block
 block discarded – undo
331 331
     		$Common = new Common();
332 332
     		if (isset($globalIVAO) && $globalIVAO) {
333 333
         		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
334
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
336 336
     		} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
338
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
340 340
     		}
341 341
     		if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344 344
     			//foreach(explode("\n",$cycle) as $line) {
345 345
     			if ($globalTransaction) $this->db->beginTransaction();
346
-	    		while(($line = fgets($handle,4096)) !== false) {
347
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
346
+	    		while (($line = fgets($handle, 4096)) !== false) {
347
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
348 348
 					$date = $line;
349 349
     				} elseif ($line != '') {
350 350
     				    //$this->parse($line);
351 351
     				    if ($date == '') $date = date('Y/m/d H:m');
352 352
         			    $pos = 0;
353
-        			    $pieces = preg_split('/\s/',$line);
353
+        			    $pieces = preg_split('/\s/', $line);
354 354
         			    if ($pieces[0] == 'METAR') $pos++;
355 355
         			    if (strlen($pieces[$pos]) != 4) $pos++;
356 356
 		        	    $location = $pieces[$pos];
357
-        	        	    echo $this->addMETAR($location,$line,$date);
357
+        	        	    echo $this->addMETAR($location, $line, $date);
358 358
     				}
359 359
     			}
360 360
     			fclose($handle);
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
     		if ($globalMETARurl == '') return array();
369 369
     		date_default_timezone_set("UTC");
370 370
     		$Common = new Common();
371
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
371
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
372 372
     		$cycle = $Common->getData($url);
373 373
     		$date = '';
374
-    		foreach(explode("\n",$cycle) as $line) {
375
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
374
+    		foreach (explode("\n", $cycle) as $line) {
375
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
376 376
     				//echo "date : ".$line."\n";
377 377
     				$date = $line;
378 378
     			} 
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
     			    //echo $line;
382 382
     			    if ($date == '') $date = date('Y/m/d H:m');
383 383
     			    $pos = 0;
384
-    			    $pieces = preg_split('/\s/',$line);
384
+    			    $pieces = preg_split('/\s/', $line);
385 385
     			    if ($pieces[0] == 'METAR') $pos++;
386 386
     			    if (strlen($pieces[$pos]) != 4) $pos++;
387 387
 	        	    $location = $pieces[$pos];
388 388
 	        	    if (strlen($location == 4)) {
389
-	        		$this->addMETAR($location,$line,$date);
389
+	        		$this->addMETAR($location, $line, $date);
390 390
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391 391
 	        	    } else return array();
392 392
     			}
Please login to merge, or discard this patch.
Braces   +100 added lines, -38 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61 61
                 $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
62
+                if ($row['nb'] > 0) {
63
+                	return false;
64
+                } else {
65
+                	return true;
66
+                }
64 67
         }
65 68
 
66 69
         public static function insert_last_update() {
@@ -84,9 +87,14 @@  discard block
 block discarded – undo
84 87
     		//$pieces = explode(' ',$data);
85 88
     		$pieces = preg_split('/\s/',$data);
86 89
     		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
+    		if ($pieces[0] == 'METAR') {
91
+    			$pos++;
92
+    		} elseif ($pieces[0] == 'SPECI') {
93
+    			$pos++;
94
+    		}
95
+    		if (strlen($pieces[$pos]) != 4) {
96
+    			$pos++;
97
+    		}
90 98
     		$result = array();
91 99
     		$result['location'] = $pieces[$pos];
92 100
     		$pos++;
@@ -95,16 +103,26 @@  discard block
 block discarded – undo
95 103
     		$c = count($pieces);
96 104
     		for($pos++; $pos < $c; $pos++) {
97 105
     			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
106
+    			if ($piece == 'RMK') {
107
+    				break;
108
+    			}
109
+    			if ($piece == 'AUTO') {
110
+    				$result['auto'] = true;
111
+    			}
112
+    			if ($piece == 'COR') {
113
+    				$result['correction'] = true;
114
+    			}
101 115
     			// Wind Speed
102 116
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103 117
     				$result['wind']['direction'] = (float)$matches[1];
104 118
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
119
+    				if ($result['wind']['unit'] == 'KT') {
120
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
121
+    				} elseif ($result['wind']['unit'] == 'KPH') {
122
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
123
+    				} elseif ($result['wind']['unit'] == 'MPS') {
124
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
125
+    				}
108 126
 				$result['wind']['gust'] = (float)$matches[3];
109 127
 				$result['wind']['unit'] = $matches[4];
110 128
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -186,14 +204,23 @@  discard block
 block discarded – undo
186 204
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187 205
     				$type = $matches[1];
188 206
     				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
207
+    				if ($type == 'SKC') {
208
+    					$cloud['type'] = 'No cloud/Sky clear';
209
+    				} elseif ($type == 'CLR') {
210
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
211
+    				} elseif ($type == 'NSC') {
212
+    					$cloud['type'] = 'No significant cloud';
213
+    				} elseif ($type == 'FEW') {
214
+    					$cloud['type'] = 'Few';
215
+    				} elseif ($type == 'SCT') {
216
+    					$cloud['type'] = 'Scattered';
217
+    				} elseif ($type == 'BKN') {
218
+    					$cloud['type'] = 'Broken';
219
+    				} elseif ($type == 'OVC') {
220
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
221
+    				} elseif ($type == 'VV') {
222
+    					$cloud['type'] = 'Vertical visibility';
223
+    				}
197 224
     				$cloud['type_code'] = $type;
198 225
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199 226
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -223,8 +250,11 @@  discard block
 block discarded – undo
223 250
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 251
     				//echo $piece;
225 252
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
253
+    				if (isset($matches[5])) {
254
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
255
+    				} else {
256
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
257
+    				}
228 258
 				if (isset($matches[3])) {
229 259
 					$range = Array(
230 260
 					    'from' => (float)$matches[2],
@@ -257,8 +287,11 @@  discard block
 block discarded – undo
257 287
 				if (isset($matches[3])) {
258 288
 					$text[] = $this->texts[$matches[3]];
259 289
 				}
260
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
290
+				if (!isset($result['weather'])) {
291
+					$result['weather'] = implode(' ', $text);
292
+				} else {
293
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
294
+				}
262 295
     			}
263 296
     		}
264 297
     		return $result;
@@ -270,8 +303,11 @@  discard block
 block discarded – undo
270 303
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
271 304
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272 305
                 } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
306
+            		if ($globalDBdriver == 'mysql') {
307
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
308
+            		} else {
309
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
310
+            		}
275 311
                 }
276 312
                 $query_values = array(':icao' => $icao);
277 313
                  try {
@@ -326,7 +362,9 @@  discard block
 block discarded – undo
326 362
         
327 363
         public function addMETARCycle() {
328 364
     		global $globalDebug, $globalIVAO, $globalTransaction;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
365
+    		if (isset($globalDebug) && $globalDebug) {
366
+    			echo "Downloading METAR cycle...";
367
+    		}
330 368
     		date_default_timezone_set("UTC");
331 369
     		$Common = new Common();
332 370
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -339,33 +377,49 @@  discard block
 block discarded – undo
339 377
     			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340 378
     		}
341 379
     		if ($handle) {
342
-			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
380
+			if (isset($globalDebug) && $globalDebug) {
381
+				echo "Done - Updating DB...";
382
+			}
343 383
 			$date = '';
344 384
     			//foreach(explode("\n",$cycle) as $line) {
345
-    			if ($globalTransaction) $this->db->beginTransaction();
385
+    			if ($globalTransaction) {
386
+    				$this->db->beginTransaction();
387
+    			}
346 388
 	    		while(($line = fgets($handle,4096)) !== false) {
347 389
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
348 390
 					$date = $line;
349 391
     				} elseif ($line != '') {
350 392
     				    //$this->parse($line);
351
-    				    if ($date == '') $date = date('Y/m/d H:m');
393
+    				    if ($date == '') {
394
+    				    	$date = date('Y/m/d H:m');
395
+    				    }
352 396
         			    $pos = 0;
353 397
         			    $pieces = preg_split('/\s/',$line);
354
-        			    if ($pieces[0] == 'METAR') $pos++;
355
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
398
+        			    if ($pieces[0] == 'METAR') {
399
+        			    	$pos++;
400
+        			    }
401
+        			    if (strlen($pieces[$pos]) != 4) {
402
+        			    	$pos++;
403
+        			    }
356 404
 		        	    $location = $pieces[$pos];
357 405
         	        	    echo $this->addMETAR($location,$line,$date);
358 406
     				}
359 407
     			}
360 408
     			fclose($handle);
361
-    			if ($globalTransaction) $this->db->commit();
409
+    			if ($globalTransaction) {
410
+    				$this->db->commit();
411
+    			}
412
+    		}
413
+    		if (isset($globalDebug) && $globalDebug) {
414
+    			echo "Done\n";
362 415
     		}
363
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
364 416
         
365 417
         }
366 418
         public function downloadMETAR($icao) {
367 419
     		global $globalMETARurl;
368
-    		if ($globalMETARurl == '') return array();
420
+    		if ($globalMETARurl == '') {
421
+    			return array();
422
+    		}
369 423
     		date_default_timezone_set("UTC");
370 424
     		$Common = new Common();
371 425
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -379,16 +433,24 @@  discard block
 block discarded – undo
379 433
     			if ($line != '') {
380 434
     			    //$this->parse($line);
381 435
     			    //echo $line;
382
-    			    if ($date == '') $date = date('Y/m/d H:m');
436
+    			    if ($date == '') {
437
+    			    	$date = date('Y/m/d H:m');
438
+    			    }
383 439
     			    $pos = 0;
384 440
     			    $pieces = preg_split('/\s/',$line);
385
-    			    if ($pieces[0] == 'METAR') $pos++;
386
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
441
+    			    if ($pieces[0] == 'METAR') {
442
+    			    	$pos++;
443
+    			    }
444
+    			    if (strlen($pieces[$pos]) != 4) {
445
+    			    	$pos++;
446
+    			    }
387 447
 	        	    $location = $pieces[$pos];
388 448
 	        	    if (strlen($location == 4)) {
389 449
 	        		$this->addMETAR($location,$line,$date);
390 450
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
-	        	    } else return array();
451
+	        	    } else {
452
+	        	    	return array();
453
+	        	    }
392 454
     			}
393 455
     			//echo $line."\n";
394 456
     		}
Please login to merge, or discard this patch.
statistics.php 3 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
47 47
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
48 48
 	}
49
-    ?>
49
+	?>
50 50
     </div>
51 51
     <?php include('statistics-sub-menu.php'); ?>
52 52
     <p class="global-stats">
@@ -55,23 +55,23 @@  discard block
 block discarded – undo
55 55
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56 56
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
57 57
 	<?php
58
-	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
58
+		if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
59 59
 	?>
60 60
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
61 61
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
62 62
         <?php
63
-    	    } else {
64
-    	?>
63
+			} else {
64
+		?>
65 65
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
66 66
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
67 67
     	<?php
68
-    	    }
69
-    	?>
68
+			}
69
+		?>
70 70
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71 71
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
72 72
         <?php
73
-    		if ($airline_icao == '') {
74
-    	?>
73
+			if ($airline_icao == '') {
74
+		?>
75 75
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
76 76
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77 77
 	<?php
@@ -94,25 +94,25 @@  discard block
 block discarded – undo
94 94
             <div class="col-md-6">
95 95
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 96
                  <?php
97
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
-		    if (count($aircraft_array) == 0) print _("No data available");
99
-		    else {
97
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
+			if (count($aircraft_array) == 0) print _("No data available");
99
+			else {
100 100
 
101
-                    print '<div id="chart1" class="chart" width="100%"></div>
101
+					print '<div id="chart1" class="chart" width="100%"></div>
102 102
                     <script> 
103 103
                         google.load("visualization", "1", {packages:["corechart"]});
104 104
                       google.setOnLoadCallback(drawChart1);
105 105
                       function drawChart1() {
106 106
                         var data = google.visualization.arrayToDataTable([
107 107
                             ["'._("Aircraft").'", "'._("# of times").'"], ';
108
-                            $aircraft_data = '';
109
-                          foreach($aircraft_array as $aircraft_item)
110
-                                    {
111
-                                            $aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112
-                                    }
113
-                                    $aircraft_data = substr($aircraft_data, 0, -1);
114
-                                    print $aircraft_data;
115
-                        print ']);
108
+							$aircraft_data = '';
109
+						  foreach($aircraft_array as $aircraft_item)
110
+									{
111
+											$aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112
+									}
113
+									$aircraft_data = substr($aircraft_data, 0, -1);
114
+									print $aircraft_data;
115
+						print ']);
116 116
 
117 117
                         var options = {
118 118
                             chartArea: {"width": "80%", "height": "60%"},
@@ -127,45 +127,45 @@  discard block
 block discarded – undo
127 127
                               drawChart1();
128 128
                             });
129 129
                   </script>';
130
-                  }
131
-                  ?>
130
+				  }
131
+				  ?>
132 132
                 <div class="more">
133 133
             	    <?php
134
-            		if ($year != '' && $month != '') {
135
-            	    ?>
134
+					if ($year != '' && $month != '') {
135
+					?>
136 136
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
137 137
             	    <?php
138
-            		} else {
139
-            	    ?>
138
+					} else {
139
+					?>
140 140
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
141 141
             	    <?php
142
-            		}
143
-            	    ?>
142
+					}
143
+					?>
144 144
                 </div>
145 145
             </div>
146 146
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
147 147
 <?php
148 148
 //    echo $airline_icao;
149
-    if ($airline_icao == '' || $airline_icao == 'all') {
149
+	if ($airline_icao == '' || $airline_icao == 'all') {
150 150
 	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
151 151
 	if (count($airline_array) > 0) {
152
-            print '<div class="col-md-6">';
153
-	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
154
-	    print '<div id="chart2" class="chart" width="100%"></div>
152
+			print '<div class="col-md-6">';
153
+		print '<h2>'._("Top 10 Most Common Airline").'</h2>';
154
+		print '<div id="chart2" class="chart" width="100%"></div>
155 155
                     <script> 
156 156
                         google.load("visualization", "1", {packages:["corechart"]});
157 157
                       google.setOnLoadCallback(drawChart2);
158 158
                       function drawChart2() {
159 159
                         var data = google.visualization.arrayToDataTable([
160 160
                             ["'._("Airline").'", "'._("# of times").'"], ';
161
-	    $airline_data = '';
162
-	    foreach($airline_array as $airline_item)
163
-	    {
161
+		$airline_data = '';
162
+		foreach($airline_array as $airline_item)
163
+		{
164 164
 		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
165
-	    }
166
-	    $airline_data = substr($airline_data, 0, -1);
167
-	    print $airline_data;
168
-	    print ']);
165
+		}
166
+		$airline_data = substr($airline_data, 0, -1);
167
+		print $airline_data;
168
+		print ']);
169 169
 
170 170
                         var options = {
171 171
                             chartArea: {"width": "80%", "height": "60%"},
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
                               drawChart2();
181 181
                             });
182 182
                   </script>';
183
-	    if ($year != '' && $month != '') {
183
+		if ($year != '' && $month != '') {
184 184
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
185 185
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
186 186
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
187
-	    } else {
187
+		} else {
188 188
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189 189
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
190 190
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191
-	    }
192
-    	    print '</div>';
191
+		}
192
+			print '</div>';
193 193
 	}
194 194
 ?>
195 195
         </div>
196 196
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
197 197
 <?php
198
-    }
198
+	}
199 199
 ?>
200 200
         <div class="row column">
201 201
 <?php
202
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
203
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
202
+	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
203
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
204 204
 	if (empty($flightover_array)) {
205
-	    print '<div class="col-md-12">';
205
+		print '<div class="col-md-12">';
206 206
 	} else {
207
-            print '<div class="col-md-6">';
207
+			print '<div class="col-md-6">';
208 208
 	}
209 209
 ?>
210 210
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
213 213
 	if (count($pilot_array) == 0) print _("No data available");
214 214
 	else {
215
-	    print '<div id="chart7" class="chart" width="100%"></div>
215
+		print '<div id="chart7" class="chart" width="100%"></div>
216 216
                     <script> 
217 217
                         google.load("visualization", "1", {packages:["corechart"]});
218 218
                       google.setOnLoadCallback(drawChart7);
219 219
                       function drawChart7() {
220 220
                         var data = google.visualization.arrayToDataTable([
221 221
                             ["'._("Pilots").'", "'._("# of times").'"], ';
222
-	    $pilot_data = '';
223
-	    foreach($pilot_array as $pilot_item)
224
-	    {
222
+		$pilot_data = '';
223
+		foreach($pilot_array as $pilot_item)
224
+		{
225 225
 		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
226
-	    }
227
-	    $pilot_data = substr($pilot_data, 0, -1);
228
-	    print $pilot_data;
229
-	    print ']);
226
+		}
227
+		$pilot_data = substr($pilot_data, 0, -1);
228
+		print $pilot_data;
229
+		print ']);
230 230
 
231 231
                         var options = {
232 232
                             chartArea: {"width": "80%", "height": "60%"},
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
                               drawChart7();
242 242
                             });
243 243
                   </script>';
244
-        }
245
-        print '<div class="more">';
244
+		}
245
+		print '<div class="more">';
246 246
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
247 247
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
248 248
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         
253 253
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
254 254
 <?php
255
-    } else {
255
+	} else {
256 256
 ?>
257 257
             <div class="col-md-6">
258 258
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
@@ -260,21 +260,21 @@  discard block
 block discarded – undo
260 260
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
261 261
 	if (count($owner_array) == 0) print _("No data available");
262 262
 	else {
263
-	    print '<div id="chart7" class="chart" width="100%"></div>
263
+		print '<div id="chart7" class="chart" width="100%"></div>
264 264
                     <script> 
265 265
                         google.load("visualization", "1", {packages:["corechart"]});
266 266
                       google.setOnLoadCallback(drawChart7);
267 267
                       function drawChart7() {
268 268
                         var data = google.visualization.arrayToDataTable([
269 269
                             ["'._("Owner").'", "'._("# of times").'"], ';
270
-                            $owner_data = '';
271
-	    foreach($owner_array as $owner_item)
272
-	    {
270
+							$owner_data = '';
271
+		foreach($owner_array as $owner_item)
272
+		{
273 273
 		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
274
-	    }
275
-	    $owner_data = substr($owner_data, 0, -1);
276
-	    print $owner_data;
277
-	    print ']);
274
+		}
275
+		$owner_data = substr($owner_data, 0, -1);
276
+		print $owner_data;
277
+		print ']);
278 278
 
279 279
                         var options = {
280 280
                             chartArea: {"width": "80%", "height": "60%"},
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
         
299 299
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
300 300
 <?php
301
-    }
302
-    if (!empty($flightover_array)) {
301
+	}
302
+	if (!empty($flightover_array)) {
303 303
 ?>
304 304
             <div class="col-md-6">
305 305
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
@@ -307,21 +307,21 @@  discard block
 block discarded – undo
307 307
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
308 308
 	if (count($flightover_array) == 0) print _("No data available");
309 309
 	else {
310
-	    print '<div id="chart10" class="chart" width="100%"></div>
310
+		print '<div id="chart10" class="chart" width="100%"></div>
311 311
                     <script> 
312 312
                         google.load("visualization", "1", {packages:["corechart"]});
313 313
                       google.setOnLoadCallback(drawChart10);
314 314
                       function drawChart10() {
315 315
                         var data = google.visualization.arrayToDataTable([
316 316
                             ["'._("Country").'", "'._("# of times").'"], ';
317
-                            $flightover_data = '';
318
-	    foreach($flightover_array as $flightover_item)
319
-	    {
317
+							$flightover_data = '';
318
+		foreach($flightover_array as $flightover_item)
319
+		{
320 320
 		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
321
-	    }
322
-	    $flightover_data = substr($flightover_data, 0, -1);
323
-	    print $flightover_data;
324
-	    print ']);
321
+		}
322
+		$flightover_data = substr($flightover_data, 0, -1);
323
+		print $flightover_data;
324
+		print ']);
325 325
 
326 326
                         var options = {
327 327
                             chartArea: {"width": "80%", "height": "60%"},
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
                 </div>
346 346
             </div>
347 347
 <?php
348
-    }
348
+	}
349 349
 ?>
350 350
         </div>
351 351
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
         <div class="row column">
356 356
             <div class="col-md-6">
357 357
 <?php
358
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
359
-    if (count($airport_airport_array) > 0) {
358
+	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
359
+	if (count($airport_airport_array) > 0) {
360 360
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
361 361
 	print '<div id="chart3" class="chart" width="100%"></div>
362 362
                 <script>
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 
370 370
                 var data = google.visualization.arrayToDataTable([ 
371 371
                     ["'._("Airport").'", "'._("# of times").'"],';
372
-                    $airport_data = '';
372
+					$airport_data = '';
373 373
 	foreach($airport_airport_array as $airport_item)
374 374
 	{
375
-	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376
-	    $name = str_replace("'", "", $name);
377
-	    $name = str_replace('"', "", $name);
378
-	    $airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
375
+		$name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376
+		$name = str_replace("'", "", $name);
377
+		$name = str_replace('"', "", $name);
378
+		$airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
379 379
 	}
380 380
 	$airport_data = substr($airport_data, 0, -1);
381 381
 	print $airport_data;
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
397 397
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
398 398
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
399
-    }
399
+	}
400 400
 ?>
401 401
             </div>
402 402
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
403 403
 
404 404
             <div class="col-md-6">
405 405
 <?php
406
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
407
-    if (count($airport_airport_array2) > 0) {
406
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
407
+	if (count($airport_airport_array2) > 0) {
408 408
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
409 409
 	print '<div id="chart4" class="chart" width="100%"></div>
410 410
                 <script>
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 	$airport_data2 = '';
421 421
 	foreach($airport_airport_array2 as $airport_item2)
422 422
 	{
423
-	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
-	    $name2 = str_replace(array("'",'"'), '', $name2);
425
-	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
423
+		$name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
+		$name2 = str_replace(array("'",'"'), '', $name2);
425
+		$airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
426 426
 	}
427 427
 	$airport_data2 = substr($airport_data2, 0, -1);
428 428
 	print $airport_data2;
@@ -443,36 +443,36 @@  discard block
 block discarded – undo
443 443
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
444 444
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
445 445
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
446
-    }
446
+	}
447 447
 ?>
448 448
             </div>
449 449
         </div>
450 450
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
451 451
 <?php
452
-    if ($year == '' && $month == '') {
452
+	if ($year == '' && $month == '') {
453 453
 ?>
454 454
         <div class="row column">
455 455
             <div class="col-md-6">
456 456
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457 457
                 <?php
458
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
-		    if (count($year_array) == 0) print _("No data available");
460
-		    else {
461
-                  print '<div id="chart8" class="chart" width="100%"></div>
458
+				  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
+			if (count($year_array) == 0) print _("No data available");
460
+			else {
461
+				  print '<div id="chart8" class="chart" width="100%"></div>
462 462
                     <script> 
463 463
                         google.load("visualization", "1", {packages:["corechart"]});
464 464
                       google.setOnLoadCallback(drawChart8);
465 465
                       function drawChart8() {
466 466
                         var data = google.visualization.arrayToDataTable([
467 467
                             ["'._("Month").'", "'._("# of Flights").'"], ';
468
-                            $year_data = '';
469
-                          foreach($year_array as $year_item)
470
-                                    {
471
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472
-                                    }
473
-                                    $year_data = substr($year_data, 0, -1);
474
-                                    print $year_data;
475
-                        print ']);
468
+							$year_data = '';
469
+						  foreach($year_array as $year_item)
470
+									{
471
+										$year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472
+									}
473
+									$year_data = substr($year_data, 0, -1);
474
+									print $year_data;
475
+						print ']);
476 476
 
477 477
                         var options = {
478 478
                             legend: {position: "none"},
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
                               drawChart8();
491 491
                             });
492 492
                   </script>';
493
-                  }
494
-                  ?>
493
+				  }
494
+				  ?>
495 495
                 <div class="more">
496 496
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 497
                 </div>
@@ -500,24 +500,24 @@  discard block
 block discarded – undo
500 500
             <div class="col-md-6">
501 501
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502 502
                 <?php
503
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
-		    if (count($month_array) == 0) print _("No data available");
505
-		    else {
506
-                  print '<div id="chart9" class="chart" width="100%"></div>
503
+				  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
+			if (count($month_array) == 0) print _("No data available");
505
+			else {
506
+				  print '<div id="chart9" class="chart" width="100%"></div>
507 507
                     <script> 
508 508
                         google.load("visualization", "1", {packages:["corechart"]});
509 509
                       google.setOnLoadCallback(drawChart9);
510 510
                       function drawChart9() {
511 511
                         var data = google.visualization.arrayToDataTable([
512 512
                             ["'._("Day").'", "'._("# of Flights").'"], ';
513
-                            $month_data = '';
514
-                          foreach($month_array as $month_item)
515
-                                    {
516
-                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517
-                                    }
518
-                                    $month_data = substr($month_data, 0, -1);
519
-                                    print $month_data;
520
-                        print ']);
513
+							$month_data = '';
514
+						  foreach($month_array as $month_item)
515
+									{
516
+										$month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517
+									}
518
+									$month_data = substr($month_data, 0, -1);
519
+									print $month_data;
520
+						print ']);
521 521
 
522 522
                         var options = {
523 523
                             legend: {position: "none"},
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
                               drawChart9();
536 536
                             });
537 537
                   </script>';
538
-                  }
539
-                  ?>
538
+				  }
539
+				  ?>
540 540
                 <div class="more">
541 541
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
542 542
                 </div>
@@ -546,25 +546,25 @@  discard block
 block discarded – undo
546 546
             <div class="col-md-6">
547 547
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548 548
                 <?php
549
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
-		    if (empty($date_array)) print _("No data available");
551
-		    else {
552
-                  print '<div id="chart5" class="chart" width="100%"></div>
549
+					$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
+			if (empty($date_array)) print _("No data available");
551
+			else {
552
+				  print '<div id="chart5" class="chart" width="100%"></div>
553 553
                     <script> 
554 554
                         google.load("visualization", "1", {packages:["corechart"]});
555 555
                       google.setOnLoadCallback(drawChart5);
556 556
                       function drawChart5() {
557 557
                         var data = google.visualization.arrayToDataTable([
558 558
                             ["'._("Date").'", "'._("# of Flights").'"], ';
559
-                            $date_data = '';
559
+							$date_data = '';
560 560
                         
561
-                          foreach($date_array as $date_item)
562
-                                    {
563
-                                        $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564
-                                    }
565
-                                    $date_data = substr($date_data, 0, -1);
566
-                                    print $date_data;
567
-                        print ']);
561
+						  foreach($date_array as $date_item)
562
+									{
563
+										$date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564
+									}
565
+									$date_data = substr($date_data, 0, -1);
566
+									print $date_data;
567
+						print ']);
568 568
 
569 569
                         var options = {
570 570
                             legend: {position: "none"},
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
                               drawChart5();
583 583
                             });
584 584
                   </script>';
585
-                  }
586
-                  ?>
585
+				  }
586
+				  ?>
587 587
                 <div class="more">
588 588
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
589 589
                 </div>
@@ -592,25 +592,25 @@  discard block
 block discarded – undo
592 592
             <div class="col-md-6">
593 593
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594 594
                 <?php
595
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
-		    if (empty($hour_array)) print _("No data available");
597
-		    else {
595
+				  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
+			if (empty($hour_array)) print _("No data available");
597
+			else {
598 598
 
599
-                  print '<div id="chart6" class="chart" width="100%"></div>
599
+				  print '<div id="chart6" class="chart" width="100%"></div>
600 600
                     <script> 
601 601
                         google.load("visualization", "1", {packages:["corechart"]});
602 602
                       google.setOnLoadCallback(drawChart6);
603 603
                       function drawChart6() {
604 604
                         var data = google.visualization.arrayToDataTable([
605 605
                             ["'._("Hour").'", "'._("# of Flights").'"], ';
606
-                            $hour_data = '';
607
-                          foreach($hour_array as $hour_item)
608
-                                    {
609
-                                        $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610
-                                    }
611
-                                    $hour_data = substr($hour_data, 0, -1);
612
-                                    print $hour_data;
613
-                        print ']);
606
+							$hour_data = '';
607
+						  foreach($hour_array as $hour_item)
608
+									{
609
+										$hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610
+									}
611
+									$hour_data = substr($hour_data, 0, -1);
612
+									print $hour_data;
613
+						print ']);
614 614
 
615 615
                         var options = {
616 616
                             legend: {position: "none"},
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
                               drawChart6();
629 629
                             });
630 630
                   </script>';
631
-                  }
632
-                ?>
631
+				  }
632
+				?>
633 633
                 <div class="more">
634 634
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635 635
                 </div>
@@ -637,36 +637,36 @@  discard block
 block discarded – undo
637 637
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
638 638
         </div>
639 639
 <?php
640
-    }
640
+	}
641 641
 ?>
642 642
 
643 643
 <?php
644
-    if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
644
+	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
645 645
 ?>
646 646
         <div class="row column">
647 647
             <div class="col-md-6">
648 648
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
649 649
                 <?php
650
-		    require_once('require/class.Accident.php');
651
-            	    $Accident = new Accident();
652
-                  $year_array = $Accident->countFatalitiesByYear($filter_name);
653
-		    if (count($year_array) == 0) print _("No data available");
654
-		    else {
655
-                  print '<div id="chart32" class="chart" width="100%"></div>
650
+			require_once('require/class.Accident.php');
651
+					$Accident = new Accident();
652
+				  $year_array = $Accident->countFatalitiesByYear($filter_name);
653
+			if (count($year_array) == 0) print _("No data available");
654
+			else {
655
+				  print '<div id="chart32" class="chart" width="100%"></div>
656 656
                     <script> 
657 657
                         google.load("visualization", "1", {packages:["corechart"]});
658 658
                       google.setOnLoadCallback(drawChart32);
659 659
                       function drawChart32() {
660 660
                         var data = google.visualization.arrayToDataTable([
661 661
                             ["'._("Year").'", "'._("# of Fatalities").'"], ';
662
-                            $year_data = '';
663
-                          foreach($year_array as $year_item)
664
-                                    {
665
-                                        $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
666
-                                    }
667
-                                    $year_data = substr($year_data, 0, -1);
668
-                                    print $year_data;
669
-                        print ']);
662
+							$year_data = '';
663
+						  foreach($year_array as $year_item)
664
+									{
665
+										$year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
666
+									}
667
+									$year_data = substr($year_data, 0, -1);
668
+									print $year_data;
669
+						print ']);
670 670
 
671 671
                         var options = {
672 672
                             legend: {position: "none"},
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
                               drawChart32();
685 685
                             });
686 686
                   </script>';
687
-                  }
688
-                  ?>
687
+				  }
688
+				  ?>
689 689
                 <div class="more">
690 690
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
691 691
                 </div>
@@ -696,26 +696,26 @@  discard block
 block discarded – undo
696 696
             <div class="col-md-6">
697 697
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
698 698
                 <?php
699
-		    require_once('require/class.Accident.php');
700
-            	    $Accident = new Accident();
701
-                  $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
-		    if (count($year_array) == 0) print _("No data available");
703
-		    else {
704
-                  print '<div id="chart33" class="chart" width="100%"></div>
699
+			require_once('require/class.Accident.php');
700
+					$Accident = new Accident();
701
+				  $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
+			if (count($year_array) == 0) print _("No data available");
703
+			else {
704
+				  print '<div id="chart33" class="chart" width="100%"></div>
705 705
                     <script> 
706 706
                         google.load("visualization", "1", {packages:["corechart"]});
707 707
                       google.setOnLoadCallback(drawChart33);
708 708
                       function drawChart33() {
709 709
                         var data = google.visualization.arrayToDataTable([
710 710
                             ["'._("Month").'", "'._("# of Fatalities").'"], ';
711
-                            $year_data = '';
712
-                          foreach($year_array as $year_item)
713
-                                    {
714
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
715
-                                    }
716
-                                    $year_data = substr($year_data, 0, -1);
717
-                                    print $year_data;
718
-                        print ']);
711
+							$year_data = '';
712
+						  foreach($year_array as $year_item)
713
+									{
714
+										$year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
715
+									}
716
+									$year_data = substr($year_data, 0, -1);
717
+									print $year_data;
718
+						print ']);
719 719
 
720 720
                         var options = {
721 721
                             legend: {position: "none"},
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
                               drawChart33();
734 734
                             });
735 735
                   </script>';
736
-                  }
737
-                  ?>
736
+				  }
737
+				  ?>
738 738
                 <div class="more">
739 739
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
740 740
                 </div>
@@ -742,30 +742,30 @@  discard block
 block discarded – undo
742 742
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
743 743
 <br/>
744 744
 <?php
745
-    }
745
+	}
746 746
 ?>
747 747
 
748 748
 <?php
749
-    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
749
+	if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
750 750
 ?>
751 751
         <div class="row column">
752 752
         	<?php
753
-        	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
754
-        	    if ($year == '' && $month == '') {
755
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
756
-		    } else {
757
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
758
-        	    }
759
-        	    if (!empty($polar)) {
760
-            		print '<h2>'._("Coverage pattern").'</h2>';
761
-        		foreach ($polar as $eachpolar) {
762
-        		    unset($polar_data);
763
-	        	    $Spotter = new Spotter();
764
-        		    $data = json_decode($eachpolar['source_data']);
765
-        		    foreach($data as $value => $key) {
766
-        			$direction = $Spotter->parseDirection(($value*22.5));
767
-        			$distance = $key;
768
-        			$unit = 'km';
753
+				//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
754
+				if ($year == '' && $month == '') {
755
+				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
756
+			} else {
757
+				$polar = $Stats->getStatsSource('polar',$year,$month);
758
+				}
759
+				if (!empty($polar)) {
760
+					print '<h2>'._("Coverage pattern").'</h2>';
761
+				foreach ($polar as $eachpolar) {
762
+					unset($polar_data);
763
+					$Spotter = new Spotter();
764
+					$data = json_decode($eachpolar['source_data']);
765
+					foreach($data as $value => $key) {
766
+					$direction = $Spotter->parseDirection(($value*22.5));
767
+					$distance = $key;
768
+					$unit = 'km';
769 769
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
770 770
 					$distance = round($distance*0.539957);
771 771
 					$unit = 'nm';
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
 					$distance = $distance;
777 777
 					$unit = 'km';
778 778
 				}
779
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
781
-        		    }
782
-        	?>
779
+					if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
+						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
781
+					}
782
+			?>
783 783
             <div class="col-md-6">
784 784
                 <h4><?php print $eachpolar['source_name']; ?></h4>
785 785
         	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
@@ -811,27 +811,27 @@  discard block
 block discarded – undo
811 811
 		</script>
812 812
             </div>
813 813
             <?php
814
-        	    }
815
-        	}
816
-            ?>
814
+				}
815
+			}
816
+			?>
817 817
         </div>
818 818
         <div class="row column">
819 819
             <div class="col-md-6">
820 820
         	<?php
821
-        	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
822
-        	    if ($year == '' && $month == '') {
823
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
824
-        	    } else {
825
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
826
-        	    }
827
-        	    if (!empty($msg)) {
828
-            		print '<h2>'._("Messages received").'</h2>';
829
-        		foreach ($msg as $eachmsg) {
830
-        		    //$eachmsg = $msg[0];
831
-        		    $data = $eachmsg['source_data'];
832
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
833
-        		    else $max = 500;
834
-        	?>
821
+				//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
822
+				if ($year == '' && $month == '') {
823
+				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
824
+				} else {
825
+				$msg = $Stats->getStatsSource('msg',$year,$month);
826
+				}
827
+				if (!empty($msg)) {
828
+					print '<h2>'._("Messages received").'</h2>';
829
+				foreach ($msg as $eachmsg) {
830
+					//$eachmsg = $msg[0];
831
+					$data = $eachmsg['source_data'];
832
+					if ($data > 500) $max = (round(($data+100)/100))*100;
833
+					else $max = 500;
834
+			?>
835 835
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
836 836
         	<script>
837 837
 		      var g = new JustGage({
@@ -847,9 +847,9 @@  discard block
 block discarded – undo
847 847
 			  });
848 848
 		</script>
849 849
             <?php
850
-        	   }
851
-        	}
852
-            ?>
850
+			   }
851
+			}
852
+			?>
853 853
             </div>
854 854
         </div>
855 855
         <div class="row column">
@@ -881,19 +881,19 @@  discard block
 block discarded – undo
881 881
 				$hist_data .= '[ "'.$distance.'",'.$nb.'],';
882 882
 			}
883 883
 			$hist_data = substr($hist_data, 0, -1);
884
-            ?>
884
+			?>
885 885
             <div class="col-md-6">
886 886
                 <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
887 887
                 <?php
888
-                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
888
+				  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
889 889
                     <script> 
890 890
                         google.load("visualization", "1", {packages:["corechart"]});
891 891
                       google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
892 892
                       function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
893 893
                         var data = google.visualization.arrayToDataTable([
894 894
                             ["'._("Distance").'", "'._("# of Flights").'"], ';
895
-                            print $hist_data;
896
-                        print ']);
895
+							print $hist_data;
896
+						print ']);
897 897
 
898 898
                         var options = {
899 899
                             legend: {position: "none"},
@@ -911,15 +911,15 @@  discard block
 block discarded – undo
911 911
                               drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
912 912
                             });
913 913
                   </script>';
914
-        	?>
914
+			?>
915 915
     	    </div>
916 916
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
917 917
         	<?php
918
-                  }
919
-                ?>
918
+				  }
919
+				?>
920 920
         </div>
921 921
 <?php
922
-    }
922
+	}
923 923
 ?>
924 924
     </div>
925 925
 </div>  
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $Stats = new Stats();
8 8
 
9 9
 if (!isset($filter_name)) $filter_name = '';
10
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
11 11
 if ($airline_icao == '' && isset($globalFilter)) {
12 12
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13 13
 }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	$title = _("Statistics");
23 23
 }
24 24
 
25
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
26
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
25
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
26
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
27 27
 
28 28
 require_once('header.php');
29 29
 
@@ -44,36 +44,36 @@  discard block
 block discarded – undo
44 44
 		date_default_timezone_set('UTC');
45 45
 		$lastupdate = strtotime($last_update[0]['value']);
46 46
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
47
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
47
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
48 48
 	}
49 49
     ?>
50 50
     </div>
51 51
     <?php include('statistics-sub-menu.php'); ?>
52 52
     <p class="global-stats">
53
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
54
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
55
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
53
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
54
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
55
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
57 57
 	<?php
58 58
 	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
59 59
 	?>
60
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
61
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
60
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
61
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
62 62
         <?php
63 63
     	    } else {
64 64
     	?>
65
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
66
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
65
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
66
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
67 67
     	<?php
68 68
     	    }
69 69
     	?>
70
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
70
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
72 72
         <?php
73 73
     		if ($airline_icao == '') {
74 74
     	?>
75
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
76
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
75
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
76
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
77 77
 	<?php
78 78
 		}
79 79
 	?>
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
82 82
 			if ($airline_icao == '' || $airline_icao == 'all') {
83 83
 	?>
84
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
85
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
84
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
85
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
86 86
 	<?php
87 87
 			}
88 88
 		}
89 89
 	?>
90 90
     </p>
91
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
91
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
92 92
     <div class="specific-stats">
93 93
         <div class="row column">
94 94
             <div class="col-md-6">
95 95
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 96
                  <?php
97
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
97
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
98 98
 		    if (count($aircraft_array) == 0) print _("No data available");
99 99
 		    else {
100 100
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                         var data = google.visualization.arrayToDataTable([
107 107
                             ["'._("Aircraft").'", "'._("# of times").'"], ';
108 108
                             $aircraft_data = '';
109
-                          foreach($aircraft_array as $aircraft_item)
109
+                          foreach ($aircraft_array as $aircraft_item)
110 110
                                     {
111 111
                                             $aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112 112
                                     }
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
             	    ?>
144 144
                 </div>
145 145
             </div>
146
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
146
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
147 147
 <?php
148 148
 //    echo $airline_icao;
149 149
     if ($airline_icao == '' || $airline_icao == 'all') {
150
-	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
150
+	$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
151 151
 	if (count($airline_array) > 0) {
152 152
             print '<div class="col-md-6">';
153 153
 	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                         var data = google.visualization.arrayToDataTable([
160 160
                             ["'._("Airline").'", "'._("# of times").'"], ';
161 161
 	    $airline_data = '';
162
-	    foreach($airline_array as $airline_item)
162
+	    foreach ($airline_array as $airline_item)
163 163
 	    {
164 164
 		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
165 165
 	    }
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 	}
194 194
 ?>
195 195
         </div>
196
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
196
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
197 197
 <?php
198 198
     }
199 199
 ?>
200 200
         <div class="row column">
201 201
 <?php
202
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
202
+    $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
203 203
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
204 204
 	if (empty($flightover_array)) {
205 205
 	    print '<div class="col-md-12">';
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 ?>
210 210
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
211 211
 <?php
212
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
212
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
213 213
 	if (count($pilot_array) == 0) print _("No data available");
214 214
 	else {
215 215
 	    print '<div id="chart7" class="chart" width="100%"></div>
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                         var data = google.visualization.arrayToDataTable([
221 221
                             ["'._("Pilots").'", "'._("# of times").'"], ';
222 222
 	    $pilot_data = '';
223
-	    foreach($pilot_array as $pilot_item)
223
+	    foreach ($pilot_array as $pilot_item)
224 224
 	    {
225 225
 		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
226 226
 	    }
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 ?>
251 251
             </div>
252 252
         
253
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
253
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
254 254
 <?php
255 255
     } else {
256 256
 ?>
257 257
             <div class="col-md-6">
258 258
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
259 259
 <?php
260
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
260
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
261 261
 	if (count($owner_array) == 0) print _("No data available");
262 262
 	else {
263 263
 	    print '<div id="chart7" class="chart" width="100%"></div>
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                         var data = google.visualization.arrayToDataTable([
269 269
                             ["'._("Owner").'", "'._("# of times").'"], ';
270 270
                             $owner_data = '';
271
-	    foreach($owner_array as $owner_item)
271
+	    foreach ($owner_array as $owner_item)
272 272
 	    {
273 273
 		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
274 274
 	    }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
                 </div>
297 297
             </div>
298 298
         
299
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
299
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
300 300
 <?php
301 301
     }
302 302
     if (!empty($flightover_array)) {
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                         var data = google.visualization.arrayToDataTable([
316 316
                             ["'._("Country").'", "'._("# of times").'"], ';
317 317
                             $flightover_data = '';
318
-	    foreach($flightover_array as $flightover_item)
318
+	    foreach ($flightover_array as $flightover_item)
319 319
 	    {
320 320
 		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
321 321
 	    }
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
     }
349 349
 ?>
350 350
         </div>
351
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
351
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
352 352
 
353 353
     	
354 354
         </div>
355 355
         <div class="row column">
356 356
             <div class="col-md-6">
357 357
 <?php
358
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
358
+    $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
359 359
     if (count($airport_airport_array) > 0) {
360 360
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
361 361
 	print '<div id="chart3" class="chart" width="100%"></div>
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
                 var data = google.visualization.arrayToDataTable([ 
371 371
                     ["'._("Airport").'", "'._("# of times").'"],';
372 372
                     $airport_data = '';
373
-	foreach($airport_airport_array as $airport_item)
373
+	foreach ($airport_airport_array as $airport_item)
374 374
 	{
375 375
 	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376 376
 	    $name = str_replace("'", "", $name);
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
     }
400 400
 ?>
401 401
             </div>
402
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
402
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
403 403
 
404 404
             <div class="col-md-6">
405 405
 <?php
406
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
406
+    $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
407 407
     if (count($airport_airport_array2) > 0) {
408 408
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
409 409
 	print '<div id="chart4" class="chart" width="100%"></div>
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
                 var data = google.visualization.arrayToDataTable([ 
419 419
                     ["'._("Airport").'", "'._("# of times").'"],';
420 420
 	$airport_data2 = '';
421
-	foreach($airport_airport_array2 as $airport_item2)
421
+	foreach ($airport_airport_array2 as $airport_item2)
422 422
 	{
423 423
 	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
-	    $name2 = str_replace(array("'",'"'), '', $name2);
424
+	    $name2 = str_replace(array("'", '"'), '', $name2);
425 425
 	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
426 426
 	}
427 427
 	$airport_data2 = substr($airport_data2, 0, -1);
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 ?>
448 448
             </div>
449 449
         </div>
450
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
450
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
451 451
 <?php
452 452
     if ($year == '' && $month == '') {
453 453
 ?>
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
             <div class="col-md-6">
456 456
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457 457
                 <?php
458
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
458
+                  $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
459 459
 		    if (count($year_array) == 0) print _("No data available");
460 460
 		    else {
461 461
                   print '<div id="chart8" class="chart" width="100%"></div>
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
                         var data = google.visualization.arrayToDataTable([
467 467
                             ["'._("Month").'", "'._("# of Flights").'"], ';
468 468
                             $year_data = '';
469
-                          foreach($year_array as $year_item)
469
+                          foreach ($year_array as $year_item)
470 470
                                     {
471
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
471
+                                        $year_data .= '[ "'.date('F, Y', strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472 472
                                     }
473 473
                                     $year_data = substr($year_data, 0, -1);
474 474
                                     print $year_data;
@@ -496,11 +496,11 @@  discard block
 block discarded – undo
496 496
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 497
                 </div>
498 498
             </div>
499
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
499
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
500 500
             <div class="col-md-6">
501 501
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502 502
                 <?php
503
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
503
+                  $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
504 504
 		    if (count($month_array) == 0) print _("No data available");
505 505
 		    else {
506 506
                   print '<div id="chart9" class="chart" width="100%"></div>
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
                         var data = google.visualization.arrayToDataTable([
512 512
                             ["'._("Day").'", "'._("# of Flights").'"], ';
513 513
                             $month_data = '';
514
-                          foreach($month_array as $month_item)
514
+                          foreach ($month_array as $month_item)
515 515
                                     {
516
-                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
516
+                                        $month_data .= '[ "'.date('F j, Y', strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517 517
                                     }
518 518
                                     $month_data = substr($month_data, 0, -1);
519 519
                                     print $month_data;
@@ -541,12 +541,12 @@  discard block
 block discarded – undo
541 541
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
542 542
                 </div>
543 543
             </div>
544
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
544
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
545 545
 
546 546
             <div class="col-md-6">
547 547
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548 548
                 <?php
549
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
549
+                    $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
550 550
 		    if (empty($date_array)) print _("No data available");
551 551
 		    else {
552 552
                   print '<div id="chart5" class="chart" width="100%"></div>
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
                             ["'._("Date").'", "'._("# of Flights").'"], ';
559 559
                             $date_data = '';
560 560
                         
561
-                          foreach($date_array as $date_item)
561
+                          foreach ($date_array as $date_item)
562 562
                                     {
563 563
                                         $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564 564
                                     }
@@ -588,11 +588,11 @@  discard block
 block discarded – undo
588 588
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
589 589
                 </div>
590 590
             </div>
591
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
591
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
592 592
             <div class="col-md-6">
593 593
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594 594
                 <?php
595
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
595
+                  $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
596 596
 		    if (empty($hour_array)) print _("No data available");
597 597
 		    else {
598 598
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
                         var data = google.visualization.arrayToDataTable([
605 605
                             ["'._("Hour").'", "'._("# of Flights").'"], ';
606 606
                             $hour_data = '';
607
-                          foreach($hour_array as $hour_item)
607
+                          foreach ($hour_array as $hour_item)
608 608
                                     {
609 609
                                         $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610 610
                                     }
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635 635
                 </div>
636 636
             </div>
637
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
637
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
638 638
         </div>
639 639
 <?php
640 640
     }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
                         var data = google.visualization.arrayToDataTable([
661 661
                             ["'._("Year").'", "'._("# of Fatalities").'"], ';
662 662
                             $year_data = '';
663
-                          foreach($year_array as $year_item)
663
+                          foreach ($year_array as $year_item)
664 664
                                     {
665 665
                                         $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
666 666
                                     }
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
691 691
                 </div>
692 692
             </div>
693
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
693
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
694 694
 
695 695
         <div class="row column">
696 696
             <div class="col-md-6">
@@ -709,9 +709,9 @@  discard block
 block discarded – undo
709 709
                         var data = google.visualization.arrayToDataTable([
710 710
                             ["'._("Month").'", "'._("# of Fatalities").'"], ';
711 711
                             $year_data = '';
712
-                          foreach($year_array as $year_item)
712
+                          foreach ($year_array as $year_item)
713 713
                                     {
714
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
714
+                                        $year_data .= '[ "'.date('F, Y', strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
715 715
                                     }
716 716
                                     $year_data = substr($year_data, 0, -1);
717 717
                                     print $year_data;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
740 740
                 </div>
741 741
             </div>
742
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
742
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
743 743
 <br/>
744 744
 <?php
745 745
     }
@@ -752,9 +752,9 @@  discard block
 block discarded – undo
752 752
         	<?php
753 753
         	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
754 754
         	    if ($year == '' && $month == '') {
755
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
755
+		        $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
756 756
 		    } else {
757
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
757
+        		$polar = $Stats->getStatsSource('polar', $year, $month);
758 758
         	    }
759 759
         	    if (!empty($polar)) {
760 760
             		print '<h2>'._("Coverage pattern").'</h2>';
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         		    unset($polar_data);
763 763
 	        	    $Spotter = new Spotter();
764 764
         		    $data = json_decode($eachpolar['source_data']);
765
-        		    foreach($data as $value => $key) {
765
+        		    foreach ($data as $value => $key) {
766 766
         			$direction = $Spotter->parseDirection(($value*22.5));
767 767
         			$distance = $key;
768 768
         			$unit = 'km';
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
         	?>
783 783
             <div class="col-md-6">
784 784
                 <h4><?php print $eachpolar['source_name']; ?></h4>
785
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
785
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
786 786
         	<script>
787 787
         	    (function() {
788 788
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 		      color: color,
807 807
 		      unit: '<?php echo $unit; ?>'
808 808
 		    };
809
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
809
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
810 810
 		    })();
811 811
 		</script>
812 812
             </div>
@@ -820,22 +820,22 @@  discard block
 block discarded – undo
820 820
         	<?php
821 821
         	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
822 822
         	    if ($year == '' && $month == '') {
823
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
823
+        		$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
824 824
         	    } else {
825
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
825
+        		$msg = $Stats->getStatsSource('msg', $year, $month);
826 826
         	    }
827 827
         	    if (!empty($msg)) {
828 828
             		print '<h2>'._("Messages received").'</h2>';
829 829
         		foreach ($msg as $eachmsg) {
830 830
         		    //$eachmsg = $msg[0];
831 831
         		    $data = $eachmsg['source_data'];
832
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
832
+        		    if ($data > 500) $max = (round(($data + 100)/100))*100;
833 833
         		    else $max = 500;
834 834
         	?>
835
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
835
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
836 836
         	<script>
837 837
 		      var g = new JustGage({
838
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
838
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
839 839
 			    value: <?php echo $data; ?>,
840 840
 			    min: 0,
841 841
 			    max: <?php print $max; ?>,
@@ -857,15 +857,15 @@  discard block
 block discarded – undo
857 857
             <?php
858 858
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
859 859
 		if ($year == '' && $month == '') {
860
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
860
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
861 861
 		} else {
862
-			$hist = $Stats->getStatsSource('hist',$year,$month);
862
+			$hist = $Stats->getStatsSource('hist', $year, $month);
863 863
 		}
864 864
 		foreach ($hist as $hists) {
865 865
 			$hist_data = '';
866 866
 			$source = $hists['source_name'];
867 867
 			$hist_array = json_decode($hists['source_data']);
868
-			foreach($hist_array as $distance => $nb)
868
+			foreach ($hist_array as $distance => $nb)
869 869
 			{
870 870
 				$unit = 'km';
871 871
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -883,13 +883,13 @@  discard block
 block discarded – undo
883 883
 			$hist_data = substr($hist_data, 0, -1);
884 884
             ?>
885 885
             <div class="col-md-6">
886
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
886
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
887 887
                 <?php
888
-                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
888
+                  print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div>
889 889
                     <script> 
890 890
                         google.load("visualization", "1", {packages:["corechart"]});
891
-                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
892
-                      function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
891
+                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ', '_', strtolower($source)).');
892
+                      function drawCharthist_'.str_replace(' ', '_', strtolower($source)).'() {
893 893
                         var data = google.visualization.arrayToDataTable([
894 894
                             ["'._("Distance").'", "'._("# of Flights").'"], ';
895 895
                             print $hist_data;
@@ -904,16 +904,16 @@  discard block
 block discarded – undo
904 904
                             colors: ["#1a3151"]
905 905
                         };
906 906
 
907
-                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ','_',strtolower($source)).'"));
907
+                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ', '_', strtolower($source)).'"));
908 908
                         chart.draw(data, options);
909 909
                       }
910 910
                       $(window).resize(function(){
911
-                              drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
911
+                              drawCharthist_'.str_replace(' ', '_', strtolower($source)).'();
912 912
                             });
913 913
                   </script>';
914 914
         	?>
915 915
     	    </div>
916
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
916
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
917 917
         	<?php
918 918
                   }
919 919
                 ?>
Please login to merge, or discard this patch.
Braces   +103 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,11 +6,15 @@  discard block
 block discarded – undo
6 6
 $beginpage = microtime(true);
7 7
 $Stats = new Stats();
8 8
 
9
-if (!isset($filter_name)) $filter_name = '';
9
+if (!isset($filter_name)) {
10
+	$filter_name = '';
11
+}
10 12
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 13
 if ($airline_icao == '' && isset($globalFilter)) {
12
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13
-}
14
+	if (isset($globalFilter['airline'])) {
15
+		$airline_icao = $globalFilter['airline'][0];
16
+	}
17
+	}
14 18
 if ($airline_icao != '' && $airline_icao != 'all') {
15 19
 	$Spotter = new Spotter();
16 20
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -36,14 +40,21 @@  discard block
 block discarded – undo
36 40
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script>
37 41
 <div class="column">
38 42
     <div class="info">
39
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
43
+            <h1><?php if (isset($airline_name)) {
44
+	echo _("Statistics for ").$airline_name;
45
+} else {
46
+	echo _("Statistics");
47
+}
48
+?></h1>
40 49
     <?php 
41 50
 	$last_update = $Stats->getLastStatsUpdate();
42 51
 	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
43 52
 	if (isset($last_update[0]['value'])) {
44 53
 		date_default_timezone_set('UTC');
45 54
 		$lastupdate = strtotime($last_update[0]['value']);
46
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
55
+		if (isset($globalTimezone) && $globalTimezone != '') {
56
+			date_default_timezone_set($globalTimezone);
57
+		}
47 58
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
48 59
 	}
49 60
     ?>
@@ -95,8 +106,9 @@  discard block
 block discarded – undo
95 106
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 107
                  <?php
97 108
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
-		    if (count($aircraft_array) == 0) print _("No data available");
99
-		    else {
109
+		    if (count($aircraft_array) == 0) {
110
+		    	print _("No data available");
111
+		    } else {
100 112
 
101 113
                     print '<div id="chart1" class="chart" width="100%"></div>
102 114
                     <script> 
@@ -133,11 +145,17 @@  discard block
 block discarded – undo
133 145
             	    <?php
134 146
             		if ($year != '' && $month != '') {
135 147
             	    ?>
136
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
148
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
149
+	echo '/'.$airline_icao;
150
+}
151
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
137 152
             	    <?php
138 153
             		} else {
139 154
             	    ?>
140
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
155
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
156
+	echo '/'.$airline_icao;
157
+}
158
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
141 159
             	    <?php
142 160
             		}
143 161
             	    ?>
@@ -182,11 +200,15 @@  discard block
 block discarded – undo
182 200
                   </script>';
183 201
 	    if ($year != '' && $month != '') {
184 202
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
185
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
203
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
204
+			echo '/'.$airline_icao;
205
+		}
186 206
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
187 207
 	    } else {
188 208
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
209
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
210
+			echo '/'.$airline_icao;
211
+		}
190 212
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191 213
 	    }
192 214
     	    print '</div>';
@@ -210,8 +232,9 @@  discard block
 block discarded – undo
210 232
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
211 233
 <?php
212 234
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
213
-	if (count($pilot_array) == 0) print _("No data available");
214
-	else {
235
+	if (count($pilot_array) == 0) {
236
+		print _("No data available");
237
+	} else {
215 238
 	    print '<div id="chart7" class="chart" width="100%"></div>
216 239
                     <script> 
217 240
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -244,7 +267,9 @@  discard block
 block discarded – undo
244 267
         }
245 268
         print '<div class="more">';
246 269
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
247
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
270
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
271
+		echo '/'.$airline_icao;
272
+	}
248 273
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
249 274
 	print '</div>';
250 275
 ?>
@@ -258,8 +283,9 @@  discard block
 block discarded – undo
258 283
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
259 284
 <?php
260 285
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
261
-	if (count($owner_array) == 0) print _("No data available");
262
-	else {
286
+	if (count($owner_array) == 0) {
287
+		print _("No data available");
288
+	} else {
263 289
 	    print '<div id="chart7" class="chart" width="100%"></div>
264 290
                     <script> 
265 291
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -292,7 +318,10 @@  discard block
 block discarded – undo
292 318
 	}
293 319
 ?>
294 320
                 <div class="more">
295
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
321
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
322
+	echo '/'.$airline_icao;
323
+}
324
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
296 325
                 </div>
297 326
             </div>
298 327
         
@@ -305,8 +334,9 @@  discard block
 block discarded – undo
305 334
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
306 335
 <?php
307 336
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
308
-	if (count($flightover_array) == 0) print _("No data available");
309
-	else {
337
+	if (count($flightover_array) == 0) {
338
+		print _("No data available");
339
+	} else {
310 340
 	    print '<div id="chart10" class="chart" width="100%"></div>
311 341
                     <script> 
312 342
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -341,7 +371,10 @@  discard block
 block discarded – undo
341 371
 	}
342 372
 ?>
343 373
                 <div class="more">
344
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
374
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
375
+	echo '/'.$airline_icao;
376
+}
377
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
345 378
                 </div>
346 379
             </div>
347 380
 <?php
@@ -394,7 +427,9 @@  discard block
 block discarded – undo
394 427
               }
395 428
                 </script>';
396 429
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
397
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
430
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
431
+		echo '/'.$airline_icao;
432
+	}
398 433
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
399 434
     }
400 435
 ?>
@@ -441,7 +476,9 @@  discard block
 block discarded – undo
441 476
               }
442 477
                 </script>';
443 478
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
444
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
479
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
480
+		echo '/'.$airline_icao;
481
+	}
445 482
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
446 483
     }
447 484
 ?>
@@ -456,8 +493,9 @@  discard block
 block discarded – undo
456 493
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457 494
                 <?php
458 495
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
-		    if (count($year_array) == 0) print _("No data available");
460
-		    else {
496
+		    if (count($year_array) == 0) {
497
+		    	print _("No data available");
498
+		    } else {
461 499
                   print '<div id="chart8" class="chart" width="100%"></div>
462 500
                     <script> 
463 501
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -493,7 +531,10 @@  discard block
 block discarded – undo
493 531
                   }
494 532
                   ?>
495 533
                 <div class="more">
496
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
534
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
535
+	echo '/'.$airline_icao;
536
+}
537
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 538
                 </div>
498 539
             </div>
499 540
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -501,8 +542,9 @@  discard block
 block discarded – undo
501 542
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502 543
                 <?php
503 544
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
-		    if (count($month_array) == 0) print _("No data available");
505
-		    else {
545
+		    if (count($month_array) == 0) {
546
+		    	print _("No data available");
547
+		    } else {
506 548
                   print '<div id="chart9" class="chart" width="100%"></div>
507 549
                     <script> 
508 550
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -538,7 +580,10 @@  discard block
 block discarded – undo
538 580
                   }
539 581
                   ?>
540 582
                 <div class="more">
541
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
583
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
584
+	echo '/'.$airline_icao;
585
+}
586
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
542 587
                 </div>
543 588
             </div>
544 589
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -547,8 +592,9 @@  discard block
 block discarded – undo
547 592
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548 593
                 <?php
549 594
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
-		    if (empty($date_array)) print _("No data available");
551
-		    else {
595
+		    if (empty($date_array)) {
596
+		    	print _("No data available");
597
+		    } else {
552 598
                   print '<div id="chart5" class="chart" width="100%"></div>
553 599
                     <script> 
554 600
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -585,7 +631,10 @@  discard block
 block discarded – undo
585 631
                   }
586 632
                   ?>
587 633
                 <div class="more">
588
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
634
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
635
+	echo '/'.$airline_icao;
636
+}
637
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
589 638
                 </div>
590 639
             </div>
591 640
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -593,8 +642,9 @@  discard block
 block discarded – undo
593 642
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594 643
                 <?php
595 644
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
-		    if (empty($hour_array)) print _("No data available");
597
-		    else {
645
+		    if (empty($hour_array)) {
646
+		    	print _("No data available");
647
+		    } else {
598 648
 
599 649
                   print '<div id="chart6" class="chart" width="100%"></div>
600 650
                     <script> 
@@ -631,7 +681,10 @@  discard block
 block discarded – undo
631 681
                   }
632 682
                 ?>
633 683
                 <div class="more">
634
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
684
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
685
+	echo '/'.$airline_icao;
686
+}
687
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635 688
                 </div>
636 689
             </div>
637 690
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -650,8 +703,9 @@  discard block
 block discarded – undo
650 703
 		    require_once('require/class.Accident.php');
651 704
             	    $Accident = new Accident();
652 705
                   $year_array = $Accident->countFatalitiesByYear($filter_name);
653
-		    if (count($year_array) == 0) print _("No data available");
654
-		    else {
706
+		    if (count($year_array) == 0) {
707
+		    	print _("No data available");
708
+		    } else {
655 709
                   print '<div id="chart32" class="chart" width="100%"></div>
656 710
                     <script> 
657 711
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -699,8 +753,9 @@  discard block
 block discarded – undo
699 753
 		    require_once('require/class.Accident.php');
700 754
             	    $Accident = new Accident();
701 755
                   $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
-		    if (count($year_array) == 0) print _("No data available");
703
-		    else {
756
+		    if (count($year_array) == 0) {
757
+		    	print _("No data available");
758
+		    } else {
704 759
                   print '<div id="chart33" class="chart" width="100%"></div>
705 760
                     <script> 
706 761
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -776,8 +831,11 @@  discard block
 block discarded – undo
776 831
 					$distance = $distance;
777 832
 					$unit = 'km';
778 833
 				}
779
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
834
+        			if (!isset($polar_data)) {
835
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
836
+        			} else {
837
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
838
+        	    		}
781 839
         		    }
782 840
         	?>
783 841
             <div class="col-md-6">
@@ -829,8 +887,11 @@  discard block
 block discarded – undo
829 887
         		foreach ($msg as $eachmsg) {
830 888
         		    //$eachmsg = $msg[0];
831 889
         		    $data = $eachmsg['source_data'];
832
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
833
-        		    else $max = 500;
890
+        		    if ($data > 500) {
891
+        		    	$max = (round(($data+100)/100))*100;
892
+        		    } else {
893
+        		    	$max = 500;
894
+        		    }
834 895
         	?>
835 896
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
836 897
         	<script>
Please login to merge, or discard this patch.
require/class.Stats.php 4 patches
Doc Comments   +31 added lines patch added patch discarded remove patch
@@ -17,6 +17,10 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
+	/**
21
+	 * @param string $type
22
+	 * @param string $stats_date
23
+	 */
20 24
 	public function addLastStatsUpdate($type,$stats_date) {
21 25
                 $query = "DELETE FROM config WHERE name = :type;
22 26
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -878,6 +882,11 @@  discard block
 block discarded – undo
878 882
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
879 883
                 return $all;
880 884
         }
885
+
886
+	/**
887
+	 * @param string $type
888
+	 * @param string $year
889
+	 */
881 890
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
882 891
 		if ($filter_name == '') $filter_name = $this->filter_name;
883 892
     		global $globalArchiveMonths, $globalDBdriver;
@@ -1022,6 +1031,10 @@  discard block
 block discarded – undo
1022 1031
                 else return 0;
1023 1032
         }
1024 1033
 
1034
+	/**
1035
+	 * @param string $type
1036
+	 * @param string $stats_date
1037
+	 */
1025 1038
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1026 1039
 		global $globalDBdriver;
1027 1040
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -1075,6 +1088,9 @@  discard block
 block discarded – undo
1075 1088
         }
1076 1089
         */
1077 1090
 
1091
+	/**
1092
+	 * @param string $stats_type
1093
+	 */
1078 1094
 	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1079 1095
 		global $globalDBdriver;
1080 1096
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
@@ -1118,6 +1134,9 @@  discard block
 block discarded – undo
1118 1134
 		return $all;
1119 1135
 	}
1120 1136
 
1137
+	/**
1138
+	 * @param string $stats_type
1139
+	 */
1121 1140
 	public function addStatSource($data,$source_name,$stats_type,$date) {
1122 1141
 		global $globalDBdriver;
1123 1142
 		if ($globalDBdriver == 'mysql') {
@@ -1133,6 +1152,10 @@  discard block
 block discarded – undo
1133 1152
                         return "error : ".$e->getMessage();
1134 1153
                 }
1135 1154
         }
1155
+
1156
+	/**
1157
+	 * @param string $type
1158
+	 */
1136 1159
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1137 1160
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138 1161
                 $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
@@ -1399,6 +1422,10 @@  discard block
 block discarded – undo
1399 1422
                         return "error : ".$e->getMessage();
1400 1423
                 }
1401 1424
         }
1425
+
1426
+	/**
1427
+	 * @param string $type
1428
+	 */
1402 1429
 	public function deleteStatFlight($type) {
1403 1430
                 $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1404 1431
                 $query_values = array(':type' => $type);
@@ -1409,6 +1436,10 @@  discard block
 block discarded – undo
1409 1436
                         return "error : ".$e->getMessage();
1410 1437
                 }
1411 1438
         }
1439
+
1440
+	/**
1441
+	 * @param string $type
1442
+	 */
1412 1443
 	public function deleteStatAirport($type) {
1413 1444
                 $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1414 1445
                 $query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Indentation   +779 added lines, -779 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
43
-        public function deleteStats($filter_name = '') {
44
-        	/*
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43
+		public function deleteStats($filter_name = '') {
44
+			/*
45 45
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
@@ -50,106 +50,106 @@  discard block
 block discarded – undo
50 50
                         return "error : ".$e->getMessage();
51 51
                 }
52 52
                 */
53
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
-                 try {
55
-                        $sth = $this->db->prepare($query);
56
-                        $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-        }
61
-        public function deleteOldStats($filter_name = '') {
53
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
+				 try {
55
+						$sth = $this->db->prepare($query);
56
+						$sth->execute(array(':filter_name' => $filter_name));
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+		}
61
+		public function deleteOldStats($filter_name = '') {
62 62
         	
63
-        	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute();
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
63
+			$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute();
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70 70
                 
71
-        	$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;";
72
-                 try {
73
-                        $sth = $this->db->prepare($query);
74
-                        $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
76
-                        return "error : ".$e->getMessage();
77
-                }
78
-        }
71
+			$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;";
72
+				 try {
73
+						$sth = $this->db->prepare($query);
74
+						$sth->execute(array(':filter_name' => $filter_name));
75
+				} catch(PDOException $e) {
76
+						return "error : ".$e->getMessage();
77
+				}
78
+		}
79 79
 	public function getAllAirlineNames($filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
-                 try {
95
-                        $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
98
-                        echo "error : ".$e->getMessage();
99
-                }
100
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
-                return $all;
102
-        }
93
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
+				 try {
95
+						$sth = $this->db->prepare($query);
96
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
+				} catch(PDOException $e) {
98
+						echo "error : ".$e->getMessage();
99
+				}
100
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
+				return $all;
102
+		}
103 103
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105
-                $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";
106
-                 try {
107
-                        $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
110
-                        echo "error : ".$e->getMessage();
111
-                }
112
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
-                return $all;
114
-        }
105
+				$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";
106
+				 try {
107
+						$sth = $this->db->prepare($query);
108
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
+				} catch(PDOException $e) {
110
+						echo "error : ".$e->getMessage();
111
+				}
112
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
+				return $all;
114
+		}
115 115
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117
-                $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";
118
-                 try {
119
-                        $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
122
-                        echo "error : ".$e->getMessage();
123
-                }
124
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
-                return $all;
126
-        }
117
+				$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";
118
+				 try {
119
+						$sth = $this->db->prepare($query);
120
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
+				} catch(PDOException $e) {
122
+						echo "error : ".$e->getMessage();
123
+				}
124
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
+				return $all;
126
+		}
127 127
 
128 128
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
-                 try {
132
-                        $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
135
-                        echo "error : ".$e->getMessage();
136
-                }
137
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
-                return $all;
139
-        }
130
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
+				 try {
132
+						$sth = $this->db->prepare($query);
133
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
+				} catch(PDOException $e) {
135
+						echo "error : ".$e->getMessage();
136
+				}
137
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
+				return $all;
139
+		}
140 140
 
141 141
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
-                 try {
145
-                        $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
148
-                        echo "error : ".$e->getMessage();
149
-                }
150
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
-                return $all;
152
-        }
143
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
+				 try {
145
+						$sth = $this->db->prepare($query);
146
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
+				} catch(PDOException $e) {
148
+						echo "error : ".$e->getMessage();
149
+				}
150
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
+				return $all;
152
+		}
153 153
 
154 154
 
155 155
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168 168
 		} else $all = array();
169
-                if (empty($all)) {
170
-            	    $filters = array('airlines' => array($stats_airline));
171
-            	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
-            	    }
174
-            	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
-                }
177
-                return $all;
169
+				if (empty($all)) {
170
+					$filters = array('airlines' => array($stats_airline));
171
+					if ($filter_name != '') {
172
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
+					}
174
+					$Spotter = new Spotter($this->db);
175
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
+				}
177
+				return $all;
178 178
 	}
179 179
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 180
 		global $globalStatsFilters;
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192 192
 		} else $all = array();
193
-                if (empty($all)) {
194
-            		$Spotter = new Spotter($this->db);
195
-            		$filters = array();
196
-            		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
193
+				if (empty($all)) {
194
+					$Spotter = new Spotter($this->db);
195
+					$filters = array();
196
+					if ($filter_name != '') {
197
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
-                }
201
-                return $all;
199
+					$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
+				}
201
+				return $all;
202 202
 	}
203 203
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 204
 		global $globalStatsFilters;
@@ -239,37 +239,37 @@  discard block
 block discarded – undo
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242
-                if (empty($all)) {
242
+				if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
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
 			$Spotter = new Spotter($this->db);
248 248
 			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
249
-                }
250
-                return $all;
249
+				}
250
+				return $all;
251 251
 	}
252 252
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 253
 		global $globalStatsFilters;
254 254
 		if ($filter_name == '') $filter_name = $this->filter_name;
255 255
 		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256 256
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257
-                 try {
258
-                        $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
261
-                        echo "error : ".$e->getMessage();
262
-                }
263
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
-                if (empty($all)) {
257
+				 try {
258
+						$sth = $this->db->prepare($query);
259
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
+				} catch(PDOException $e) {
261
+						echo "error : ".$e->getMessage();
262
+				}
263
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
+				if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270 270
 			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
271
-                }
272
-                return $all;
271
+				}
272
+				return $all;
273 273
 	}
274 274
 
275 275
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288 288
 		} else $all = array();
289
-                if (empty($all)) {
290
-	                $Spotter = new Spotter($this->db);
291
-            		$filters = array();
292
-            		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
289
+				if (empty($all)) {
290
+					$Spotter = new Spotter($this->db);
291
+					$filters = array();
292
+					if ($filter_name != '') {
293
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
-                }
298
-                return $all;
296
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
+				}
298
+				return $all;
299 299
 	}
300 300
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 301
 		global $globalStatsFilters;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313 313
 		} else $all = array();
314
-                if (empty($all)) {
314
+				if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317 317
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
318 318
 			}
319
-	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
-                }
322
-                return $all;
319
+					$Spotter = new Spotter($this->db);
320
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
+				}
322
+				return $all;
323 323
 	}
324 324
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 325
 		global $globalStatsFilters;
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
-                /*
362
+				/*
363 363
                 if (empty($all)) {
364 364
 	                $Spotter = new Spotter($this->db);
365 365
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412 412
 		} else $all = array();
413
-                if (empty($all)) {
413
+				if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416 416
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
417 417
 			}
418
-            		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
-                }
421
-                return $all;
418
+					$Spotter = new Spotter($this->db);
419
+					$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
+				}
421
+				return $all;
422 422
 	}
423 423
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 424
 		global $globalStatsFilters;
@@ -434,33 +434,33 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436 436
 		} else $all = array();
437
-                if (empty($all)) {
437
+				if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439
-            		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
-			}
442
-            		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
-        		$all = array();
446
-        		foreach ($pall as $value) {
447
-        			$icao = $value['airport_departure_icao'];
448
-        			$all[$icao] = $value;
449
-        		}
439
+					if ($filter_name != '') {
440
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
+			}
442
+					$Spotter = new Spotter($this->db);
443
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
+				$all = array();
446
+				foreach ($pall as $value) {
447
+					$icao = $value['airport_departure_icao'];
448
+					$all[$icao] = $value;
449
+				}
450 450
         		
451
-        		foreach ($dall as $value) {
452
-        			$icao = $value['airport_departure_icao'];
453
-        			if (isset($all[$icao])) {
454
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
456
-        		}
457
-        		$count = array();
458
-        		foreach ($all as $key => $row) {
459
-        			$count[$key] = $row['airport_departure_icao_count'];
460
-        		}
461
-        		array_multisort($count,SORT_DESC,$all);
462
-                }
463
-                return $all;
451
+				foreach ($dall as $value) {
452
+					$icao = $value['airport_departure_icao'];
453
+					if (isset($all[$icao])) {
454
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
+					} else $all[$icao] = $value;
456
+				}
457
+				$count = array();
458
+				foreach ($all as $key => $row) {
459
+					$count[$key] = $row['airport_departure_icao_count'];
460
+				}
461
+				array_multisort($count,SORT_DESC,$all);
462
+				}
463
+				return $all;
464 464
 	}
465 465
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 466
 		global $globalStatsFilters;
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
 			$Spotter = new Spotter($this->db);
485 485
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486 486
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
487
-        		$all = array();
488
-        		foreach ($pall as $value) {
489
-        			$icao = $value['airport_arrival_icao'];
490
-        			$all[$icao] = $value;
491
-        		}
487
+				$all = array();
488
+				foreach ($pall as $value) {
489
+					$icao = $value['airport_arrival_icao'];
490
+					$all[$icao] = $value;
491
+				}
492 492
         		
493
-        		foreach ($dall as $value) {
494
-        			$icao = $value['airport_arrival_icao'];
495
-        			if (isset($all[$icao])) {
496
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
498
-        		}
499
-        		$count = array();
500
-        		foreach ($all as $key => $row) {
501
-        			$count[$key] = $row['airport_arrival_icao_count'];
502
-        		}
503
-        		array_multisort($count,SORT_DESC,$all);
504
-                }
493
+				foreach ($dall as $value) {
494
+					$icao = $value['airport_arrival_icao'];
495
+					if (isset($all[$icao])) {
496
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
+					} else $all[$icao] = $value;
498
+				}
499
+				$count = array();
500
+				foreach ($all as $key => $row) {
501
+					$count[$key] = $row['airport_arrival_icao_count'];
502
+				}
503
+				array_multisort($count,SORT_DESC,$all);
504
+				}
505 505
  
506
-                return $all;
506
+				return $all;
507 507
 	}
508 508
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 			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";
517 517
 		}
518 518
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519
-                 try {
520
-                        $sth = $this->db->prepare($query);
521
-                        $sth->execute($query_data);
522
-                } catch(PDOException $e) {
523
-                        echo "error : ".$e->getMessage();
524
-                }
525
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
-                if (empty($all)) {
519
+				 try {
520
+						$sth = $this->db->prepare($query);
521
+						$sth->execute($query_data);
522
+				} catch(PDOException $e) {
523
+						echo "error : ".$e->getMessage();
524
+				}
525
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
+				if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529 529
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
530 530
 			}
531
-            		$Spotter = new Spotter($this->db);
532
-            		$all = $Spotter->countAllMonthsLastYear($filters);
533
-                }
531
+					$Spotter = new Spotter($this->db);
532
+					$all = $Spotter->countAllMonthsLastYear($filters);
533
+				}
534 534
                 
535
-                return $all;
535
+				return $all;
536 536
 	}
537 537
 	
538 538
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -540,22 +540,22 @@  discard block
 block discarded – undo
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$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";
542 542
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543
-                 try {
544
-                        $sth = $this->db->prepare($query);
545
-                        $sth->execute($query_data);
546
-                } catch(PDOException $e) {
547
-                        echo "error : ".$e->getMessage();
548
-                }
549
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
-                if (empty($all)) {
543
+				 try {
544
+						$sth = $this->db->prepare($query);
545
+						$sth->execute($query_data);
546
+				} catch(PDOException $e) {
547
+						echo "error : ".$e->getMessage();
548
+				}
549
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
+				if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553 553
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
554 554
 			}
555
-            		$Spotter = new Spotter($this->db);
556
-            		$all = $Spotter->countAllDatesLastMonth($filters);
557
-                }
558
-                return $all;
555
+					$Spotter = new Spotter($this->db);
556
+					$all = $Spotter->countAllDatesLastMonth($filters);
557
+				}
558
+				return $all;
559 559
 	}
560 560
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
@@ -566,110 +566,110 @@  discard block
 block discarded – undo
566 566
 			$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";
567 567
 		}
568 568
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
569
-                 try {
570
-                        $sth = $this->db->prepare($query);
571
-                        $sth->execute($query_data);
572
-                } catch(PDOException $e) {
573
-                        echo "error : ".$e->getMessage();
574
-                }
575
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
-                if (empty($all)) {
569
+				 try {
570
+						$sth = $this->db->prepare($query);
571
+						$sth->execute($query_data);
572
+				} catch(PDOException $e) {
573
+						echo "error : ".$e->getMessage();
574
+				}
575
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
+				if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579 579
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
580 580
 			}
581
-            		$Spotter = new Spotter($this->db);
582
-            		$all = $Spotter->countAllDatesLast7Days($filters);
583
-                }
584
-                return $all;
581
+					$Spotter = new Spotter($this->db);
582
+					$all = $Spotter->countAllDatesLast7Days($filters);
583
+				}
584
+				return $all;
585 585
 	}
586 586
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$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";
590 590
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591
-                 try {
592
-                        $sth = $this->db->prepare($query);
593
-                        $sth->execute($query_data);
594
-                } catch(PDOException $e) {
595
-                        echo "error : ".$e->getMessage();
596
-                }
597
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
-                if (empty($all)) {
591
+				 try {
592
+						$sth = $this->db->prepare($query);
593
+						$sth->execute($query_data);
594
+				} catch(PDOException $e) {
595
+						echo "error : ".$e->getMessage();
596
+				}
597
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
+				if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
602 602
 			}
603
-            		$Spotter = new Spotter($this->db);
604
-            		$all = $Spotter->countAllDates($filters);
605
-                }
606
-                return $all;
603
+					$Spotter = new Spotter($this->db);
604
+					$all = $Spotter->countAllDates($filters);
605
+				}
606
+				return $all;
607 607
 	}
608 608
 	public function countAllDatesByAirlines($filter_name = '') {
609 609
 		global $globalStatsFilters;
610 610
 		if ($filter_name == '') $filter_name = $this->filter_name;
611 611
 		$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";
612 612
 		$query_data = array('filter_name' => $filter_name);
613
-                 try {
614
-                        $sth = $this->db->prepare($query);
615
-                        $sth->execute($query_data);
616
-                } catch(PDOException $e) {
617
-                        echo "error : ".$e->getMessage();
618
-                }
619
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
-                if (empty($all)) {
621
-            		$filters = array();
622
-            		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
613
+				 try {
614
+						$sth = $this->db->prepare($query);
615
+						$sth->execute($query_data);
616
+				} catch(PDOException $e) {
617
+						echo "error : ".$e->getMessage();
618
+				}
619
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
+				if (empty($all)) {
621
+					$filters = array();
622
+					if ($filter_name != '') {
623
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
624 624
 			}
625
-            		$Spotter = new Spotter($this->db);
626
-            		$all = $Spotter->countAllDatesByAirlines($filters);
627
-                }
628
-                return $all;
625
+					$Spotter = new Spotter($this->db);
626
+					$all = $Spotter->countAllDatesByAirlines($filters);
627
+				}
628
+				return $all;
629 629
 	}
630 630
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634
-                 try {
635
-                        $sth = $this->db->prepare($query);
636
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
638
-                        echo "error : ".$e->getMessage();
639
-                }
640
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
633
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634
+				 try {
635
+						$sth = $this->db->prepare($query);
636
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
+				} catch(PDOException $e) {
638
+						echo "error : ".$e->getMessage();
639
+				}
640
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
641 641
                 
642
-                if (empty($all)) {
642
+				if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645 645
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
646 646
 			}
647
-            		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllMonths($filters);
649
-                }
647
+					$Spotter = new Spotter($this->db);
648
+					$all = $Spotter->countAllMonths($filters);
649
+				}
650 650
                 
651
-                return $all;
651
+				return $all;
652 652
 	}
653 653
 	public function countAllMilitaryMonths($filter_name = '') {
654 654
 		global $globalStatsFilters;
655 655
 		if ($filter_name == '') $filter_name = $this->filter_name;
656
-	    	$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";
657
-                 try {
658
-                        $sth = $this->db->prepare($query);
659
-                        $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
661
-                        echo "error : ".$e->getMessage();
662
-                }
663
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
-                if (empty($all)) {
665
-            		$filters = array();
666
-            		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
656
+			$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";
657
+				 try {
658
+						$sth = $this->db->prepare($query);
659
+						$sth->execute(array(':filter_name' => $filter_name));
660
+				} catch(PDOException $e) {
661
+						echo "error : ".$e->getMessage();
662
+				}
663
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
+				if (empty($all)) {
665
+					$filters = array();
666
+					if ($filter_name != '') {
667
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
668 668
 			}
669
-            		$Spotter = new Spotter($this->db);
670
-            		$all = $Spotter->countAllMilitaryMonths($filters);
671
-                }
672
-                return $all;
669
+					$Spotter = new Spotter($this->db);
670
+					$all = $Spotter->countAllMilitaryMonths($filters);
671
+				}
672
+				return $all;
673 673
 	}
674 674
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -685,22 +685,22 @@  discard block
 block discarded – undo
685 685
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 686
 		}
687 687
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
688
-                 try {
689
-                        $sth = $this->db->prepare($query);
690
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
692
-                        echo "error : ".$e->getMessage();
693
-                }
694
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-                if (empty($all)) {
688
+				 try {
689
+						$sth = $this->db->prepare($query);
690
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
+				} catch(PDOException $e) {
692
+						echo "error : ".$e->getMessage();
693
+				}
694
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
+				if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
699 699
 			}
700
-            		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
702
-                }
703
-                return $all;
700
+					$Spotter = new Spotter($this->db);
701
+					$all = $Spotter->countAllHours($orderby,$filters);
702
+				}
703
+				return $all;
704 704
 	}
705 705
 	
706 706
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -724,9 +724,9 @@  discard block
 block discarded – undo
724 724
 		if ($year == '') $year = date('Y');
725 725
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 726
 		if (empty($all)) {
727
-		        $filters = array();
728
-            		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
727
+				$filters = array();
728
+					if ($filter_name != '') {
729
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732 732
 			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -787,9 +787,9 @@  discard block
 block discarded – undo
787 787
 			$all = $result[0]['nb_airline'];
788 788
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
789 789
 		if (empty($all)) {
790
-            		$filters = array();
791
-            		if ($filter_name != '') {
792
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
790
+					$filters = array();
791
+					if ($filter_name != '') {
792
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
793 793
 			}
794 794
 			$Spotter = new Spotter($this->db);
795 795
 			$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -856,33 +856,33 @@  discard block
 block discarded – undo
856 856
 		if ($filter_name == '') $filter_name = $this->filter_name;
857 857
 		$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";
858 858
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
859
-                 try {
860
-                        $sth = $this->db->prepare($query);
861
-                        $sth->execute($query_values);
862
-                } catch(PDOException $e) {
863
-                        echo "error : ".$e->getMessage();
864
-                }
865
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
-                return $all;
859
+				 try {
860
+						$sth = $this->db->prepare($query);
861
+						$sth->execute($query_values);
862
+				} catch(PDOException $e) {
863
+						echo "error : ".$e->getMessage();
864
+				}
865
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
+				return $all;
867 867
 	}
868 868
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
869 869
 		if ($filter_name == '') $filter_name = $this->filter_name;
870
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872
-                 try {
873
-                        $sth = $this->db->prepare($query);
874
-                        $sth->execute($query_values);
875
-                } catch(PDOException $e) {
876
-                        echo "error : ".$e->getMessage();
877
-                }
878
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
879
-                return $all;
880
-        }
870
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872
+				 try {
873
+						$sth = $this->db->prepare($query);
874
+						$sth->execute($query_values);
875
+				} catch(PDOException $e) {
876
+						echo "error : ".$e->getMessage();
877
+				}
878
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
879
+				return $all;
880
+		}
881 881
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
882 882
 		if ($filter_name == '') $filter_name = $this->filter_name;
883
-    		global $globalArchiveMonths, $globalDBdriver;
884
-    		if ($globalDBdriver == 'mysql') {
885
-    			if ($month == '') {
883
+			global $globalArchiveMonths, $globalDBdriver;
884
+			if ($globalDBdriver == 'mysql') {
885
+				if ($month == '') {
886 886
 				$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";
887 887
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
888 888
 			} else {
@@ -897,165 +897,165 @@  discard block
 block discarded – undo
897 897
 				$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";
898 898
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
899 899
 			}
900
-                }
901
-                 try {
902
-                        $sth = $this->db->prepare($query);
903
-                        $sth->execute($query_values);
904
-                } catch(PDOException $e) {
905
-                        echo "error : ".$e->getMessage();
906
-                }
907
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
908
-                return $all[0]['total'];
909
-        }
900
+				}
901
+				 try {
902
+						$sth = $this->db->prepare($query);
903
+						$sth->execute($query_values);
904
+				} catch(PDOException $e) {
905
+						echo "error : ".$e->getMessage();
906
+				}
907
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
908
+				return $all[0]['total'];
909
+		}
910 910
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
911
-    		global $globalArchiveMonths, $globalDBdriver;
911
+			global $globalArchiveMonths, $globalDBdriver;
912 912
 		if ($filter_name == '') $filter_name = $this->filter_name;
913
-    		if ($globalDBdriver == 'mysql') {
913
+			if ($globalDBdriver == 'mysql') {
914 914
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
915 915
 		} else {
916 916
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
917
-                }
918
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
919
-                 try {
920
-                        $sth = $this->db->prepare($query);
921
-                        $sth->execute($query_values);
922
-                } catch(PDOException $e) {
923
-                        echo "error : ".$e->getMessage();
924
-                }
925
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
926
-                return $all[0]['total'];
927
-        }
917
+				}
918
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
919
+				 try {
920
+						$sth = $this->db->prepare($query);
921
+						$sth->execute($query_values);
922
+				} catch(PDOException $e) {
923
+						echo "error : ".$e->getMessage();
924
+				}
925
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
926
+				return $all[0]['total'];
927
+		}
928 928
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
929
-    		global $globalArchiveMonths, $globalDBdriver;
929
+			global $globalArchiveMonths, $globalDBdriver;
930 930
 		if ($filter_name == '') $filter_name = $this->filter_name;
931
-    		if ($globalDBdriver == 'mysql') {
931
+			if ($globalDBdriver == 'mysql') {
932 932
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
933
-                } else {
933
+				} else {
934 934
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
935
-                }
936
-                 try {
937
-                        $sth = $this->db->prepare($query);
938
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
939
-                } catch(PDOException $e) {
940
-                        echo "error : ".$e->getMessage();
941
-                }
942
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
943
-                return $all[0]['total'];
944
-        }
935
+				}
936
+				 try {
937
+						$sth = $this->db->prepare($query);
938
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
939
+				} catch(PDOException $e) {
940
+						echo "error : ".$e->getMessage();
941
+				}
942
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
943
+				return $all[0]['total'];
944
+		}
945 945
 	public function getStatsAirlineTotal($filter_name = '') {
946
-    		global $globalArchiveMonths, $globalDBdriver;
946
+			global $globalArchiveMonths, $globalDBdriver;
947 947
 		if ($filter_name == '') $filter_name = $this->filter_name;
948
-    		if ($globalDBdriver == 'mysql') {
948
+			if ($globalDBdriver == 'mysql') {
949 949
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
950
-                } else {
950
+				} else {
951 951
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
952
-                }
953
-                 try {
954
-                        $sth = $this->db->prepare($query);
955
-                        $sth->execute(array(':filter_name' => $filter_name));
956
-                } catch(PDOException $e) {
957
-                        echo "error : ".$e->getMessage();
958
-                }
959
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
960
-                return $all[0]['total'];
961
-        }
952
+				}
953
+				 try {
954
+						$sth = $this->db->prepare($query);
955
+						$sth->execute(array(':filter_name' => $filter_name));
956
+				} catch(PDOException $e) {
957
+						echo "error : ".$e->getMessage();
958
+				}
959
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
960
+				return $all[0]['total'];
961
+		}
962 962
 	public function getStatsOwnerTotal($filter_name = '') {
963
-    		global $globalArchiveMonths, $globalDBdriver;
963
+			global $globalArchiveMonths, $globalDBdriver;
964 964
 		if ($filter_name == '') $filter_name = $this->filter_name;
965
-    		if ($globalDBdriver == 'mysql') {
965
+			if ($globalDBdriver == 'mysql') {
966 966
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
967 967
 		} else {
968 968
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
969
-                }
970
-                 try {
971
-                        $sth = $this->db->prepare($query);
972
-                        $sth->execute(array(':filter_name' => $filter_name));
973
-                } catch(PDOException $e) {
974
-                        echo "error : ".$e->getMessage();
975
-                }
976
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
977
-                return $all[0]['total'];
978
-        }
969
+				}
970
+				 try {
971
+						$sth = $this->db->prepare($query);
972
+						$sth->execute(array(':filter_name' => $filter_name));
973
+				} catch(PDOException $e) {
974
+						echo "error : ".$e->getMessage();
975
+				}
976
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
977
+				return $all[0]['total'];
978
+		}
979 979
 	public function getStatsOwner($owner_name,$filter_name = '') {
980
-    		global $globalArchiveMonths, $globalDBdriver;
980
+			global $globalArchiveMonths, $globalDBdriver;
981 981
 		if ($filter_name == '') $filter_name = $this->filter_name;
982 982
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
983
-                 try {
984
-                        $sth = $this->db->prepare($query);
985
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
986
-                } catch(PDOException $e) {
987
-                        echo "error : ".$e->getMessage();
988
-                }
989
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
990
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
991
-                else return 0;
992
-        }
983
+				 try {
984
+						$sth = $this->db->prepare($query);
985
+						$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
986
+				} catch(PDOException $e) {
987
+						echo "error : ".$e->getMessage();
988
+				}
989
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
990
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
991
+				else return 0;
992
+		}
993 993
 	public function getStatsPilotTotal($filter_name = '') {
994
-    		global $globalArchiveMonths, $globalDBdriver;
994
+			global $globalArchiveMonths, $globalDBdriver;
995 995
 		if ($filter_name == '') $filter_name = $this->filter_name;
996
-    		if ($globalDBdriver == 'mysql') {
997
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
998
-            	} else {
999
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1000
-            	}
1001
-                 try {
1002
-                        $sth = $this->db->prepare($query);
1003
-                        $sth->execute(array(':filter_name' => $filter_name));
1004
-                } catch(PDOException $e) {
1005
-                        echo "error : ".$e->getMessage();
1006
-                }
1007
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1008
-                return $all[0]['total'];
1009
-        }
996
+			if ($globalDBdriver == 'mysql') {
997
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
998
+				} else {
999
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1000
+				}
1001
+				 try {
1002
+						$sth = $this->db->prepare($query);
1003
+						$sth->execute(array(':filter_name' => $filter_name));
1004
+				} catch(PDOException $e) {
1005
+						echo "error : ".$e->getMessage();
1006
+				}
1007
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1008
+				return $all[0]['total'];
1009
+		}
1010 1010
 	public function getStatsPilot($pilot,$filter_name = '') {
1011
-    		global $globalArchiveMonths, $globalDBdriver;
1011
+			global $globalArchiveMonths, $globalDBdriver;
1012 1012
 		if ($filter_name == '') $filter_name = $this->filter_name;
1013 1013
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1014
-                 try {
1015
-                        $sth = $this->db->prepare($query);
1016
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1017
-                } catch(PDOException $e) {
1018
-                        echo "error : ".$e->getMessage();
1019
-                }
1020
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1021
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1022
-                else return 0;
1023
-        }
1014
+				 try {
1015
+						$sth = $this->db->prepare($query);
1016
+						$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1017
+				} catch(PDOException $e) {
1018
+						echo "error : ".$e->getMessage();
1019
+				}
1020
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1021
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1022
+				else return 0;
1023
+		}
1024 1024
 
1025 1025
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1026 1026
 		global $globalDBdriver;
1027 1027
 		if ($filter_name == '') $filter_name = $this->filter_name;
1028 1028
 		if ($globalDBdriver == 'mysql') {
1029 1029
 			$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";
1030
-                } else {
1030
+				} else {
1031 1031
 			$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);"; 
1032 1032
 		}
1033
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1034
-                 try {
1035
-                        $sth = $this->db->prepare($query);
1036
-                        $sth->execute($query_values);
1037
-                } catch(PDOException $e) {
1038
-                        return "error : ".$e->getMessage();
1039
-                }
1040
-        }
1033
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1034
+				 try {
1035
+						$sth = $this->db->prepare($query);
1036
+						$sth->execute($query_values);
1037
+				} catch(PDOException $e) {
1038
+						return "error : ".$e->getMessage();
1039
+				}
1040
+		}
1041 1041
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1042 1042
 		global $globalDBdriver;
1043 1043
 		if ($filter_name == '') $filter_name = $this->filter_name;
1044 1044
 		if ($globalDBdriver == 'mysql') {
1045 1045
 			$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";
1046 1046
 		} else {
1047
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1047
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1048 1048
 			$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);"; 
1049
-                }
1050
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1051
-                 try {
1052
-                        $sth = $this->db->prepare($query);
1053
-                        $sth->execute($query_values);
1054
-                } catch(PDOException $e) {
1055
-                        return "error : ".$e->getMessage();
1056
-                }
1057
-        }
1058
-        /*
1049
+				}
1050
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1051
+				 try {
1052
+						$sth = $this->db->prepare($query);
1053
+						$sth->execute($query_values);
1054
+				} catch(PDOException $e) {
1055
+						return "error : ".$e->getMessage();
1056
+				}
1057
+		}
1058
+		/*
1059 1059
 	public function getStatsSource($date,$stats_type = '') {
1060 1060
 		if ($stats_type == '') {
1061 1061
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1124,25 +1124,25 @@  discard block
 block discarded – undo
1124 1124
 			$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";
1125 1125
 		} else {
1126 1126
 			$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);"; 
1127
-                }
1128
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1129
-                 try {
1130
-                        $sth = $this->db->prepare($query);
1131
-                        $sth->execute($query_values);
1132
-                } catch(PDOException $e) {
1133
-                        return "error : ".$e->getMessage();
1134
-                }
1135
-        }
1136
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1137
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1139
-                 try {
1140
-                        $sth = $this->db->prepare($query);
1141
-                        $sth->execute($query_values);
1142
-                } catch(PDOException $e) {
1143
-                        return "error : ".$e->getMessage();
1144
-                }
1145
-        }
1127
+				}
1128
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1129
+				 try {
1130
+						$sth = $this->db->prepare($query);
1131
+						$sth->execute($query_values);
1132
+				} catch(PDOException $e) {
1133
+						return "error : ".$e->getMessage();
1134
+				}
1135
+		}
1136
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1137
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1139
+				 try {
1140
+						$sth = $this->db->prepare($query);
1141
+						$sth->execute($query_values);
1142
+				} catch(PDOException $e) {
1143
+						return "error : ".$e->getMessage();
1144
+				}
1145
+		}
1146 1146
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1147 1147
 		global $globalDBdriver;
1148 1148
 		if ($globalDBdriver == 'mysql') {
@@ -1158,14 +1158,14 @@  discard block
 block discarded – undo
1158 1158
 				$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);"; 
1159 1159
 			}
1160 1160
 		}
1161
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1162
-                 try {
1163
-                        $sth = $this->db->prepare($query);
1164
-                        $sth->execute($query_values);
1165
-                } catch(PDOException $e) {
1166
-                        return "error : ".$e->getMessage();
1167
-                }
1168
-        }
1161
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1162
+				 try {
1163
+						$sth = $this->db->prepare($query);
1164
+						$sth->execute($query_values);
1165
+				} catch(PDOException $e) {
1166
+						return "error : ".$e->getMessage();
1167
+				}
1168
+		}
1169 1169
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1170 1170
 		global $globalDBdriver;
1171 1171
 		if ($globalDBdriver == 'mysql') {
@@ -1181,14 +1181,14 @@  discard block
 block discarded – undo
1181 1181
 				$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);"; 
1182 1182
 			}
1183 1183
 		}
1184
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1185
-                 try {
1186
-                        $sth = $this->db->prepare($query);
1187
-                        $sth->execute($query_values);
1188
-                } catch(PDOException $e) {
1189
-                        return "error : ".$e->getMessage();
1190
-                }
1191
-        }
1184
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1185
+				 try {
1186
+						$sth = $this->db->prepare($query);
1187
+						$sth->execute($query_values);
1188
+				} catch(PDOException $e) {
1189
+						return "error : ".$e->getMessage();
1190
+				}
1191
+		}
1192 1192
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1193 1193
 		global $globalDBdriver;
1194 1194
 		if ($globalDBdriver == 'mysql') {
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
 				$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);"; 
1205 1205
 			}
1206 1206
 		}
1207
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1208
-                 try {
1209
-                        $sth = $this->db->prepare($query);
1210
-                        $sth->execute($query_values);
1211
-                } catch(PDOException $e) {
1212
-                        return "error : ".$e->getMessage();
1213
-                }
1214
-        }
1207
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1208
+				 try {
1209
+						$sth = $this->db->prepare($query);
1210
+						$sth->execute($query_values);
1211
+				} catch(PDOException $e) {
1212
+						return "error : ".$e->getMessage();
1213
+				}
1214
+		}
1215 1215
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1216 1216
 		global $globalDBdriver;
1217 1217
 		if ($globalDBdriver == 'mysql') {
@@ -1227,14 +1227,14 @@  discard block
 block discarded – undo
1227 1227
 				$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);"; 
1228 1228
 			}
1229 1229
 		}
1230
-                $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);
1231
-                 try {
1232
-                        $sth = $this->db->prepare($query);
1233
-                        $sth->execute($query_values);
1234
-                } catch(PDOException $e) {
1235
-                        return "error : ".$e->getMessage();
1236
-                }
1237
-        }
1230
+				$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);
1231
+				 try {
1232
+						$sth = $this->db->prepare($query);
1233
+						$sth->execute($query_values);
1234
+				} catch(PDOException $e) {
1235
+						return "error : ".$e->getMessage();
1236
+				}
1237
+		}
1238 1238
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1239 1239
 		global $globalDBdriver;
1240 1240
 		if ($globalDBdriver == 'mysql') {
@@ -1250,14 +1250,14 @@  discard block
 block discarded – undo
1250 1250
 				$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);"; 
1251 1251
 			}
1252 1252
 		}
1253
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1254
-                 try {
1255
-                        $sth = $this->db->prepare($query);
1256
-                        $sth->execute($query_values);
1257
-                } catch(PDOException $e) {
1258
-                        return "error : ".$e->getMessage();
1259
-                }
1260
-        }
1253
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1254
+				 try {
1255
+						$sth = $this->db->prepare($query);
1256
+						$sth->execute($query_values);
1257
+				} catch(PDOException $e) {
1258
+						return "error : ".$e->getMessage();
1259
+				}
1260
+		}
1261 1261
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1262 1262
 		global $globalDBdriver;
1263 1263
 		if ($globalDBdriver == 'mysql') {
@@ -1273,14 +1273,14 @@  discard block
 block discarded – undo
1273 1273
 				$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);"; 
1274 1274
 			}
1275 1275
 		}
1276
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1277
-                 try {
1278
-                        $sth = $this->db->prepare($query);
1279
-                        $sth->execute($query_values);
1280
-                } catch(PDOException $e) {
1281
-                        return "error : ".$e->getMessage();
1282
-                }
1283
-        }
1276
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1277
+				 try {
1278
+						$sth = $this->db->prepare($query);
1279
+						$sth->execute($query_values);
1280
+				} catch(PDOException $e) {
1281
+						return "error : ".$e->getMessage();
1282
+				}
1283
+		}
1284 1284
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1285 1285
 		global $globalDBdriver;
1286 1286
 		if ($globalDBdriver == 'mysql') {
@@ -1296,14 +1296,14 @@  discard block
 block discarded – undo
1296 1296
 				$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);"; 
1297 1297
 			}
1298 1298
 		}
1299
-                $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);
1300
-                 try {
1301
-                        $sth = $this->db->prepare($query);
1302
-                        $sth->execute($query_values);
1303
-                } catch(PDOException $e) {
1304
-                        return "error : ".$e->getMessage();
1305
-                }
1306
-        }
1299
+				$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);
1300
+				 try {
1301
+						$sth = $this->db->prepare($query);
1302
+						$sth->execute($query_values);
1303
+				} catch(PDOException $e) {
1304
+						return "error : ".$e->getMessage();
1305
+				}
1306
+		}
1307 1307
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1308 1308
 		global $globalDBdriver;
1309 1309
 		if ($airport_icao != '') {
@@ -1327,8 +1327,8 @@  discard block
 block discarded – undo
1327 1327
 			} catch(PDOException $e) {
1328 1328
 				return "error : ".$e->getMessage();
1329 1329
 			}
1330
-                }
1331
-        }
1330
+				}
1331
+		}
1332 1332
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1333 1333
 		global $globalDBdriver;
1334 1334
 		if ($airport_icao != '') {
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 			} catch(PDOException $e) {
1345 1345
 				return "error : ".$e->getMessage();
1346 1346
 			}
1347
-                }
1348
-        }
1347
+				}
1348
+		}
1349 1349
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1350 1350
 		global $globalDBdriver;
1351 1351
 		if ($airport_icao != '') {
@@ -1362,15 +1362,15 @@  discard block
 block discarded – undo
1362 1362
 					$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);"; 
1363 1363
 				}
1364 1364
 			}
1365
-	                $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);
1365
+					$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);
1366 1366
 			 try {
1367
-                    		$sth = $this->db->prepare($query);
1368
-	                        $sth->execute($query_values);
1369
-    		        } catch(PDOException $e) {
1370
-            		        return "error : ".$e->getMessage();
1371
-	                }
1372
-	        }
1373
-        }
1367
+							$sth = $this->db->prepare($query);
1368
+							$sth->execute($query_values);
1369
+					} catch(PDOException $e) {
1370
+							return "error : ".$e->getMessage();
1371
+					}
1372
+			}
1373
+		}
1374 1374
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1375 1375
 		global $globalDBdriver;
1376 1376
 		if ($airport_icao != '') {
@@ -1386,46 +1386,46 @@  discard block
 block discarded – undo
1386 1386
 			} catch(PDOException $e) {
1387 1387
 				return "error : ".$e->getMessage();
1388 1388
 			}
1389
-                }
1390
-        }
1389
+				}
1390
+		}
1391 1391
 
1392 1392
 	public function deleteStat($id) {
1393
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1394
-                $query_values = array(':id' => $id);
1395
-                 try {
1396
-                        $sth = $this->db->prepare($query);
1397
-                        $sth->execute($query_values);
1398
-                } catch(PDOException $e) {
1399
-                        return "error : ".$e->getMessage();
1400
-                }
1401
-        }
1393
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1394
+				$query_values = array(':id' => $id);
1395
+				 try {
1396
+						$sth = $this->db->prepare($query);
1397
+						$sth->execute($query_values);
1398
+				} catch(PDOException $e) {
1399
+						return "error : ".$e->getMessage();
1400
+				}
1401
+		}
1402 1402
 	public function deleteStatFlight($type) {
1403
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1404
-                $query_values = array(':type' => $type);
1405
-                 try {
1406
-                        $sth = $this->db->prepare($query);
1407
-                        $sth->execute($query_values);
1408
-                } catch(PDOException $e) {
1409
-                        return "error : ".$e->getMessage();
1410
-                }
1411
-        }
1403
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1404
+				$query_values = array(':type' => $type);
1405
+				 try {
1406
+						$sth = $this->db->prepare($query);
1407
+						$sth->execute($query_values);
1408
+				} catch(PDOException $e) {
1409
+						return "error : ".$e->getMessage();
1410
+				}
1411
+		}
1412 1412
 	public function deleteStatAirport($type) {
1413
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1414
-                $query_values = array(':type' => $type);
1415
-                 try {
1416
-                        $sth = $this->db->prepare($query);
1417
-                        $sth->execute($query_values);
1418
-                } catch(PDOException $e) {
1419
-                        return "error : ".$e->getMessage();
1420
-                }
1421
-        }
1413
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1414
+				$query_values = array(':type' => $type);
1415
+				 try {
1416
+						$sth = $this->db->prepare($query);
1417
+						$sth->execute($query_values);
1418
+				} catch(PDOException $e) {
1419
+						return "error : ".$e->getMessage();
1420
+				}
1421
+		}
1422 1422
         
1423
-        public function addOldStats() {
1424
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1425
-    		$Common = new Common();
1426
-    		$Connection = new Connection();
1427
-    		date_default_timezone_set('UTC');
1428
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1423
+		public function addOldStats() {
1424
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1425
+			$Common = new Common();
1426
+			$Connection = new Connection();
1427
+			date_default_timezone_set('UTC');
1428
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1429 1429
 			if ($globalDebug) echo 'Update stats !'."\n";
1430 1430
 			if (isset($last_update[0]['value'])) {
1431 1431
 				$last_update_day = $last_update[0]['value'];
@@ -1471,24 +1471,24 @@  discard block
 block discarded – undo
1471 1471
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1472 1472
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1473 1473
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1474
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1474
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1475 1475
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1476
-	        	$alldata = array();
1476
+				$alldata = array();
1477 1477
 	        	
1478
-    			foreach ($pall as $value) {
1479
-	        		$icao = $value['airport_departure_icao'];
1480
-    				$alldata[$icao] = $value;
1481
-	        	}
1482
-	        	foreach ($dall as $value) {
1483
-    				$icao = $value['airport_departure_icao'];
1484
-        			if (isset($alldata[$icao])) {
1485
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1486
-        			} else $alldata[$icao] = $value;
1487
-			}
1488
-    			$count = array();
1489
-    			foreach ($alldata as $key => $row) {
1490
-    				$count[$key] = $row['airport_departure_icao_count'];
1491
-        		}
1478
+				foreach ($pall as $value) {
1479
+					$icao = $value['airport_departure_icao'];
1480
+					$alldata[$icao] = $value;
1481
+				}
1482
+				foreach ($dall as $value) {
1483
+					$icao = $value['airport_departure_icao'];
1484
+					if (isset($alldata[$icao])) {
1485
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1486
+					} else $alldata[$icao] = $value;
1487
+			}
1488
+				$count = array();
1489
+				foreach ($alldata as $key => $row) {
1490
+					$count[$key] = $row['airport_departure_icao_count'];
1491
+				}
1492 1492
 			array_multisort($count,SORT_DESC,$alldata);
1493 1493
 			foreach ($alldata as $number) {
1494 1494
 				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);
@@ -1496,25 +1496,25 @@  discard block
 block discarded – undo
1496 1496
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1497 1497
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1498 1498
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1499
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1499
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1500 1500
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1501
-	        	$alldata = array();
1502
-    			foreach ($pall as $value) {
1503
-	        		$icao = $value['airport_arrival_icao'];
1504
-    				$alldata[$icao] = $value;
1505
-	        	}
1506
-	        	foreach ($dall as $value) {
1507
-    				$icao = $value['airport_arrival_icao'];
1508
-        			if (isset($alldata[$icao])) {
1509
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1510
-	        		} else $alldata[$icao] = $value;
1511
-    			}
1512
-        		$count = array();
1513
-        		foreach ($alldata as $key => $row) {
1514
-        			$count[$key] = $row['airport_arrival_icao_count'];
1515
-	        	}
1516
-    			array_multisort($count,SORT_DESC,$alldata);
1517
-                        foreach ($alldata as $number) {
1501
+				$alldata = array();
1502
+				foreach ($pall as $value) {
1503
+					$icao = $value['airport_arrival_icao'];
1504
+					$alldata[$icao] = $value;
1505
+				}
1506
+				foreach ($dall as $value) {
1507
+					$icao = $value['airport_arrival_icao'];
1508
+					if (isset($alldata[$icao])) {
1509
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1510
+					} else $alldata[$icao] = $value;
1511
+				}
1512
+				$count = array();
1513
+				foreach ($alldata as $key => $row) {
1514
+					$count[$key] = $row['airport_arrival_icao_count'];
1515
+				}
1516
+				array_multisort($count,SORT_DESC,$alldata);
1517
+						foreach ($alldata as $number) {
1518 1518
 				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);
1519 1519
 			}
1520 1520
 			if ($Connection->tableExists('countries')) {
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1575 1575
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1576 1576
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1577
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1578
-        		/*
1577
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1578
+				/*
1579 1579
 	        	$alldata = array();
1580 1580
     			foreach ($pall as $value) {
1581 1581
 	        		$icao = $value['departure_airport_icao'];
@@ -1594,29 +1594,29 @@  discard block
 block discarded – undo
1594 1594
 	        	}
1595 1595
     			array_multisort($count,SORT_DESC,$alldata);
1596 1596
     			*/
1597
-    			foreach ($dall as $value) {
1598
-    				$icao = $value['departure_airport_icao'];
1599
-    				$ddate = $value['date'];
1600
-    				$find = false;
1601
-    				foreach ($pall as $pvalue) {
1602
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1603
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1604
-    						$find = true;
1605
-    						break;
1606
-    					}
1607
-    				}
1608
-    				if ($find === false) {
1609
-    					$pall[] = $value;
1610
-    				}
1611
-    			}
1612
-    			$alldata = $pall;
1597
+				foreach ($dall as $value) {
1598
+					$icao = $value['departure_airport_icao'];
1599
+					$ddate = $value['date'];
1600
+					$find = false;
1601
+					foreach ($pall as $pvalue) {
1602
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1603
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1604
+							$find = true;
1605
+							break;
1606
+						}
1607
+					}
1608
+					if ($find === false) {
1609
+						$pall[] = $value;
1610
+					}
1611
+				}
1612
+				$alldata = $pall;
1613 1613
 			foreach ($alldata as $number) {
1614 1614
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1615 1615
 			}
1616 1616
 			echo '...Arrival'."\n";
1617 1617
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1618
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1619
-        		/*
1618
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1619
+				/*
1620 1620
 	        	$alldata = array();
1621 1621
     			foreach ($pall as $value) {
1622 1622
 	        		$icao = $value['arrival_airport_icao'];
@@ -1636,22 +1636,22 @@  discard block
 block discarded – undo
1636 1636
     			*/
1637 1637
 
1638 1638
 
1639
-    			foreach ($dall as $value) {
1640
-    				$icao = $value['arrival_airport_icao'];
1641
-    				$ddate = $value['date'];
1642
-    				$find = false;
1643
-    				foreach ($pall as $pvalue) {
1644
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1645
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1646
-    						$find = true;
1647
-    						break;
1648
-    					}
1649
-    				}
1650
-    				if ($find === false) {
1651
-    					$pall[] = $value;
1652
-    				}
1653
-    			}
1654
-    			$alldata = $pall;
1639
+				foreach ($dall as $value) {
1640
+					$icao = $value['arrival_airport_icao'];
1641
+					$ddate = $value['date'];
1642
+					$find = false;
1643
+					foreach ($pall as $pvalue) {
1644
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1645
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1646
+							$find = true;
1647
+							break;
1648
+						}
1649
+					}
1650
+					if ($find === false) {
1651
+						$pall[] = $value;
1652
+					}
1653
+				}
1654
+				$alldata = $pall;
1655 1655
 			foreach ($alldata as $number) {
1656 1656
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1657 1657
 			}
@@ -1726,51 +1726,51 @@  discard block
 block discarded – undo
1726 1726
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1727 1727
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1728 1728
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1729
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1729
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1730 1730
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1731
-	        	//$alldata = array();
1732
-    			foreach ($dall as $value) {
1733
-    				$icao = $value['airport_departure_icao'];
1734
-    				$dicao = $value['airline_icao'];
1735
-    				$find = false;
1736
-    				foreach ($pall as $pvalue) {
1737
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1738
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1739
-    						$find = true;
1740
-    						break;
1741
-    					}
1742
-    				}
1743
-    				if ($find === false) {
1744
-    					$pall[] = $value;
1745
-    				}
1746
-    			}
1747
-    			$alldata = $pall;
1731
+				//$alldata = array();
1732
+				foreach ($dall as $value) {
1733
+					$icao = $value['airport_departure_icao'];
1734
+					$dicao = $value['airline_icao'];
1735
+					$find = false;
1736
+					foreach ($pall as $pvalue) {
1737
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1738
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1739
+							$find = true;
1740
+							break;
1741
+						}
1742
+					}
1743
+					if ($find === false) {
1744
+						$pall[] = $value;
1745
+					}
1746
+				}
1747
+				$alldata = $pall;
1748 1748
 			foreach ($alldata as $number) {
1749 1749
 				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);
1750 1750
 			}
1751 1751
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1752 1752
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1753 1753
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1754
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1754
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1755 1755
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1756
-	        	//$alldata = array();
1757
-    			foreach ($dall as $value) {
1758
-    				$icao = $value['airport_arrival_icao'];
1759
-    				$dicao = $value['airline_icao'];
1760
-    				$find = false;
1761
-    				foreach ($pall as $pvalue) {
1762
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1763
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1764
-    						$find = true;
1765
-    						break;
1766
-    					}
1767
-    				}
1768
-    				if ($find === false) {
1769
-    					$pall[] = $value;
1770
-    				}
1771
-    			}
1772
-    			$alldata = $pall;
1773
-                        foreach ($alldata as $number) {
1756
+				//$alldata = array();
1757
+				foreach ($dall as $value) {
1758
+					$icao = $value['airport_arrival_icao'];
1759
+					$dicao = $value['airline_icao'];
1760
+					$find = false;
1761
+					foreach ($pall as $pvalue) {
1762
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1763
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1764
+							$find = true;
1765
+							break;
1766
+						}
1767
+					}
1768
+					if ($find === false) {
1769
+						$pall[] = $value;
1770
+					}
1771
+				}
1772
+				$alldata = $pall;
1773
+						foreach ($alldata as $number) {
1774 1774
 				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);
1775 1775
 			}
1776 1776
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1803,47 +1803,47 @@  discard block
 block discarded – undo
1803 1803
 			}
1804 1804
 			if ($globalDebug) echo '...Departure'."\n";
1805 1805
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1806
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1807
-    			foreach ($dall as $value) {
1808
-    				$icao = $value['departure_airport_icao'];
1809
-    				$airline = $value['airline_icao'];
1810
-    				$ddate = $value['date'];
1811
-    				$find = false;
1812
-    				foreach ($pall as $pvalue) {
1813
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1814
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1815
-    						$find = true;
1816
-    						break;
1817
-    					}
1818
-    				}
1819
-    				if ($find === false) {
1820
-    					$pall[] = $value;
1821
-    				}
1822
-    			}
1823
-    			$alldata = $pall;
1806
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1807
+				foreach ($dall as $value) {
1808
+					$icao = $value['departure_airport_icao'];
1809
+					$airline = $value['airline_icao'];
1810
+					$ddate = $value['date'];
1811
+					$find = false;
1812
+					foreach ($pall as $pvalue) {
1813
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1814
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1815
+							$find = true;
1816
+							break;
1817
+						}
1818
+					}
1819
+					if ($find === false) {
1820
+						$pall[] = $value;
1821
+					}
1822
+				}
1823
+				$alldata = $pall;
1824 1824
 			foreach ($alldata as $number) {
1825 1825
 				$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']);
1826 1826
 			}
1827 1827
 			if ($globalDebug) echo '...Arrival'."\n";
1828 1828
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1829
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1830
-    			foreach ($dall as $value) {
1831
-    				$icao = $value['arrival_airport_icao'];
1832
-    				$airline = $value['airline_icao'];
1833
-    				$ddate = $value['date'];
1834
-    				$find = false;
1835
-    				foreach ($pall as $pvalue) {
1836
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1837
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1838
-    						$find = true;
1839
-    						break;
1840
-    					}
1841
-    				}
1842
-    				if ($find === false) {
1843
-    					$pall[] = $value;
1844
-    				}
1845
-    			}
1846
-    			$alldata = $pall;
1829
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1830
+				foreach ($dall as $value) {
1831
+					$icao = $value['arrival_airport_icao'];
1832
+					$airline = $value['airline_icao'];
1833
+					$ddate = $value['date'];
1834
+					$find = false;
1835
+					foreach ($pall as $pvalue) {
1836
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1837
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1838
+							$find = true;
1839
+							break;
1840
+						}
1841
+					}
1842
+					if ($find === false) {
1843
+						$pall[] = $value;
1844
+					}
1845
+				}
1846
+				$alldata = $pall;
1847 1847
 			foreach ($alldata as $number) {
1848 1848
 				$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']);
1849 1849
 			}
@@ -1914,44 +1914,44 @@  discard block
 block discarded – undo
1914 1914
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1915 1915
 				}
1916 1916
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1917
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1918
-		        	$alldata = array();
1919
-	    			foreach ($pall as $value) {
1920
-		        		$icao = $value['airport_departure_icao'];
1921
-    					$alldata[$icao] = $value;
1922
-	    			}
1923
-		        	foreach ($dall as $value) {
1924
-	    				$icao = $value['airport_departure_icao'];
1925
-        				if (isset($alldata[$icao])) {
1926
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1927
-        				} else $alldata[$icao] = $value;
1928
-				}
1929
-	    			$count = array();
1930
-    				foreach ($alldata as $key => $row) {
1931
-    					$count[$key] = $row['airport_departure_icao_count'];
1932
-    				}
1917
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1918
+					$alldata = array();
1919
+					foreach ($pall as $value) {
1920
+						$icao = $value['airport_departure_icao'];
1921
+						$alldata[$icao] = $value;
1922
+					}
1923
+					foreach ($dall as $value) {
1924
+						$icao = $value['airport_departure_icao'];
1925
+						if (isset($alldata[$icao])) {
1926
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1927
+						} else $alldata[$icao] = $value;
1928
+				}
1929
+					$count = array();
1930
+					foreach ($alldata as $key => $row) {
1931
+						$count[$key] = $row['airport_departure_icao_count'];
1932
+					}
1933 1933
 				array_multisort($count,SORT_DESC,$alldata);
1934 1934
 				foreach ($alldata as $number) {
1935
-    					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);
1935
+						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);
1936 1936
 				}
1937 1937
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1938
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1938
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1939 1939
 				$alldata = array();
1940
-    				foreach ($pall as $value) {
1941
-		        		$icao = $value['airport_arrival_icao'];
1942
-    					$alldata[$icao] = $value;
1943
-	    			}
1944
-		        	foreach ($dall as $value) {
1945
-	    				$icao = $value['airport_arrival_icao'];
1946
-        				if (isset($alldata[$icao])) {
1947
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1948
-		        		} else $alldata[$icao] = $value;
1949
-	    			}
1950
-        			$count = array();
1951
-        			foreach ($alldata as $key => $row) {
1952
-    					$count[$key] = $row['airport_arrival_icao_count'];
1953
-		        	}
1954
-        			array_multisort($count,SORT_DESC,$alldata);
1940
+					foreach ($pall as $value) {
1941
+						$icao = $value['airport_arrival_icao'];
1942
+						$alldata[$icao] = $value;
1943
+					}
1944
+					foreach ($dall as $value) {
1945
+						$icao = $value['airport_arrival_icao'];
1946
+						if (isset($alldata[$icao])) {
1947
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1948
+						} else $alldata[$icao] = $value;
1949
+					}
1950
+					$count = array();
1951
+					foreach ($alldata as $key => $row) {
1952
+						$count[$key] = $row['airport_arrival_icao_count'];
1953
+					}
1954
+					array_multisort($count,SORT_DESC,$alldata);
1955 1955
 				foreach ($alldata as $number) {
1956 1956
 					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);
1957 1957
 				}
@@ -1984,45 +1984,45 @@  discard block
 block discarded – undo
1984 1984
 				}
1985 1985
 				echo '...Departure'."\n";
1986 1986
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1987
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1987
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1988 1988
 				foreach ($dall as $value) {
1989
-    					$icao = $value['departure_airport_icao'];
1990
-    					$ddate = $value['date'];
1991
-    					$find = false;
1992
-    					foreach ($pall as $pvalue) {
1993
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1994
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1995
-	    						$find = true;
1996
-    							break;
1997
-    						}
1998
-    					}
1999
-    					if ($find === false) {
2000
-    						$pall[] = $value;
2001
-	    				}
2002
-    				}
2003
-	    			$alldata = $pall;
1989
+						$icao = $value['departure_airport_icao'];
1990
+						$ddate = $value['date'];
1991
+						$find = false;
1992
+						foreach ($pall as $pvalue) {
1993
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1994
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1995
+								$find = true;
1996
+								break;
1997
+							}
1998
+						}
1999
+						if ($find === false) {
2000
+							$pall[] = $value;
2001
+						}
2002
+					}
2003
+					$alldata = $pall;
2004 2004
 				foreach ($alldata as $number) {
2005 2005
 					$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);
2006 2006
 				}
2007 2007
 				echo '...Arrival'."\n";
2008 2008
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2009
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2009
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2010 2010
 				foreach ($dall as $value) {
2011 2011
 					$icao = $value['arrival_airport_icao'];
2012 2012
 					$ddate = $value['date'];
2013
-    					$find = false;
2013
+						$find = false;
2014 2014
 					foreach ($pall as $pvalue) {
2015
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2016
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2017
-    							$find = true;
2018
-    							break;
2019
-	    					}
2020
-    					}
2021
-    					if ($find === false) {
2022
-    						$pall[] = $value;
2023
-	    				}
2024
-    				}
2025
-    				$alldata = $pall;
2015
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2016
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2017
+								$find = true;
2018
+								break;
2019
+							}
2020
+						}
2021
+						if ($find === false) {
2022
+							$pall[] = $value;
2023
+						}
2024
+					}
2025
+					$alldata = $pall;
2026 2026
 				foreach ($alldata as $number) {
2027 2027
 					$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);
2028 2028
 				}
Please login to merge, or discard this patch.
Spacing   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute();
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
                 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                  try {
73 73
                         $sth = $this->db->prepare($query);
74 74
                         $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
75
+                } catch (PDOException $e) {
76 76
                         return "error : ".$e->getMessage();
77 77
                 }
78 78
         }
@@ -82,69 +82,69 @@  discard block
 block discarded – undo
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84 84
                         $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89 89
                 return $all;
90 90
         }
91
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
91
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93 93
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 94
                  try {
95 95
                         $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
96
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
97
+                } catch (PDOException $e) {
98 98
                         echo "error : ".$e->getMessage();
99 99
                 }
100 100
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101 101
                 return $all;
102 102
         }
103
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
103
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105 105
                 $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";
106 106
                  try {
107 107
                         $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
108
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
109
+                } catch (PDOException $e) {
110 110
                         echo "error : ".$e->getMessage();
111 111
                 }
112 112
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113 113
                 return $all;
114 114
         }
115
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
115
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
                 $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";
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 127
 
128
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
128
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130 130
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 131
                  try {
132 132
                         $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
133
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
134
+                } catch (PDOException $e) {
135 135
                         echo "error : ".$e->getMessage();
136 136
                 }
137 137
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138 138
                 return $all;
139 139
         }
140 140
 
141
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
141
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143 143
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 144
                  try {
145 145
                         $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
146
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
147
+                } catch (PDOException $e) {
148 148
                         echo "error : ".$e->getMessage();
149 149
                 }
150 150
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
 
155
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
155
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
156 156
 		global $globalStatsFilters;
157 157
 		if ($filter_name == '') $filter_name = $this->filter_name;
158 158
 		if ($year == '' && $month == '') {
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
161 161
 			try {
162 162
 				$sth = $this->db->prepare($query);
163
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
164
-			} catch(PDOException $e) {
163
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
164
+			} catch (PDOException $e) {
165 165
 				echo "error : ".$e->getMessage();
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
                 if (empty($all)) {
170 170
             	    $filters = array('airlines' => array($stats_airline));
171 171
             	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
172
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
173 173
             	    }
174 174
             	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
175
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month);
176 176
                 }
177 177
                 return $all;
178 178
 	}
179
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
179
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182 182
 		if ($year == '' && $month == '') {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			try {
186 186
 				$sth = $this->db->prepare($query);
187 187
 				$sth->execute(array(':filter_name' => $filter_name));
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				echo "error : ".$e->getMessage();
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
             		$Spotter = new Spotter($this->db);
195 195
             		$filters = array();
196 196
             		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
197
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
199
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month);
200 200
                 }
201 201
                 return $all;
202 202
 	}
203
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
203
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
204 204
 		global $globalStatsFilters;
205 205
 		if ($filter_name == '') $filter_name = $this->filter_name;
206 206
 		if ($year == '' && $month == '') {
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			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";
209 209
 			try {
210 210
 				$sth = $this->db->prepare($query);
211
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
212
-			} catch(PDOException $e) {
211
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
212
+			} catch (PDOException $e) {
213 213
 				echo "error : ".$e->getMessage();
214 214
 			}
215 215
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 		if (empty($all)) {
218 218
 			$filters = array('airlines' => array($stats_airline));
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
-			$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
223
+			$all = $Spotter->countAllAircraftManufacturers($filters, $year, $month);
224 224
 		}
225 225
 		return $all;
226 226
 	}
227 227
 
228
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
228
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
236
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
                 if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
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
 			$Spotter = new Spotter($this->db);
248
-			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
248
+			$all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month);
249 249
                 }
250 250
                 return $all;
251 251
 	}
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257 257
                  try {
258 258
                         $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
259
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
260
+                } catch (PDOException $e) {
261 261
                         echo "error : ".$e->getMessage();
262 262
                 }
263 263
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
                 if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270
-			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
270
+			$all = $Spotter->countAllDepartureCountries($filters, $year, $month);
271 271
                 }
272 272
                 return $all;
273 273
 	}
274 274
 
275
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
275
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
276 276
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
277 277
 		if ($filter_name == '') $filter_name = $this->filter_name;
278 278
 		if ($year == '' && $month == '') {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			if (isset($forsource)) {
282 282
 				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";
283 283
 				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";
284
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
284
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
285 285
 			} else {
286 286
 				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";
287 287
 				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";
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			try {
291 291
 				$sth = $this->db->prepare($query);
292 292
 				$sth->execute($query_values);
293
-			} catch(PDOException $e) {
293
+			} catch (PDOException $e) {
294 294
 				echo "error : ".$e->getMessage();
295 295
 			}
296 296
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 	                $Spotter = new Spotter($this->db);
300 300
             		$filters = array();
301 301
             		if ($filter_name != '') {
302
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
302
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
303 303
 			}
304
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
304
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month);
305 305
                 }
306 306
                 return $all;
307 307
 	}
308
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
308
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
309 309
 		global $globalStatsFilters;
310 310
 		if ($filter_name == '') $filter_name = $this->filter_name;
311 311
 		if ($year == '' && $month == '') {
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 			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";
314 314
 			try {
315 315
 				$sth = $this->db->prepare($query);
316
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
317
-			} catch(PDOException $e) {
316
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
317
+			} catch (PDOException $e) {
318 318
 				echo "error : ".$e->getMessage();
319 319
 			}
320 320
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
                 if (empty($all)) {
323 323
 			$filters = array('airlines' => array($stats_airline));
324 324
 			if ($filter_name != '') {
325
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
325
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
326 326
 			}
327 327
 	                $Spotter = new Spotter($this->db);
328
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
328
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month);
329 329
                 }
330 330
                 return $all;
331 331
 	}
332
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
332
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
333 333
 		global $globalStatsFilters;
334 334
 		if ($filter_name == '') $filter_name = $this->filter_name;
335 335
 		if ($year == '' && $month == '') {
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 			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";
338 338
 			 try {
339 339
 				$sth = $this->db->prepare($query);
340
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
341
-			} catch(PDOException $e) {
340
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
341
+			} catch (PDOException $e) {
342 342
 				echo "error : ".$e->getMessage();
343 343
 			}
344 344
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -346,14 +346,14 @@  discard block
 block discarded – undo
346 346
 		if (empty($all)) {
347 347
 			$filters = array('airlines' => array($stats_airline));
348 348
 			if ($filter_name != '') {
349
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
349
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
350 350
 			}
351 351
 			$Spotter = new Spotter($this->db);
352
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
352
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month);
353 353
 		}
354 354
 		return $all;
355 355
 	}
356
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
356
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
357 357
 		$Connection = new Connection();
358 358
 		if ($filter_name == '') $filter_name = $this->filter_name;
359 359
 		if ($Connection->tableExists('countries')) {
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 				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";
363 363
 				 try {
364 364
 					$sth = $this->db->prepare($query);
365
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
366
-				} catch(PDOException $e) {
365
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
366
+				} catch (PDOException $e) {
367 367
 					echo "error : ".$e->getMessage();
368 368
 				}
369 369
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 			return array();
380 380
 		}
381 381
 	}
382
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
382
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
383 383
 		global $globalStatsFilters;
384 384
 		if ($filter_name == '') $filter_name = $this->filter_name;
385 385
 		if ($year == '' && $month == '') {
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 			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";
388 388
 			try {
389 389
 				$sth = $this->db->prepare($query);
390
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
391
-			} catch(PDOException $e) {
390
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
391
+			} catch (PDOException $e) {
392 392
 				echo "error : ".$e->getMessage();
393 393
 			}
394 394
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
 		if (empty($all)) {
397 397
 			$filters = array('airlines' => array($stats_airline));
398 398
 			if ($filter_name != '') {
399
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
399
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
400 400
 			}
401 401
 			$Spotter = new Spotter($this->db);
402
-			$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
402
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month);
403 403
 		}
404 404
 		return $all;
405 405
 	}
406 406
 
407
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
407
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
408 408
 		global $globalStatsFilters;
409 409
 		if ($filter_name == '') $filter_name = $this->filter_name;
410 410
 		if ($year == '' && $month == '') {
@@ -412,8 +412,8 @@  discard block
 block discarded – undo
412 412
 			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";
413 413
 			try {
414 414
 				$sth = $this->db->prepare($query);
415
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
416
-			} catch(PDOException $e) {
415
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
416
+			} catch (PDOException $e) {
417 417
 				echo "error : ".$e->getMessage();
418 418
 			}
419 419
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
                 if (empty($all)) {
422 422
 			$filters = array('airlines' => array($stats_airline));
423 423
 			if ($filter_name != '') {
424
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
424
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
425 425
 			}
426 426
             		$Spotter = new Spotter($this->db);
427
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
427
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month);
428 428
                 }
429 429
                 return $all;
430 430
 	}
431
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
431
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
432 432
 		global $globalStatsFilters;
433 433
 		if ($filter_name == '') $filter_name = $this->filter_name;
434 434
 		if ($year == '' && $month == '') {
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
 			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
437 437
 			try {
438 438
 				$sth = $this->db->prepare($query);
439
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
440
-			} catch(PDOException $e) {
439
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
440
+			} catch (PDOException $e) {
441 441
 				echo "error : ".$e->getMessage();
442 442
 			}
443 443
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -445,11 +445,11 @@  discard block
 block discarded – undo
445 445
                 if (empty($all)) {
446 446
 			$filters = array('airlines' => array($stats_airline));
447 447
             		if ($filter_name != '') {
448
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
448
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
449 449
 			}
450 450
             		$Spotter = new Spotter($this->db);
451
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
452
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
451
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month);
452
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month);
453 453
         		$all = array();
454 454
         		foreach ($pall as $value) {
455 455
         			$icao = $value['airport_departure_icao'];
@@ -466,11 +466,11 @@  discard block
 block discarded – undo
466 466
         		foreach ($all as $key => $row) {
467 467
         			$count[$key] = $row['airport_departure_icao_count'];
468 468
         		}
469
-        		array_multisort($count,SORT_DESC,$all);
469
+        		array_multisort($count, SORT_DESC, $all);
470 470
                 }
471 471
                 return $all;
472 472
 	}
473
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
473
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
474 474
 		global $globalStatsFilters;
475 475
 		if ($filter_name == '') $filter_name = $this->filter_name;
476 476
 		if ($year == '' && $month == '') {
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
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);
@@ -487,11 +487,11 @@  discard block
 block discarded – undo
487 487
 		if (empty($all)) {
488 488
 			$filters = array('airlines' => array($stats_airline));
489 489
 			if ($filter_name != '') {
490
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
490
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
491 491
 			}
492 492
 			$Spotter = new Spotter($this->db);
493
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
494
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
493
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month);
494
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month);
495 495
         		$all = array();
496 496
         		foreach ($pall as $value) {
497 497
         			$icao = $value['airport_arrival_icao'];
@@ -508,12 +508,12 @@  discard block
 block discarded – undo
508 508
         		foreach ($all as $key => $row) {
509 509
         			$count[$key] = $row['airport_arrival_icao_count'];
510 510
         		}
511
-        		array_multisort($count,SORT_DESC,$all);
511
+        		array_multisort($count, SORT_DESC, $all);
512 512
                 }
513 513
  
514 514
                 return $all;
515 515
 	}
516
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
516
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
517 517
 		global $globalDBdriver, $globalStatsFilters;
518 518
 		if ($filter_name == '') $filter_name = $this->filter_name;
519 519
 		if ($globalDBdriver == 'mysql') {
@@ -523,18 +523,18 @@  discard block
 block discarded – undo
523 523
 			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";
524 524
 			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";
525 525
 		}
526
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
526
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
527 527
                  try {
528 528
                         $sth = $this->db->prepare($query);
529 529
                         $sth->execute($query_data);
530
-                } catch(PDOException $e) {
530
+                } catch (PDOException $e) {
531 531
                         echo "error : ".$e->getMessage();
532 532
                 }
533 533
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
534 534
                 if (empty($all)) {
535 535
 			$filters = array('airlines' => array($stats_airline));
536 536
 			if ($filter_name != '') {
537
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
537
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
538 538
 			}
539 539
             		$Spotter = new Spotter($this->db);
540 540
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -543,29 +543,29 @@  discard block
 block discarded – undo
543 543
                 return $all;
544 544
 	}
545 545
 	
546
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
546
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
547 547
 		global $globalStatsFilters;
548 548
 		if ($filter_name == '') $filter_name = $this->filter_name;
549 549
 		$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";
550
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
550
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
551 551
                  try {
552 552
                         $sth = $this->db->prepare($query);
553 553
                         $sth->execute($query_data);
554
-                } catch(PDOException $e) {
554
+                } catch (PDOException $e) {
555 555
                         echo "error : ".$e->getMessage();
556 556
                 }
557 557
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
558 558
                 if (empty($all)) {
559 559
 			$filters = array('airlines' => array($stats_airline));
560 560
 			if ($filter_name != '') {
561
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
561
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
562 562
 			}
563 563
             		$Spotter = new Spotter($this->db);
564 564
             		$all = $Spotter->countAllDatesLastMonth($filters);
565 565
                 }
566 566
                 return $all;
567 567
 	}
568
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
568
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
569 569
 		global $globalDBdriver, $globalStatsFilters;
570 570
 		if ($filter_name == '') $filter_name = $this->filter_name;
571 571
 		if ($globalDBdriver == 'mysql') {
@@ -573,40 +573,40 @@  discard block
 block discarded – undo
573 573
 		} else {
574 574
 			$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";
575 575
 		}
576
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
576
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
577 577
                  try {
578 578
                         $sth = $this->db->prepare($query);
579 579
                         $sth->execute($query_data);
580
-                } catch(PDOException $e) {
580
+                } catch (PDOException $e) {
581 581
                         echo "error : ".$e->getMessage();
582 582
                 }
583 583
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
584 584
                 if (empty($all)) {
585 585
 			$filters = array('airlines' => array($stats_airline));
586 586
 			if ($filter_name != '') {
587
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
587
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
588 588
 			}
589 589
             		$Spotter = new Spotter($this->db);
590 590
             		$all = $Spotter->countAllDatesLast7Days($filters);
591 591
                 }
592 592
                 return $all;
593 593
 	}
594
-	public function countAllDates($stats_airline = '',$filter_name = '') {
594
+	public function countAllDates($stats_airline = '', $filter_name = '') {
595 595
 		global $globalStatsFilters;
596 596
 		if ($filter_name == '') $filter_name = $this->filter_name;
597 597
 		$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";
598
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
598
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
599 599
                  try {
600 600
                         $sth = $this->db->prepare($query);
601 601
                         $sth->execute($query_data);
602
-                } catch(PDOException $e) {
602
+                } catch (PDOException $e) {
603 603
                         echo "error : ".$e->getMessage();
604 604
                 }
605 605
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
606 606
                 if (empty($all)) {
607 607
 			$filters = array('airlines' => array($stats_airline));
608 608
 			if ($filter_name != '') {
609
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
609
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
610 610
 			}
611 611
             		$Spotter = new Spotter($this->db);
612 612
             		$all = $Spotter->countAllDates($filters);
@@ -621,28 +621,28 @@  discard block
 block discarded – undo
621 621
                  try {
622 622
                         $sth = $this->db->prepare($query);
623 623
                         $sth->execute($query_data);
624
-                } catch(PDOException $e) {
624
+                } catch (PDOException $e) {
625 625
                         echo "error : ".$e->getMessage();
626 626
                 }
627 627
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
628 628
                 if (empty($all)) {
629 629
             		$filters = array();
630 630
             		if ($filter_name != '') {
631
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
631
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
632 632
 			}
633 633
             		$Spotter = new Spotter($this->db);
634 634
             		$all = $Spotter->countAllDatesByAirlines($filters);
635 635
                 }
636 636
                 return $all;
637 637
 	}
638
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
638
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
639 639
 		global $globalStatsFilters;
640 640
 		if ($filter_name == '') $filter_name = $this->filter_name;
641 641
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
642 642
                  try {
643 643
                         $sth = $this->db->prepare($query);
644 644
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
645
-                } catch(PDOException $e) {
645
+                } catch (PDOException $e) {
646 646
                         echo "error : ".$e->getMessage();
647 647
                 }
648 648
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
                 if (empty($all)) {
651 651
 			$filters = array('airlines' => array($stats_airline));
652 652
 			if ($filter_name != '') {
653
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
653
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
654 654
 			}
655 655
             		$Spotter = new Spotter($this->db);
656 656
             		$all = $Spotter->countAllMonths($filters);
@@ -665,21 +665,21 @@  discard block
 block discarded – undo
665 665
                  try {
666 666
                         $sth = $this->db->prepare($query);
667 667
                         $sth->execute(array(':filter_name' => $filter_name));
668
-                } catch(PDOException $e) {
668
+                } catch (PDOException $e) {
669 669
                         echo "error : ".$e->getMessage();
670 670
                 }
671 671
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
672 672
                 if (empty($all)) {
673 673
             		$filters = array();
674 674
             		if ($filter_name != '') {
675
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
675
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
676 676
 			}
677 677
             		$Spotter = new Spotter($this->db);
678 678
             		$all = $Spotter->countAllMilitaryMonths($filters);
679 679
                 }
680 680
                 return $all;
681 681
 	}
682
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
682
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
683 683
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
684 684
 		if ($filter_name == '') $filter_name = $this->filter_name;
685 685
 		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";
@@ -696,91 +696,91 @@  discard block
 block discarded – undo
696 696
                  try {
697 697
                         $sth = $this->db->prepare($query);
698 698
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
699
-                } catch(PDOException $e) {
699
+                } catch (PDOException $e) {
700 700
                         echo "error : ".$e->getMessage();
701 701
                 }
702 702
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
703 703
                 if (empty($all)) {
704 704
 			$filters = array('airlines' => array($stats_airline));
705 705
 			if ($filter_name != '') {
706
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
706
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
707 707
 			}
708 708
             		$Spotter = new Spotter($this->db);
709
-            		$all = $Spotter->countAllHours($orderby,$filters);
709
+            		$all = $Spotter->countAllHours($orderby, $filters);
710 710
                 }
711 711
                 return $all;
712 712
 	}
713 713
 	
714
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
714
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
715 715
 		global $globalStatsFilters;
716 716
 		if ($filter_name == '') $filter_name = $this->filter_name;
717 717
 		if ($year == '') $year = date('Y');
718
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
718
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
719 719
 		if (empty($all)) {
720 720
 			$filters = array('airlines' => array($stats_airline));
721 721
 			if ($filter_name != '') {
722
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
722
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
723 723
 			}
724 724
 			$Spotter = new Spotter($this->db);
725
-			$all = $Spotter->countOverallFlights($filters,$year,$month);
725
+			$all = $Spotter->countOverallFlights($filters, $year, $month);
726 726
 		}
727 727
 		return $all;
728 728
 	}
729
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
729
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
730 730
 		global $globalStatsFilters;
731 731
 		if ($filter_name == '') $filter_name = $this->filter_name;
732 732
 		if ($year == '') $year = date('Y');
733
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
733
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
734 734
 		if (empty($all)) {
735 735
 		        $filters = array();
736 736
             		if ($filter_name != '') {
737
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
737
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
738 738
 			}
739 739
 			$Spotter = new Spotter($this->db);
740
-			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
740
+			$all = $Spotter->countOverallMilitaryFlights($filters, $year, $month);
741 741
 		}
742 742
 		return $all;
743 743
 	}
744
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
744
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
745 745
 		global $globalStatsFilters;
746 746
 		if ($filter_name == '') $filter_name = $this->filter_name;
747 747
 		if ($year == '') $year = date('Y');
748
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
748
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
749 749
 		if (empty($all)) {
750 750
 			$filters = array('airlines' => array($stats_airline));
751 751
 			if ($filter_name != '') {
752
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
752
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
753 753
 			}
754 754
 			$Spotter = new Spotter($this->db);
755
-			$all = $Spotter->countOverallArrival($filters,$year,$month);
755
+			$all = $Spotter->countOverallArrival($filters, $year, $month);
756 756
 		}
757 757
 		return $all;
758 758
 	}
759
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
759
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
760 760
 		global $globalStatsFilters;
761 761
 		if ($filter_name == '') $filter_name = $this->filter_name;
762 762
 		if ($year == '' && $month == '') {
763 763
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
764 764
 			try {
765 765
 				$sth = $this->db->prepare($query);
766
-				$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
767
-			} catch(PDOException $e) {
766
+				$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
767
+			} catch (PDOException $e) {
768 768
 				echo "error : ".$e->getMessage();
769 769
 			}
770 770
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
771 771
 			$all = $result[0]['nb'];
772
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
772
+		} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
773 773
 		if (empty($all)) {
774 774
 			$filters = array('airlines' => array($stats_airline));
775 775
 			if ($filter_name != '') {
776
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
776
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
777 777
 			}
778 778
 			$Spotter = new Spotter($this->db);
779
-			$all = $Spotter->countOverallAircrafts($filters,$year,$month);
779
+			$all = $Spotter->countOverallAircrafts($filters, $year, $month);
780 780
 		}
781 781
 		return $all;
782 782
 	}
783
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
783
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
784 784
 		global $globalStatsFilters;
785 785
 		if ($filter_name == '') $filter_name = $this->filter_name;
786 786
 		if ($year == '' && $month == '') {
@@ -788,23 +788,23 @@  discard block
 block discarded – undo
788 788
 			try {
789 789
 				$sth = $this->db->prepare($query);
790 790
 				$sth->execute(array(':filter_name' => $filter_name));
791
-			} catch(PDOException $e) {
791
+			} catch (PDOException $e) {
792 792
 				echo "error : ".$e->getMessage();
793 793
 			}
794 794
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
795 795
 			$all = $result[0]['nb_airline'];
796
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
796
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
797 797
 		if (empty($all)) {
798 798
             		$filters = array();
799 799
             		if ($filter_name != '') {
800
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
800
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
801 801
 			}
802 802
 			$Spotter = new Spotter($this->db);
803
-			$all = $Spotter->countOverallAirlines($filters,$year,$month);
803
+			$all = $Spotter->countOverallAirlines($filters, $year, $month);
804 804
 		}
805 805
 		return $all;
806 806
 	}
807
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
807
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
808 808
 		global $globalStatsFilters;
809 809
 		if ($filter_name == '') $filter_name = $this->filter_name;
810 810
 		if ($year == '' && $month == '') {
@@ -813,25 +813,25 @@  discard block
 block discarded – undo
813 813
 			try {
814 814
 				$sth = $this->db->prepare($query);
815 815
 				$sth->execute($query_values);
816
-			} catch(PDOException $e) {
816
+			} catch (PDOException $e) {
817 817
 				echo "error : ".$e->getMessage();
818 818
 			}
819 819
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
820 820
 			$all = $result[0]['nb'];
821 821
 		} else {
822
-			$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
822
+			$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
823 823
 		}
824 824
 		if (empty($all)) {
825 825
 			$filters = array('airlines' => array($stats_airline));
826 826
 			if ($filter_name != '') {
827
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
827
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
828 828
 			}
829 829
 			$Spotter = new Spotter($this->db);
830
-			$all = $Spotter->countOverallOwners($filters,$year,$month);
830
+			$all = $Spotter->countOverallOwners($filters, $year, $month);
831 831
 		}
832 832
 		return $all;
833 833
 	}
834
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
834
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
835 835
 		global $globalStatsFilters;
836 836
 		if ($filter_name == '') $filter_name = $this->filter_name;
837 837
 		//if ($year == '') $year = date('Y');
@@ -841,75 +841,75 @@  discard block
 block discarded – undo
841 841
 			try {
842 842
 				$sth = $this->db->prepare($query);
843 843
 				$sth->execute($query_values);
844
-			} catch(PDOException $e) {
844
+			} catch (PDOException $e) {
845 845
 				echo "error : ".$e->getMessage();
846 846
 			}
847 847
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
848 848
 			$all = $result[0]['nb'];
849 849
 		} else {
850
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
850
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
851 851
 		}
852 852
 		if (empty($all)) {
853 853
 			$filters = array('airlines' => array($stats_airline));
854 854
 			if ($filter_name != '') {
855
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
855
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
856 856
 			}
857 857
 			$Spotter = new Spotter($this->db);
858
-			$all = $Spotter->countOverallPilots($filters,$year,$month);
858
+			$all = $Spotter->countOverallPilots($filters, $year, $month);
859 859
 		}
860 860
 		return $all;
861 861
 	}
862 862
 
863
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
863
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
864 864
 		if ($filter_name == '') $filter_name = $this->filter_name;
865 865
 		$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";
866
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
866
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
867 867
                  try {
868 868
                         $sth = $this->db->prepare($query);
869 869
                         $sth->execute($query_values);
870
-                } catch(PDOException $e) {
870
+                } catch (PDOException $e) {
871 871
                         echo "error : ".$e->getMessage();
872 872
                 }
873 873
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
874 874
                 return $all;
875 875
 	}
876
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
876
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
877 877
 		if ($filter_name == '') $filter_name = $this->filter_name;
878 878
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
879
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
879
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
880 880
                  try {
881 881
                         $sth = $this->db->prepare($query);
882 882
                         $sth->execute($query_values);
883
-                } catch(PDOException $e) {
883
+                } catch (PDOException $e) {
884 884
                         echo "error : ".$e->getMessage();
885 885
                 }
886 886
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
887 887
                 return $all;
888 888
         }
889
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
889
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
890 890
 		if ($filter_name == '') $filter_name = $this->filter_name;
891 891
     		global $globalArchiveMonths, $globalDBdriver;
892 892
     		if ($globalDBdriver == 'mysql') {
893 893
     			if ($month == '') {
894 894
 				$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";
895
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
895
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896 896
 			} else {
897 897
 				$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";
898
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
898
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
899 899
 			}
900 900
 		} else {
901 901
 			if ($month == '') {
902 902
 				$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";
903
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
903
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
904 904
 			} else {
905 905
 				$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";
906
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
906
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
907 907
 			}
908 908
                 }
909 909
                  try {
910 910
                         $sth = $this->db->prepare($query);
911 911
                         $sth->execute($query_values);
912
-                } catch(PDOException $e) {
912
+                } catch (PDOException $e) {
913 913
                         echo "error : ".$e->getMessage();
914 914
                 }
915 915
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
                  try {
928 928
                         $sth = $this->db->prepare($query);
929 929
                         $sth->execute($query_values);
930
-                } catch(PDOException $e) {
930
+                } catch (PDOException $e) {
931 931
                         echo "error : ".$e->getMessage();
932 932
                 }
933 933
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
                  try {
945 945
                         $sth = $this->db->prepare($query);
946 946
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
947
-                } catch(PDOException $e) {
947
+                } catch (PDOException $e) {
948 948
                         echo "error : ".$e->getMessage();
949 949
                 }
950 950
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
                  try {
962 962
                         $sth = $this->db->prepare($query);
963 963
                         $sth->execute(array(':filter_name' => $filter_name));
964
-                } catch(PDOException $e) {
964
+                } catch (PDOException $e) {
965 965
                         echo "error : ".$e->getMessage();
966 966
                 }
967 967
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -978,20 +978,20 @@  discard block
 block discarded – undo
978 978
                  try {
979 979
                         $sth = $this->db->prepare($query);
980 980
                         $sth->execute(array(':filter_name' => $filter_name));
981
-                } catch(PDOException $e) {
981
+                } catch (PDOException $e) {
982 982
                         echo "error : ".$e->getMessage();
983 983
                 }
984 984
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
985 985
                 return $all[0]['total'];
986 986
         }
987
-	public function getStatsOwner($owner_name,$filter_name = '') {
987
+	public function getStatsOwner($owner_name, $filter_name = '') {
988 988
     		global $globalArchiveMonths, $globalDBdriver;
989 989
 		if ($filter_name == '') $filter_name = $this->filter_name;
990 990
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
991 991
                  try {
992 992
                         $sth = $this->db->prepare($query);
993
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
994
-                } catch(PDOException $e) {
993
+                        $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
994
+                } catch (PDOException $e) {
995 995
                         echo "error : ".$e->getMessage();
996 996
                 }
997 997
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1009,20 +1009,20 @@  discard block
 block discarded – undo
1009 1009
                  try {
1010 1010
                         $sth = $this->db->prepare($query);
1011 1011
                         $sth->execute(array(':filter_name' => $filter_name));
1012
-                } catch(PDOException $e) {
1012
+                } catch (PDOException $e) {
1013 1013
                         echo "error : ".$e->getMessage();
1014 1014
                 }
1015 1015
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1016 1016
                 return $all[0]['total'];
1017 1017
         }
1018
-	public function getStatsPilot($pilot,$filter_name = '') {
1018
+	public function getStatsPilot($pilot, $filter_name = '') {
1019 1019
     		global $globalArchiveMonths, $globalDBdriver;
1020 1020
 		if ($filter_name == '') $filter_name = $this->filter_name;
1021 1021
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1022 1022
                  try {
1023 1023
                         $sth = $this->db->prepare($query);
1024
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1025
-                } catch(PDOException $e) {
1024
+                        $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1025
+                } catch (PDOException $e) {
1026 1026
                         echo "error : ".$e->getMessage();
1027 1027
                 }
1028 1028
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
                 else return 0;
1031 1031
         }
1032 1032
 
1033
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1033
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1034 1034
 		global $globalDBdriver;
1035 1035
 		if ($filter_name == '') $filter_name = $this->filter_name;
1036 1036
 		if ($globalDBdriver == 'mysql') {
@@ -1038,15 +1038,15 @@  discard block
 block discarded – undo
1038 1038
                 } else {
1039 1039
 			$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);"; 
1040 1040
 		}
1041
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1041
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1042 1042
                  try {
1043 1043
                         $sth = $this->db->prepare($query);
1044 1044
                         $sth->execute($query_values);
1045
-                } catch(PDOException $e) {
1045
+                } catch (PDOException $e) {
1046 1046
                         return "error : ".$e->getMessage();
1047 1047
                 }
1048 1048
         }
1049
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1049
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1050 1050
 		global $globalDBdriver;
1051 1051
 		if ($filter_name == '') $filter_name = $this->filter_name;
1052 1052
 		if ($globalDBdriver == 'mysql') {
@@ -1055,11 +1055,11 @@  discard block
 block discarded – undo
1055 1055
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1056 1056
 			$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);"; 
1057 1057
                 }
1058
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1058
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1059 1059
                  try {
1060 1060
                         $sth = $this->db->prepare($query);
1061 1061
                         $sth->execute($query_values);
1062
-                } catch(PDOException $e) {
1062
+                } catch (PDOException $e) {
1063 1063
                         return "error : ".$e->getMessage();
1064 1064
                 }
1065 1065
         }
@@ -1083,75 +1083,75 @@  discard block
 block discarded – undo
1083 1083
         }
1084 1084
         */
1085 1085
 
1086
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1086
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1087 1087
 		global $globalDBdriver;
1088 1088
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1089 1089
 		$query_values = array();
1090 1090
 		if ($globalDBdriver == 'mysql') {
1091 1091
 			if ($year != '') {
1092 1092
 				$query .= ' AND YEAR(stats_date) = :year';
1093
-				$query_values = array_merge($query_values,array(':year' => $year));
1093
+				$query_values = array_merge($query_values, array(':year' => $year));
1094 1094
 			}
1095 1095
 			if ($month != '') {
1096 1096
 				$query .= ' AND MONTH(stats_date) = :month';
1097
-				$query_values = array_merge($query_values,array(':month' => $month));
1097
+				$query_values = array_merge($query_values, array(':month' => $month));
1098 1098
 			}
1099 1099
 			if ($day != '') {
1100 1100
 				$query .= ' AND DAY(stats_date) = :day';
1101
-				$query_values = array_merge($query_values,array(':day' => $day));
1101
+				$query_values = array_merge($query_values, array(':day' => $day));
1102 1102
 			}
1103 1103
 		} else {
1104 1104
 			if ($year != '') {
1105 1105
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1106
-				$query_values = array_merge($query_values,array(':year' => $year));
1106
+				$query_values = array_merge($query_values, array(':year' => $year));
1107 1107
 			}
1108 1108
 			if ($month != '') {
1109 1109
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1110
-				$query_values = array_merge($query_values,array(':month' => $month));
1110
+				$query_values = array_merge($query_values, array(':month' => $month));
1111 1111
 			}
1112 1112
 			if ($day != '') {
1113 1113
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1114
-				$query_values = array_merge($query_values,array(':day' => $day));
1114
+				$query_values = array_merge($query_values, array(':day' => $day));
1115 1115
 			}
1116 1116
 		}
1117 1117
 		$query .= " ORDER BY source_name";
1118
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1118
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1119 1119
 		try {
1120 1120
 			$sth = $this->db->prepare($query);
1121 1121
 			$sth->execute($query_values);
1122
-		} catch(PDOException $e) {
1122
+		} catch (PDOException $e) {
1123 1123
 			echo "error : ".$e->getMessage();
1124 1124
 		}
1125 1125
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1126 1126
 		return $all;
1127 1127
 	}
1128 1128
 
1129
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1129
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1130 1130
 		global $globalDBdriver;
1131 1131
 		if ($globalDBdriver == 'mysql') {
1132 1132
 			$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";
1133 1133
 		} else {
1134 1134
 			$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);"; 
1135 1135
                 }
1136
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1136
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1137 1137
                  try {
1138 1138
                         $sth = $this->db->prepare($query);
1139 1139
                         $sth->execute($query_values);
1140
-                } catch(PDOException $e) {
1140
+                } catch (PDOException $e) {
1141 1141
                         return "error : ".$e->getMessage();
1142 1142
                 }
1143 1143
         }
1144
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1144
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1145 1145
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1146
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1146
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1147 1147
                  try {
1148 1148
                         $sth = $this->db->prepare($query);
1149 1149
                         $sth->execute($query_values);
1150
-                } catch(PDOException $e) {
1150
+                } catch (PDOException $e) {
1151 1151
                         return "error : ".$e->getMessage();
1152 1152
                 }
1153 1153
         }
1154
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1154
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1155 1155
 		global $globalDBdriver;
1156 1156
 		if ($globalDBdriver == 'mysql') {
1157 1157
 			if ($reset) {
@@ -1166,15 +1166,15 @@  discard block
 block discarded – undo
1166 1166
 				$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);"; 
1167 1167
 			}
1168 1168
 		}
1169
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1169
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1170 1170
                  try {
1171 1171
                         $sth = $this->db->prepare($query);
1172 1172
                         $sth->execute($query_values);
1173
-                } catch(PDOException $e) {
1173
+                } catch (PDOException $e) {
1174 1174
                         return "error : ".$e->getMessage();
1175 1175
                 }
1176 1176
         }
1177
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1177
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1178 1178
 		global $globalDBdriver;
1179 1179
 		if ($globalDBdriver == 'mysql') {
1180 1180
 			if ($reset) {
@@ -1189,15 +1189,15 @@  discard block
 block discarded – undo
1189 1189
 				$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);"; 
1190 1190
 			}
1191 1191
 		}
1192
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1192
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1193 1193
                  try {
1194 1194
                         $sth = $this->db->prepare($query);
1195 1195
                         $sth->execute($query_values);
1196
-                } catch(PDOException $e) {
1196
+                } catch (PDOException $e) {
1197 1197
                         return "error : ".$e->getMessage();
1198 1198
                 }
1199 1199
         }
1200
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1200
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1201 1201
 		global $globalDBdriver;
1202 1202
 		if ($globalDBdriver == 'mysql') {
1203 1203
 			if ($reset) {
@@ -1212,15 +1212,15 @@  discard block
 block discarded – undo
1212 1212
 				$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);"; 
1213 1213
 			}
1214 1214
 		}
1215
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1215
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1216 1216
                  try {
1217 1217
                         $sth = $this->db->prepare($query);
1218 1218
                         $sth->execute($query_values);
1219
-                } catch(PDOException $e) {
1219
+                } catch (PDOException $e) {
1220 1220
                         return "error : ".$e->getMessage();
1221 1221
                 }
1222 1222
         }
1223
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1223
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1224 1224
 		global $globalDBdriver;
1225 1225
 		if ($globalDBdriver == 'mysql') {
1226 1226
 			if ($reset) {
@@ -1235,15 +1235,15 @@  discard block
 block discarded – undo
1235 1235
 				$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);"; 
1236 1236
 			}
1237 1237
 		}
1238
-                $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);
1238
+                $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);
1239 1239
                  try {
1240 1240
                         $sth = $this->db->prepare($query);
1241 1241
                         $sth->execute($query_values);
1242
-                } catch(PDOException $e) {
1242
+                } catch (PDOException $e) {
1243 1243
                         return "error : ".$e->getMessage();
1244 1244
                 }
1245 1245
         }
1246
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1246
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1247 1247
 		global $globalDBdriver;
1248 1248
 		if ($globalDBdriver == 'mysql') {
1249 1249
 			if ($reset) {
@@ -1258,15 +1258,15 @@  discard block
 block discarded – undo
1258 1258
 				$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);"; 
1259 1259
 			}
1260 1260
 		}
1261
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1261
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1262 1262
                  try {
1263 1263
                         $sth = $this->db->prepare($query);
1264 1264
                         $sth->execute($query_values);
1265
-                } catch(PDOException $e) {
1265
+                } catch (PDOException $e) {
1266 1266
                         return "error : ".$e->getMessage();
1267 1267
                 }
1268 1268
         }
1269
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1269
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1270 1270
 		global $globalDBdriver;
1271 1271
 		if ($globalDBdriver == 'mysql') {
1272 1272
 			if ($reset) {
@@ -1281,15 +1281,15 @@  discard block
 block discarded – undo
1281 1281
 				$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);"; 
1282 1282
 			}
1283 1283
 		}
1284
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1284
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1285 1285
                  try {
1286 1286
                         $sth = $this->db->prepare($query);
1287 1287
                         $sth->execute($query_values);
1288
-                } catch(PDOException $e) {
1288
+                } catch (PDOException $e) {
1289 1289
                         return "error : ".$e->getMessage();
1290 1290
                 }
1291 1291
         }
1292
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1292
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1293 1293
 		global $globalDBdriver;
1294 1294
 		if ($globalDBdriver == 'mysql') {
1295 1295
 			if ($reset) {
@@ -1304,15 +1304,15 @@  discard block
 block discarded – undo
1304 1304
 				$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);"; 
1305 1305
 			}
1306 1306
 		}
1307
-                $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);
1307
+                $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);
1308 1308
                  try {
1309 1309
                         $sth = $this->db->prepare($query);
1310 1310
                         $sth->execute($query_values);
1311
-                } catch(PDOException $e) {
1311
+                } catch (PDOException $e) {
1312 1312
                         return "error : ".$e->getMessage();
1313 1313
                 }
1314 1314
         }
1315
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1315
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1316 1316
 		global $globalDBdriver;
1317 1317
 		if ($airport_icao != '') {
1318 1318
 			if ($globalDBdriver == 'mysql') {
@@ -1328,16 +1328,16 @@  discard block
 block discarded – undo
1328 1328
 					$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);"; 
1329 1329
 				}
1330 1330
 			}
1331
-			$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);
1331
+			$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);
1332 1332
 			try {
1333 1333
 				$sth = $this->db->prepare($query);
1334 1334
 				$sth->execute($query_values);
1335
-			} catch(PDOException $e) {
1335
+			} catch (PDOException $e) {
1336 1336
 				return "error : ".$e->getMessage();
1337 1337
 			}
1338 1338
                 }
1339 1339
         }
1340
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1340
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1341 1341
 		global $globalDBdriver;
1342 1342
 		if ($airport_icao != '') {
1343 1343
 			if ($globalDBdriver == 'mysql') {
@@ -1345,16 +1345,16 @@  discard block
 block discarded – undo
1345 1345
 			} else {
1346 1346
 				$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);"; 
1347 1347
 			}
1348
-			$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);
1348
+			$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);
1349 1349
 			 try {
1350 1350
 				$sth = $this->db->prepare($query);
1351 1351
 				$sth->execute($query_values);
1352
-			} catch(PDOException $e) {
1352
+			} catch (PDOException $e) {
1353 1353
 				return "error : ".$e->getMessage();
1354 1354
 			}
1355 1355
                 }
1356 1356
         }
1357
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1357
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1358 1358
 		global $globalDBdriver;
1359 1359
 		if ($airport_icao != '') {
1360 1360
 			if ($globalDBdriver == 'mysql') {
@@ -1370,16 +1370,16 @@  discard block
 block discarded – undo
1370 1370
 					$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);"; 
1371 1371
 				}
1372 1372
 			}
1373
-	                $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);
1373
+	                $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);
1374 1374
 			 try {
1375 1375
                     		$sth = $this->db->prepare($query);
1376 1376
 	                        $sth->execute($query_values);
1377
-    		        } catch(PDOException $e) {
1377
+    		        } catch (PDOException $e) {
1378 1378
             		        return "error : ".$e->getMessage();
1379 1379
 	                }
1380 1380
 	        }
1381 1381
         }
1382
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1382
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1383 1383
 		global $globalDBdriver;
1384 1384
 		if ($airport_icao != '') {
1385 1385
 			if ($globalDBdriver == 'mysql') {
@@ -1387,11 +1387,11 @@  discard block
 block discarded – undo
1387 1387
 			} else {
1388 1388
 				$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);"; 
1389 1389
 			}
1390
-			$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);
1390
+			$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);
1391 1391
 			try {
1392 1392
 				$sth = $this->db->prepare($query);
1393 1393
 				$sth->execute($query_values);
1394
-			} catch(PDOException $e) {
1394
+			} catch (PDOException $e) {
1395 1395
 				return "error : ".$e->getMessage();
1396 1396
 			}
1397 1397
                 }
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
                  try {
1404 1404
                         $sth = $this->db->prepare($query);
1405 1405
                         $sth->execute($query_values);
1406
-                } catch(PDOException $e) {
1406
+                } catch (PDOException $e) {
1407 1407
                         return "error : ".$e->getMessage();
1408 1408
                 }
1409 1409
         }
@@ -1413,7 +1413,7 @@  discard block
 block discarded – undo
1413 1413
                  try {
1414 1414
                         $sth = $this->db->prepare($query);
1415 1415
                         $sth->execute($query_values);
1416
-                } catch(PDOException $e) {
1416
+                } catch (PDOException $e) {
1417 1417
                         return "error : ".$e->getMessage();
1418 1418
                 }
1419 1419
         }
@@ -1423,13 +1423,13 @@  discard block
 block discarded – undo
1423 1423
                  try {
1424 1424
                         $sth = $this->db->prepare($query);
1425 1425
                         $sth->execute($query_values);
1426
-                } catch(PDOException $e) {
1426
+                } catch (PDOException $e) {
1427 1427
                         return "error : ".$e->getMessage();
1428 1428
                 }
1429 1429
         }
1430 1430
         
1431 1431
         public function addOldStats() {
1432
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1432
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1433 1433
     		$Common = new Common();
1434 1434
     		$Connection = new Connection();
1435 1435
     		date_default_timezone_set('UTC');
@@ -1446,40 +1446,40 @@  discard block
 block discarded – undo
1446 1446
 			$Spotter = new Spotter($this->db);
1447 1447
 
1448 1448
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1449
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1449
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1450 1450
 			foreach ($alldata as $number) {
1451
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1451
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1452 1452
 			}
1453 1453
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1454
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1454
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1455 1455
 			foreach ($alldata as $number) {
1456
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1456
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1457 1457
 			}
1458 1458
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1459
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1459
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1460 1460
 			foreach ($alldata as $number) {
1461
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1461
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1462 1462
 			}
1463 1463
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1464
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1464
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1465 1465
 			foreach ($alldata as $number) {
1466
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1466
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1467 1467
 			}
1468 1468
 			if ($globalDebug) echo 'Count all owners...'."\n";
1469
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1469
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1470 1470
 			foreach ($alldata as $number) {
1471
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1471
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1472 1472
 			}
1473 1473
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1474
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1474
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1475 1475
 			foreach ($alldata as $number) {
1476
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1476
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1477 1477
 			}
1478 1478
 			
1479 1479
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1480
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1480
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1481 1481
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1482
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1482
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1483 1483
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1484 1484
 	        	$alldata = array();
1485 1485
 	        	
@@ -1497,14 +1497,14 @@  discard block
 block discarded – undo
1497 1497
     			foreach ($alldata as $key => $row) {
1498 1498
     				$count[$key] = $row['airport_departure_icao_count'];
1499 1499
         		}
1500
-			array_multisort($count,SORT_DESC,$alldata);
1500
+			array_multisort($count, SORT_DESC, $alldata);
1501 1501
 			foreach ($alldata as $number) {
1502
-				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);
1502
+				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);
1503 1503
 			}
1504 1504
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1505
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1505
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1506 1506
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1507
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1507
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1508 1508
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1509 1509
 	        	$alldata = array();
1510 1510
     			foreach ($pall as $value) {
@@ -1521,16 +1521,16 @@  discard block
 block discarded – undo
1521 1521
         		foreach ($alldata as $key => $row) {
1522 1522
         			$count[$key] = $row['airport_arrival_icao_count'];
1523 1523
 	        	}
1524
-    			array_multisort($count,SORT_DESC,$alldata);
1524
+    			array_multisort($count, SORT_DESC, $alldata);
1525 1525
                         foreach ($alldata as $number) {
1526
-				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);
1526
+				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);
1527 1527
 			}
1528 1528
 			if ($Connection->tableExists('countries')) {
1529 1529
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1530 1530
 				$SpotterArchive = new SpotterArchive();
1531
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1531
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1532 1532
 				foreach ($alldata as $number) {
1533
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1533
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1534 1534
 				}
1535 1535
 			}
1536 1536
 			
@@ -1544,37 +1544,37 @@  discard block
 block discarded – undo
1544 1544
 			$lastyear = false;
1545 1545
 			foreach ($alldata as $number) {
1546 1546
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1547
-				$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'])));
1547
+				$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'])));
1548 1548
 			}
1549 1549
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1550 1550
 			$alldata = $Spotter->countAllMilitaryMonths();
1551 1551
 			foreach ($alldata as $number) {
1552
-				$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'])));
1552
+				$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'])));
1553 1553
 			}
1554 1554
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1555 1555
 			$alldata = $Spotter->countAllMonthsOwners();
1556 1556
 			foreach ($alldata as $number) {
1557
-				$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'])));
1557
+				$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'])));
1558 1558
 			}
1559 1559
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1560 1560
 			$alldata = $Spotter->countAllMonthsPilots();
1561 1561
 			foreach ($alldata as $number) {
1562
-				$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'])));
1562
+				$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'])));
1563 1563
 			}
1564 1564
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1565 1565
 			$alldata = $Spotter->countAllMonthsAirlines();
1566 1566
 			foreach ($alldata as $number) {
1567
-				$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'])));
1567
+				$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'])));
1568 1568
 			}
1569 1569
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1570 1570
 			$alldata = $Spotter->countAllMonthsAircrafts();
1571 1571
 			foreach ($alldata as $number) {
1572
-				$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'])));
1572
+				$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'])));
1573 1573
 			}
1574 1574
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1575 1575
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1576 1576
 			foreach ($alldata as $number) {
1577
-				$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'])));
1577
+				$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'])));
1578 1578
 			}
1579 1579
 			if ($globalDebug) echo 'Airports data...'."\n";
1580 1580
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
     			}
1620 1620
     			$alldata = $pall;
1621 1621
 			foreach ($alldata as $number) {
1622
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1622
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1623 1623
 			}
1624 1624
 			echo '...Arrival'."\n";
1625 1625
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
     			}
1662 1662
     			$alldata = $pall;
1663 1663
 			foreach ($alldata as $number) {
1664
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1664
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1665 1665
 			}
1666 1666
 
1667 1667
 			echo 'Flights data...'."\n";
@@ -1669,28 +1669,28 @@  discard block
 block discarded – undo
1669 1669
 			echo '-> countAllDatesLastMonth...'."\n";
1670 1670
 			$alldata = $Spotter->countAllDatesLastMonth();
1671 1671
 			foreach ($alldata as $number) {
1672
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1672
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1673 1673
 			}
1674 1674
 			echo '-> countAllDates...'."\n";
1675 1675
 			$previousdata = $this->countAllDates();
1676 1676
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1677 1677
 			$this->deleteStatFlight('date');
1678
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1678
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1679 1679
 			$values = array();
1680 1680
 			foreach ($alldata as $cnt) {
1681 1681
 				$values[] = $cnt['date_count'];
1682 1682
 			}
1683
-			array_multisort($values,SORT_DESC,$alldata);
1684
-			array_splice($alldata,11);
1683
+			array_multisort($values, SORT_DESC, $alldata);
1684
+			array_splice($alldata, 11);
1685 1685
 			foreach ($alldata as $number) {
1686
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1686
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1687 1687
 			}
1688 1688
 			
1689 1689
 			$this->deleteStatFlight('hour');
1690 1690
 			echo '-> countAllHours...'."\n";
1691 1691
 			$alldata = $Spotter->countAllHours('hour');
1692 1692
 			foreach ($alldata as $number) {
1693
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1693
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1694 1694
 			}
1695 1695
 
1696 1696
 
@@ -1700,41 +1700,41 @@  discard block
 block discarded – undo
1700 1700
 			if ($Connection->tableExists('countries')) {
1701 1701
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1702 1702
 				$SpotterArchive = new SpotterArchive();
1703
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1703
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1704 1704
 				foreach ($alldata as $number) {
1705
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1705
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1706 1706
 				}
1707 1707
 			}
1708 1708
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1709 1709
 			$Spotter = new Spotter($this->db);
1710
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1710
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1711 1711
 			foreach ($alldata as $number) {
1712
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1712
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1713 1713
 			}
1714 1714
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1715
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1715
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1716 1716
 			foreach ($alldata as $number) {
1717
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1717
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1718 1718
 			}
1719 1719
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1720
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1720
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1721 1721
 			foreach ($alldata as $number) {
1722
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1722
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1723 1723
 			}
1724 1724
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1725
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1725
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1726 1726
 			foreach ($alldata as $number) {
1727
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1727
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1728 1728
 			}
1729 1729
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1730
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1730
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1731 1731
 			foreach ($alldata as $number) {
1732
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1732
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1733 1733
 			}
1734 1734
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1735
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1735
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1736 1736
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1737
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1737
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1738 1738
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1739 1739
 	        	//$alldata = array();
1740 1740
     			foreach ($dall as $value) {
@@ -1754,12 +1754,12 @@  discard block
 block discarded – undo
1754 1754
     			}
1755 1755
     			$alldata = $pall;
1756 1756
 			foreach ($alldata as $number) {
1757
-				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);
1757
+				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);
1758 1758
 			}
1759 1759
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1760
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1760
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1761 1761
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1762
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1762
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1763 1763
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1764 1764
 	        	//$alldata = array();
1765 1765
     			foreach ($dall as $value) {
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
     			}
1780 1780
     			$alldata = $pall;
1781 1781
                         foreach ($alldata as $number) {
1782
-				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);
1782
+				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);
1783 1783
 			}
1784 1784
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1785 1785
 			$Spotter = new Spotter($this->db);
@@ -1787,27 +1787,27 @@  discard block
 block discarded – undo
1787 1787
 			$lastyear = false;
1788 1788
 			foreach ($alldata as $number) {
1789 1789
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1790
-				$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']);
1790
+				$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']);
1791 1791
 			}
1792 1792
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1793 1793
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1794 1794
 			foreach ($alldata as $number) {
1795
-				$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']);
1795
+				$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']);
1796 1796
 			}
1797 1797
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1798 1798
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1799 1799
 			foreach ($alldata as $number) {
1800
-				$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']);
1800
+				$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']);
1801 1801
 			}
1802 1802
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1803 1803
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1804 1804
 			foreach ($alldata as $number) {
1805
-				$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']);
1805
+				$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']);
1806 1806
 			}
1807 1807
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1808 1808
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1809 1809
 			foreach ($alldata as $number) {
1810
-				$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']);
1810
+				$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']);
1811 1811
 			}
1812 1812
 			if ($globalDebug) echo '...Departure'."\n";
1813 1813
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
     			}
1831 1831
     			$alldata = $pall;
1832 1832
 			foreach ($alldata as $number) {
1833
-				$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']);
1833
+				$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']);
1834 1834
 			}
1835 1835
 			if ($globalDebug) echo '...Arrival'."\n";
1836 1836
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1853,32 +1853,32 @@  discard block
 block discarded – undo
1853 1853
     			}
1854 1854
     			$alldata = $pall;
1855 1855
 			foreach ($alldata as $number) {
1856
-				$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']);
1856
+				$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']);
1857 1857
 			}
1858 1858
 
1859 1859
 			if ($globalDebug) echo 'Flights data...'."\n";
1860 1860
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1861 1861
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1862 1862
 			foreach ($alldata as $number) {
1863
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1863
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1864 1864
 			}
1865 1865
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1866 1866
 			//$previousdata = $this->countAllDatesByAirlines();
1867
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1867
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1868 1868
 			$values = array();
1869 1869
 			foreach ($alldata as $cnt) {
1870 1870
 				$values[] = $cnt['date_count'];
1871 1871
 			}
1872
-			array_multisort($values,SORT_DESC,$alldata);
1873
-			array_splice($alldata,11);
1872
+			array_multisort($values, SORT_DESC, $alldata);
1873
+			array_splice($alldata, 11);
1874 1874
 			foreach ($alldata as $number) {
1875
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1875
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1876 1876
 			}
1877 1877
 			
1878 1878
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1879 1879
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1880 1880
 			foreach ($alldata as $number) {
1881
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1881
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1882 1882
 			}
1883 1883
 			
1884 1884
 
@@ -1897,32 +1897,32 @@  discard block
 block discarded – undo
1897 1897
 				// Count by filter
1898 1898
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1899 1899
 				$Spotter = new Spotter($this->db);
1900
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1900
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1901 1901
 				foreach ($alldata as $number) {
1902
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1902
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1903 1903
 				}
1904
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1904
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1905 1905
 				foreach ($alldata as $number) {
1906
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1906
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1907 1907
 				}
1908
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1908
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1909 1909
 				foreach ($alldata as $number) {
1910
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1910
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1911 1911
 				}
1912
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1912
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1913 1913
 				foreach ($alldata as $number) {
1914
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1914
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1915 1915
 				}
1916
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1916
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1917 1917
 				foreach ($alldata as $number) {
1918
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1918
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1919 1919
 				}
1920
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1920
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1921 1921
 				foreach ($alldata as $number) {
1922
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1922
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1923 1923
 				}
1924
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1925
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1924
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1925
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1926 1926
 		        	$alldata = array();
1927 1927
 	    			foreach ($pall as $value) {
1928 1928
 		        		$icao = $value['airport_departure_icao'];
@@ -1938,12 +1938,12 @@  discard block
 block discarded – undo
1938 1938
     				foreach ($alldata as $key => $row) {
1939 1939
     					$count[$key] = $row['airport_departure_icao_count'];
1940 1940
     				}
1941
-				array_multisort($count,SORT_DESC,$alldata);
1941
+				array_multisort($count, SORT_DESC, $alldata);
1942 1942
 				foreach ($alldata as $number) {
1943
-    					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);
1943
+    					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);
1944 1944
 				}
1945
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1946
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1945
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1946
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1947 1947
 				$alldata = array();
1948 1948
     				foreach ($pall as $value) {
1949 1949
 		        		$icao = $value['airport_arrival_icao'];
@@ -1959,40 +1959,40 @@  discard block
 block discarded – undo
1959 1959
         			foreach ($alldata as $key => $row) {
1960 1960
     					$count[$key] = $row['airport_arrival_icao_count'];
1961 1961
 		        	}
1962
-        			array_multisort($count,SORT_DESC,$alldata);
1962
+        			array_multisort($count, SORT_DESC, $alldata);
1963 1963
 				foreach ($alldata as $number) {
1964
-					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);
1964
+					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);
1965 1965
 				}
1966 1966
 				$Spotter = new Spotter($this->db);
1967 1967
 				$alldata = $Spotter->countAllMonths($filter);
1968 1968
 				$lastyear = false;
1969 1969
 				foreach ($alldata as $number) {
1970 1970
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1971
-					$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);
1971
+					$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);
1972 1972
 				}
1973 1973
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1974 1974
 				foreach ($alldata as $number) {
1975
-					$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);
1975
+					$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);
1976 1976
 				}
1977 1977
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1978 1978
 				foreach ($alldata as $number) {
1979
-					$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);
1979
+					$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);
1980 1980
 				}
1981 1981
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
1982 1982
 				foreach ($alldata as $number) {
1983
-					$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);
1983
+					$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);
1984 1984
 				}
1985 1985
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1986 1986
 				foreach ($alldata as $number) {
1987
-					$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);
1987
+					$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);
1988 1988
 				}
1989 1989
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1990 1990
 				foreach ($alldata as $number) {
1991
-					$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);
1991
+					$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);
1992 1992
 				}
1993 1993
 				echo '...Departure'."\n";
1994
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1995
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1994
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1995
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1996 1996
 				foreach ($dall as $value) {
1997 1997
     					$icao = $value['departure_airport_icao'];
1998 1998
     					$ddate = $value['date'];
@@ -2010,11 +2010,11 @@  discard block
 block discarded – undo
2010 2010
     				}
2011 2011
 	    			$alldata = $pall;
2012 2012
 				foreach ($alldata as $number) {
2013
-					$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);
2013
+					$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);
2014 2014
 				}
2015 2015
 				echo '...Arrival'."\n";
2016
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2017
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2016
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
2017
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
2018 2018
 				foreach ($dall as $value) {
2019 2019
 					$icao = $value['arrival_airport_icao'];
2020 2020
 					$ddate = $value['date'];
@@ -2032,40 +2032,40 @@  discard block
 block discarded – undo
2032 2032
     				}
2033 2033
     				$alldata = $pall;
2034 2034
 				foreach ($alldata as $number) {
2035
-					$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);
2035
+					$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);
2036 2036
 				}
2037 2037
     
2038 2038
 				echo 'Flights data...'."\n";
2039 2039
 				echo '-> countAllDatesLastMonth...'."\n";
2040 2040
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
2041 2041
 				foreach ($alldata as $number) {
2042
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2042
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2043 2043
 				}
2044 2044
 				echo '-> countAllDates...'."\n";
2045
-				$previousdata = $this->countAllDates('',$filter_name);
2046
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2045
+				$previousdata = $this->countAllDates('', $filter_name);
2046
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2047 2047
 				$values = array();
2048 2048
 				foreach ($alldata as $cnt) {
2049 2049
 					$values[] = $cnt['date_count'];
2050 2050
 				}
2051
-				array_multisort($values,SORT_DESC,$alldata);
2052
-				array_splice($alldata,11);
2051
+				array_multisort($values, SORT_DESC, $alldata);
2052
+				array_splice($alldata, 11);
2053 2053
 				foreach ($alldata as $number) {
2054
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2054
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2055 2055
 				}
2056 2056
 				
2057 2057
 				echo '-> countAllHours...'."\n";
2058
-				$alldata = $Spotter->countAllHours('hour',$filter);
2058
+				$alldata = $Spotter->countAllHours('hour', $filter);
2059 2059
 				foreach ($alldata as $number) {
2060
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2060
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2061 2061
 				}
2062 2062
 				echo 'Insert last stats update date...'."\n";
2063 2063
 				date_default_timezone_set('UTC');
2064
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2064
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2065 2065
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2066
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2066
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2067 2067
 						$this->deleteOldStats($filter_name);
2068
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2068
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2069 2069
 					}
2070 2070
 				}
2071 2071
 
@@ -2078,16 +2078,16 @@  discard block
 block discarded – undo
2078 2078
 				// SUM all previous month to put as year
2079 2079
 				$previous_year = date('Y');
2080 2080
 				$previous_year--;
2081
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2082
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2083
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2084
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2081
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2082
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2083
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2084
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2085 2085
 				$allairlines = $this->getAllAirlineNames();
2086 2086
 				foreach ($allairlines as $data) {
2087
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2088
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2089
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2090
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2087
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2088
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2089
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2090
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2091 2091
 				}
2092 2092
 				
2093 2093
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2096,7 +2096,7 @@  discard block
 block discarded – undo
2096 2096
 						try {
2097 2097
 							$sth = $this->db->prepare($query);
2098 2098
 							$sth->execute();
2099
-						} catch(PDOException $e) {
2099
+						} catch (PDOException $e) {
2100 2100
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2101 2101
 						}
2102 2102
 					}
@@ -2105,15 +2105,15 @@  discard block
 block discarded – undo
2105 2105
 					try {
2106 2106
 						$sth = $this->db->prepare($query);
2107 2107
 						$sth->execute();
2108
-					} catch(PDOException $e) {
2108
+					} catch (PDOException $e) {
2109 2109
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2110 2110
 					}
2111 2111
 				}
2112 2112
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2113 2113
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2114
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2114
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2115 2115
 						$this->deleteOldStats();
2116
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2116
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2117 2117
 						$lastyearupdate = true;
2118 2118
 					}
2119 2119
 				}
@@ -2135,7 +2135,7 @@  discard block
 block discarded – undo
2135 2135
 					try {
2136 2136
 						$sth = $this->db->prepare($query);
2137 2137
 						$sth->execute();
2138
-					} catch(PDOException $e) {
2138
+					} catch (PDOException $e) {
2139 2139
 						return "error : ".$e->getMessage();
2140 2140
 					}
2141 2141
 				}
@@ -2149,14 +2149,14 @@  discard block
 block discarded – undo
2149 2149
 				try {
2150 2150
 					$sth = $this->db->prepare($query);
2151 2151
 					$sth->execute();
2152
-				} catch(PDOException $e) {
2152
+				} catch (PDOException $e) {
2153 2153
 					return "error : ".$e->getMessage();
2154 2154
 				}
2155 2155
 			}
2156 2156
 			if (!isset($lastyearupdate)) {
2157 2157
 				echo 'Insert last stats update date...'."\n";
2158 2158
 				date_default_timezone_set('UTC');
2159
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2159
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2160 2160
 			}
2161 2161
 			if ($globalStatsResetYear) {
2162 2162
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +476 added lines, -165 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $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";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $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";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -126,7 +136,9 @@  discard block
 block discarded – undo
126 136
         }
127 137
 
128 138
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129
-		if ($filter_name == '') $filter_name = $this->filter_name;
139
+		if ($filter_name == '') {
140
+			$filter_name = $this->filter_name;
141
+		}
130 142
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 143
                  try {
132 144
                         $sth = $this->db->prepare($query);
@@ -139,7 +151,9 @@  discard block
 block discarded – undo
139 151
         }
140 152
 
141 153
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
+		if ($filter_name == '') {
155
+			$filter_name = $this->filter_name;
156
+		}
143 157
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 158
                  try {
145 159
                         $sth = $this->db->prepare($query);
@@ -154,10 +168,15 @@  discard block
 block discarded – undo
154 168
 
155 169
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
156 170
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
171
+		if ($filter_name == '') {
172
+			$filter_name = $this->filter_name;
173
+		}
158 174
 		if ($year == '' && $month == '') {
159
-			if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
160
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
175
+			if ($limit) {
176
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
177
+			} else {
178
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
179
+			}
161 180
 			try {
162 181
 				$sth = $this->db->prepare($query);
163 182
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -165,7 +184,9 @@  discard block
 block discarded – undo
165 184
 				echo "error : ".$e->getMessage();
166 185
 			}
167 186
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168
-		} else $all = array();
187
+		} else {
188
+			$all = array();
189
+		}
169 190
                 if (empty($all)) {
170 191
             	    $filters = array('airlines' => array($stats_airline));
171 192
             	    if ($filter_name != '') {
@@ -178,10 +199,15 @@  discard block
 block discarded – undo
178 199
 	}
179 200
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 201
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
202
+		if ($filter_name == '') {
203
+			$filter_name = $this->filter_name;
204
+		}
182 205
 		if ($year == '' && $month == '') {
183
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
184
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
206
+			if ($limit) {
207
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
208
+			} else {
209
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
210
+			}
185 211
 			try {
186 212
 				$sth = $this->db->prepare($query);
187 213
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -189,7 +215,9 @@  discard block
 block discarded – undo
189 215
 				echo "error : ".$e->getMessage();
190 216
 			}
191 217
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-		} else $all = array();
218
+		} else {
219
+			$all = array();
220
+		}
193 221
                 if (empty($all)) {
194 222
             		$Spotter = new Spotter($this->db);
195 223
             		$filters = array();
@@ -202,10 +230,15 @@  discard block
 block discarded – undo
202 230
 	}
203 231
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 232
 		global $globalStatsFilters;
205
-		if ($filter_name == '') $filter_name = $this->filter_name;
233
+		if ($filter_name == '') {
234
+			$filter_name = $this->filter_name;
235
+		}
206 236
 		if ($year == '' && $month == '') {
207
-			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";
208
-			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";
237
+			if ($limit) {
238
+				$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";
239
+			} else {
240
+				$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";
241
+			}
209 242
 			try {
210 243
 				$sth = $this->db->prepare($query);
211 244
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -213,7 +246,9 @@  discard block
 block discarded – undo
213 246
 				echo "error : ".$e->getMessage();
214 247
 			}
215 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
216
-		} else $all = array();
249
+		} else {
250
+			$all = array();
251
+		}
217 252
 		if (empty($all)) {
218 253
 			$filters = array('airlines' => array($stats_airline));
219 254
 			if ($filter_name != '') {
@@ -227,10 +262,15 @@  discard block
 block discarded – undo
227 262
 
228 263
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
229 264
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
265
+		if ($filter_name == '') {
266
+			$filter_name = $this->filter_name;
267
+		}
231 268
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
269
+			if ($limit) {
270
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
271
+			} else {
272
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
273
+			}
234 274
 			try {
235 275
 				$sth = $this->db->prepare($query);
236 276
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -238,7 +278,9 @@  discard block
 block discarded – undo
238 278
 				echo "error : ".$e->getMessage();
239 279
 			}
240 280
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
281
+		} else {
282
+			$all = array();
283
+		}
242 284
                 if (empty($all)) {
243 285
 			$filters = array('airlines' => array($stats_airline));
244 286
 			if ($filter_name != '') {
@@ -251,9 +293,14 @@  discard block
 block discarded – undo
251 293
 	}
252 294
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 295
 		global $globalStatsFilters;
254
-		if ($filter_name == '') $filter_name = $this->filter_name;
255
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
296
+		if ($filter_name == '') {
297
+			$filter_name = $this->filter_name;
298
+		}
299
+		if ($limit) {
300
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
301
+		} else {
302
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
303
+		}
257 304
                  try {
258 305
                         $sth = $this->db->prepare($query);
259 306
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -274,17 +321,29 @@  discard block
 block discarded – undo
274 321
 
275 322
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
276 323
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
277
-		if ($filter_name == '') $filter_name = $this->filter_name;
324
+		if ($filter_name == '') {
325
+			$filter_name = $this->filter_name;
326
+		}
278 327
 		if ($year == '' && $month == '') {
279
-			if ($globalVATSIM) $forsource = 'vatsim';
280
-			if ($globalIVAO) $forsource = 'ivao';
328
+			if ($globalVATSIM) {
329
+				$forsource = 'vatsim';
330
+			}
331
+			if ($globalIVAO) {
332
+				$forsource = 'ivao';
333
+			}
281 334
 			if (isset($forsource)) {
282
-				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";
283
-				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";
335
+				if ($limit) {
336
+					$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";
337
+				} else {
338
+					$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";
339
+				}
284 340
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
285 341
 			} else {
286
-				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";
287
-				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";
342
+				if ($limit) {
343
+					$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";
344
+				} else {
345
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
346
+				}
288 347
 				$query_values = array(':filter_name' => $filter_name);
289 348
 			}
290 349
 			try {
@@ -294,7 +353,9 @@  discard block
 block discarded – undo
294 353
 				echo "error : ".$e->getMessage();
295 354
 			}
296 355
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
297
-		} else $all = array();
356
+		} else {
357
+			$all = array();
358
+		}
298 359
                 if (empty($all)) {
299 360
 	                $Spotter = new Spotter($this->db);
300 361
             		$filters = array();
@@ -307,10 +368,15 @@  discard block
 block discarded – undo
307 368
 	}
308 369
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
309 370
 		global $globalStatsFilters;
310
-		if ($filter_name == '') $filter_name = $this->filter_name;
371
+		if ($filter_name == '') {
372
+			$filter_name = $this->filter_name;
373
+		}
311 374
 		if ($year == '' && $month == '') {
312
-			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";
313
-			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";
375
+			if ($limit) {
376
+				$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";
377
+			} else {
378
+				$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";
379
+			}
314 380
 			try {
315 381
 				$sth = $this->db->prepare($query);
316 382
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -318,7 +384,9 @@  discard block
 block discarded – undo
318 384
 				echo "error : ".$e->getMessage();
319 385
 			}
320 386
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
321
-		} else $all = array();
387
+		} else {
388
+			$all = array();
389
+		}
322 390
                 if (empty($all)) {
323 391
 			$filters = array('airlines' => array($stats_airline));
324 392
 			if ($filter_name != '') {
@@ -331,10 +399,15 @@  discard block
 block discarded – undo
331 399
 	}
332 400
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
333 401
 		global $globalStatsFilters;
334
-		if ($filter_name == '') $filter_name = $this->filter_name;
402
+		if ($filter_name == '') {
403
+			$filter_name = $this->filter_name;
404
+		}
335 405
 		if ($year == '' && $month == '') {
336
-			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";
337
-			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";
406
+			if ($limit) {
407
+				$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";
408
+			} else {
409
+				$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";
410
+			}
338 411
 			 try {
339 412
 				$sth = $this->db->prepare($query);
340 413
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -342,7 +415,9 @@  discard block
 block discarded – undo
342 415
 				echo "error : ".$e->getMessage();
343 416
 			}
344 417
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
345
-		} else $all = array();
418
+		} else {
419
+			$all = array();
420
+		}
346 421
 		if (empty($all)) {
347 422
 			$filters = array('airlines' => array($stats_airline));
348 423
 			if ($filter_name != '') {
@@ -355,11 +430,16 @@  discard block
 block discarded – undo
355 430
 	}
356 431
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
357 432
 		$Connection = new Connection();
358
-		if ($filter_name == '') $filter_name = $this->filter_name;
433
+		if ($filter_name == '') {
434
+			$filter_name = $this->filter_name;
435
+		}
359 436
 		if ($Connection->tableExists('countries')) {
360 437
 			if ($year == '' && $month == '') {
361
-				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";
362
-				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";
438
+				if ($limit) {
439
+					$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";
440
+				} else {
441
+					$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";
442
+				}
363 443
 				 try {
364 444
 					$sth = $this->db->prepare($query);
365 445
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -374,17 +454,24 @@  discard block
 block discarded – undo
374 454
                 }
375 455
                 */
376 456
 				return $all;
377
-			} else return array();
457
+			} else {
458
+				return array();
459
+			}
378 460
 		} else {
379 461
 			return array();
380 462
 		}
381 463
 	}
382 464
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
383 465
 		global $globalStatsFilters;
384
-		if ($filter_name == '') $filter_name = $this->filter_name;
466
+		if ($filter_name == '') {
467
+			$filter_name = $this->filter_name;
468
+		}
385 469
 		if ($year == '' && $month == '') {
386
-			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";
387
-			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";
470
+			if ($limit) {
471
+				$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";
472
+			} else {
473
+				$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";
474
+			}
388 475
 			try {
389 476
 				$sth = $this->db->prepare($query);
390 477
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -392,7 +479,9 @@  discard block
 block discarded – undo
392 479
 				echo "error : ".$e->getMessage();
393 480
 			}
394 481
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
395
-		} else $all = array();
482
+		} else {
483
+			$all = array();
484
+		}
396 485
 		if (empty($all)) {
397 486
 			$filters = array('airlines' => array($stats_airline));
398 487
 			if ($filter_name != '') {
@@ -406,10 +495,15 @@  discard block
 block discarded – undo
406 495
 
407 496
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
408 497
 		global $globalStatsFilters;
409
-		if ($filter_name == '') $filter_name = $this->filter_name;
498
+		if ($filter_name == '') {
499
+			$filter_name = $this->filter_name;
500
+		}
410 501
 		if ($year == '' && $month == '') {
411
-			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";
412
-			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";
502
+			if ($limit) {
503
+				$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";
504
+			} else {
505
+				$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";
506
+			}
413 507
 			try {
414 508
 				$sth = $this->db->prepare($query);
415 509
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -417,7 +511,9 @@  discard block
 block discarded – undo
417 511
 				echo "error : ".$e->getMessage();
418 512
 			}
419 513
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
420
-		} else $all = array();
514
+		} else {
515
+			$all = array();
516
+		}
421 517
                 if (empty($all)) {
422 518
 			$filters = array('airlines' => array($stats_airline));
423 519
 			if ($filter_name != '') {
@@ -430,10 +526,15 @@  discard block
 block discarded – undo
430 526
 	}
431 527
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
432 528
 		global $globalStatsFilters;
433
-		if ($filter_name == '') $filter_name = $this->filter_name;
529
+		if ($filter_name == '') {
530
+			$filter_name = $this->filter_name;
531
+		}
434 532
 		if ($year == '' && $month == '') {
435
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
436
-			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
533
+			if ($limit) {
534
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
535
+			} else {
536
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
537
+			}
437 538
 			try {
438 539
 				$sth = $this->db->prepare($query);
439 540
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -441,7 +542,9 @@  discard block
 block discarded – undo
441 542
 				echo "error : ".$e->getMessage();
442 543
 			}
443 544
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
444
-		} else $all = array();
545
+		} else {
546
+			$all = array();
547
+		}
445 548
                 if (empty($all)) {
446 549
 			$filters = array('airlines' => array($stats_airline));
447 550
             		if ($filter_name != '') {
@@ -460,7 +563,9 @@  discard block
 block discarded – undo
460 563
         			$icao = $value['airport_departure_icao'];
461 564
         			if (isset($all[$icao])) {
462 565
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
463
-        			} else $all[$icao] = $value;
566
+        			} else {
567
+        				$all[$icao] = $value;
568
+        			}
464 569
         		}
465 570
         		$count = array();
466 571
         		foreach ($all as $key => $row) {
@@ -472,10 +577,15 @@  discard block
 block discarded – undo
472 577
 	}
473 578
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
474 579
 		global $globalStatsFilters;
475
-		if ($filter_name == '') $filter_name = $this->filter_name;
580
+		if ($filter_name == '') {
581
+			$filter_name = $this->filter_name;
582
+		}
476 583
 		if ($year == '' && $month == '') {
477
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
478
-			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
584
+			if ($limit) {
585
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
586
+			} else {
587
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
588
+			}
479 589
 			try {
480 590
 				$sth = $this->db->prepare($query);
481 591
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -483,7 +593,9 @@  discard block
 block discarded – undo
483 593
 				echo "error : ".$e->getMessage();
484 594
 			}
485 595
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486
-		} else $all = array();
596
+		} else {
597
+			$all = array();
598
+		}
487 599
 		if (empty($all)) {
488 600
 			$filters = array('airlines' => array($stats_airline));
489 601
 			if ($filter_name != '') {
@@ -502,7 +614,9 @@  discard block
 block discarded – undo
502 614
         			$icao = $value['airport_arrival_icao'];
503 615
         			if (isset($all[$icao])) {
504 616
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
505
-        			} else $all[$icao] = $value;
617
+        			} else {
618
+        				$all[$icao] = $value;
619
+        			}
506 620
         		}
507 621
         		$count = array();
508 622
         		foreach ($all as $key => $row) {
@@ -515,13 +629,21 @@  discard block
 block discarded – undo
515 629
 	}
516 630
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
517 631
 		global $globalDBdriver, $globalStatsFilters;
518
-		if ($filter_name == '') $filter_name = $this->filter_name;
632
+		if ($filter_name == '') {
633
+			$filter_name = $this->filter_name;
634
+		}
519 635
 		if ($globalDBdriver == 'mysql') {
520
-			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";
521
-			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";
636
+			if ($limit) {
637
+				$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";
638
+			} else {
639
+				$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";
640
+			}
522 641
 		} else {
523
-			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";
524
-			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";
642
+			if ($limit) {
643
+				$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";
644
+			} else {
645
+				$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";
646
+			}
525 647
 		}
526 648
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
527 649
                  try {
@@ -545,7 +667,9 @@  discard block
 block discarded – undo
545 667
 	
546 668
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
547 669
 		global $globalStatsFilters;
548
-		if ($filter_name == '') $filter_name = $this->filter_name;
670
+		if ($filter_name == '') {
671
+			$filter_name = $this->filter_name;
672
+		}
549 673
 		$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";
550 674
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
551 675
                  try {
@@ -567,7 +691,9 @@  discard block
 block discarded – undo
567 691
 	}
568 692
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
569 693
 		global $globalDBdriver, $globalStatsFilters;
570
-		if ($filter_name == '') $filter_name = $this->filter_name;
694
+		if ($filter_name == '') {
695
+			$filter_name = $this->filter_name;
696
+		}
571 697
 		if ($globalDBdriver == 'mysql') {
572 698
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
573 699
 		} else {
@@ -593,7 +719,9 @@  discard block
 block discarded – undo
593 719
 	}
594 720
 	public function countAllDates($stats_airline = '',$filter_name = '') {
595 721
 		global $globalStatsFilters;
596
-		if ($filter_name == '') $filter_name = $this->filter_name;
722
+		if ($filter_name == '') {
723
+			$filter_name = $this->filter_name;
724
+		}
597 725
 		$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";
598 726
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
599 727
                  try {
@@ -615,7 +743,9 @@  discard block
 block discarded – undo
615 743
 	}
616 744
 	public function countAllDatesByAirlines($filter_name = '') {
617 745
 		global $globalStatsFilters;
618
-		if ($filter_name == '') $filter_name = $this->filter_name;
746
+		if ($filter_name == '') {
747
+			$filter_name = $this->filter_name;
748
+		}
619 749
 		$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";
620 750
 		$query_data = array('filter_name' => $filter_name);
621 751
                  try {
@@ -637,7 +767,9 @@  discard block
 block discarded – undo
637 767
 	}
638 768
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
639 769
 		global $globalStatsFilters;
640
-		if ($filter_name == '') $filter_name = $this->filter_name;
770
+		if ($filter_name == '') {
771
+			$filter_name = $this->filter_name;
772
+		}
641 773
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
642 774
                  try {
643 775
                         $sth = $this->db->prepare($query);
@@ -660,7 +792,9 @@  discard block
 block discarded – undo
660 792
 	}
661 793
 	public function countAllMilitaryMonths($filter_name = '') {
662 794
 		global $globalStatsFilters;
663
-		if ($filter_name == '') $filter_name = $this->filter_name;
795
+		if ($filter_name == '') {
796
+			$filter_name = $this->filter_name;
797
+		}
664 798
 	    	$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";
665 799
                  try {
666 800
                         $sth = $this->db->prepare($query);
@@ -681,9 +815,14 @@  discard block
 block discarded – undo
681 815
 	}
682 816
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
683 817
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
684
-		if ($filter_name == '') $filter_name = $this->filter_name;
685
-		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";
686
-		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";
818
+		if ($filter_name == '') {
819
+			$filter_name = $this->filter_name;
820
+		}
821
+		if ($limit) {
822
+			$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";
823
+		} else {
824
+			$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";
825
+		}
687 826
 		if ($orderby == 'hour') {
688 827
 			/*
689 828
 			if ($globalDBdriver == 'mysql') {
@@ -692,7 +831,9 @@  discard block
 block discarded – undo
692 831
 			*/
693 832
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
694 833
 		}
695
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
834
+		if ($orderby == 'count') {
835
+			$query .= " ORDER BY hour_count DESC";
836
+		}
696 837
                  try {
697 838
                         $sth = $this->db->prepare($query);
698 839
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -713,8 +854,12 @@  discard block
 block discarded – undo
713 854
 	
714 855
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
715 856
 		global $globalStatsFilters;
716
-		if ($filter_name == '') $filter_name = $this->filter_name;
717
-		if ($year == '') $year = date('Y');
857
+		if ($filter_name == '') {
858
+			$filter_name = $this->filter_name;
859
+		}
860
+		if ($year == '') {
861
+			$year = date('Y');
862
+		}
718 863
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
719 864
 		if (empty($all)) {
720 865
 			$filters = array('airlines' => array($stats_airline));
@@ -728,8 +873,12 @@  discard block
 block discarded – undo
728 873
 	}
729 874
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
730 875
 		global $globalStatsFilters;
731
-		if ($filter_name == '') $filter_name = $this->filter_name;
732
-		if ($year == '') $year = date('Y');
876
+		if ($filter_name == '') {
877
+			$filter_name = $this->filter_name;
878
+		}
879
+		if ($year == '') {
880
+			$year = date('Y');
881
+		}
733 882
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
734 883
 		if (empty($all)) {
735 884
 		        $filters = array();
@@ -743,8 +892,12 @@  discard block
 block discarded – undo
743 892
 	}
744 893
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
745 894
 		global $globalStatsFilters;
746
-		if ($filter_name == '') $filter_name = $this->filter_name;
747
-		if ($year == '') $year = date('Y');
895
+		if ($filter_name == '') {
896
+			$filter_name = $this->filter_name;
897
+		}
898
+		if ($year == '') {
899
+			$year = date('Y');
900
+		}
748 901
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
749 902
 		if (empty($all)) {
750 903
 			$filters = array('airlines' => array($stats_airline));
@@ -758,7 +911,9 @@  discard block
 block discarded – undo
758 911
 	}
759 912
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
760 913
 		global $globalStatsFilters;
761
-		if ($filter_name == '') $filter_name = $this->filter_name;
914
+		if ($filter_name == '') {
915
+			$filter_name = $this->filter_name;
916
+		}
762 917
 		if ($year == '' && $month == '') {
763 918
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
764 919
 			try {
@@ -769,7 +924,9 @@  discard block
 block discarded – undo
769 924
 			}
770 925
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
771 926
 			$all = $result[0]['nb'];
772
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
927
+		} else {
928
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
929
+		}
773 930
 		if (empty($all)) {
774 931
 			$filters = array('airlines' => array($stats_airline));
775 932
 			if ($filter_name != '') {
@@ -782,7 +939,9 @@  discard block
 block discarded – undo
782 939
 	}
783 940
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
784 941
 		global $globalStatsFilters;
785
-		if ($filter_name == '') $filter_name = $this->filter_name;
942
+		if ($filter_name == '') {
943
+			$filter_name = $this->filter_name;
944
+		}
786 945
 		if ($year == '' && $month == '') {
787 946
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
788 947
 			try {
@@ -793,7 +952,9 @@  discard block
 block discarded – undo
793 952
 			}
794 953
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
795 954
 			$all = $result[0]['nb_airline'];
796
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
955
+		} else {
956
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
957
+		}
797 958
 		if (empty($all)) {
798 959
             		$filters = array();
799 960
             		if ($filter_name != '') {
@@ -806,7 +967,9 @@  discard block
 block discarded – undo
806 967
 	}
807 968
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
808 969
 		global $globalStatsFilters;
809
-		if ($filter_name == '') $filter_name = $this->filter_name;
970
+		if ($filter_name == '') {
971
+			$filter_name = $this->filter_name;
972
+		}
810 973
 		if ($year == '' && $month == '') {
811 974
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
812 975
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -833,7 +996,9 @@  discard block
 block discarded – undo
833 996
 	}
834 997
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
835 998
 		global $globalStatsFilters;
836
-		if ($filter_name == '') $filter_name = $this->filter_name;
999
+		if ($filter_name == '') {
1000
+			$filter_name = $this->filter_name;
1001
+		}
837 1002
 		//if ($year == '') $year = date('Y');
838 1003
 		if ($year == '' && $month == '') {
839 1004
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -861,7 +1026,9 @@  discard block
 block discarded – undo
861 1026
 	}
862 1027
 
863 1028
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
864
-		if ($filter_name == '') $filter_name = $this->filter_name;
1029
+		if ($filter_name == '') {
1030
+			$filter_name = $this->filter_name;
1031
+		}
865 1032
 		$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";
866 1033
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
867 1034
                  try {
@@ -874,7 +1041,9 @@  discard block
 block discarded – undo
874 1041
                 return $all;
875 1042
 	}
876 1043
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
877
-		if ($filter_name == '') $filter_name = $this->filter_name;
1044
+		if ($filter_name == '') {
1045
+			$filter_name = $this->filter_name;
1046
+		}
878 1047
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
879 1048
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
880 1049
                  try {
@@ -887,7 +1056,9 @@  discard block
 block discarded – undo
887 1056
                 return $all;
888 1057
         }
889 1058
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
890
-		if ($filter_name == '') $filter_name = $this->filter_name;
1059
+		if ($filter_name == '') {
1060
+			$filter_name = $this->filter_name;
1061
+		}
891 1062
     		global $globalArchiveMonths, $globalDBdriver;
892 1063
     		if ($globalDBdriver == 'mysql') {
893 1064
     			if ($month == '') {
@@ -917,7 +1088,9 @@  discard block
 block discarded – undo
917 1088
         }
918 1089
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
919 1090
     		global $globalArchiveMonths, $globalDBdriver;
920
-		if ($filter_name == '') $filter_name = $this->filter_name;
1091
+		if ($filter_name == '') {
1092
+			$filter_name = $this->filter_name;
1093
+		}
921 1094
     		if ($globalDBdriver == 'mysql') {
922 1095
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
923 1096
 		} else {
@@ -935,7 +1108,9 @@  discard block
 block discarded – undo
935 1108
         }
936 1109
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
937 1110
     		global $globalArchiveMonths, $globalDBdriver;
938
-		if ($filter_name == '') $filter_name = $this->filter_name;
1111
+		if ($filter_name == '') {
1112
+			$filter_name = $this->filter_name;
1113
+		}
939 1114
     		if ($globalDBdriver == 'mysql') {
940 1115
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
941 1116
                 } else {
@@ -952,7 +1127,9 @@  discard block
 block discarded – undo
952 1127
         }
953 1128
 	public function getStatsAirlineTotal($filter_name = '') {
954 1129
     		global $globalArchiveMonths, $globalDBdriver;
955
-		if ($filter_name == '') $filter_name = $this->filter_name;
1130
+		if ($filter_name == '') {
1131
+			$filter_name = $this->filter_name;
1132
+		}
956 1133
     		if ($globalDBdriver == 'mysql') {
957 1134
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
958 1135
                 } else {
@@ -969,7 +1146,9 @@  discard block
 block discarded – undo
969 1146
         }
970 1147
 	public function getStatsOwnerTotal($filter_name = '') {
971 1148
     		global $globalArchiveMonths, $globalDBdriver;
972
-		if ($filter_name == '') $filter_name = $this->filter_name;
1149
+		if ($filter_name == '') {
1150
+			$filter_name = $this->filter_name;
1151
+		}
973 1152
     		if ($globalDBdriver == 'mysql') {
974 1153
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
975 1154
 		} else {
@@ -986,7 +1165,9 @@  discard block
 block discarded – undo
986 1165
         }
987 1166
 	public function getStatsOwner($owner_name,$filter_name = '') {
988 1167
     		global $globalArchiveMonths, $globalDBdriver;
989
-		if ($filter_name == '') $filter_name = $this->filter_name;
1168
+		if ($filter_name == '') {
1169
+			$filter_name = $this->filter_name;
1170
+		}
990 1171
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
991 1172
                  try {
992 1173
                         $sth = $this->db->prepare($query);
@@ -995,12 +1176,17 @@  discard block
 block discarded – undo
995 1176
                         echo "error : ".$e->getMessage();
996 1177
                 }
997 1178
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
998
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
999
-                else return 0;
1179
+                if (isset($all[0]['cnt'])) {
1180
+                	return $all[0]['cnt'];
1181
+                } else {
1182
+                	return 0;
1183
+                }
1000 1184
         }
1001 1185
 	public function getStatsPilotTotal($filter_name = '') {
1002 1186
     		global $globalArchiveMonths, $globalDBdriver;
1003
-		if ($filter_name == '') $filter_name = $this->filter_name;
1187
+		if ($filter_name == '') {
1188
+			$filter_name = $this->filter_name;
1189
+		}
1004 1190
     		if ($globalDBdriver == 'mysql') {
1005 1191
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1006 1192
             	} else {
@@ -1017,7 +1203,9 @@  discard block
 block discarded – undo
1017 1203
         }
1018 1204
 	public function getStatsPilot($pilot,$filter_name = '') {
1019 1205
     		global $globalArchiveMonths, $globalDBdriver;
1020
-		if ($filter_name == '') $filter_name = $this->filter_name;
1206
+		if ($filter_name == '') {
1207
+			$filter_name = $this->filter_name;
1208
+		}
1021 1209
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1022 1210
                  try {
1023 1211
                         $sth = $this->db->prepare($query);
@@ -1026,13 +1214,18 @@  discard block
 block discarded – undo
1026 1214
                         echo "error : ".$e->getMessage();
1027 1215
                 }
1028 1216
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1029
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1030
-                else return 0;
1217
+                if (isset($all[0]['cnt'])) {
1218
+                	return $all[0]['cnt'];
1219
+                } else {
1220
+                	return 0;
1221
+                }
1031 1222
         }
1032 1223
 
1033 1224
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1034 1225
 		global $globalDBdriver;
1035
-		if ($filter_name == '') $filter_name = $this->filter_name;
1226
+		if ($filter_name == '') {
1227
+			$filter_name = $this->filter_name;
1228
+		}
1036 1229
 		if ($globalDBdriver == 'mysql') {
1037 1230
 			$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";
1038 1231
                 } else {
@@ -1048,7 +1241,9 @@  discard block
 block discarded – undo
1048 1241
         }
1049 1242
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1050 1243
 		global $globalDBdriver;
1051
-		if ($filter_name == '') $filter_name = $this->filter_name;
1244
+		if ($filter_name == '') {
1245
+			$filter_name = $this->filter_name;
1246
+		}
1052 1247
 		if ($globalDBdriver == 'mysql') {
1053 1248
 			$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";
1054 1249
 		} else {
@@ -1434,10 +1629,14 @@  discard block
 block discarded – undo
1434 1629
     		$Connection = new Connection();
1435 1630
     		date_default_timezone_set('UTC');
1436 1631
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1437
-			if ($globalDebug) echo 'Update stats !'."\n";
1632
+			if ($globalDebug) {
1633
+				echo 'Update stats !'."\n";
1634
+			}
1438 1635
 			if (isset($last_update[0]['value'])) {
1439 1636
 				$last_update_day = $last_update[0]['value'];
1440
-			} else $last_update_day = '2012-12-12 12:12:12';
1637
+			} else {
1638
+				$last_update_day = '2012-12-12 12:12:12';
1639
+			}
1441 1640
 			$reset = false;
1442 1641
 			if ($globalStatsResetYear) {
1443 1642
 				$reset = true;
@@ -1445,42 +1644,60 @@  discard block
 block discarded – undo
1445 1644
 			}
1446 1645
 			$Spotter = new Spotter($this->db);
1447 1646
 
1448
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1647
+			if ($globalDebug) {
1648
+				echo 'Count all aircraft types...'."\n";
1649
+			}
1449 1650
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1450 1651
 			foreach ($alldata as $number) {
1451 1652
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1452 1653
 			}
1453
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1654
+			if ($globalDebug) {
1655
+				echo 'Count all airlines...'."\n";
1656
+			}
1454 1657
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1455 1658
 			foreach ($alldata as $number) {
1456 1659
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1457 1660
 			}
1458
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1661
+			if ($globalDebug) {
1662
+				echo 'Count all registrations...'."\n";
1663
+			}
1459 1664
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1460 1665
 			foreach ($alldata as $number) {
1461 1666
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1462 1667
 			}
1463
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1668
+			if ($globalDebug) {
1669
+				echo 'Count all callsigns...'."\n";
1670
+			}
1464 1671
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1465 1672
 			foreach ($alldata as $number) {
1466 1673
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1467 1674
 			}
1468
-			if ($globalDebug) echo 'Count all owners...'."\n";
1675
+			if ($globalDebug) {
1676
+				echo 'Count all owners...'."\n";
1677
+			}
1469 1678
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1470 1679
 			foreach ($alldata as $number) {
1471 1680
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1472 1681
 			}
1473
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1682
+			if ($globalDebug) {
1683
+				echo 'Count all pilots...'."\n";
1684
+			}
1474 1685
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1475 1686
 			foreach ($alldata as $number) {
1476 1687
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1477 1688
 			}
1478 1689
 			
1479
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1690
+			if ($globalDebug) {
1691
+				echo 'Count all departure airports...'."\n";
1692
+			}
1480 1693
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1481
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1694
+			if ($globalDebug) {
1695
+				echo 'Count all detected departure airports...'."\n";
1696
+			}
1482 1697
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1483
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1698
+			if ($globalDebug) {
1699
+				echo 'Order departure airports...'."\n";
1700
+			}
1484 1701
 	        	$alldata = array();
1485 1702
 	        	
1486 1703
     			foreach ($pall as $value) {
@@ -1491,7 +1708,9 @@  discard block
 block discarded – undo
1491 1708
     				$icao = $value['airport_departure_icao'];
1492 1709
         			if (isset($alldata[$icao])) {
1493 1710
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1494
-        			} else $alldata[$icao] = $value;
1711
+        			} else {
1712
+        				$alldata[$icao] = $value;
1713
+        			}
1495 1714
 			}
1496 1715
     			$count = array();
1497 1716
     			foreach ($alldata as $key => $row) {
@@ -1501,11 +1720,17 @@  discard block
 block discarded – undo
1501 1720
 			foreach ($alldata as $number) {
1502 1721
 				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);
1503 1722
 			}
1504
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1723
+			if ($globalDebug) {
1724
+				echo 'Count all arrival airports...'."\n";
1725
+			}
1505 1726
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1506
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1727
+			if ($globalDebug) {
1728
+				echo 'Count all detected arrival airports...'."\n";
1729
+			}
1507 1730
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1508
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1731
+			if ($globalDebug) {
1732
+				echo 'Order arrival airports...'."\n";
1733
+			}
1509 1734
 	        	$alldata = array();
1510 1735
     			foreach ($pall as $value) {
1511 1736
 	        		$icao = $value['airport_arrival_icao'];
@@ -1515,7 +1740,9 @@  discard block
 block discarded – undo
1515 1740
     				$icao = $value['airport_arrival_icao'];
1516 1741
         			if (isset($alldata[$icao])) {
1517 1742
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1518
-	        		} else $alldata[$icao] = $value;
1743
+	        		} else {
1744
+	        			$alldata[$icao] = $value;
1745
+	        		}
1519 1746
     			}
1520 1747
         		$count = array();
1521 1748
         		foreach ($alldata as $key => $row) {
@@ -1526,7 +1753,9 @@  discard block
 block discarded – undo
1526 1753
 				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);
1527 1754
 			}
1528 1755
 			if ($Connection->tableExists('countries')) {
1529
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1756
+				if ($globalDebug) {
1757
+					echo 'Count all flights by countries...'."\n";
1758
+				}
1530 1759
 				$SpotterArchive = new SpotterArchive();
1531 1760
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1532 1761
 				foreach ($alldata as $number) {
@@ -1538,46 +1767,66 @@  discard block
 block discarded – undo
1538 1767
 			// Add by month using getstat if month finish...
1539 1768
 
1540 1769
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1541
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1770
+			if ($globalDebug) {
1771
+				echo 'Count all flights by months...'."\n";
1772
+			}
1542 1773
 			$Spotter = new Spotter($this->db);
1543 1774
 			$alldata = $Spotter->countAllMonths();
1544 1775
 			$lastyear = false;
1545 1776
 			foreach ($alldata as $number) {
1546
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1777
+				if ($number['year_name'] != date('Y')) {
1778
+					$lastyear = true;
1779
+				}
1547 1780
 				$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'])));
1548 1781
 			}
1549
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1782
+			if ($globalDebug) {
1783
+				echo 'Count all military flights by months...'."\n";
1784
+			}
1550 1785
 			$alldata = $Spotter->countAllMilitaryMonths();
1551 1786
 			foreach ($alldata as $number) {
1552 1787
 				$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'])));
1553 1788
 			}
1554
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1789
+			if ($globalDebug) {
1790
+				echo 'Count all owners by months...'."\n";
1791
+			}
1555 1792
 			$alldata = $Spotter->countAllMonthsOwners();
1556 1793
 			foreach ($alldata as $number) {
1557 1794
 				$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'])));
1558 1795
 			}
1559
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1796
+			if ($globalDebug) {
1797
+				echo 'Count all pilots by months...'."\n";
1798
+			}
1560 1799
 			$alldata = $Spotter->countAllMonthsPilots();
1561 1800
 			foreach ($alldata as $number) {
1562 1801
 				$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'])));
1563 1802
 			}
1564
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1803
+			if ($globalDebug) {
1804
+				echo 'Count all airlines by months...'."\n";
1805
+			}
1565 1806
 			$alldata = $Spotter->countAllMonthsAirlines();
1566 1807
 			foreach ($alldata as $number) {
1567 1808
 				$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'])));
1568 1809
 			}
1569
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1810
+			if ($globalDebug) {
1811
+				echo 'Count all aircrafts by months...'."\n";
1812
+			}
1570 1813
 			$alldata = $Spotter->countAllMonthsAircrafts();
1571 1814
 			foreach ($alldata as $number) {
1572 1815
 				$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'])));
1573 1816
 			}
1574
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1817
+			if ($globalDebug) {
1818
+				echo 'Count all real arrivals by months...'."\n";
1819
+			}
1575 1820
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1576 1821
 			foreach ($alldata as $number) {
1577 1822
 				$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'])));
1578 1823
 			}
1579
-			if ($globalDebug) echo 'Airports data...'."\n";
1580
-			if ($globalDebug) echo '...Departure'."\n";
1824
+			if ($globalDebug) {
1825
+				echo 'Airports data...'."\n";
1826
+			}
1827
+			if ($globalDebug) {
1828
+				echo '...Departure'."\n";
1829
+			}
1581 1830
 			$this->deleteStatAirport('daily');
1582 1831
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1583 1832
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1698,44 +1947,62 @@  discard block
 block discarded – undo
1698 1947
 			// Count by airlines
1699 1948
 			echo '--- Stats by airlines ---'."\n";
1700 1949
 			if ($Connection->tableExists('countries')) {
1701
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1950
+				if ($globalDebug) {
1951
+					echo 'Count all flights by countries by airlines...'."\n";
1952
+				}
1702 1953
 				$SpotterArchive = new SpotterArchive();
1703 1954
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1704 1955
 				foreach ($alldata as $number) {
1705 1956
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1706 1957
 				}
1707 1958
 			}
1708
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1959
+			if ($globalDebug) {
1960
+				echo 'Count all aircraft types by airlines...'."\n";
1961
+			}
1709 1962
 			$Spotter = new Spotter($this->db);
1710 1963
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1711 1964
 			foreach ($alldata as $number) {
1712 1965
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1713 1966
 			}
1714
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1967
+			if ($globalDebug) {
1968
+				echo 'Count all aircraft registrations by airlines...'."\n";
1969
+			}
1715 1970
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1716 1971
 			foreach ($alldata as $number) {
1717 1972
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1718 1973
 			}
1719
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1974
+			if ($globalDebug) {
1975
+				echo 'Count all callsigns by airlines...'."\n";
1976
+			}
1720 1977
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1721 1978
 			foreach ($alldata as $number) {
1722 1979
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1723 1980
 			}
1724
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1981
+			if ($globalDebug) {
1982
+				echo 'Count all owners by airlines...'."\n";
1983
+			}
1725 1984
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1726 1985
 			foreach ($alldata as $number) {
1727 1986
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1728 1987
 			}
1729
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1988
+			if ($globalDebug) {
1989
+				echo 'Count all pilots by airlines...'."\n";
1990
+			}
1730 1991
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1731 1992
 			foreach ($alldata as $number) {
1732 1993
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1733 1994
 			}
1734
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1995
+			if ($globalDebug) {
1996
+				echo 'Count all departure airports by airlines...'."\n";
1997
+			}
1735 1998
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1736
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1999
+			if ($globalDebug) {
2000
+				echo 'Count all detected departure airports by airlines...'."\n";
2001
+			}
1737 2002
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1738
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2003
+			if ($globalDebug) {
2004
+				echo 'Order detected departure airports by airlines...'."\n";
2005
+			}
1739 2006
 	        	//$alldata = array();
1740 2007
     			foreach ($dall as $value) {
1741 2008
     				$icao = $value['airport_departure_icao'];
@@ -1756,11 +2023,17 @@  discard block
 block discarded – undo
1756 2023
 			foreach ($alldata as $number) {
1757 2024
 				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);
1758 2025
 			}
1759
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2026
+			if ($globalDebug) {
2027
+				echo 'Count all arrival airports by airlines...'."\n";
2028
+			}
1760 2029
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1761
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2030
+			if ($globalDebug) {
2031
+				echo 'Count all detected arrival airports by airlines...'."\n";
2032
+			}
1762 2033
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1763
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2034
+			if ($globalDebug) {
2035
+				echo 'Order arrival airports by airlines...'."\n";
2036
+			}
1764 2037
 	        	//$alldata = array();
1765 2038
     			foreach ($dall as $value) {
1766 2039
     				$icao = $value['airport_arrival_icao'];
@@ -1779,37 +2052,53 @@  discard block
 block discarded – undo
1779 2052
     			}
1780 2053
     			$alldata = $pall;
1781 2054
                         foreach ($alldata as $number) {
1782
-				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);
2055
+				if ($number['airline_icao'] != '') {
2056
+					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);
2057
+				}
2058
+			}
2059
+			if ($globalDebug) {
2060
+				echo 'Count all flights by months by airlines...'."\n";
1783 2061
 			}
1784
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1785 2062
 			$Spotter = new Spotter($this->db);
1786 2063
 			$alldata = $Spotter->countAllMonthsByAirlines();
1787 2064
 			$lastyear = false;
1788 2065
 			foreach ($alldata as $number) {
1789
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2066
+				if ($number['year_name'] != date('Y')) {
2067
+					$lastyear = true;
2068
+				}
1790 2069
 				$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']);
1791 2070
 			}
1792
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2071
+			if ($globalDebug) {
2072
+				echo 'Count all owners by months by airlines...'."\n";
2073
+			}
1793 2074
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1794 2075
 			foreach ($alldata as $number) {
1795 2076
 				$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']);
1796 2077
 			}
1797
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2078
+			if ($globalDebug) {
2079
+				echo 'Count all pilots by months by airlines...'."\n";
2080
+			}
1798 2081
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1799 2082
 			foreach ($alldata as $number) {
1800 2083
 				$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']);
1801 2084
 			}
1802
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2085
+			if ($globalDebug) {
2086
+				echo 'Count all aircrafts by months by airlines...'."\n";
2087
+			}
1803 2088
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1804 2089
 			foreach ($alldata as $number) {
1805 2090
 				$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']);
1806 2091
 			}
1807
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2092
+			if ($globalDebug) {
2093
+				echo 'Count all real arrivals by months by airlines...'."\n";
2094
+			}
1808 2095
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1809 2096
 			foreach ($alldata as $number) {
1810 2097
 				$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']);
1811 2098
 			}
1812
-			if ($globalDebug) echo '...Departure'."\n";
2099
+			if ($globalDebug) {
2100
+				echo '...Departure'."\n";
2101
+			}
1813 2102
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1814 2103
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1815 2104
     			foreach ($dall as $value) {
@@ -1832,7 +2121,9 @@  discard block
 block discarded – undo
1832 2121
 			foreach ($alldata as $number) {
1833 2122
 				$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']);
1834 2123
 			}
1835
-			if ($globalDebug) echo '...Arrival'."\n";
2124
+			if ($globalDebug) {
2125
+				echo '...Arrival'."\n";
2126
+			}
1836 2127
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1837 2128
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1838 2129
     			foreach ($dall as $value) {
@@ -1856,13 +2147,19 @@  discard block
 block discarded – undo
1856 2147
 				$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']);
1857 2148
 			}
1858 2149
 
1859
-			if ($globalDebug) echo 'Flights data...'."\n";
1860
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2150
+			if ($globalDebug) {
2151
+				echo 'Flights data...'."\n";
2152
+			}
2153
+			if ($globalDebug) {
2154
+				echo '-> countAllDatesLastMonth...'."\n";
2155
+			}
1861 2156
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1862 2157
 			foreach ($alldata as $number) {
1863 2158
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1864 2159
 			}
1865
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2160
+			if ($globalDebug) {
2161
+				echo '-> countAllDates...'."\n";
2162
+			}
1866 2163
 			//$previousdata = $this->countAllDatesByAirlines();
1867 2164
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1868 2165
 			$values = array();
@@ -1875,7 +2172,9 @@  discard block
 block discarded – undo
1875 2172
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1876 2173
 			}
1877 2174
 			
1878
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2175
+			if ($globalDebug) {
2176
+				echo '-> countAllHours...'."\n";
2177
+			}
1879 2178
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1880 2179
 			foreach ($alldata as $number) {
1881 2180
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1883,7 +2182,9 @@  discard block
 block discarded – undo
1883 2182
 			
1884 2183
 
1885 2184
 			// Stats by filters
1886
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2185
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2186
+				$globalStatsFilters = array();
2187
+			}
1887 2188
 			foreach ($globalStatsFilters as $name => $filter) {
1888 2189
 				//$filter_name = $filter['name'];
1889 2190
 				$filter_name = $name;
@@ -1891,11 +2192,15 @@  discard block
 block discarded – undo
1891 2192
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1892 2193
 				if (isset($last_update[0]['value'])) {
1893 2194
 					$last_update_day = $last_update[0]['value'];
1894
-				} else $last_update_day = '2012-12-12 12:12:12';
2195
+				} else {
2196
+					$last_update_day = '2012-12-12 12:12:12';
2197
+				}
1895 2198
 				$reset = false;
1896 2199
 
1897 2200
 				// Count by filter
1898
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2201
+				if ($globalDebug) {
2202
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2203
+				}
1899 2204
 				$Spotter = new Spotter($this->db);
1900 2205
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1901 2206
 				foreach ($alldata as $number) {
@@ -1932,7 +2237,9 @@  discard block
 block discarded – undo
1932 2237
 	    				$icao = $value['airport_departure_icao'];
1933 2238
         				if (isset($alldata[$icao])) {
1934 2239
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1935
-        				} else $alldata[$icao] = $value;
2240
+        				} else {
2241
+        					$alldata[$icao] = $value;
2242
+        				}
1936 2243
 				}
1937 2244
 	    			$count = array();
1938 2245
     				foreach ($alldata as $key => $row) {
@@ -1953,7 +2260,9 @@  discard block
 block discarded – undo
1953 2260
 	    				$icao = $value['airport_arrival_icao'];
1954 2261
         				if (isset($alldata[$icao])) {
1955 2262
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1956
-		        		} else $alldata[$icao] = $value;
2263
+		        		} else {
2264
+		        			$alldata[$icao] = $value;
2265
+		        		}
1957 2266
 	    			}
1958 2267
         			$count = array();
1959 2268
         			foreach ($alldata as $key => $row) {
@@ -1967,7 +2276,9 @@  discard block
 block discarded – undo
1967 2276
 				$alldata = $Spotter->countAllMonths($filter);
1968 2277
 				$lastyear = false;
1969 2278
 				foreach ($alldata as $number) {
1970
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2279
+					if ($number['year_name'] != date('Y')) {
2280
+						$lastyear = true;
2281
+					}
1971 2282
 					$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);
1972 2283
 				}
1973 2284
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +598 added lines, -598 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
431 416
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431
+			$sth->execute();
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1490,165 +1490,165 @@  discard block
 block discarded – undo
1490 1490
 	}
1491 1491
 
1492 1492
 
1493
-    	public static function check_version($update = false) {
1494
-    	    global $globalDBname;
1495
-    	    $version = 0;
1496
-    	    $Connection = new Connection();
1497
-    	    if ($Connection->tableExists('aircraft')) {
1498
-    		if (!$Connection->tableExists('config')) {
1499
-    		    $version = '1';
1500
-    		    if ($update) return self::update_from_1();
1501
-    		    else return $version;
1493
+		public static function check_version($update = false) {
1494
+			global $globalDBname;
1495
+			$version = 0;
1496
+			$Connection = new Connection();
1497
+			if ($Connection->tableExists('aircraft')) {
1498
+			if (!$Connection->tableExists('config')) {
1499
+				$version = '1';
1500
+				if ($update) return self::update_from_1();
1501
+				else return $version;
1502 1502
 		} else {
1503
-    		    $Connection = new Connection();
1504
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1505
-		    try {
1506
-            		$sth = $Connection->db->prepare($query);
1507
-		        $sth->execute();
1508
-		    } catch(PDOException $e) {
1503
+				$Connection = new Connection();
1504
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1505
+			try {
1506
+					$sth = $Connection->db->prepare($query);
1507
+				$sth->execute();
1508
+			} catch(PDOException $e) {
1509 1509
 			return "error : ".$e->getMessage()."\n";
1510
-    		    }
1511
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1512
-    		    if ($update) {
1513
-    			if ($result['value'] == '2') {
1514
-    			    $error = self::update_from_2();
1515
-    			    if ($error != '') return $error;
1516
-    			    else return self::check_version(true);
1517
-    			} elseif ($result['value'] == '3') {
1518
-    			    $error = self::update_from_3();
1519
-    			    if ($error != '') return $error;
1520
-    			    else return self::check_version(true);
1521
-    			} elseif ($result['value'] == '4') {
1522
-    			    $error = self::update_from_4();
1523
-    			    if ($error != '') return $error;
1524
-    			    else return self::check_version(true);
1525
-    			} elseif ($result['value'] == '5') {
1526
-    			    $error = self::update_from_5();
1527
-    			    if ($error != '') return $error;
1528
-    			    else return self::check_version(true);
1529
-    			} elseif ($result['value'] == '6') {
1530
-    			    $error = self::update_from_6();
1531
-    			    if ($error != '') return $error;
1532
-    			    else return self::check_version(true);
1533
-    			} elseif ($result['value'] == '7') {
1534
-    			    $error = self::update_from_7();
1535
-    			    if ($error != '') return $error;
1536
-    			    else return self::check_version(true);
1537
-    			} elseif ($result['value'] == '8') {
1538
-    			    $error = self::update_from_8();
1539
-    			    if ($error != '') return $error;
1540
-    			    else return self::check_version(true);
1541
-    			} elseif ($result['value'] == '9') {
1542
-    			    $error = self::update_from_9();
1543
-    			    if ($error != '') return $error;
1544
-    			    else return self::check_version(true);
1545
-    			} elseif ($result['value'] == '10') {
1546
-    			    $error = self::update_from_10();
1547
-    			    if ($error != '') return $error;
1548
-    			    else return self::check_version(true);
1549
-    			} elseif ($result['value'] == '11') {
1550
-    			    $error = self::update_from_11();
1551
-    			    if ($error != '') return $error;
1552
-    			    else return self::check_version(true);
1553
-    			} elseif ($result['value'] == '12') {
1554
-    			    $error = self::update_from_12();
1555
-    			    if ($error != '') return $error;
1556
-    			    else return self::check_version(true);
1557
-    			} elseif ($result['value'] == '13') {
1558
-    			    $error = self::update_from_13();
1559
-    			    if ($error != '') return $error;
1560
-    			    else return self::check_version(true);
1561
-    			} elseif ($result['value'] == '14') {
1562
-    			    $error = self::update_from_14();
1563
-    			    if ($error != '') return $error;
1564
-    			    else return self::check_version(true);
1565
-    			} elseif ($result['value'] == '15') {
1566
-    			    $error = self::update_from_15();
1567
-    			    if ($error != '') return $error;
1568
-    			    else return self::check_version(true);
1569
-    			} elseif ($result['value'] == '16') {
1570
-    			    $error = self::update_from_16();
1571
-    			    if ($error != '') return $error;
1572
-    			    else return self::check_version(true);
1573
-    			} elseif ($result['value'] == '17') {
1574
-    			    $error = self::update_from_17();
1575
-    			    if ($error != '') return $error;
1576
-    			    else return self::check_version(true);
1577
-    			} elseif ($result['value'] == '18') {
1578
-    			    $error = self::update_from_18();
1579
-    			    if ($error != '') return $error;
1580
-    			    else return self::check_version(true);
1581
-    			} elseif ($result['value'] == '19') {
1582
-    			    $error = self::update_from_19();
1583
-    			    if ($error != '') return $error;
1584
-    			    else return self::check_version(true);
1585
-    			} elseif ($result['value'] == '20') {
1586
-    			    $error = self::update_from_20();
1587
-    			    if ($error != '') return $error;
1588
-    			    else return self::check_version(true);
1589
-    			} elseif ($result['value'] == '21') {
1590
-    			    $error = self::update_from_21();
1591
-    			    if ($error != '') return $error;
1592
-    			    else return self::check_version(true);
1593
-    			} elseif ($result['value'] == '22') {
1594
-    			    $error = self::update_from_22();
1595
-    			    if ($error != '') return $error;
1596
-    			    else return self::check_version(true);
1597
-    			} elseif ($result['value'] == '23') {
1598
-    			    $error = self::update_from_23();
1599
-    			    if ($error != '') return $error;
1600
-    			    else return self::check_version(true);
1601
-    			} elseif ($result['value'] == '24') {
1602
-    			    $error = self::update_from_24();
1603
-    			    if ($error != '') return $error;
1604
-    			    else return self::check_version(true);
1605
-    			} elseif ($result['value'] == '25') {
1606
-    			    $error = self::update_from_25();
1607
-    			    if ($error != '') return $error;
1608
-    			    else return self::check_version(true);
1609
-    			} elseif ($result['value'] == '26') {
1610
-    			    $error = self::update_from_26();
1611
-    			    if ($error != '') return $error;
1612
-    			    else return self::check_version(true);
1613
-    			} elseif ($result['value'] == '27') {
1614
-    			    $error = self::update_from_27();
1615
-    			    if ($error != '') return $error;
1616
-    			    else return self::check_version(true);
1617
-    			} elseif ($result['value'] == '28') {
1618
-    			    $error = self::update_from_28();
1619
-    			    if ($error != '') return $error;
1620
-    			    else return self::check_version(true);
1621
-    			} elseif ($result['value'] == '29') {
1622
-    			    $error = self::update_from_29();
1623
-    			    if ($error != '') return $error;
1624
-    			    else return self::check_version(true);
1625
-    			} elseif ($result['value'] == '30') {
1626
-    			    $error = self::update_from_30();
1627
-    			    if ($error != '') return $error;
1628
-    			    else return self::check_version(true);
1629
-    			} elseif ($result['value'] == '31') {
1630
-    			    $error = self::update_from_31();
1631
-    			    if ($error != '') return $error;
1632
-    			    else return self::check_version(true);
1633
-    			} elseif ($result['value'] == '32') {
1634
-    			    $error = self::update_from_32();
1635
-    			    if ($error != '') return $error;
1636
-    			    else return self::check_version(true);
1637
-    			} elseif ($result['value'] == '33') {
1638
-    			    $error = self::update_from_33();
1639
-    			    if ($error != '') return $error;
1640
-    			    else return self::check_version(true);
1641
-    			} elseif ($result['value'] == '34') {
1642
-    			    $error = self::update_from_34();
1643
-    			    if ($error != '') return $error;
1644
-    			    else return self::check_version(true);
1645
-    			} else return '';
1646
-    		    }
1647
-    		    else return $result['value'];
1510
+				}
1511
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1512
+				if ($update) {
1513
+				if ($result['value'] == '2') {
1514
+					$error = self::update_from_2();
1515
+					if ($error != '') return $error;
1516
+					else return self::check_version(true);
1517
+				} elseif ($result['value'] == '3') {
1518
+					$error = self::update_from_3();
1519
+					if ($error != '') return $error;
1520
+					else return self::check_version(true);
1521
+				} elseif ($result['value'] == '4') {
1522
+					$error = self::update_from_4();
1523
+					if ($error != '') return $error;
1524
+					else return self::check_version(true);
1525
+				} elseif ($result['value'] == '5') {
1526
+					$error = self::update_from_5();
1527
+					if ($error != '') return $error;
1528
+					else return self::check_version(true);
1529
+				} elseif ($result['value'] == '6') {
1530
+					$error = self::update_from_6();
1531
+					if ($error != '') return $error;
1532
+					else return self::check_version(true);
1533
+				} elseif ($result['value'] == '7') {
1534
+					$error = self::update_from_7();
1535
+					if ($error != '') return $error;
1536
+					else return self::check_version(true);
1537
+				} elseif ($result['value'] == '8') {
1538
+					$error = self::update_from_8();
1539
+					if ($error != '') return $error;
1540
+					else return self::check_version(true);
1541
+				} elseif ($result['value'] == '9') {
1542
+					$error = self::update_from_9();
1543
+					if ($error != '') return $error;
1544
+					else return self::check_version(true);
1545
+				} elseif ($result['value'] == '10') {
1546
+					$error = self::update_from_10();
1547
+					if ($error != '') return $error;
1548
+					else return self::check_version(true);
1549
+				} elseif ($result['value'] == '11') {
1550
+					$error = self::update_from_11();
1551
+					if ($error != '') return $error;
1552
+					else return self::check_version(true);
1553
+				} elseif ($result['value'] == '12') {
1554
+					$error = self::update_from_12();
1555
+					if ($error != '') return $error;
1556
+					else return self::check_version(true);
1557
+				} elseif ($result['value'] == '13') {
1558
+					$error = self::update_from_13();
1559
+					if ($error != '') return $error;
1560
+					else return self::check_version(true);
1561
+				} elseif ($result['value'] == '14') {
1562
+					$error = self::update_from_14();
1563
+					if ($error != '') return $error;
1564
+					else return self::check_version(true);
1565
+				} elseif ($result['value'] == '15') {
1566
+					$error = self::update_from_15();
1567
+					if ($error != '') return $error;
1568
+					else return self::check_version(true);
1569
+				} elseif ($result['value'] == '16') {
1570
+					$error = self::update_from_16();
1571
+					if ($error != '') return $error;
1572
+					else return self::check_version(true);
1573
+				} elseif ($result['value'] == '17') {
1574
+					$error = self::update_from_17();
1575
+					if ($error != '') return $error;
1576
+					else return self::check_version(true);
1577
+				} elseif ($result['value'] == '18') {
1578
+					$error = self::update_from_18();
1579
+					if ($error != '') return $error;
1580
+					else return self::check_version(true);
1581
+				} elseif ($result['value'] == '19') {
1582
+					$error = self::update_from_19();
1583
+					if ($error != '') return $error;
1584
+					else return self::check_version(true);
1585
+				} elseif ($result['value'] == '20') {
1586
+					$error = self::update_from_20();
1587
+					if ($error != '') return $error;
1588
+					else return self::check_version(true);
1589
+				} elseif ($result['value'] == '21') {
1590
+					$error = self::update_from_21();
1591
+					if ($error != '') return $error;
1592
+					else return self::check_version(true);
1593
+				} elseif ($result['value'] == '22') {
1594
+					$error = self::update_from_22();
1595
+					if ($error != '') return $error;
1596
+					else return self::check_version(true);
1597
+				} elseif ($result['value'] == '23') {
1598
+					$error = self::update_from_23();
1599
+					if ($error != '') return $error;
1600
+					else return self::check_version(true);
1601
+				} elseif ($result['value'] == '24') {
1602
+					$error = self::update_from_24();
1603
+					if ($error != '') return $error;
1604
+					else return self::check_version(true);
1605
+				} elseif ($result['value'] == '25') {
1606
+					$error = self::update_from_25();
1607
+					if ($error != '') return $error;
1608
+					else return self::check_version(true);
1609
+				} elseif ($result['value'] == '26') {
1610
+					$error = self::update_from_26();
1611
+					if ($error != '') return $error;
1612
+					else return self::check_version(true);
1613
+				} elseif ($result['value'] == '27') {
1614
+					$error = self::update_from_27();
1615
+					if ($error != '') return $error;
1616
+					else return self::check_version(true);
1617
+				} elseif ($result['value'] == '28') {
1618
+					$error = self::update_from_28();
1619
+					if ($error != '') return $error;
1620
+					else return self::check_version(true);
1621
+				} elseif ($result['value'] == '29') {
1622
+					$error = self::update_from_29();
1623
+					if ($error != '') return $error;
1624
+					else return self::check_version(true);
1625
+				} elseif ($result['value'] == '30') {
1626
+					$error = self::update_from_30();
1627
+					if ($error != '') return $error;
1628
+					else return self::check_version(true);
1629
+				} elseif ($result['value'] == '31') {
1630
+					$error = self::update_from_31();
1631
+					if ($error != '') return $error;
1632
+					else return self::check_version(true);
1633
+				} elseif ($result['value'] == '32') {
1634
+					$error = self::update_from_32();
1635
+					if ($error != '') return $error;
1636
+					else return self::check_version(true);
1637
+				} elseif ($result['value'] == '33') {
1638
+					$error = self::update_from_33();
1639
+					if ($error != '') return $error;
1640
+					else return self::check_version(true);
1641
+				} elseif ($result['value'] == '34') {
1642
+					$error = self::update_from_34();
1643
+					if ($error != '') return $error;
1644
+					else return self::check_version(true);
1645
+				} else return '';
1646
+				}
1647
+				else return $result['value'];
1648 1648
 		}
1649 1649
 		
1650
-	    } else return $version;
1651
-    	}
1650
+		} else return $version;
1651
+		}
1652 1652
     	
1653 1653
 }
1654 1654
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 		global $globalDBdriver;
1109 1109
 		$Connection = new Connection();
1110 1110
 		$error = '';
1111
-		if (!$Connection->checkColumnName('atc','format_source')) {
1111
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1112 1112
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1113 1113
 			try {
1114 1114
 				$sth = $Connection->db->prepare($query);
1115 1115
 				$sth->execute();
1116
-			} catch(PDOException $e) {
1116
+			} catch (PDOException $e) {
1117 1117
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1118 1118
 			}
1119 1119
 		}
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $Connection->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1126 1126
 		}
1127 1127
 		return $error;
@@ -1131,13 +1131,13 @@  discard block
 block discarded – undo
1131 1131
 		global $globalDBdriver;
1132 1132
 		$Connection = new Connection();
1133 1133
 		$error = '';
1134
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1134
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1135 1135
 			// Add forsource to airlines
1136 1136
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1137 1137
 			try {
1138 1138
 				$sth = $Connection->db->prepare($query);
1139 1139
 				$sth->execute();
1140
-			} catch(PDOException $e) {
1140
+			} catch (PDOException $e) {
1141 1141
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1142 1142
 			}
1143 1143
 			// Add unique key
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			try {
1150 1150
 				$sth = $Connection->db->prepare($query);
1151 1151
 				$sth->execute();
1152
-			} catch(PDOException $e) {
1152
+			} catch (PDOException $e) {
1153 1153
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1154 1154
 			}
1155 1155
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		try {
1158 1158
 			$sth = $Connection->db->prepare($query);
1159 1159
 			$sth->execute();
1160
-		} catch(PDOException $e) {
1160
+		} catch (PDOException $e) {
1161 1161
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1162 1162
 		}
1163 1163
 		return $error;
@@ -1167,23 +1167,23 @@  discard block
 block discarded – undo
1167 1167
 		global $globalDBdriver;
1168 1168
 		$Connection = new Connection();
1169 1169
 		$error = '';
1170
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1170
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1171 1171
 			// Add unique key
1172 1172
 			$query = "alter table spotter_live add index(latitude,longitude)";
1173 1173
 			try {
1174 1174
 				$sth = $Connection->db->prepare($query);
1175 1175
 				$sth->execute();
1176
-			} catch(PDOException $e) {
1176
+			} catch (PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179 1179
                 }
1180
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1180
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1183 1183
 			try {
1184 1184
 				$sth = $Connection->db->prepare($query);
1185 1185
 				$sth->execute();
1186
-			} catch(PDOException $e) {
1186
+			} catch (PDOException $e) {
1187 1187
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1188 1188
 			}
1189 1189
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		try {
1200 1200
 			$sth = $Connection->db->prepare($query);
1201 1201
 			$sth->execute();
1202
-		} catch(PDOException $e) {
1202
+		} catch (PDOException $e) {
1203 1203
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1204 1204
 		}
1205 1205
 		return $error;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 		global $globalDBdriver;
1210 1210
 		$Connection = new Connection();
1211 1211
 		$error = '';
1212
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1212
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1213 1213
 			// drop mfr to aircraft
1214 1214
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1215 1215
 			try {
1216 1216
 				$sth = $Connection->db->prepare($query);
1217 1217
 				$sth->execute();
1218
-			} catch(PDOException $e) {
1218
+			} catch (PDOException $e) {
1219 1219
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1220 1220
 			}
1221 1221
 		}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		try {
1232 1232
 			$sth = $Connection->db->prepare($query);
1233 1233
 			$sth->execute();
1234
-		} catch(PDOException $e) {
1234
+		} catch (PDOException $e) {
1235 1235
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1236 1236
 		}
1237 1237
 		return $error;
@@ -1241,33 +1241,33 @@  discard block
 block discarded – undo
1241 1241
 		global $globalDBdriver;
1242 1242
 		$Connection = new Connection();
1243 1243
 		$error = '';
1244
-		if (!$Connection->indexExists('notam','ref_idx')) {
1244
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1245 1245
 			// Add index key
1246 1246
 			$query = "create index ref_idx on notam (ref)";
1247 1247
 			try {
1248 1248
 				$sth = $Connection->db->prepare($query);
1249 1249
 				$sth->execute();
1250
-			} catch(PDOException $e) {
1250
+			} catch (PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253 1253
                 }
1254
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1254
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
1257 1257
 			try {
1258 1258
 				$sth = $Connection->db->prepare($query);
1259 1259
 				$sth->execute();
1260
-			} catch(PDOException $e) {
1260
+			} catch (PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263 1263
                 }
1264
-		if (!$Connection->indexExists('accidents','rdts')) {
1264
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
1267 1267
 			try {
1268 1268
 				$sth = $Connection->db->prepare($query);
1269 1269
 				$sth->execute();
1270
-			} catch(PDOException $e) {
1270
+			} catch (PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273 1273
                 }
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		try {
1277 1277
 			$sth = $Connection->db->prepare($query);
1278 1278
 			$sth->execute();
1279
-		} catch(PDOException $e) {
1279
+		} catch (PDOException $e) {
1280 1280
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1281 1281
 		}
1282 1282
 		return $error;
@@ -1286,23 +1286,23 @@  discard block
 block discarded – undo
1286 1286
 		global $globalDBdriver;
1287 1287
 		$Connection = new Connection();
1288 1288
 		$error = '';
1289
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1289
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1290 1290
 			// Add airline_name to accidents
1291 1291
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1292 1292
 			try {
1293 1293
 				$sth = $Connection->db->prepare($query);
1294 1294
 				$sth->execute();
1295
-			} catch(PDOException $e) {
1295
+			} catch (PDOException $e) {
1296 1296
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1297 1297
 			}
1298 1298
 		}
1299
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1299
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1300 1300
 			// Add airline_icao to accidents
1301 1301
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1302 1302
 			try {
1303 1303
 				$sth = $Connection->db->prepare($query);
1304 1304
 				$sth->execute();
1305
-			} catch(PDOException $e) {
1305
+			} catch (PDOException $e) {
1306 1306
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1307 1307
 			}
1308 1308
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		try {
1311 1311
 			$sth = $Connection->db->prepare($query);
1312 1312
 			$sth->execute();
1313
-		} catch(PDOException $e) {
1313
+		} catch (PDOException $e) {
1314 1314
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1315 1315
 		}
1316 1316
 		return $error;
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1321 1321
 		$Connection = new Connection();
1322 1322
 		$error = '';
1323
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1323
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1324 1324
 			// Add alliance to airlines
1325 1325
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1326 1326
 			try {
1327 1327
 				$sth = $Connection->db->prepare($query);
1328 1328
 				$sth->execute();
1329
-			} catch(PDOException $e) {
1329
+			} catch (PDOException $e) {
1330 1330
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1331 1331
 			}
1332 1332
 		}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		try {
1354 1354
 			$sth = $Connection->db->prepare($query);
1355 1355
 			$sth->execute();
1356
-		} catch(PDOException $e) {
1356
+		} catch (PDOException $e) {
1357 1357
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1358 1358
 		}
1359 1359
 		return $error;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1364 1364
 		$Connection = new Connection();
1365 1365
 		$error = '';
1366
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1366
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1367 1367
 			// Add ban_eu to airlines
1368 1368
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1369 1369
 			try {
1370 1370
 				$sth = $Connection->db->prepare($query);
1371 1371
 				$sth->execute();
1372
-			} catch(PDOException $e) {
1372
+			} catch (PDOException $e) {
1373 1373
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1374 1374
 			}
1375 1375
 		}
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		try {
1378 1378
 			$sth = $Connection->db->prepare($query);
1379 1379
 			$sth->execute();
1380
-		} catch(PDOException $e) {
1380
+		} catch (PDOException $e) {
1381 1381
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1382 1382
 		}
1383 1383
 		return $error;
@@ -1388,12 +1388,12 @@  discard block
 block discarded – undo
1388 1388
 		$Connection = new Connection();
1389 1389
 		$error = '';
1390 1390
 		if ($globalDBdriver == 'mysql') {
1391
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1391
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1392 1392
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1393 1393
 				try {
1394 1394
 					$sth = $Connection->db->prepare($query);
1395 1395
 					$sth->execute();
1396
-				} catch(PDOException $e) {
1396
+				} catch (PDOException $e) {
1397 1397
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1398 1398
 				}
1399 1399
 				
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 				try {
1402 1402
 					$sth = $Connection->db->prepare($query);
1403 1403
 					$sth->execute();
1404
-				} catch(PDOException $e) {
1404
+				} catch (PDOException $e) {
1405 1405
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1406 1406
 				}
1407 1407
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1452,23 +1452,23 @@  discard block
 block discarded – undo
1452 1452
 				try {
1453 1453
 					$sth = $Connection->db->prepare($query);
1454 1454
 					$sth->execute();
1455
-				} catch(PDOException $e) {
1455
+				} catch (PDOException $e) {
1456 1456
 					return "error (fix date) : ".$e->getMessage()."\n";
1457 1457
 				}
1458 1458
 			}
1459
-			if ($Connection->getColumnType('spotter_archive_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_archive_output','last_seen') != 'TIMESTAMP') {
1459
+			if ($Connection->getColumnType('spotter_archive_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_archive_output', 'last_seen') != 'TIMESTAMP') {
1460 1460
 				$query = "ALTER TABLE spotter_archive_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1461 1461
 				try {
1462 1462
 					$sth = $Connection->db->prepare($query);
1463 1463
 					$sth->execute();
1464
-				} catch(PDOException $e) {
1464
+				} catch (PDOException $e) {
1465 1465
 					return "error (convert spotter_archive_output last_seen to timestamp) : ".$e->getMessage()."\n";
1466 1466
 				}
1467 1467
 				$query = "ALTER TABLE spotter_archive_output ALTER COLUMN last_seen DROP DEFAULT";
1468 1468
 				try {
1469 1469
 					$sth = $Connection->db->prepare($query);
1470 1470
 					$sth->execute();
1471
-				} catch(PDOException $e) {
1471
+				} catch (PDOException $e) {
1472 1472
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1473 1473
 				}
1474 1474
 				/*
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
 				try {
1521 1521
 					$sth = $Connection->db->prepare($query);
1522 1522
 					$sth->execute();
1523
-				} catch(PDOException $e) {
1523
+				} catch (PDOException $e) {
1524 1524
 					return "error (fix date) : ".$e->getMessage()."\n";
1525 1525
 				}
1526 1526
 			}
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 		try {
1530 1530
 			$sth = $Connection->db->prepare($query);
1531 1531
 			$sth->execute();
1532
-		} catch(PDOException $e) {
1532
+		} catch (PDOException $e) {
1533 1533
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1534 1534
 		}
1535 1535
 		return $error;
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
 		    try {
1552 1552
             		$sth = $Connection->db->prepare($query);
1553 1553
 		        $sth->execute();
1554
-		    } catch(PDOException $e) {
1554
+		    } catch (PDOException $e) {
1555 1555
 			return "error : ".$e->getMessage()."\n";
1556 1556
     		    }
1557 1557
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +277 added lines, -104 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1543,8 +1609,11 @@  discard block
 block discarded – undo
1543 1609
     	    if ($Connection->tableExists('aircraft')) {
1544 1610
     		if (!$Connection->tableExists('config')) {
1545 1611
     		    $version = '1';
1546
-    		    if ($update) return self::update_from_1();
1547
-    		    else return $version;
1612
+    		    if ($update) {
1613
+    		    	return self::update_from_1();
1614
+    		    } else {
1615
+    		    	return $version;
1616
+    		    }
1548 1617
 		} else {
1549 1618
     		    $Connection = new Connection();
1550 1619
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1558,142 +1627,246 @@  discard block
 block discarded – undo
1558 1627
     		    if ($update) {
1559 1628
     			if ($result['value'] == '2') {
1560 1629
     			    $error = self::update_from_2();
1561
-    			    if ($error != '') return $error;
1562
-    			    else return self::check_version(true);
1630
+    			    if ($error != '') {
1631
+    			    	return $error;
1632
+    			    } else {
1633
+    			    	return self::check_version(true);
1634
+    			    }
1563 1635
     			} elseif ($result['value'] == '3') {
1564 1636
     			    $error = self::update_from_3();
1565
-    			    if ($error != '') return $error;
1566
-    			    else return self::check_version(true);
1637
+    			    if ($error != '') {
1638
+    			    	return $error;
1639
+    			    } else {
1640
+    			    	return self::check_version(true);
1641
+    			    }
1567 1642
     			} elseif ($result['value'] == '4') {
1568 1643
     			    $error = self::update_from_4();
1569
-    			    if ($error != '') return $error;
1570
-    			    else return self::check_version(true);
1644
+    			    if ($error != '') {
1645
+    			    	return $error;
1646
+    			    } else {
1647
+    			    	return self::check_version(true);
1648
+    			    }
1571 1649
     			} elseif ($result['value'] == '5') {
1572 1650
     			    $error = self::update_from_5();
1573
-    			    if ($error != '') return $error;
1574
-    			    else return self::check_version(true);
1651
+    			    if ($error != '') {
1652
+    			    	return $error;
1653
+    			    } else {
1654
+    			    	return self::check_version(true);
1655
+    			    }
1575 1656
     			} elseif ($result['value'] == '6') {
1576 1657
     			    $error = self::update_from_6();
1577
-    			    if ($error != '') return $error;
1578
-    			    else return self::check_version(true);
1658
+    			    if ($error != '') {
1659
+    			    	return $error;
1660
+    			    } else {
1661
+    			    	return self::check_version(true);
1662
+    			    }
1579 1663
     			} elseif ($result['value'] == '7') {
1580 1664
     			    $error = self::update_from_7();
1581
-    			    if ($error != '') return $error;
1582
-    			    else return self::check_version(true);
1665
+    			    if ($error != '') {
1666
+    			    	return $error;
1667
+    			    } else {
1668
+    			    	return self::check_version(true);
1669
+    			    }
1583 1670
     			} elseif ($result['value'] == '8') {
1584 1671
     			    $error = self::update_from_8();
1585
-    			    if ($error != '') return $error;
1586
-    			    else return self::check_version(true);
1672
+    			    if ($error != '') {
1673
+    			    	return $error;
1674
+    			    } else {
1675
+    			    	return self::check_version(true);
1676
+    			    }
1587 1677
     			} elseif ($result['value'] == '9') {
1588 1678
     			    $error = self::update_from_9();
1589
-    			    if ($error != '') return $error;
1590
-    			    else return self::check_version(true);
1679
+    			    if ($error != '') {
1680
+    			    	return $error;
1681
+    			    } else {
1682
+    			    	return self::check_version(true);
1683
+    			    }
1591 1684
     			} elseif ($result['value'] == '10') {
1592 1685
     			    $error = self::update_from_10();
1593
-    			    if ($error != '') return $error;
1594
-    			    else return self::check_version(true);
1686
+    			    if ($error != '') {
1687
+    			    	return $error;
1688
+    			    } else {
1689
+    			    	return self::check_version(true);
1690
+    			    }
1595 1691
     			} elseif ($result['value'] == '11') {
1596 1692
     			    $error = self::update_from_11();
1597
-    			    if ($error != '') return $error;
1598
-    			    else return self::check_version(true);
1693
+    			    if ($error != '') {
1694
+    			    	return $error;
1695
+    			    } else {
1696
+    			    	return self::check_version(true);
1697
+    			    }
1599 1698
     			} elseif ($result['value'] == '12') {
1600 1699
     			    $error = self::update_from_12();
1601
-    			    if ($error != '') return $error;
1602
-    			    else return self::check_version(true);
1700
+    			    if ($error != '') {
1701
+    			    	return $error;
1702
+    			    } else {
1703
+    			    	return self::check_version(true);
1704
+    			    }
1603 1705
     			} elseif ($result['value'] == '13') {
1604 1706
     			    $error = self::update_from_13();
1605
-    			    if ($error != '') return $error;
1606
-    			    else return self::check_version(true);
1707
+    			    if ($error != '') {
1708
+    			    	return $error;
1709
+    			    } else {
1710
+    			    	return self::check_version(true);
1711
+    			    }
1607 1712
     			} elseif ($result['value'] == '14') {
1608 1713
     			    $error = self::update_from_14();
1609
-    			    if ($error != '') return $error;
1610
-    			    else return self::check_version(true);
1714
+    			    if ($error != '') {
1715
+    			    	return $error;
1716
+    			    } else {
1717
+    			    	return self::check_version(true);
1718
+    			    }
1611 1719
     			} elseif ($result['value'] == '15') {
1612 1720
     			    $error = self::update_from_15();
1613
-    			    if ($error != '') return $error;
1614
-    			    else return self::check_version(true);
1721
+    			    if ($error != '') {
1722
+    			    	return $error;
1723
+    			    } else {
1724
+    			    	return self::check_version(true);
1725
+    			    }
1615 1726
     			} elseif ($result['value'] == '16') {
1616 1727
     			    $error = self::update_from_16();
1617
-    			    if ($error != '') return $error;
1618
-    			    else return self::check_version(true);
1728
+    			    if ($error != '') {
1729
+    			    	return $error;
1730
+    			    } else {
1731
+    			    	return self::check_version(true);
1732
+    			    }
1619 1733
     			} elseif ($result['value'] == '17') {
1620 1734
     			    $error = self::update_from_17();
1621
-    			    if ($error != '') return $error;
1622
-    			    else return self::check_version(true);
1735
+    			    if ($error != '') {
1736
+    			    	return $error;
1737
+    			    } else {
1738
+    			    	return self::check_version(true);
1739
+    			    }
1623 1740
     			} elseif ($result['value'] == '18') {
1624 1741
     			    $error = self::update_from_18();
1625
-    			    if ($error != '') return $error;
1626
-    			    else return self::check_version(true);
1742
+    			    if ($error != '') {
1743
+    			    	return $error;
1744
+    			    } else {
1745
+    			    	return self::check_version(true);
1746
+    			    }
1627 1747
     			} elseif ($result['value'] == '19') {
1628 1748
     			    $error = self::update_from_19();
1629
-    			    if ($error != '') return $error;
1630
-    			    else return self::check_version(true);
1749
+    			    if ($error != '') {
1750
+    			    	return $error;
1751
+    			    } else {
1752
+    			    	return self::check_version(true);
1753
+    			    }
1631 1754
     			} elseif ($result['value'] == '20') {
1632 1755
     			    $error = self::update_from_20();
1633
-    			    if ($error != '') return $error;
1634
-    			    else return self::check_version(true);
1756
+    			    if ($error != '') {
1757
+    			    	return $error;
1758
+    			    } else {
1759
+    			    	return self::check_version(true);
1760
+    			    }
1635 1761
     			} elseif ($result['value'] == '21') {
1636 1762
     			    $error = self::update_from_21();
1637
-    			    if ($error != '') return $error;
1638
-    			    else return self::check_version(true);
1763
+    			    if ($error != '') {
1764
+    			    	return $error;
1765
+    			    } else {
1766
+    			    	return self::check_version(true);
1767
+    			    }
1639 1768
     			} elseif ($result['value'] == '22') {
1640 1769
     			    $error = self::update_from_22();
1641
-    			    if ($error != '') return $error;
1642
-    			    else return self::check_version(true);
1770
+    			    if ($error != '') {
1771
+    			    	return $error;
1772
+    			    } else {
1773
+    			    	return self::check_version(true);
1774
+    			    }
1643 1775
     			} elseif ($result['value'] == '23') {
1644 1776
     			    $error = self::update_from_23();
1645
-    			    if ($error != '') return $error;
1646
-    			    else return self::check_version(true);
1777
+    			    if ($error != '') {
1778
+    			    	return $error;
1779
+    			    } else {
1780
+    			    	return self::check_version(true);
1781
+    			    }
1647 1782
     			} elseif ($result['value'] == '24') {
1648 1783
     			    $error = self::update_from_24();
1649
-    			    if ($error != '') return $error;
1650
-    			    else return self::check_version(true);
1784
+    			    if ($error != '') {
1785
+    			    	return $error;
1786
+    			    } else {
1787
+    			    	return self::check_version(true);
1788
+    			    }
1651 1789
     			} elseif ($result['value'] == '25') {
1652 1790
     			    $error = self::update_from_25();
1653
-    			    if ($error != '') return $error;
1654
-    			    else return self::check_version(true);
1791
+    			    if ($error != '') {
1792
+    			    	return $error;
1793
+    			    } else {
1794
+    			    	return self::check_version(true);
1795
+    			    }
1655 1796
     			} elseif ($result['value'] == '26') {
1656 1797
     			    $error = self::update_from_26();
1657
-    			    if ($error != '') return $error;
1658
-    			    else return self::check_version(true);
1798
+    			    if ($error != '') {
1799
+    			    	return $error;
1800
+    			    } else {
1801
+    			    	return self::check_version(true);
1802
+    			    }
1659 1803
     			} elseif ($result['value'] == '27') {
1660 1804
     			    $error = self::update_from_27();
1661
-    			    if ($error != '') return $error;
1662
-    			    else return self::check_version(true);
1805
+    			    if ($error != '') {
1806
+    			    	return $error;
1807
+    			    } else {
1808
+    			    	return self::check_version(true);
1809
+    			    }
1663 1810
     			} elseif ($result['value'] == '28') {
1664 1811
     			    $error = self::update_from_28();
1665
-    			    if ($error != '') return $error;
1666
-    			    else return self::check_version(true);
1812
+    			    if ($error != '') {
1813
+    			    	return $error;
1814
+    			    } else {
1815
+    			    	return self::check_version(true);
1816
+    			    }
1667 1817
     			} elseif ($result['value'] == '29') {
1668 1818
     			    $error = self::update_from_29();
1669
-    			    if ($error != '') return $error;
1670
-    			    else return self::check_version(true);
1819
+    			    if ($error != '') {
1820
+    			    	return $error;
1821
+    			    } else {
1822
+    			    	return self::check_version(true);
1823
+    			    }
1671 1824
     			} elseif ($result['value'] == '30') {
1672 1825
     			    $error = self::update_from_30();
1673
-    			    if ($error != '') return $error;
1674
-    			    else return self::check_version(true);
1826
+    			    if ($error != '') {
1827
+    			    	return $error;
1828
+    			    } else {
1829
+    			    	return self::check_version(true);
1830
+    			    }
1675 1831
     			} elseif ($result['value'] == '31') {
1676 1832
     			    $error = self::update_from_31();
1677
-    			    if ($error != '') return $error;
1678
-    			    else return self::check_version(true);
1833
+    			    if ($error != '') {
1834
+    			    	return $error;
1835
+    			    } else {
1836
+    			    	return self::check_version(true);
1837
+    			    }
1679 1838
     			} elseif ($result['value'] == '32') {
1680 1839
     			    $error = self::update_from_32();
1681
-    			    if ($error != '') return $error;
1682
-    			    else return self::check_version(true);
1840
+    			    if ($error != '') {
1841
+    			    	return $error;
1842
+    			    } else {
1843
+    			    	return self::check_version(true);
1844
+    			    }
1683 1845
     			} elseif ($result['value'] == '33') {
1684 1846
     			    $error = self::update_from_33();
1685
-    			    if ($error != '') return $error;
1686
-    			    else return self::check_version(true);
1847
+    			    if ($error != '') {
1848
+    			    	return $error;
1849
+    			    } else {
1850
+    			    	return self::check_version(true);
1851
+    			    }
1687 1852
     			} elseif ($result['value'] == '34') {
1688 1853
     			    $error = self::update_from_34();
1689
-    			    if ($error != '') return $error;
1690
-    			    else return self::check_version(true);
1691
-    			} else return '';
1854
+    			    if ($error != '') {
1855
+    			    	return $error;
1856
+    			    } else {
1857
+    			    	return self::check_version(true);
1858
+    			    }
1859
+    			} else {
1860
+    				return '';
1861
+    			}
1862
+    		    } else {
1863
+    		    	return $result['value'];
1692 1864
     		    }
1693
-    		    else return $result['value'];
1694 1865
 		}
1695 1866
 		
1696
-	    } else return $version;
1867
+	    } else {
1868
+	    	return $version;
1869
+	    }
1697 1870
     	}
1698 1871
     	
1699 1872
 }
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +693 added lines, -693 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 if (PHP_SAPI != 'cli') {
26
-    echo "This script MUST be called from console, not a web browser.";
26
+	echo "This script MUST be called from console, not a web browser.";
27 27
 //    exit();
28 28
 }
29 29
 
30 30
 // This is to be compatible with old version of settings.php
31 31
 if (!isset($globalSources)) {
32
-    if (isset($globalSBS1Hosts)) {
33
-        //$hosts = $globalSBS1Hosts;
34
-        foreach ($globalSBS1Hosts as $host) {
35
-	    $globalSources[] = array('host' => $host);
36
-    	}
37
-    } else {
38
-        if (!isset($globalSBS1Host)) {
39
-	    echo '$globalSources MUST be defined !';
40
-	    die;
32
+	if (isset($globalSBS1Hosts)) {
33
+		//$hosts = $globalSBS1Hosts;
34
+		foreach ($globalSBS1Hosts as $host) {
35
+		$globalSources[] = array('host' => $host);
36
+		}
37
+	} else {
38
+		if (!isset($globalSBS1Host)) {
39
+		echo '$globalSources MUST be defined !';
40
+		die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43 43
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
44
-    }
44
+	}
45 45
 }
46 46
 
47 47
 $options = getopt('s::',array('source::','server','idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['s']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['s']);
53 53
 } elseif (isset($options['source'])) {
54
-    $globalSources = array();
55
-    $globalSources[] = array('host' => $options['source']);
54
+	$globalSources = array();
55
+	$globalSources[] = array('host' => $options['source']);
56 56
 }
57 57
 if (isset($options['server'])) $globalServer = TRUE;
58 58
 if (isset($options['idsource'])) $id_source = $options['idsource'];
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
61
+	if ($globalDebug) echo "Using Server Mode\n";
62
+	$SI=new SpotterServer();
63 63
 } else $SI=new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65 65
 $SBS=new SBS();
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
73
-        global $sockets;
74
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
-        die("Bye!\n");
76
-    });
77
-    pcntl_signal_dispatch();
72
+	pcntl_signal(SIGINT,  function() {
73
+		global $sockets;
74
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
+		die("Bye!\n");
76
+	});
77
+	pcntl_signal_dispatch();
78 78
 }
79 79
 
80 80
 // let's try and connect
@@ -84,162 +84,162 @@  discard block
 block discarded – undo
84 84
 $reset = 0;
85 85
 
86 86
 function create_socket($host, $port, &$errno, &$errstr) {
87
-    $ip = gethostbyname($host);
88
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
89
-    $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
-        return $s;
93
-    }
94
-    $errno = socket_last_error($s);
95
-    $errstr = socket_strerror($errno);
96
-    socket_close($s);
97
-    return false;
87
+	$ip = gethostbyname($host);
88
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
89
+	$r = @socket_connect($s, $ip, $port);
90
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
+		return $s;
93
+	}
94
+	$errno = socket_last_error($s);
95
+	$errstr = socket_strerror($errno);
96
+	socket_close($s);
97
+	return false;
98 98
 }
99 99
 
100 100
 function create_socket_udp($host, $port, &$errno, &$errstr) {
101
-    echo "Create an UDP socket...\n";
102
-    $ip = gethostbyname($host);
103
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
-    $r = @socket_bind($s, $ip, $port);
105
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
-        return $s;
107
-    }
108
-    $errno = socket_last_error($s);
109
-    $errstr = socket_strerror($errno);
110
-    socket_close($s);
111
-    return false;
101
+	echo "Create an UDP socket...\n";
102
+	$ip = gethostbyname($host);
103
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
+	$r = @socket_bind($s, $ip, $port);
105
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
+		return $s;
107
+	}
108
+	$errno = socket_last_error($s);
109
+	$errstr = socket_strerror($errno);
110
+	socket_close($s);
111
+	return false;
112 112
 }
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
-        	//$formats[$id] = 'radarvirtueljson';
146
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
147
-        	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
-        	    exit(0);
152
-        	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
-        	//$formats[$id] = 'planeupdatefaa';
155
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
156
-        	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
-        	    exit(0);
161
-        	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'phpvmacars';
165
-        	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
-        	//$formats[$id] = 'phpvmacars';
169
-        	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
172
-        	//$formats[$id] = 'whazzup';
173
-        	$globalSources[$id]['format'] = 'whazzup';
174
-        	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
177
-        	//$formats[$id] = 'pirepsjson';
178
-        	$globalSources[$id]['format'] = 'pirepsjson';
179
-        	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
-        	//$formats[$id] = 'fr24json';
183
-        	$globalSources[$id]['format'] = 'fr24json';
184
-        	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
-        	    exit(0);
189
-        	}
190
-            //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
-        	//$formats[$id] = 'tsv';
193
-        	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
-            }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
200
-	    if (isset($hostport[1])) {
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
+			//$formats[$id] = 'radarvirtueljson';
146
+			$globalSources[$id]['format'] = 'radarvirtueljson';
147
+			//$last_exec['radarvirtueljson'] = 0;
148
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
+				exit(0);
152
+			}
153
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+			//$formats[$id] = 'planeupdatefaa';
155
+			$globalSources[$id]['format'] = 'planeupdatefaa';
156
+			//$last_exec['planeupdatefaa'] = 0;
157
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
+				exit(0);
161
+			}
162
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'phpvmacars';
165
+			//$last_exec['phpvmacars'] = 0;
166
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
168
+			//$formats[$id] = 'phpvmacars';
169
+			$globalSources[$id]['format'] = 'vam';
170
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
+			} else if (preg_match('/whazzup/i',$host)) {
172
+			//$formats[$id] = 'whazzup';
173
+			$globalSources[$id]['format'] = 'whazzup';
174
+			//$last_exec['whazzup'] = 0;
175
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
+			} else if (preg_match('/recentpireps/i',$host)) {
177
+			//$formats[$id] = 'pirepsjson';
178
+			$globalSources[$id]['format'] = 'pirepsjson';
179
+			//$last_exec['pirepsjson'] = 0;
180
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+			//$formats[$id] = 'fr24json';
183
+			$globalSources[$id]['format'] = 'fr24json';
184
+			//$last_exec['fr24json'] = 0;
185
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
+				exit(0);
189
+			}
190
+			//} else if (preg_match('/10001/',$host)) {
191
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
+			//$formats[$id] = 'tsv';
193
+			$globalSources[$id]['format'] = 'tsv';
194
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
+			}
196
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
+		$hostport = explode(':',$host);
200
+		if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
203
-	    } else {
203
+		} else {
204 204
 		$port = $globalSources[$id]['port'];
205 205
 		$hostn = $globalSources[$id]['host'];
206
-	    }
207
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
209
-    	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
-	    }
212
-	    if ($s) {
213
-    	        $sockets[$id] = $s;
214
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
206
+		}
207
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
+			$s = create_socket($hostn,$port, $errno, $errstr);
209
+			} else {
210
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
+		}
212
+		if ($s) {
213
+				$sockets[$id] = $s;
214
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
+			if (preg_match('/aprs/',$hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
219 219
 			//$use_aprs = true;
220
-    		    } elseif ($port == '10001') {
221
-        		//$formats[$id] = 'tsv';
222
-        		$globalSources[$id]['format'] = 'tsv';
223
-		    } elseif ($port == '30002') {
224
-        		//$formats[$id] = 'raw';
225
-        		$globalSources[$id]['format'] = 'raw';
226
-		    } elseif ($port == '5001') {
227
-        		//$formats[$id] = 'raw';
228
-        		$globalSources[$id]['format'] = 'flightgearmp';
229
-		    } elseif ($port == '30005') {
220
+				} elseif ($port == '10001') {
221
+				//$formats[$id] = 'tsv';
222
+				$globalSources[$id]['format'] = 'tsv';
223
+			} elseif ($port == '30002') {
224
+				//$formats[$id] = 'raw';
225
+				$globalSources[$id]['format'] = 'raw';
226
+			} elseif ($port == '5001') {
227
+				//$formats[$id] = 'raw';
228
+				$globalSources[$id]['format'] = 'flightgearmp';
229
+			} elseif ($port == '30005') {
230 230
 			// Not yet supported
231
-        		//$formats[$id] = 'beast';
232
-        		$globalSources[$id]['format'] = 'beast';
233
-		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
235
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231
+				//$formats[$id] = 'beast';
232
+				$globalSources[$id]['format'] = 'beast';
233
+			//} else $formats[$id] = 'sbs';
234
+			} else $globalSources[$id]['format'] = 'sbs';
235
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 236
 		}
237 237
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
238
-            } else {
238
+			} else {
239 239
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
240
-    	    }
241
-        }
242
-    }
240
+			}
241
+		}
242
+	}
243 243
 }
244 244
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
245 245
 
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
 	die;
267 267
 }
268 268
 foreach ($globalSources as $key => $source) {
269
-    if (!isset($source['format'])) {
270
-        $globalSources[$key]['format'] = 'auto';
271
-    }
269
+	if (!isset($source['format'])) {
270
+		$globalSources[$key]['format'] = 'auto';
271
+	}
272 272
 }
273 273
 connect_all($globalSources);
274 274
 foreach ($globalSources as $key => $source) {
275
-    if (isset($source['format']) && $source['format'] == 'aprs') {
275
+	if (isset($source['format']) && $source['format'] == 'aprs') {
276 276
 	$aprs_connect = 0;
277 277
 	$use_aprs = true;
278 278
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
279 279
 	break;
280
-    }
280
+	}
281 281
 }
282 282
 
283 283
 if ($use_aprs) {
@@ -317,70 +317,70 @@  discard block
 block discarded – undo
317 317
 
318 318
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
319 319
 while ($i > 0) {
320
-    if (!$globalDaemon) $i = $endtime-time();
321
-    // Delete old ATC
322
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
320
+	if (!$globalDaemon) $i = $endtime-time();
321
+	// Delete old ATC
322
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
323 323
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
324
-        $ATC->deleteOldATC();
325
-    }
324
+		$ATC->deleteOldATC();
325
+	}
326 326
     
327
-    if (count($last_exec) > 0) {
327
+	if (count($last_exec) > 0) {
328 328
 	$max = $globalMinFetch;
329 329
 	foreach ($last_exec as $last) {
330
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
330
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
331 331
 	}
332 332
 	if ($max != $globalMinFetch) {
333
-	    if ($globalDebug) echo 'Sleeping...'."\n";
334
-	    sleep($globalMinFetch-$max+2);
333
+		if ($globalDebug) echo 'Sleeping...'."\n";
334
+		sleep($globalMinFetch-$max+2);
335
+	}
335 336
 	}
336
-    }
337 337
 
338 338
     
339
-    //foreach ($formats as $id => $value) {
340
-    foreach ($globalSources as $id => $value) {
339
+	//foreach ($formats as $id => $value) {
340
+	foreach ($globalSources as $id => $value) {
341 341
 	date_default_timezone_set('UTC');
342 342
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
343 343
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
344
-	    //$buffer = $Common->getData($hosts[$id]);
345
-	    $buffer = $Common->getData($value['host']);
346
-	    if ($buffer != '') $reset = 0;
347
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
348
-	    $buffer = explode('\n',$buffer);
349
-	    foreach ($buffer as $line) {
350
-    		if ($line != '' && count($line) > 7) {
351
-    		    $line = explode(',', $line);
352
-	            $data = array();
353
-	            $data['hex'] = $line[1]; // hex
354
-	            $data['ident'] = $line[2]; // ident
355
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
356
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
357
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
358
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
359
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
360
-	            $data['verticalrate'] = ''; // vertical rate
361
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
362
-	            $data['emergency'] = ''; // emergency
363
-		    $data['datetime'] = date('Y-m-d H:i:s');
364
-		    $data['format_source'] = 'deltadbtxt';
365
-    		    $data['id_source'] = $id_source;
366
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
367
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
368
-    		    $SI->add($data);
369
-		    unset($data);
370
-    		}
371
-    	    }
372
-    	    $last_exec[$id]['last'] = time();
344
+		//$buffer = $Common->getData($hosts[$id]);
345
+		$buffer = $Common->getData($value['host']);
346
+		if ($buffer != '') $reset = 0;
347
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
348
+		$buffer = explode('\n',$buffer);
349
+		foreach ($buffer as $line) {
350
+			if ($line != '' && count($line) > 7) {
351
+				$line = explode(',', $line);
352
+				$data = array();
353
+				$data['hex'] = $line[1]; // hex
354
+				$data['ident'] = $line[2]; // ident
355
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
356
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
357
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
358
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
359
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
360
+				$data['verticalrate'] = ''; // vertical rate
361
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
362
+				$data['emergency'] = ''; // emergency
363
+			$data['datetime'] = date('Y-m-d H:i:s');
364
+			$data['format_source'] = 'deltadbtxt';
365
+				$data['id_source'] = $id_source;
366
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
367
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
368
+				$SI->add($data);
369
+			unset($data);
370
+			}
371
+			}
372
+			$last_exec[$id]['last'] = time();
373 373
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
374 374
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
375
-	    //$buffer = $Common->getData($hosts[$id]);
376
-	    $buffer = $Common->getData($value['host']);
377
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
378
-	    $buffer = explode('\n',$buffer);
379
-	    $reset = 0;
380
-	    foreach ($buffer as $line) {
381
-    		if ($line != '') {
382
-    		    $line = explode(':', $line);
383
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
375
+		//$buffer = $Common->getData($hosts[$id]);
376
+		$buffer = $Common->getData($value['host']);
377
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
378
+		$buffer = explode('\n',$buffer);
379
+		$reset = 0;
380
+		foreach ($buffer as $line) {
381
+			if ($line != '') {
382
+				$line = explode(':', $line);
383
+				if (count($line) > 30 && $line[0] != 'callsign') {
384 384
 			$data = array();
385 385
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
386 386
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -393,36 +393,36 @@  discard block
 block discarded – undo
393 393
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
394 394
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
395 395
 			$data['latitude'] = $line[5]; // lat
396
-	        	$data['longitude'] = $line[6]; // long
397
-	        	$data['verticalrate'] = ''; // vertical rate
398
-	        	$data['squawk'] = ''; // squawk
399
-	        	$data['emergency'] = ''; // emergency
400
-	        	$data['waypoints'] = $line[30];
396
+				$data['longitude'] = $line[6]; // long
397
+				$data['verticalrate'] = ''; // vertical rate
398
+				$data['squawk'] = ''; // squawk
399
+				$data['emergency'] = ''; // emergency
400
+				$data['waypoints'] = $line[30];
401 401
 			$data['datetime'] = date('Y-m-d H:i:s');
402 402
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
403 403
 			//if (isset($line[37])) $data['last_update'] = $line[37];
404
-		        $data['departure_airport_icao'] = $line[11];
405
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
406
-		        $data['arrival_airport_icao'] = $line[13];
404
+				$data['departure_airport_icao'] = $line[11];
405
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
406
+				$data['arrival_airport_icao'] = $line[13];
407 407
 			$data['frequency'] = $line[4];
408 408
 			$data['type'] = $line[18];
409 409
 			$data['range'] = $line[19];
410 410
 			if (isset($line[35])) $data['info'] = $line[35];
411
-    			$data['id_source'] = $id_source;
412
-	    		//$data['arrival_airport_time'] = ;
413
-	    		if ($line[9] != '') {
414
-	    		    $aircraft_data = explode('/',$line[9]);
415
-	    		    if (isset($aircraft_data[1])) {
416
-	    			$data['aircraft_icao'] = $aircraft_data[1];
417
-	    		    }
418
-        		}
419
-	    		/*
411
+				$data['id_source'] = $id_source;
412
+				//$data['arrival_airport_time'] = ;
413
+				if ($line[9] != '') {
414
+					$aircraft_data = explode('/',$line[9]);
415
+					if (isset($aircraft_data[1])) {
416
+					$data['aircraft_icao'] = $aircraft_data[1];
417
+					}
418
+				}
419
+				/*
420 420
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
421 421
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
422 422
 	    		*/
423
-	    		$data['format_source'] = $value['format'];
423
+				$data['format_source'] = $value['format'];
424 424
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
425
-    			if ($line[3] == 'PILOT') $SI->add($data);
425
+				if ($line[3] == 'PILOT') $SI->add($data);
426 426
 			elseif ($line[3] == 'ATC') {
427 427
 				//print_r($data);
428 428
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -440,247 +440,247 @@  discard block
 block discarded – undo
440 440
 				if (!isset($data['source_name'])) $data['source_name'] = '';
441 441
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
442 442
 			}
443
-    			unset($data);
444
-    		    }
445
-    		}
446
-    	    }
447
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
448
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
449
-    	    $last_exec[$id]['last'] = time();
450
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
451
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
452
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
453
-	    if ($buffer != '') {
454
-	    $all_data = json_decode($buffer,true);
455
-	    if (isset($all_data['acList'])) {
443
+				unset($data);
444
+				}
445
+			}
446
+			}
447
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
448
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
449
+			$last_exec[$id]['last'] = time();
450
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
451
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
452
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
453
+		if ($buffer != '') {
454
+		$all_data = json_decode($buffer,true);
455
+		if (isset($all_data['acList'])) {
456 456
 		$reset = 0;
457 457
 		foreach ($all_data['acList'] as $line) {
458
-		    $data = array();
459
-		    $data['hex'] = $line['Icao']; // hex
460
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
461
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
462
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
463
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
464
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
465
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
466
-		    //$data['verticalrate'] = $line['']; // verticale rate
467
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
468
-		    $data['emergency'] = ''; // emergency
469
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
470
-		    /*
458
+			$data = array();
459
+			$data['hex'] = $line['Icao']; // hex
460
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
461
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
462
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
463
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
464
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
465
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
466
+			//$data['verticalrate'] = $line['']; // verticale rate
467
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
468
+			$data['emergency'] = ''; // emergency
469
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
470
+			/*
471 471
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
472 472
 		    else $data['datetime'] = date('Y-m-d H:i:s');
473 473
 		    */
474
-		    $data['datetime'] = date('Y-m-d H:i:s');
475
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
476
-	    	    $data['format_source'] = 'aircraftlistjson';
477
-		    $data['id_source'] = $id_source;
478
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
479
-		    if (isset($data['datetime'])) $SI->add($data);
480
-		    unset($data);
474
+			$data['datetime'] = date('Y-m-d H:i:s');
475
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
476
+				$data['format_source'] = 'aircraftlistjson';
477
+			$data['id_source'] = $id_source;
478
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
479
+			if (isset($data['datetime'])) $SI->add($data);
480
+			unset($data);
481 481
 		}
482
-	    } else {
482
+		} else {
483 483
 		$reset = 0;
484 484
 		foreach ($all_data as $line) {
485
-		    $data = array();
486
-		    $data['hex'] = $line['hex']; // hex
487
-		    $data['ident'] = $line['flight']; // ident
488
-		    $data['altitude'] = $line['altitude']; // altitude
489
-		    $data['speed'] = $line['speed']; // speed
490
-		    $data['heading'] = $line['track']; // heading
491
-		    $data['latitude'] = $line['lat']; // lat
492
-		    $data['longitude'] = $line['lon']; // long
493
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
494
-		    $data['squawk'] = $line['squawk']; // squawk
495
-		    $data['emergency'] = ''; // emergency
496
-		    $data['datetime'] = date('Y-m-d H:i:s');
497
-	    	    $data['format_source'] = 'aircraftlistjson';
498
-    		    $data['id_source'] = $id_source;
499
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
500
-		    $SI->add($data);
501
-		    unset($data);
485
+			$data = array();
486
+			$data['hex'] = $line['hex']; // hex
487
+			$data['ident'] = $line['flight']; // ident
488
+			$data['altitude'] = $line['altitude']; // altitude
489
+			$data['speed'] = $line['speed']; // speed
490
+			$data['heading'] = $line['track']; // heading
491
+			$data['latitude'] = $line['lat']; // lat
492
+			$data['longitude'] = $line['lon']; // long
493
+			$data['verticalrate'] = $line['vrt']; // verticale rate
494
+			$data['squawk'] = $line['squawk']; // squawk
495
+			$data['emergency'] = ''; // emergency
496
+			$data['datetime'] = date('Y-m-d H:i:s');
497
+				$data['format_source'] = 'aircraftlistjson';
498
+				$data['id_source'] = $id_source;
499
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
500
+			$SI->add($data);
501
+			unset($data);
502
+		}
502 503
 		}
503
-	    }
504
-	    }
505
-    	    //$last_exec['aircraftlistjson'] = time();
506
-    	    $last_exec[$id]['last'] = time();
507
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
508
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
509
-	    $buffer = $Common->getData($value['host']);
510
-	    $all_data = json_decode($buffer,true);
511
-	    if (isset($all_data['planes'])) {
504
+		}
505
+			//$last_exec['aircraftlistjson'] = time();
506
+			$last_exec[$id]['last'] = time();
507
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
508
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
509
+		$buffer = $Common->getData($value['host']);
510
+		$all_data = json_decode($buffer,true);
511
+		if (isset($all_data['planes'])) {
512 512
 		$reset = 0;
513 513
 		foreach ($all_data['planes'] as $key => $line) {
514
-		    $data = array();
515
-		    $data['hex'] = $key; // hex
516
-		    $data['ident'] = $line[3]; // ident
517
-		    $data['altitude'] = $line[6]; // altitude
518
-		    $data['speed'] = $line[8]; // speed
519
-		    $data['heading'] = $line[7]; // heading
520
-		    $data['latitude'] = $line[4]; // lat
521
-		    $data['longitude'] = $line[5]; // long
522
-		    //$data['verticalrate'] = $line[]; // verticale rate
523
-		    $data['squawk'] = $line[10]; // squawk
524
-		    $data['emergency'] = ''; // emergency
525
-		    $data['registration'] = $line[2];
526
-		    $data['aircraft_icao'] = $line[0];
527
-		    $deparr = explode('-',$line[1]);
528
-		    if (count($deparr) == 2) {
514
+			$data = array();
515
+			$data['hex'] = $key; // hex
516
+			$data['ident'] = $line[3]; // ident
517
+			$data['altitude'] = $line[6]; // altitude
518
+			$data['speed'] = $line[8]; // speed
519
+			$data['heading'] = $line[7]; // heading
520
+			$data['latitude'] = $line[4]; // lat
521
+			$data['longitude'] = $line[5]; // long
522
+			//$data['verticalrate'] = $line[]; // verticale rate
523
+			$data['squawk'] = $line[10]; // squawk
524
+			$data['emergency'] = ''; // emergency
525
+			$data['registration'] = $line[2];
526
+			$data['aircraft_icao'] = $line[0];
527
+			$deparr = explode('-',$line[1]);
528
+			if (count($deparr) == 2) {
529 529
 			$data['departure_airport_icao'] = $deparr[0];
530 530
 			$data['arrival_airport_icao'] = $deparr[1];
531
-		    }
532
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
533
-	    	    $data['format_source'] = 'planeupdatefaa';
534
-    		    $data['id_source'] = $id_source;
535
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
536
-		    $SI->add($data);
537
-		    unset($data);
531
+			}
532
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
533
+				$data['format_source'] = 'planeupdatefaa';
534
+				$data['id_source'] = $id_source;
535
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
536
+			$SI->add($data);
537
+			unset($data);
538
+		}
538 539
 		}
539
-	    }
540
-    	    //$last_exec['planeupdatefaa'] = time();
541
-    	    $last_exec[$id]['last'] = time();
542
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
543
-	    $buffer = $Common->getData($value['host']);
544
-	    $all_data = json_decode($buffer,true);
545
-	    if (isset($all_data['states'])) {
540
+			//$last_exec['planeupdatefaa'] = time();
541
+			$last_exec[$id]['last'] = time();
542
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
543
+		$buffer = $Common->getData($value['host']);
544
+		$all_data = json_decode($buffer,true);
545
+		if (isset($all_data['states'])) {
546 546
 		$reset = 0;
547 547
 		foreach ($all_data['states'] as $key => $line) {
548
-		    $data = array();
549
-		    $data['hex'] = $line[0]; // hex
550
-		    $data['ident'] = trim($line[1]); // ident
551
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
552
-		    $data['speed'] = round($line[9]*1.94384); // speed
553
-		    $data['heading'] = round($line[10]); // heading
554
-		    $data['latitude'] = $line[5]; // lat
555
-		    $data['longitude'] = $line[6]; // long
556
-		    $data['verticalrate'] = $line[11]; // verticale rate
557
-		    //$data['squawk'] = $line[10]; // squawk
558
-		    //$data['emergency'] = ''; // emergency
559
-		    //$data['registration'] = $line[2];
560
-		    //$data['aircraft_icao'] = $line[0];
561
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
562
-	    	    $data['format_source'] = 'opensky';
563
-    		    $data['id_source'] = $id_source;
564
-		    $SI->add($data);
565
-		    unset($data);
548
+			$data = array();
549
+			$data['hex'] = $line[0]; // hex
550
+			$data['ident'] = trim($line[1]); // ident
551
+			$data['altitude'] = round($line[7]*3.28084); // altitude
552
+			$data['speed'] = round($line[9]*1.94384); // speed
553
+			$data['heading'] = round($line[10]); // heading
554
+			$data['latitude'] = $line[5]; // lat
555
+			$data['longitude'] = $line[6]; // long
556
+			$data['verticalrate'] = $line[11]; // verticale rate
557
+			//$data['squawk'] = $line[10]; // squawk
558
+			//$data['emergency'] = ''; // emergency
559
+			//$data['registration'] = $line[2];
560
+			//$data['aircraft_icao'] = $line[0];
561
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
562
+				$data['format_source'] = 'opensky';
563
+				$data['id_source'] = $id_source;
564
+			$SI->add($data);
565
+			unset($data);
566
+		}
566 567
 		}
567
-	    }
568
-    	    //$last_exec['planeupdatefaa'] = time();
569
-    	    $last_exec[$id]['last'] = time();
570
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
571
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
572
-	    //$buffer = $Common->getData($hosts[$id]);
573
-	    $buffer = $Common->getData($value['host']);
574
-	    $all_data = json_decode($buffer,true);
575
-	    if (!empty($all_data)) $reset = 0;
576
-	    foreach ($all_data as $key => $line) {
568
+			//$last_exec['planeupdatefaa'] = time();
569
+			$last_exec[$id]['last'] = time();
570
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
571
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
572
+		//$buffer = $Common->getData($hosts[$id]);
573
+		$buffer = $Common->getData($value['host']);
574
+		$all_data = json_decode($buffer,true);
575
+		if (!empty($all_data)) $reset = 0;
576
+		foreach ($all_data as $key => $line) {
577 577
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
578
-		    $data = array();
579
-		    $data['hex'] = $line[0];
580
-		    $data['ident'] = $line[16]; //$line[13]
581
-	    	    $data['altitude'] = $line[4]; // altitude
582
-	    	    $data['speed'] = $line[5]; // speed
583
-	    	    $data['heading'] = $line[3]; // heading
584
-	    	    $data['latitude'] = $line[1]; // lat
585
-	    	    $data['longitude'] = $line[2]; // long
586
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
587
-	    	    $data['squawk'] = $line[6]; // squawk
588
-	    	    $data['aircraft_icao'] = $line[8];
589
-	    	    $data['registration'] = $line[9];
590
-		    $data['departure_airport_iata'] = $line[11];
591
-		    $data['arrival_airport_iata'] = $line[12];
592
-	    	    $data['emergency'] = ''; // emergency
593
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
594
-	    	    $data['format_source'] = 'fr24json';
595
-    		    $data['id_source'] = $id_source;
596
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
597
-		    $SI->add($data);
598
-		    unset($data);
578
+			$data = array();
579
+			$data['hex'] = $line[0];
580
+			$data['ident'] = $line[16]; //$line[13]
581
+				$data['altitude'] = $line[4]; // altitude
582
+				$data['speed'] = $line[5]; // speed
583
+				$data['heading'] = $line[3]; // heading
584
+				$data['latitude'] = $line[1]; // lat
585
+				$data['longitude'] = $line[2]; // long
586
+				$data['verticalrate'] = $line[15]; // verticale rate
587
+				$data['squawk'] = $line[6]; // squawk
588
+				$data['aircraft_icao'] = $line[8];
589
+				$data['registration'] = $line[9];
590
+			$data['departure_airport_iata'] = $line[11];
591
+			$data['arrival_airport_iata'] = $line[12];
592
+				$data['emergency'] = ''; // emergency
593
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
594
+				$data['format_source'] = 'fr24json';
595
+				$data['id_source'] = $id_source;
596
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
597
+			$SI->add($data);
598
+			unset($data);
599
+		}
599 600
 		}
600
-	    }
601
-    	    //$last_exec['fr24json'] = time();
602
-    	    $last_exec[$id]['last'] = time();
603
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
604
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
605
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
606
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
607
-	    //echo $buffer;
608
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
609
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
610
-	    $all_data = json_decode($buffer,true);
611
-	    if (json_last_error() != JSON_ERROR_NONE) {
601
+			//$last_exec['fr24json'] = time();
602
+			$last_exec[$id]['last'] = time();
603
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
604
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
605
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
606
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
607
+		//echo $buffer;
608
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
609
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
610
+		$all_data = json_decode($buffer,true);
611
+		if (json_last_error() != JSON_ERROR_NONE) {
612 612
 		die(json_last_error_msg());
613
-	    }
614
-	    if (isset($all_data['mrkrs'])) {
613
+		}
614
+		if (isset($all_data['mrkrs'])) {
615 615
 		$reset = 0;
616 616
 		foreach ($all_data['mrkrs'] as $key => $line) {
617
-		    if (isset($line['inf'])) {
617
+			if (isset($line['inf'])) {
618 618
 			$data = array();
619 619
 			$data['hex'] = $line['inf']['ia'];
620 620
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
621
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
622
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
623
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
624
-	    		$data['latitude'] = $line['pt'][0]; // lat
625
-	    		$data['longitude'] = $line['pt'][1]; // long
626
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
627
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
628
-	    		//$data['aircraft_icao'] = $line[8];
629
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
621
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
622
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
623
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
624
+				$data['latitude'] = $line['pt'][0]; // lat
625
+				$data['longitude'] = $line['pt'][1]; // long
626
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
627
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
628
+				//$data['aircraft_icao'] = $line[8];
629
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
630 630
 			//$data['departure_airport_iata'] = $line[11];
631 631
 			//$data['arrival_airport_iata'] = $line[12];
632
-	    		//$data['emergency'] = ''; // emergency
632
+				//$data['emergency'] = ''; // emergency
633 633
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
634
-	    		$data['format_source'] = 'radarvirtueljson';
635
-    			$data['id_source'] = $id_source;
634
+				$data['format_source'] = 'radarvirtueljson';
635
+				$data['id_source'] = $id_source;
636 636
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
637 637
 			$SI->add($data);
638 638
 			unset($data);
639
-		    }
639
+			}
640
+		}
640 641
 		}
641
-	    }
642
-    	    //$last_exec['radarvirtueljson'] = time();
643
-    	    $last_exec[$id]['last'] = time();
644
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
645
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
646
-	    //$buffer = $Common->getData($hosts[$id]);
647
-	    $buffer = $Common->getData($value['host'].'?'.time());
648
-	    $all_data = json_decode(utf8_encode($buffer),true);
642
+			//$last_exec['radarvirtueljson'] = time();
643
+			$last_exec[$id]['last'] = time();
644
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
645
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
646
+		//$buffer = $Common->getData($hosts[$id]);
647
+		$buffer = $Common->getData($value['host'].'?'.time());
648
+		$all_data = json_decode(utf8_encode($buffer),true);
649 649
 	    
650
-	    if (isset($all_data['pireps'])) {
650
+		if (isset($all_data['pireps'])) {
651 651
 		$reset = 0;
652
-	        foreach ($all_data['pireps'] as $line) {
653
-		    $data = array();
654
-		    $data['id'] = $line['id'];
655
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
656
-		    $data['ident'] = $line['callsign']; // ident
657
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
658
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
659
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
660
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
661
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
662
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
663
-		    $data['latitude'] = $line['lat']; // lat
664
-		    $data['longitude'] = $line['lon']; // long
665
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
666
-		    //$data['squawk'] = $line['squawk']; // squawk
667
-		    //$data['emergency'] = ''; // emergency
668
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
669
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
670
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
671
-		    //$data['arrival_airport_time'] = $line['arrtime'];
672
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
673
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
674
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
675
-		    else $data['info'] = '';
676
-		    $data['format_source'] = 'pireps';
677
-    		    $data['id_source'] = $id_source;
678
-		    $data['datetime'] = date('Y-m-d H:i:s');
679
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
680
-		    if ($line['icon'] == 'plane') {
652
+			foreach ($all_data['pireps'] as $line) {
653
+			$data = array();
654
+			$data['id'] = $line['id'];
655
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
656
+			$data['ident'] = $line['callsign']; // ident
657
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
658
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
659
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
660
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
661
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
662
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
663
+			$data['latitude'] = $line['lat']; // lat
664
+			$data['longitude'] = $line['lon']; // long
665
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
666
+			//$data['squawk'] = $line['squawk']; // squawk
667
+			//$data['emergency'] = ''; // emergency
668
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
669
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
670
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
671
+			//$data['arrival_airport_time'] = $line['arrtime'];
672
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
673
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
674
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
675
+			else $data['info'] = '';
676
+			$data['format_source'] = 'pireps';
677
+				$data['id_source'] = $id_source;
678
+			$data['datetime'] = date('Y-m-d H:i:s');
679
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
680
+			if ($line['icon'] == 'plane') {
681 681
 			$SI->add($data);
682
-		    //    print_r($data);
683
-    		    } elseif ($line['icon'] == 'ct') {
682
+			//    print_r($data);
683
+				} elseif ($line['icon'] == 'ct') {
684 684
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
685 685
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
686 686
 			$typec = substr($data['ident'],-3);
@@ -695,163 +695,163 @@  discard block
 block discarded – undo
695 695
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
696 696
 			else $data['type'] = 'Observer';
697 697
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
698
-		    }
699
-		    unset($data);
698
+			}
699
+			unset($data);
700
+		}
700 701
 		}
701
-	    }
702
-    	    //$last_exec['pirepsjson'] = time();
703
-    	    $last_exec[$id]['last'] = time();
704
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
705
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
706
-	    //$buffer = $Common->getData($hosts[$id]);
707
-	    if ($globalDebug) echo 'Get Data...'."\n";
708
-	    $buffer = $Common->getData($value['host']);
709
-	    $all_data = json_decode($buffer,true);
710
-	    if ($buffer != '' && is_array($all_data)) {
702
+			//$last_exec['pirepsjson'] = time();
703
+			$last_exec[$id]['last'] = time();
704
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
705
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
706
+		//$buffer = $Common->getData($hosts[$id]);
707
+		if ($globalDebug) echo 'Get Data...'."\n";
708
+		$buffer = $Common->getData($value['host']);
709
+		$all_data = json_decode($buffer,true);
710
+		if ($buffer != '' && is_array($all_data)) {
711 711
 		$reset = 0;
712 712
 		foreach ($all_data as $line) {
713
-	    	    $data = array();
714
-	    	    //$data['id'] = $line['id']; // id not usable
715
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
716
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
717
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
718
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
719
-	    	    $data['ident'] = $line['flightnum']; // ident
720
-	    	    $data['altitude'] = $line['alt']; // altitude
721
-	    	    $data['speed'] = $line['gs']; // speed
722
-	    	    $data['heading'] = $line['heading']; // heading
723
-	    	    $data['latitude'] = $line['lat']; // lat
724
-	    	    $data['longitude'] = $line['lng']; // long
725
-	    	    $data['verticalrate'] = ''; // verticale rate
726
-	    	    $data['squawk'] = ''; // squawk
727
-	    	    $data['emergency'] = ''; // emergency
728
-	    	    //$data['datetime'] = $line['lastupdate'];
729
-	    	    $data['last_update'] = $line['lastupdate'];
730
-		    $data['datetime'] = date('Y-m-d H:i:s');
731
-	    	    $data['departure_airport_icao'] = $line['depicao'];
732
-	    	    $data['departure_airport_time'] = $line['deptime'];
733
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
734
-    		    $data['arrival_airport_time'] = $line['arrtime'];
735
-    		    $data['registration'] = $line['aircraft'];
736
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
737
-		    if (isset($line['aircraftname'])) {
713
+				$data = array();
714
+				//$data['id'] = $line['id']; // id not usable
715
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
716
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
717
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
718
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
719
+				$data['ident'] = $line['flightnum']; // ident
720
+				$data['altitude'] = $line['alt']; // altitude
721
+				$data['speed'] = $line['gs']; // speed
722
+				$data['heading'] = $line['heading']; // heading
723
+				$data['latitude'] = $line['lat']; // lat
724
+				$data['longitude'] = $line['lng']; // long
725
+				$data['verticalrate'] = ''; // verticale rate
726
+				$data['squawk'] = ''; // squawk
727
+				$data['emergency'] = ''; // emergency
728
+				//$data['datetime'] = $line['lastupdate'];
729
+				$data['last_update'] = $line['lastupdate'];
730
+			$data['datetime'] = date('Y-m-d H:i:s');
731
+				$data['departure_airport_icao'] = $line['depicao'];
732
+				$data['departure_airport_time'] = $line['deptime'];
733
+				$data['arrival_airport_icao'] = $line['arricao'];
734
+				$data['arrival_airport_time'] = $line['arrtime'];
735
+				$data['registration'] = $line['aircraft'];
736
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
737
+			if (isset($line['aircraftname'])) {
738 738
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
739 739
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
740
-	    		$aircraft_data = explode('-',$line['aircraftname']);
741
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
742
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
743
-	    		else {
744
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
745
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
746
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
747
-	    		}
748
-	    	    }
749
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
750
-    		    $data['id_source'] = $id_source;
751
-	    	    $data['format_source'] = 'phpvmacars';
752
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
753
-		    $SI->add($data);
754
-		    unset($data);
740
+				$aircraft_data = explode('-',$line['aircraftname']);
741
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
742
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
743
+				else {
744
+					$aircraft_data = explode(' ',$line['aircraftname']);
745
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
746
+					else $data['aircraft_icao'] = $line['aircraftname'];
747
+				}
748
+				}
749
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
750
+				$data['id_source'] = $id_source;
751
+				$data['format_source'] = 'phpvmacars';
752
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
753
+			$SI->add($data);
754
+			unset($data);
755 755
 		}
756 756
 		if ($globalDebug) echo 'No more data...'."\n";
757 757
 		unset($buffer);
758 758
 		unset($all_data);
759
-	    }
760
-    	    //$last_exec['phpvmacars'] = time();
761
-    	    $last_exec[$id]['last'] = time();
762
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
763
-	    //$buffer = $Common->getData($hosts[$id]);
764
-	    if ($globalDebug) echo 'Get Data...'."\n";
765
-	    $buffer = $Common->getData($value['host']);
766
-	    $all_data = json_decode($buffer,true);
767
-	    if ($buffer != '' && is_array($all_data)) {
759
+		}
760
+			//$last_exec['phpvmacars'] = time();
761
+			$last_exec[$id]['last'] = time();
762
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
763
+		//$buffer = $Common->getData($hosts[$id]);
764
+		if ($globalDebug) echo 'Get Data...'."\n";
765
+		$buffer = $Common->getData($value['host']);
766
+		$all_data = json_decode($buffer,true);
767
+		if ($buffer != '' && is_array($all_data)) {
768 768
 		$reset = 0;
769 769
 		foreach ($all_data as $line) {
770
-	    	    $data = array();
771
-	    	    //$data['id'] = $line['id']; // id not usable
772
-	    	    $data['id'] = trim($line['flight_id']);
773
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
774
-	    	    $data['pilot_name'] = $line['pilot_name'];
775
-	    	    $data['pilot_id'] = $line['pilot_id'];
776
-	    	    $data['ident'] = trim($line['callsign']); // ident
777
-	    	    $data['altitude'] = $line['altitude']; // altitude
778
-	    	    $data['speed'] = $line['gs']; // speed
779
-	    	    $data['heading'] = $line['heading']; // heading
780
-	    	    $data['latitude'] = $line['latitude']; // lat
781
-	    	    $data['longitude'] = $line['longitude']; // long
782
-	    	    $data['verticalrate'] = ''; // verticale rate
783
-	    	    $data['squawk'] = ''; // squawk
784
-	    	    $data['emergency'] = ''; // emergency
785
-	    	    //$data['datetime'] = $line['lastupdate'];
786
-	    	    $data['last_update'] = $line['last_update'];
787
-		    $data['datetime'] = date('Y-m-d H:i:s');
788
-	    	    $data['departure_airport_icao'] = $line['departure'];
789
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
790
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
791
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
792
-    		    //$data['registration'] = $line['aircraft'];
793
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
794
-	    	    $data['aircraft_icao'] = $line['plane_type'];
795
-    		    $data['id_source'] = $id_source;
796
-	    	    $data['format_source'] = 'vam';
797
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
798
-		    $SI->add($data);
799
-		    unset($data);
770
+				$data = array();
771
+				//$data['id'] = $line['id']; // id not usable
772
+				$data['id'] = trim($line['flight_id']);
773
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
774
+				$data['pilot_name'] = $line['pilot_name'];
775
+				$data['pilot_id'] = $line['pilot_id'];
776
+				$data['ident'] = trim($line['callsign']); // ident
777
+				$data['altitude'] = $line['altitude']; // altitude
778
+				$data['speed'] = $line['gs']; // speed
779
+				$data['heading'] = $line['heading']; // heading
780
+				$data['latitude'] = $line['latitude']; // lat
781
+				$data['longitude'] = $line['longitude']; // long
782
+				$data['verticalrate'] = ''; // verticale rate
783
+				$data['squawk'] = ''; // squawk
784
+				$data['emergency'] = ''; // emergency
785
+				//$data['datetime'] = $line['lastupdate'];
786
+				$data['last_update'] = $line['last_update'];
787
+			$data['datetime'] = date('Y-m-d H:i:s');
788
+				$data['departure_airport_icao'] = $line['departure'];
789
+				//$data['departure_airport_time'] = $line['departure_time'];
790
+				$data['arrival_airport_icao'] = $line['arrival'];
791
+				//$data['arrival_airport_time'] = $line['arrival_time'];
792
+				//$data['registration'] = $line['aircraft'];
793
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
794
+				$data['aircraft_icao'] = $line['plane_type'];
795
+				$data['id_source'] = $id_source;
796
+				$data['format_source'] = 'vam';
797
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
798
+			$SI->add($data);
799
+			unset($data);
800 800
 		}
801 801
 		if ($globalDebug) echo 'No more data...'."\n";
802 802
 		unset($buffer);
803 803
 		unset($all_data);
804
-	    }
805
-    	    //$last_exec['phpvmacars'] = time();
806
-    	    $last_exec[$id]['last'] = time();
804
+		}
805
+			//$last_exec['phpvmacars'] = time();
806
+			$last_exec[$id]['last'] = time();
807 807
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
808 808
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
809
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
810
-    	    //$last_exec[$id]['last'] = time();
809
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
810
+			//$last_exec[$id]['last'] = time();
811 811
 
812
-	    //$read = array( $sockets[$id] );
813
-	    $read = $sockets;
814
-	    $write = NULL;
815
-	    $e = NULL;
816
-	    $n = socket_select($read, $write, $e, $timeout);
817
-	    if ($e != NULL) var_dump($e);
818
-	    if ($n > 0) {
812
+		//$read = array( $sockets[$id] );
813
+		$read = $sockets;
814
+		$write = NULL;
815
+		$e = NULL;
816
+		$n = socket_select($read, $write, $e, $timeout);
817
+		if ($e != NULL) var_dump($e);
818
+		if ($n > 0) {
819 819
 		$reset = 0;
820 820
 		foreach ($read as $nb => $r) {
821
-		    //$value = $formats[$nb];
822
-		    $format = $globalSources[$nb]['format'];
823
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
824
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
825
-        	    } else {
826
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
827
-	    	    }
828
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
829
-        	    //echo $buffer."\n";
830
-		    // lets play nice and handle signals such as ctrl-c/kill properly
831
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
832
-		    $error = false;
833
-		    //$SI::del();
834
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
835
-		    // SBS format is CSV format
836
-		    if ($buffer != '') {
821
+			//$value = $formats[$nb];
822
+			$format = $globalSources[$nb]['format'];
823
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
824
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
825
+				} else {
826
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
827
+				}
828
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
829
+				//echo $buffer."\n";
830
+			// lets play nice and handle signals such as ctrl-c/kill properly
831
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
832
+			$error = false;
833
+			//$SI::del();
834
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
835
+			// SBS format is CSV format
836
+			if ($buffer != '') {
837 837
 			$tt[$format] = 0;
838 838
 			if ($format == 'acarssbs3') {
839
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
840
-			    $ACARS->add(trim($buffer));
841
-			    $ACARS->deleteLiveAcarsData();
839
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
840
+				$ACARS->add(trim($buffer));
841
+				$ACARS->deleteLiveAcarsData();
842 842
 			} elseif ($format == 'raw') {
843
-			    // AVR format
844
-			    $data = $SBS->parse($buffer);
845
-			    if (is_array($data)) {
843
+				// AVR format
844
+				$data = $SBS->parse($buffer);
845
+				if (is_array($data)) {
846 846
 				$data['datetime'] = date('Y-m-d H:i:s');
847 847
 				$data['format_source'] = 'raw';
848 848
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
849
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
850
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
851
-                            }
852
-                        } elseif ($format == 'flightgearsp') {
853
-                    	    //echo $buffer."\n";
854
-                    	    if (strlen($buffer) > 5) {
849
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
850
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
851
+							}
852
+						} elseif ($format == 'flightgearsp') {
853
+							//echo $buffer."\n";
854
+							if (strlen($buffer) > 5) {
855 855
 				$line = explode(',',$buffer);
856 856
 				$data = array();
857 857
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -867,114 +867,114 @@  discard block
 block discarded – undo
867 867
 				$data['format_source'] = 'flightgearsp';
868 868
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
869 869
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
870
-			    }
871
-                        } elseif ($format == 'acars') {
872
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
873
-			    $ACARS->add(trim($buffer));
874
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
875
-			    $ACARS->deleteLiveAcarsData();
870
+				}
871
+						} elseif ($format == 'acars') {
872
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
873
+				$ACARS->add(trim($buffer));
874
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
875
+				$ACARS->deleteLiveAcarsData();
876 876
 			} elseif ($format == 'flightgearmp') {
877
-			    if (substr($buffer,0,1) != '#') {
877
+				if (substr($buffer,0,1) != '#') {
878 878
 				$data = array();
879 879
 				//echo $buffer."\n";
880 880
 				$line = explode(' ',$buffer);
881 881
 				if (count($line) == 11) {
882
-				    $userserver = explode('@',$line[0]);
883
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
884
-				    $data['ident'] = $userserver[0];
885
-				    $data['registration'] = $userserver[0];
886
-				    $data['latitude'] = $line[4];
887
-				    $data['longitude'] = $line[5];
888
-				    $data['altitude'] = $line[6];
889
-				    $data['datetime'] = date('Y-m-d H:i:s');
890
-				    $aircraft_type = $line[10];
891
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
892
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
893
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
882
+					$userserver = explode('@',$line[0]);
883
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
884
+					$data['ident'] = $userserver[0];
885
+					$data['registration'] = $userserver[0];
886
+					$data['latitude'] = $line[4];
887
+					$data['longitude'] = $line[5];
888
+					$data['altitude'] = $line[6];
889
+					$data['datetime'] = date('Y-m-d H:i:s');
890
+					$aircraft_type = $line[10];
891
+					$aircraft_type = preg_split(':/:',$aircraft_type);
892
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
893
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
894
+				}
894 895
 				}
895
-			    }
896 896
 			} elseif ($format == 'beast') {
897
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
898
-			    die;
897
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
898
+				die;
899 899
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
900
-			    $line = explode("\t", $buffer);
901
-			    for($k = 0; $k < count($line); $k=$k+2) {
900
+				$line = explode("\t", $buffer);
901
+				for($k = 0; $k < count($line); $k=$k+2) {
902 902
 				$key = $line[$k];
903
-			        $lined[$key] = $line[$k+1];
904
-			    }
905
-    			    if (count($lined) > 3) {
906
-    				$data['hex'] = $lined['hexid'];
907
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
908
-    				$data['datetime'] = date('Y-m-d H:i:s');;
909
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
910
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
911
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
912
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
913
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
914
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
915
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
916
-    				$data['id_source'] = $id_source;
917
-    				$data['format_source'] = 'tsv';
918
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
919
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
920
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
921
-    				unset($lined);
922
-    				unset($data);
923
-    			    } else $error = true;
903
+					$lined[$key] = $line[$k+1];
904
+				}
905
+					if (count($lined) > 3) {
906
+					$data['hex'] = $lined['hexid'];
907
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
908
+					$data['datetime'] = date('Y-m-d H:i:s');;
909
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
910
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
911
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
912
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
913
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
914
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
915
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
916
+					$data['id_source'] = $id_source;
917
+					$data['format_source'] = 'tsv';
918
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
919
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
920
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
921
+					unset($lined);
922
+					unset($data);
923
+					} else $error = true;
924 924
 			} elseif ($format == 'aprs' && $use_aprs) {
925
-			    if ($aprs_connect == 0) {
925
+				if ($aprs_connect == 0) {
926 926
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
927 927
 				$aprs_connect = 1;
928
-			    }
929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
928
+				}
929
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
930 930
 				$aprs_last_tx = time();
931 931
 				$data_aprs = "# Keep alive";
932 932
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
933
-			    }
934
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
935
-			    $buffer = str_replace('APRS <- ','',$buffer);
936
-			    $buffer = str_replace('APRS -> ','',$buffer);
937
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
933
+				}
934
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
935
+				$buffer = str_replace('APRS <- ','',$buffer);
936
+				$buffer = str_replace('APRS -> ','',$buffer);
937
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
938 938
 				$line = $APRS->parse($buffer);
939 939
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
940
-				    $data = array();
941
-				    //print_r($line);
942
-				    $data['hex'] = $line['address'];
943
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
944
-				    //$data['datetime'] = date('Y-m-d H:i:s');
945
-				    $data['ident'] = $line['ident'];
946
-				    $data['latitude'] = $line['latitude'];
947
-				    $data['longitude'] = $line['longitude'];
948
-				    //$data['verticalrate'] = $line[16];
949
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
950
-				    else $data['speed'] = 0;
951
-				    $data['altitude'] = $line['altitude'];
952
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
953
-				    //else $data['heading'] = 0;
954
-				    $data['aircraft_type'] = $line['stealth'];
955
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
956
-    				    $data['id_source'] = $id_source;
957
-				    $data['format_source'] = 'aprs';
958
-				    $data['source_name'] = $line['source'];
959
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
960
-				    $currentdate = date('Y-m-d H:i:s');
961
-				    $aprsdate = strtotime($data['datetime']);
962
-				    // Accept data if time <= system time + 20s
963
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
964
-				    else {
940
+					$data = array();
941
+					//print_r($line);
942
+					$data['hex'] = $line['address'];
943
+					$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
944
+					//$data['datetime'] = date('Y-m-d H:i:s');
945
+					$data['ident'] = $line['ident'];
946
+					$data['latitude'] = $line['latitude'];
947
+					$data['longitude'] = $line['longitude'];
948
+					//$data['verticalrate'] = $line[16];
949
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
950
+					else $data['speed'] = 0;
951
+					$data['altitude'] = $line['altitude'];
952
+					if (isset($line['course'])) $data['heading'] = $line['course'];
953
+					//else $data['heading'] = 0;
954
+					$data['aircraft_type'] = $line['stealth'];
955
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
956
+						$data['id_source'] = $id_source;
957
+					$data['format_source'] = 'aprs';
958
+					$data['source_name'] = $line['source'];
959
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
960
+					$currentdate = date('Y-m-d H:i:s');
961
+					$aprsdate = strtotime($data['datetime']);
962
+					// Accept data if time <= system time + 20s
963
+					if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
964
+					else {
965 965
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
966 966
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
967
-				    }
968
-				    unset($data);
967
+					}
968
+					unset($data);
969 969
 				} 
970 970
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
971 971
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
972
-			    }
972
+				}
973 973
 			} else {
974
-			    $line = explode(',', $buffer);
975
-    			    if (count($line) > 20) {
976
-    			    	$data['hex'] = $line[4];
977
-    				/*
974
+				$line = explode(',', $buffer);
975
+					if (count($line) > 20) {
976
+						$data['hex'] = $line[4];
977
+					/*
978 978
     				$data['datetime'] = $line[6].' '.$line[7];
979 979
     					date_default_timezone_set($globalTimezone);
980 980
     					$datetime = new DateTime($data['datetime']);
@@ -982,29 +982,29 @@  discard block
 block discarded – undo
982 982
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
983 983
     					date_default_timezone_set('UTC');
984 984
     				*/
985
-    				// Force datetime to current UTC datetime
986
-    				date_default_timezone_set('UTC');
987
-    				$data['datetime'] = date('Y-m-d H:i:s');
988
-    				$data['ident'] = trim($line[10]);
989
-    				$data['latitude'] = $line[14];
990
-    				$data['longitude'] = $line[15];
991
-    				$data['verticalrate'] = $line[16];
992
-    				$data['emergency'] = $line[20];
993
-    				$data['speed'] = $line[12];
994
-    				$data['squawk'] = $line[17];
995
-    				$data['altitude'] = $line[11];
996
-    				$data['heading'] = $line[13];
997
-    				$data['ground'] = $line[21];
998
-    				$data['emergency'] = $line[19];
999
-    				$data['format_source'] = 'sbs';
985
+					// Force datetime to current UTC datetime
986
+					date_default_timezone_set('UTC');
987
+					$data['datetime'] = date('Y-m-d H:i:s');
988
+					$data['ident'] = trim($line[10]);
989
+					$data['latitude'] = $line[14];
990
+					$data['longitude'] = $line[15];
991
+					$data['verticalrate'] = $line[16];
992
+					$data['emergency'] = $line[20];
993
+					$data['speed'] = $line[12];
994
+					$data['squawk'] = $line[17];
995
+					$data['altitude'] = $line[11];
996
+					$data['heading'] = $line[13];
997
+					$data['ground'] = $line[21];
998
+					$data['emergency'] = $line[19];
999
+					$data['format_source'] = 'sbs';
1000 1000
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1001
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1002
-    				$data['id_source'] = $id_source;
1003
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1004
-    				else $error = true;
1005
-    				unset($data);
1006
-    			    } else $error = true;
1007
-			    if ($error) {
1001
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1002
+					$data['id_source'] = $id_source;
1003
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1004
+					else $error = true;
1005
+					unset($data);
1006
+					} else $error = true;
1007
+				if ($error) {
1008 1008
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1009 1009
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1010 1010
 				} else {
@@ -1020,13 +1020,13 @@  discard block
 block discarded – undo
1020 1020
 					connect_all($sourceer);
1021 1021
 					$sourceer = array();
1022 1022
 				}
1023
-			    }
1023
+				}
1024 1024
 			}
1025 1025
 			// Sleep for xxx microseconds
1026 1026
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1027
-		    } else {
1027
+			} else {
1028 1028
 			if ($format == 'flightgearmp') {
1029
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1029
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1030 1030
 				//@socket_close($r);
1031 1031
 				sleep($globalMinFetch);
1032 1032
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1035,9 +1035,9 @@  discard block
 block discarded – undo
1035 1035
 				break;
1036 1036
 				
1037 1037
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1038
-			    if (isset($tt[$format])) $tt[$format]++;
1039
-			    else $tt[$format] = 0;
1040
-			    if ($tt[$format] > 30) {
1038
+				if (isset($tt[$format])) $tt[$format]++;
1039
+				else $tt[$format] = 0;
1040
+				if ($tt[$format] > 30) {
1041 1041
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1042 1042
 				//@socket_close($r);
1043 1043
 				sleep(2);
@@ -1048,23 +1048,23 @@  discard block
 block discarded – undo
1048 1048
 				//connect_all($globalSources);
1049 1049
 				$tt[$format]=0;
1050 1050
 				break;
1051
-			    }
1051
+				}
1052
+			}
1052 1053
 			}
1053
-		    }
1054 1054
 		}
1055
-	    } else {
1055
+		} else {
1056 1056
 		$error = socket_strerror(socket_last_error());
1057 1057
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1058 1058
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1059 1059
 			if (isset($globalDebug)) echo "Restarting...\n";
1060 1060
 			// Restart the script if possible
1061 1061
 			if (is_array($sockets)) {
1062
-			    if ($globalDebug) echo "Shutdown all sockets...";
1062
+				if ($globalDebug) echo "Shutdown all sockets...";
1063 1063
 			    
1064
-			    foreach ($sockets as $sock) {
1064
+				foreach ($sockets as $sock) {
1065 1065
 				@socket_shutdown($sock,2);
1066 1066
 				@socket_close($sock);
1067
-			    }
1067
+				}
1068 1068
 			    
1069 1069
 			}
1070 1070
 			if ($globalDebug) echo "Restart all connections...";
@@ -1075,13 +1075,13 @@  discard block
 block discarded – undo
1075 1075
 			if ($reset > 40) exit('Too many attempts...');
1076 1076
 			connect_all($globalSources);
1077 1077
 		}
1078
-	    }
1078
+		}
1079 1079
 	}
1080 1080
 	if ($globalDaemon === false) {
1081
-	    if ($globalDebug) echo 'Check all...'."\n";
1082
-	    $SI->checkAll();
1081
+		if ($globalDebug) echo 'Check all...'."\n";
1082
+		$SI->checkAll();
1083
+	}
1083 1084
 	}
1084
-    }
1085 1085
 }
1086 1086
 
1087 1087
 ?>
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	    die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
43
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
44 44
     }
45 45
 }
46 46
 
47
-$options = getopt('s::',array('source::','server','idsource::'));
47
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61 61
     if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
62
+    $SI = new SpotterServer();
63
+} else $SI = new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65
-$SBS=new SBS();
66
-$ACARS=new ACARS($Connection->db);
67
-$Common=new Common();
65
+$SBS = new SBS();
66
+$ACARS = new ACARS($Connection->db);
67
+$Common = new Common();
68 68
 date_default_timezone_set('UTC');
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
72
+    pcntl_signal(SIGINT, function() {
73 73
         global $sockets;
74 74
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75 75
         die("Bye!\n");
@@ -113,35 +113,35 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
116
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
143 143
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
144
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
145 145
         	//$formats[$id] = 'radarvirtueljson';
146 146
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 147
         	//$last_exec['radarvirtueljson'] = 0;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 151
         	    exit(0);
152 152
         	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
153
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
154 154
         	//$formats[$id] = 'planeupdatefaa';
155 155
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 156
         	//$last_exec['planeupdatefaa'] = 0;
@@ -159,26 +159,26 @@  discard block
 block discarded – undo
159 159
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 160
         	    exit(0);
161 161
         	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
162
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'phpvmacars';
165 165
         	//$last_exec['phpvmacars'] = 0;
166 166
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
167
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
168 168
         	//$formats[$id] = 'phpvmacars';
169 169
         	$globalSources[$id]['format'] = 'vam';
170 170
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
171
+            } else if (preg_match('/whazzup/i', $host)) {
172 172
         	//$formats[$id] = 'whazzup';
173 173
         	$globalSources[$id]['format'] = 'whazzup';
174 174
         	//$last_exec['whazzup'] = 0;
175 175
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
176
+            } else if (preg_match('/recentpireps/i', $host)) {
177 177
         	//$formats[$id] = 'pirepsjson';
178 178
         	$globalSources[$id]['format'] = 'pirepsjson';
179 179
         	//$last_exec['pirepsjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
181
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
182 182
         	//$formats[$id] = 'fr24json';
183 183
         	$globalSources[$id]['format'] = 'fr24json';
184 184
         	//$last_exec['fr24json'] = 0;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
         	    exit(0);
189 189
         	}
190 190
             //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 192
         	//$formats[$id] = 'tsv';
193 193
         	$globalSources[$id]['format'] = 'tsv';
194 194
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195 195
             }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
197 197
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
198
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
199
+	    $hostport = explode(':', $host);
200 200
 	    if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 		$hostn = $globalSources[$id]['host'];
206 206
 	    }
207 207
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
208
+        	$s = create_socket($hostn, $port, $errno, $errstr);
209 209
     	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
210
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
211 211
 	    }
212 212
 	    if ($s) {
213 213
     	        $sockets[$id] = $s;
214 214
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
215
+		    if (preg_match('/aprs/', $hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254 254
 else $timeout = 20;
255 255
 $errno = '';
256
-$errstr='';
256
+$errstr = '';
257 257
 
258 258
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
259 259
 /* Initiate connections to all the hosts simultaneously */
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 if ($use_aprs) {
284 284
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
285
-	$APRS=new APRS();
285
+	$APRS = new APRS();
286 286
 	$aprs_connect = 0;
287 287
 	$aprs_keep = 120;
288 288
 	$aprs_last_tx = time();
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	else $aprs_ssid = 'FAM';
294 294
 	//else $aprs_ssid = 'PerlEx';
295 295
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
296
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
296
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
297 297
 	if ($aprs_full) $aprs_filter = '';
298 298
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
299 299
 	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
 sleep(1);
305 305
 if ($globalDebug) echo "SCAN MODE \n\n";
306 306
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
307
-$endtime = time()+$globalCronEnd;
307
+$endtime = time() + $globalCronEnd;
308 308
 $i = 1;
309 309
 $tt = array();
310 310
 // Delete all ATC
311 311
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
312
-	$ATC=new ATC($Connection->db);
312
+	$ATC = new ATC($Connection->db);
313 313
 }
314 314
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
315 315
 	$ATC->deleteAll();
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
319 319
 while ($i > 0) {
320
-    if (!$globalDaemon) $i = $endtime-time();
320
+    if (!$globalDaemon) $i = $endtime - time();
321 321
     // Delete old ATC
322 322
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
323 323
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	}
332 332
 	if ($max != $globalMinFetch) {
333 333
 	    if ($globalDebug) echo 'Sleeping...'."\n";
334
-	    sleep($globalMinFetch-$max+2);
334
+	    sleep($globalMinFetch - $max + 2);
335 335
 	}
336 336
     }
337 337
 
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
 	    //$buffer = $Common->getData($hosts[$id]);
345 345
 	    $buffer = $Common->getData($value['host']);
346 346
 	    if ($buffer != '') $reset = 0;
347
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
348
-	    $buffer = explode('\n',$buffer);
347
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
348
+	    $buffer = explode('\n', $buffer);
349 349
 	    foreach ($buffer as $line) {
350 350
     		if ($line != '' && count($line) > 7) {
351 351
     		    $line = explode(',', $line);
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
375 375
 	    //$buffer = $Common->getData($hosts[$id]);
376 376
 	    $buffer = $Common->getData($value['host']);
377
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
378
-	    $buffer = explode('\n',$buffer);
377
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
378
+	    $buffer = explode('\n', $buffer);
379 379
 	    $reset = 0;
380 380
 	    foreach ($buffer as $line) {
381 381
     		if ($line != '') {
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
387 387
 			$data['pilot_id'] = $line[1];
388 388
 			$data['pilot_name'] = $line[2];
389
-			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
389
+			$data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT);
390 390
 			$data['ident'] = $line[0]; // ident
391 391
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
392 392
 			$data['speed'] = $line[8]; // speed
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
403 403
 			//if (isset($line[37])) $data['last_update'] = $line[37];
404 404
 		        $data['departure_airport_icao'] = $line[11];
405
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
405
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
406 406
 		        $data['arrival_airport_icao'] = $line[13];
407 407
 			$data['frequency'] = $line[4];
408 408
 			$data['type'] = $line[18];
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
     			$data['id_source'] = $id_source;
412 412
 	    		//$data['arrival_airport_time'] = ;
413 413
 	    		if ($line[9] != '') {
414
-	    		    $aircraft_data = explode('/',$line[9]);
414
+	    		    $aircraft_data = explode('/', $line[9]);
415 415
 	    		    if (isset($aircraft_data[1])) {
416 416
 	    			$data['aircraft_icao'] = $aircraft_data[1];
417 417
 	    		    }
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
     			if ($line[3] == 'PILOT') $SI->add($data);
426 426
 			elseif ($line[3] == 'ATC') {
427 427
 				//print_r($data);
428
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
429
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
430
-				$typec = substr($data['ident'],-3);
428
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
429
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
430
+				$typec = substr($data['ident'], -3);
431 431
 				if ($typec == 'APP') $data['type'] = 'Approach';
432 432
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
433 433
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
439 439
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
440 440
 				if (!isset($data['source_name'])) $data['source_name'] = '';
441
-				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
441
+				echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
442 442
 			}
443 443
     			unset($data);
444 444
     		    }
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
     	    $last_exec[$id]['last'] = time();
450 450
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
451 451
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
452
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
452
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
453 453
 	    if ($buffer != '') {
454
-	    $all_data = json_decode($buffer,true);
454
+	    $all_data = json_decode($buffer, true);
455 455
 	    if (isset($all_data['acList'])) {
456 456
 		$reset = 0;
457 457
 		foreach ($all_data['acList'] as $line) {
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
508 508
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
509 509
 	    $buffer = $Common->getData($value['host']);
510
-	    $all_data = json_decode($buffer,true);
510
+	    $all_data = json_decode($buffer, true);
511 511
 	    if (isset($all_data['planes'])) {
512 512
 		$reset = 0;
513 513
 		foreach ($all_data['planes'] as $key => $line) {
@@ -524,12 +524,12 @@  discard block
 block discarded – undo
524 524
 		    $data['emergency'] = ''; // emergency
525 525
 		    $data['registration'] = $line[2];
526 526
 		    $data['aircraft_icao'] = $line[0];
527
-		    $deparr = explode('-',$line[1]);
527
+		    $deparr = explode('-', $line[1]);
528 528
 		    if (count($deparr) == 2) {
529 529
 			$data['departure_airport_icao'] = $deparr[0];
530 530
 			$data['arrival_airport_icao'] = $deparr[1];
531 531
 		    }
532
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
533 533
 	    	    $data['format_source'] = 'planeupdatefaa';
534 534
     		    $data['id_source'] = $id_source;
535 535
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
     	    $last_exec[$id]['last'] = time();
542 542
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
543 543
 	    $buffer = $Common->getData($value['host']);
544
-	    $all_data = json_decode($buffer,true);
544
+	    $all_data = json_decode($buffer, true);
545 545
 	    if (isset($all_data['states'])) {
546 546
 		$reset = 0;
547 547
 		foreach ($all_data['states'] as $key => $line) {
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 		    //$data['emergency'] = ''; // emergency
559 559
 		    //$data['registration'] = $line[2];
560 560
 		    //$data['aircraft_icao'] = $line[0];
561
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
561
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
562 562
 	    	    $data['format_source'] = 'opensky';
563 563
     		    $data['id_source'] = $id_source;
564 564
 		    $SI->add($data);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
572 572
 	    //$buffer = $Common->getData($hosts[$id]);
573 573
 	    $buffer = $Common->getData($value['host']);
574
-	    $all_data = json_decode($buffer,true);
574
+	    $all_data = json_decode($buffer, true);
575 575
 	    if (!empty($all_data)) $reset = 0;
576 576
 	    foreach ($all_data as $key => $line) {
577 577
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
604 604
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
605 605
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
606
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
606
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
607 607
 	    //echo $buffer;
608
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
609
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
610
-	    $all_data = json_decode($buffer,true);
608
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
609
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
610
+	    $all_data = json_decode($buffer, true);
611 611
 	    if (json_last_error() != JSON_ERROR_NONE) {
612 612
 		die(json_last_error_msg());
613 613
 	    }
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 			//$data['departure_airport_iata'] = $line[11];
631 631
 			//$data['arrival_airport_iata'] = $line[12];
632 632
 	    		//$data['emergency'] = ''; // emergency
633
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
633
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
634 634
 	    		$data['format_source'] = 'radarvirtueljson';
635 635
     			$data['id_source'] = $id_source;
636 636
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -645,14 +645,14 @@  discard block
 block discarded – undo
645 645
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
646 646
 	    //$buffer = $Common->getData($hosts[$id]);
647 647
 	    $buffer = $Common->getData($value['host'].'?'.time());
648
-	    $all_data = json_decode(utf8_encode($buffer),true);
648
+	    $all_data = json_decode(utf8_encode($buffer), true);
649 649
 	    
650 650
 	    if (isset($all_data['pireps'])) {
651 651
 		$reset = 0;
652 652
 	        foreach ($all_data['pireps'] as $line) {
653 653
 		    $data = array();
654 654
 		    $data['id'] = $line['id'];
655
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
656 656
 		    $data['ident'] = $line['callsign']; // ident
657 657
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
658 658
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -681,9 +681,9 @@  discard block
 block discarded – undo
681 681
 			$SI->add($data);
682 682
 		    //    print_r($data);
683 683
     		    } elseif ($line['icon'] == 'ct') {
684
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
685
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
686
-			$typec = substr($data['ident'],-3);
684
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
685
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
686
+			$typec = substr($data['ident'], -3);
687 687
 			$data['type'] = '';
688 688
 			if ($typec == 'APP') $data['type'] = 'Approach';
689 689
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
695 695
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
696 696
 			else $data['type'] = 'Observer';
697
-			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
697
+			echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
698 698
 		    }
699 699
 		    unset($data);
700 700
 		}
@@ -706,14 +706,14 @@  discard block
 block discarded – undo
706 706
 	    //$buffer = $Common->getData($hosts[$id]);
707 707
 	    if ($globalDebug) echo 'Get Data...'."\n";
708 708
 	    $buffer = $Common->getData($value['host']);
709
-	    $all_data = json_decode($buffer,true);
709
+	    $all_data = json_decode($buffer, true);
710 710
 	    if ($buffer != '' && is_array($all_data)) {
711 711
 		$reset = 0;
712 712
 		foreach ($all_data as $line) {
713 713
 	    	    $data = array();
714 714
 	    	    //$data['id'] = $line['id']; // id not usable
715 715
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
716
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
717 717
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
718 718
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
719 719
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -736,12 +736,12 @@  discard block
 block discarded – undo
736 736
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
737 737
 		    if (isset($line['aircraftname'])) {
738 738
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
739
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
740
-	    		$aircraft_data = explode('-',$line['aircraftname']);
739
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
740
+	    		$aircraft_data = explode('-', $line['aircraftname']);
741 741
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
742 742
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
743 743
 	    		else {
744
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
744
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
745 745
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
746 746
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
747 747
 	    		}
@@ -763,14 +763,14 @@  discard block
 block discarded – undo
763 763
 	    //$buffer = $Common->getData($hosts[$id]);
764 764
 	    if ($globalDebug) echo 'Get Data...'."\n";
765 765
 	    $buffer = $Common->getData($value['host']);
766
-	    $all_data = json_decode($buffer,true);
766
+	    $all_data = json_decode($buffer, true);
767 767
 	    if ($buffer != '' && is_array($all_data)) {
768 768
 		$reset = 0;
769 769
 		foreach ($all_data as $line) {
770 770
 	    	    $data = array();
771 771
 	    	    //$data['id'] = $line['id']; // id not usable
772 772
 	    	    $data['id'] = trim($line['flight_id']);
773
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
773
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
774 774
 	    	    $data['pilot_name'] = $line['pilot_name'];
775 775
 	    	    $data['pilot_id'] = $line['pilot_id'];
776 776
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -821,9 +821,9 @@  discard block
 block discarded – undo
821 821
 		    //$value = $formats[$nb];
822 822
 		    $format = $globalSources[$nb]['format'];
823 823
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
824
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
824
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
825 825
         	    } else {
826
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
826
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
827 827
 	    	    }
828 828
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
829 829
         	    //echo $buffer."\n";
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
832 832
 		    $error = false;
833 833
 		    //$SI::del();
834
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
834
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
835 835
 		    // SBS format is CSV format
836 836
 		    if ($buffer != '') {
837 837
 			$tt[$format] = 0;
@@ -852,10 +852,10 @@  discard block
 block discarded – undo
852 852
                         } elseif ($format == 'flightgearsp') {
853 853
                     	    //echo $buffer."\n";
854 854
                     	    if (strlen($buffer) > 5) {
855
-				$line = explode(',',$buffer);
855
+				$line = explode(',', $buffer);
856 856
 				$data = array();
857 857
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
858
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
858
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
859 859
 				$data['ident'] = $line[6];
860 860
 				$data['aircraft_name'] = $line[7];
861 861
 				$data['longitude'] = $line[1];
@@ -866,21 +866,21 @@  discard block
 block discarded – undo
866 866
 				$data['datetime'] = date('Y-m-d H:i:s');
867 867
 				$data['format_source'] = 'flightgearsp';
868 868
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
869
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
869
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
870 870
 			    }
871 871
                         } elseif ($format == 'acars') {
872 872
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
873 873
 			    $ACARS->add(trim($buffer));
874
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
875 875
 			    $ACARS->deleteLiveAcarsData();
876 876
 			} elseif ($format == 'flightgearmp') {
877
-			    if (substr($buffer,0,1) != '#') {
877
+			    if (substr($buffer, 0, 1) != '#') {
878 878
 				$data = array();
879 879
 				//echo $buffer."\n";
880
-				$line = explode(' ',$buffer);
880
+				$line = explode(' ', $buffer);
881 881
 				if (count($line) == 11) {
882
-				    $userserver = explode('@',$line[0]);
883
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
882
+				    $userserver = explode('@', $line[0]);
883
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
884 884
 				    $data['ident'] = $userserver[0];
885 885
 				    $data['registration'] = $userserver[0];
886 886
 				    $data['latitude'] = $line[4];
@@ -888,24 +888,24 @@  discard block
 block discarded – undo
888 888
 				    $data['altitude'] = $line[6];
889 889
 				    $data['datetime'] = date('Y-m-d H:i:s');
890 890
 				    $aircraft_type = $line[10];
891
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
892
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
891
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
892
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
893 893
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
894 894
 				}
895 895
 			    }
896 896
 			} elseif ($format == 'beast') {
897 897
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
898 898
 			    die;
899
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
899
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
900 900
 			    $line = explode("\t", $buffer);
901
-			    for($k = 0; $k < count($line); $k=$k+2) {
901
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
902 902
 				$key = $line[$k];
903
-			        $lined[$key] = $line[$k+1];
903
+			        $lined[$key] = $line[$k + 1];
904 904
 			    }
905 905
     			    if (count($lined) > 3) {
906 906
     				$data['hex'] = $lined['hexid'];
907 907
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
908
-    				$data['datetime'] = date('Y-m-d H:i:s');;
908
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
909 909
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
910 910
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
911 911
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -923,24 +923,24 @@  discard block
 block discarded – undo
923 923
     			    } else $error = true;
924 924
 			} elseif ($format == 'aprs' && $use_aprs) {
925 925
 			    if ($aprs_connect == 0) {
926
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
926
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
927 927
 				$aprs_connect = 1;
928 928
 			    }
929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
929
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
930 930
 				$aprs_last_tx = time();
931 931
 				$data_aprs = "# Keep alive";
932
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
932
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
933 933
 			    }
934 934
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
935
-			    $buffer = str_replace('APRS <- ','',$buffer);
936
-			    $buffer = str_replace('APRS -> ','',$buffer);
937
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
935
+			    $buffer = str_replace('APRS <- ', '', $buffer);
936
+			    $buffer = str_replace('APRS -> ', '', $buffer);
937
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
938 938
 				$line = $APRS->parse($buffer);
939 939
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
940 940
 				    $data = array();
941 941
 				    //print_r($line);
942 942
 				    $data['hex'] = $line['address'];
943
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
943
+				    $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
944 944
 				    //$data['datetime'] = date('Y-m-d H:i:s');
945 945
 				    $data['ident'] = $line['ident'];
946 946
 				    $data['latitude'] = $line['latitude'];
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 				    $currentdate = date('Y-m-d H:i:s');
961 961
 				    $aprsdate = strtotime($data['datetime']);
962 962
 				    // Accept data if time <= system time + 20s
963
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
963
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
964 964
 				    else {
965 965
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
966 966
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 				connect_all($sourceee);
1047 1047
 				$sourceee = array();
1048 1048
 				//connect_all($globalSources);
1049
-				$tt[$format]=0;
1049
+				$tt[$format] = 0;
1050 1050
 				break;
1051 1051
 			    }
1052 1052
 			}
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 		}
1055 1055
 	    } else {
1056 1056
 		$error = socket_strerror(socket_last_error());
1057
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1057
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1058 1058
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1059 1059
 			if (isset($globalDebug)) echo "Restarting...\n";
1060 1060
 			// Restart the script if possible
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 			    if ($globalDebug) echo "Shutdown all sockets...";
1063 1063
 			    
1064 1064
 			    foreach ($sockets as $sock) {
1065
-				@socket_shutdown($sock,2);
1065
+				@socket_shutdown($sock, 2);
1066 1066
 				@socket_close($sock);
1067 1067
 			    }
1068 1068
 			    
Please login to merge, or discard this patch.
Braces   +546 added lines, -187 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -54,13 +56,22 @@  discard block
 block discarded – undo
54 56
     $globalSources = array();
55 57
     $globalSources[] = array('host' => $options['source']);
56 58
 }
57
-if (isset($options['server'])) $globalServer = TRUE;
58
-if (isset($options['idsource'])) $id_source = $options['idsource'];
59
-else $id_source = 1;
59
+if (isset($options['server'])) {
60
+	$globalServer = TRUE;
61
+}
62
+if (isset($options['idsource'])) {
63
+	$id_source = $options['idsource'];
64
+} else {
65
+	$id_source = 1;
66
+}
60 67
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
68
+    if ($globalDebug) {
69
+    	echo "Using Server Mode\n";
70
+    }
62 71
     $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
72
+} else {
73
+	$SI=new SpotterImport($Connection->db);
74
+}
64 75
 //$APRS=new APRS($Connection->db);
65 76
 $SBS=new SBS();
66 77
 $ACARS=new ACARS($Connection->db);
@@ -78,7 +89,9 @@  discard block
 block discarded – undo
78 89
 }
79 90
 
80 91
 // let's try and connect
81
-if ($globalDebug) echo "Connecting...\n";
92
+if ($globalDebug) {
93
+	echo "Connecting...\n";
94
+}
82 95
 $use_aprs = false;
83 96
 $aprs_full = false;
84 97
 $reset = 0;
@@ -87,7 +100,9 @@  discard block
 block discarded – undo
87 100
     $ip = gethostbyname($host);
88 101
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
89 102
     $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
103
+    if (!socket_set_nonblock($s)) {
104
+    	echo "Unable to set nonblock on socket\n";
105
+    }
91 106
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92 107
         return $s;
93 108
     }
@@ -115,7 +130,9 @@  discard block
 block discarded – undo
115 130
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 131
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117 132
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
133
+    if ($globalDebug) {
134
+    	echo 'Connect to all...'."\n";
135
+    }
119 136
     foreach ($hosts as $id => $value) {
120 137
 	$host = $value['host'];
121 138
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,27 +142,37 @@  discard block
 block discarded – undo
125 142
         	//$formats[$id] = 'deltadbtxt';
126 143
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 144
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
145
+        	if ($globalDebug) {
146
+        		echo "Connect to deltadb source (".$host.")...\n";
147
+        	}
129 148
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 149
         	//$formats[$id] = 'vatsimtxt';
131 150
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 151
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
152
+        	if ($globalDebug) {
153
+        		echo "Connect to vatsim source (".$host.")...\n";
154
+        	}
134 155
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 156
         	//$formats[$id] = 'aircraftlistjson';
136 157
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 158
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
159
+        	if ($globalDebug) {
160
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
161
+        	}
139 162
     	    } else if (preg_match('/opensky/i',$host)) {
140 163
         	//$formats[$id] = 'aircraftlistjson';
141 164
         	$globalSources[$id]['format'] = 'opensky';
142 165
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
166
+        	if ($globalDebug) {
167
+        		echo "Connect to opensky source (".$host.")...\n";
168
+        	}
144 169
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145 170
         	//$formats[$id] = 'radarvirtueljson';
146 171
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 172
         	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
173
+        	if ($globalDebug) {
174
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
175
+        	}
149 176
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150 177
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 178
         	    exit(0);
@@ -154,7 +181,9 @@  discard block
 block discarded – undo
154 181
         	//$formats[$id] = 'planeupdatefaa';
155 182
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 183
         	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
186
+        	}
158 187
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 189
         	    exit(0);
@@ -163,26 +192,36 @@  discard block
 block discarded – undo
163 192
         	//$formats[$id] = 'phpvmacars';
164 193
         	$globalSources[$id]['format'] = 'phpvmacars';
165 194
         	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
195
+        	if ($globalDebug) {
196
+        		echo "Connect to phpvmacars source (".$host.")...\n";
197
+        	}
167 198
             } else if (preg_match('/VAM-json.php$/i',$host)) {
168 199
         	//$formats[$id] = 'phpvmacars';
169 200
         	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to Vam source (".$host.")...\n";
203
+        	}
171 204
             } else if (preg_match('/whazzup/i',$host)) {
172 205
         	//$formats[$id] = 'whazzup';
173 206
         	$globalSources[$id]['format'] = 'whazzup';
174 207
         	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
208
+        	if ($globalDebug) {
209
+        		echo "Connect to whazzup source (".$host.")...\n";
210
+        	}
176 211
             } else if (preg_match('/recentpireps/i',$host)) {
177 212
         	//$formats[$id] = 'pirepsjson';
178 213
         	$globalSources[$id]['format'] = 'pirepsjson';
179 214
         	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
215
+        	if ($globalDebug) {
216
+        		echo "Connect to pirepsjson source (".$host.")...\n";
217
+        	}
181 218
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182 219
         	//$formats[$id] = 'fr24json';
183 220
         	$globalSources[$id]['format'] = 'fr24json';
184 221
         	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to fr24 source (".$host.")...\n";
224
+        	}
186 225
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187 226
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188 227
         	    exit(0);
@@ -191,10 +230,14 @@  discard block
 block discarded – undo
191 230
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 231
         	//$formats[$id] = 'tsv';
193 232
         	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to tsv source (".$host.")...\n";
235
+        	}
195 236
             }
196 237
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
+        	}
198 241
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199 242
 	    $hostport = explode(':',$host);
200 243
 	    if (isset($hostport[1])) {
@@ -231,17 +274,25 @@  discard block
 block discarded – undo
231 274
         		//$formats[$id] = 'beast';
232 275
         		$globalSources[$id]['format'] = 'beast';
233 276
 		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
277
+		    } else {
278
+		    	$globalSources[$id]['format'] = 'sbs';
279
+		    }
235 280
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 281
 		}
237
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
282
+		if ($globalDebug) {
283
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
284
+		}
238 285
             } else {
239
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
286
+		if ($globalDebug) {
287
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
288
+		}
240 289
     	    }
241 290
         }
242 291
     }
243 292
 }
244
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
293
+if (!isset($globalMinFetch)) {
294
+	$globalMinFetch = 15;
295
+}
245 296
 
246 297
 // Initialize all
247 298
 $status = array();
@@ -249,13 +300,19 @@  discard block
 block discarded – undo
249 300
 $formats = array();
250 301
 $last_exec = array();
251 302
 $time = time();
252
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
253
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254
-else $timeout = 20;
303
+if (isset($globalSourcesTimeout)) {
304
+	$timeout = $globalSourcesTimeOut;
305
+} else if (isset($globalSBS1TimeOut)) {
306
+	$timeout = $globalSBS1TimeOut;
307
+} else {
308
+	$timeout = 20;
309
+}
255 310
 $errno = '';
256 311
 $errstr='';
257 312
 
258
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
313
+if (!isset($globalDaemon)) {
314
+	$globalDaemon = TRUE;
315
+}
259 316
 /* Initiate connections to all the hosts simultaneously */
260 317
 //connect_all($hosts);
261 318
 //connect_all($globalSources);
@@ -275,7 +332,9 @@  discard block
 block discarded – undo
275 332
     if (isset($source['format']) && $source['format'] == 'aprs') {
276 333
 	$aprs_connect = 0;
277 334
 	$use_aprs = true;
278
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
335
+	if (isset($source['port']) && $source['port'] == '10152') {
336
+		$aprs_full = true;
337
+	}
279 338
 	break;
280 339
     }
281 340
 }
@@ -286,24 +345,44 @@  discard block
 block discarded – undo
286 345
 	$aprs_connect = 0;
287 346
 	$aprs_keep = 120;
288 347
 	$aprs_last_tx = time();
289
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = $globalName.' using FlightAirMap';
348
+	if (isset($globalAPRSversion)) {
349
+		$aprs_version = $globalAPRSversion;
350
+	} else {
351
+		$aprs_version = $globalName.' using FlightAirMap';
352
+	}
291 353
 	//else $aprs_version = 'Perl Example App';
292
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
293
-	else $aprs_ssid = 'FAM';
354
+	if (isset($globalAPRSssid)) {
355
+		$aprs_ssid = $globalAPRSssid;
356
+	} else {
357
+		$aprs_ssid = 'FAM';
358
+	}
294 359
 	//else $aprs_ssid = 'PerlEx';
295
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
296
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
297
-	if ($aprs_full) $aprs_filter = '';
298
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
299
-	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
300
-}
360
+	if (isset($globalAPRSfilter)) {
361
+		$aprs_filter = $globalAPRSfilter;
362
+	} else {
363
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
364
+	}
365
+	if ($aprs_full) {
366
+		$aprs_filter = '';
367
+	}
368
+	if ($aprs_filter != '') {
369
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
370
+	} else {
371
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
372
+	}
373
+	}
301 374
 
302 375
 // connected - lets do some work
303
-if ($globalDebug) echo "Connected!\n";
376
+if ($globalDebug) {
377
+	echo "Connected!\n";
378
+}
304 379
 sleep(1);
305
-if ($globalDebug) echo "SCAN MODE \n\n";
306
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
380
+if ($globalDebug) {
381
+	echo "SCAN MODE \n\n";
382
+}
383
+if (!isset($globalCronEnd)) {
384
+	$globalCronEnd = 60;
385
+}
307 386
 $endtime = time()+$globalCronEnd;
308 387
 $i = 1;
309 388
 $tt = array();
@@ -317,20 +396,28 @@  discard block
 block discarded – undo
317 396
 
318 397
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
319 398
 while ($i > 0) {
320
-    if (!$globalDaemon) $i = $endtime-time();
399
+    if (!$globalDaemon) {
400
+    	$i = $endtime-time();
401
+    }
321 402
     // Delete old ATC
322 403
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
323
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
404
+	if ($globalDebug) {
405
+		echo 'Delete old ATC...'."\n";
406
+	}
324 407
         $ATC->deleteOldATC();
325 408
     }
326 409
     
327 410
     if (count($last_exec) > 0) {
328 411
 	$max = $globalMinFetch;
329 412
 	foreach ($last_exec as $last) {
330
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
413
+	    if ((time() - $last['last']) < $max) {
414
+	    	$max = time() - $last['last'];
415
+	    }
331 416
 	}
332 417
 	if ($max != $globalMinFetch) {
333
-	    if ($globalDebug) echo 'Sleeping...'."\n";
418
+	    if ($globalDebug) {
419
+	    	echo 'Sleeping...'."\n";
420
+	    }
334 421
 	    sleep($globalMinFetch-$max+2);
335 422
 	}
336 423
     }
@@ -339,11 +426,15 @@  discard block
 block discarded – undo
339 426
     //foreach ($formats as $id => $value) {
340 427
     foreach ($globalSources as $id => $value) {
341 428
 	date_default_timezone_set('UTC');
342
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
429
+	if (!isset($last_exec[$id]['last'])) {
430
+		$last_exec[$id]['last'] = 0;
431
+	}
343 432
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
344 433
 	    //$buffer = $Common->getData($hosts[$id]);
345 434
 	    $buffer = $Common->getData($value['host']);
346
-	    if ($buffer != '') $reset = 0;
435
+	    if ($buffer != '') {
436
+	    	$reset = 0;
437
+	    }
347 438
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
348 439
 	    $buffer = explode('\n',$buffer);
349 440
 	    foreach ($buffer as $line) {
@@ -352,19 +443,38 @@  discard block
 block discarded – undo
352 443
 	            $data = array();
353 444
 	            $data['hex'] = $line[1]; // hex
354 445
 	            $data['ident'] = $line[2]; // ident
355
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
356
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
357
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
358
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
359
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
446
+	            if (isset($line[3])) {
447
+	            	$data['altitude'] = $line[3];
448
+	            }
449
+	            // altitude
450
+	            if (isset($line[4])) {
451
+	            	$data['speed'] = $line[4];
452
+	            }
453
+	            // speed
454
+	            if (isset($line[5])) {
455
+	            	$data['heading'] = $line[5];
456
+	            }
457
+	            // heading
458
+	            if (isset($line[6])) {
459
+	            	$data['latitude'] = $line[6];
460
+	            }
461
+	            // lat
462
+	            if (isset($line[7])) {
463
+	            	$data['longitude'] = $line[7];
464
+	            }
465
+	            // long
360 466
 	            $data['verticalrate'] = ''; // vertical rate
361 467
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
362 468
 	            $data['emergency'] = ''; // emergency
363 469
 		    $data['datetime'] = date('Y-m-d H:i:s');
364 470
 		    $data['format_source'] = 'deltadbtxt';
365 471
     		    $data['id_source'] = $id_source;
366
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
367
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
472
+		    if (isset($value['name']) && $value['name'] != '') {
473
+		    	$data['source_name'] = $value['name'];
474
+		    }
475
+		    if (isset($value['sourcestats'])) {
476
+		    	$data['sourcestats'] = $value['sourcestats'];
477
+		    }
368 478
     		    $SI->add($data);
369 479
 		    unset($data);
370 480
     		}
@@ -382,16 +492,28 @@  discard block
 block discarded – undo
382 492
     		    $line = explode(':', $line);
383 493
     		    if (count($line) > 30 && $line[0] != 'callsign') {
384 494
 			$data = array();
385
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
386
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
495
+			if (isset($line[37]) && $line[37] != '') {
496
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
497
+			} else {
498
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
499
+			}
387 500
 			$data['pilot_id'] = $line[1];
388 501
 			$data['pilot_name'] = $line[2];
389 502
 			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
390 503
 			$data['ident'] = $line[0]; // ident
391
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
504
+			if ($line[7] != '' && $line[7] != 0) {
505
+				$data['altitude'] = $line[7];
506
+			}
507
+			// altitude
392 508
 			$data['speed'] = $line[8]; // speed
393
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
394
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
509
+			if (isset($line[45])) {
510
+				$data['heading'] = $line[45];
511
+			}
512
+			// heading
513
+			elseif (isset($line[38])) {
514
+				$data['heading'] = $line[38];
515
+			}
516
+			// heading
395 517
 			$data['latitude'] = $line[5]; // lat
396 518
 	        	$data['longitude'] = $line[6]; // long
397 519
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -407,7 +529,9 @@  discard block
 block discarded – undo
407 529
 			$data['frequency'] = $line[4];
408 530
 			$data['type'] = $line[18];
409 531
 			$data['range'] = $line[19];
410
-			if (isset($line[35])) $data['info'] = $line[35];
532
+			if (isset($line[35])) {
533
+				$data['info'] = $line[35];
534
+			}
411 535
     			$data['id_source'] = $id_source;
412 536
 	    		//$data['arrival_airport_time'] = ;
413 537
 	    		if ($line[9] != '') {
@@ -421,23 +545,38 @@  discard block
 block discarded – undo
421 545
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
422 546
 	    		*/
423 547
 	    		$data['format_source'] = $value['format'];
424
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
425
-    			if ($line[3] == 'PILOT') $SI->add($data);
426
-			elseif ($line[3] == 'ATC') {
548
+			if (isset($value['name']) && $value['name'] != '') {
549
+				$data['source_name'] = $value['name'];
550
+			}
551
+    			if ($line[3] == 'PILOT') {
552
+    				$SI->add($data);
553
+    			} elseif ($line[3] == 'ATC') {
427 554
 				//print_r($data);
428 555
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
429 556
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
430 557
 				$typec = substr($data['ident'],-3);
431
-				if ($typec == 'APP') $data['type'] = 'Approach';
432
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
433
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
434
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
435
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
436
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
437
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
438
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
439
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
440
-				if (!isset($data['source_name'])) $data['source_name'] = '';
558
+				if ($typec == 'APP') {
559
+					$data['type'] = 'Approach';
560
+				} elseif ($typec == 'TWR') {
561
+					$data['type'] = 'Tower';
562
+				} elseif ($typec == 'OBS') {
563
+					$data['type'] = 'Observer';
564
+				} elseif ($typec == 'GND') {
565
+					$data['type'] = 'Ground';
566
+				} elseif ($typec == 'DEL') {
567
+					$data['type'] = 'Delivery';
568
+				} elseif ($typec == 'DEP') {
569
+					$data['type'] = 'Departure';
570
+				} elseif ($typec == 'FSS') {
571
+					$data['type'] = 'Flight Service Station';
572
+				} elseif ($typec == 'CTR') {
573
+					$data['type'] = 'Control Radar or Centre';
574
+				} elseif ($data['type'] == '') {
575
+					$data['type'] = 'Observer';
576
+				}
577
+				if (!isset($data['source_name'])) {
578
+					$data['source_name'] = '';
579
+				}
441 580
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
442 581
 			}
443 582
     			unset($data);
@@ -457,26 +596,55 @@  discard block
 block discarded – undo
457 596
 		foreach ($all_data['acList'] as $line) {
458 597
 		    $data = array();
459 598
 		    $data['hex'] = $line['Icao']; // hex
460
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
461
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
462
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
463
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
464
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
465
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
599
+		    if (isset($line['Call'])) {
600
+		    	$data['ident'] = $line['Call'];
601
+		    }
602
+		    // ident
603
+		    if (isset($line['Alt'])) {
604
+		    	$data['altitude'] = $line['Alt'];
605
+		    }
606
+		    // altitude
607
+		    if (isset($line['Spd'])) {
608
+		    	$data['speed'] = $line['Spd'];
609
+		    }
610
+		    // speed
611
+		    if (isset($line['Trak'])) {
612
+		    	$data['heading'] = $line['Trak'];
613
+		    }
614
+		    // heading
615
+		    if (isset($line['Lat'])) {
616
+		    	$data['latitude'] = $line['Lat'];
617
+		    }
618
+		    // lat
619
+		    if (isset($line['Long'])) {
620
+		    	$data['longitude'] = $line['Long'];
621
+		    }
622
+		    // long
466 623
 		    //$data['verticalrate'] = $line['']; // verticale rate
467
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
624
+		    if (isset($line['Sqk'])) {
625
+		    	$data['squawk'] = $line['Sqk'];
626
+		    }
627
+		    // squawk
468 628
 		    $data['emergency'] = ''; // emergency
469
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
629
+		    if (isset($line['Reg'])) {
630
+		    	$data['registration'] = $line['Reg'];
631
+		    }
470 632
 		    /*
471 633
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
472 634
 		    else $data['datetime'] = date('Y-m-d H:i:s');
473 635
 		    */
474 636
 		    $data['datetime'] = date('Y-m-d H:i:s');
475
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
637
+		    if (isset($line['Type'])) {
638
+		    	$data['aircraft_icao'] = $line['Type'];
639
+		    }
476 640
 	    	    $data['format_source'] = 'aircraftlistjson';
477 641
 		    $data['id_source'] = $id_source;
478
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
479
-		    if (isset($data['datetime'])) $SI->add($data);
642
+		    if (isset($value['name']) && $value['name'] != '') {
643
+		    	$data['source_name'] = $value['name'];
644
+		    }
645
+		    if (isset($data['datetime'])) {
646
+		    	$SI->add($data);
647
+		    }
480 648
 		    unset($data);
481 649
 		}
482 650
 	    } else {
@@ -496,7 +664,9 @@  discard block
 block discarded – undo
496 664
 		    $data['datetime'] = date('Y-m-d H:i:s');
497 665
 	    	    $data['format_source'] = 'aircraftlistjson';
498 666
     		    $data['id_source'] = $id_source;
499
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
667
+		    if (isset($value['name']) && $value['name'] != '') {
668
+		    	$data['source_name'] = $value['name'];
669
+		    }
500 670
 		    $SI->add($data);
501 671
 		    unset($data);
502 672
 		}
@@ -532,7 +702,9 @@  discard block
 block discarded – undo
532 702
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
533 703
 	    	    $data['format_source'] = 'planeupdatefaa';
534 704
     		    $data['id_source'] = $id_source;
535
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
705
+		    if (isset($value['name']) && $value['name'] != '') {
706
+		    	$data['source_name'] = $value['name'];
707
+		    }
536 708
 		    $SI->add($data);
537 709
 		    unset($data);
538 710
 		}
@@ -572,7 +744,9 @@  discard block
 block discarded – undo
572 744
 	    //$buffer = $Common->getData($hosts[$id]);
573 745
 	    $buffer = $Common->getData($value['host']);
574 746
 	    $all_data = json_decode($buffer,true);
575
-	    if (!empty($all_data)) $reset = 0;
747
+	    if (!empty($all_data)) {
748
+	    	$reset = 0;
749
+	    }
576 750
 	    foreach ($all_data as $key => $line) {
577 751
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
578 752
 		    $data = array();
@@ -593,7 +767,9 @@  discard block
 block discarded – undo
593 767
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
594 768
 	    	    $data['format_source'] = 'fr24json';
595 769
     		    $data['id_source'] = $id_source;
596
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
770
+		    if (isset($value['name']) && $value['name'] != '') {
771
+		    	$data['source_name'] = $value['name'];
772
+		    }
597 773
 		    $SI->add($data);
598 774
 		    unset($data);
599 775
 		}
@@ -617,23 +793,39 @@  discard block
 block discarded – undo
617 793
 		    if (isset($line['inf'])) {
618 794
 			$data = array();
619 795
 			$data['hex'] = $line['inf']['ia'];
620
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
796
+			if (isset($line['inf']['cs'])) {
797
+				$data['ident'] = $line['inf']['cs'];
798
+			}
799
+			//$line[13]
621 800
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
622
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
623
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
801
+	    		if (isset($line['inf']['gs'])) {
802
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
803
+	    		}
804
+	    		// speed
805
+	    		if (isset($line['inf']['tr'])) {
806
+	    			$data['heading'] = $line['inf']['tr'];
807
+	    		}
808
+	    		// heading
624 809
 	    		$data['latitude'] = $line['pt'][0]; // lat
625 810
 	    		$data['longitude'] = $line['pt'][1]; // long
626 811
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
627
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
812
+	    		if (isset($line['inf']['sq'])) {
813
+	    			$data['squawk'] = $line['inf']['sq'];
814
+	    		}
815
+	    		// squawk
628 816
 	    		//$data['aircraft_icao'] = $line[8];
629
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
817
+	    		if (isset($line['inf']['rc'])) {
818
+	    			$data['registration'] = $line['inf']['rc'];
819
+	    		}
630 820
 			//$data['departure_airport_iata'] = $line[11];
631 821
 			//$data['arrival_airport_iata'] = $line[12];
632 822
 	    		//$data['emergency'] = ''; // emergency
633 823
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
634 824
 	    		$data['format_source'] = 'radarvirtueljson';
635 825
     			$data['id_source'] = $id_source;
636
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
826
+			if (isset($value['name']) && $value['name'] != '') {
827
+				$data['source_name'] = $value['name'];
828
+			}
637 829
 			$SI->add($data);
638 830
 			unset($data);
639 831
 		    }
@@ -654,29 +846,62 @@  discard block
 block discarded – undo
654 846
 		    $data['id'] = $line['id'];
655 847
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
656 848
 		    $data['ident'] = $line['callsign']; // ident
657
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
658
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
659
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
660
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
661
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
662
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
849
+		    if (isset($line['pilotid'])) {
850
+		    	$data['pilot_id'] = $line['pilotid'];
851
+		    }
852
+		    // pilot id
853
+		    if (isset($line['name'])) {
854
+		    	$data['pilot_name'] = $line['name'];
855
+		    }
856
+		    // pilot name
857
+		    if (isset($line['alt'])) {
858
+		    	$data['altitude'] = $line['alt'];
859
+		    }
860
+		    // altitude
861
+		    if (isset($line['gs'])) {
862
+		    	$data['speed'] = $line['gs'];
863
+		    }
864
+		    // speed
865
+		    if (isset($line['heading'])) {
866
+		    	$data['heading'] = $line['heading'];
867
+		    }
868
+		    // heading
869
+		    if (isset($line['route'])) {
870
+		    	$data['waypoints'] = $line['route'];
871
+		    }
872
+		    // route
663 873
 		    $data['latitude'] = $line['lat']; // lat
664 874
 		    $data['longitude'] = $line['lon']; // long
665 875
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
666 876
 		    //$data['squawk'] = $line['squawk']; // squawk
667 877
 		    //$data['emergency'] = ''; // emergency
668
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
669
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
670
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
878
+		    if (isset($line['depicao'])) {
879
+		    	$data['departure_airport_icao'] = $line['depicao'];
880
+		    }
881
+		    if (isset($line['deptime'])) {
882
+		    	$data['departure_airport_time'] = $line['deptime'];
883
+		    }
884
+		    if (isset($line['arricao'])) {
885
+		    	$data['arrival_airport_icao'] = $line['arricao'];
886
+		    }
671 887
 		    //$data['arrival_airport_time'] = $line['arrtime'];
672
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
673
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
674
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
675
-		    else $data['info'] = '';
888
+		    if (isset($line['aircraft'])) {
889
+		    	$data['aircraft_icao'] = $line['aircraft'];
890
+		    }
891
+		    if (isset($line['transponder'])) {
892
+		    	$data['squawk'] = $line['transponder'];
893
+		    }
894
+		    if (isset($line['atis'])) {
895
+		    	$data['info'] = $line['atis'];
896
+		    } else {
897
+		    	$data['info'] = '';
898
+		    }
676 899
 		    $data['format_source'] = 'pireps';
677 900
     		    $data['id_source'] = $id_source;
678 901
 		    $data['datetime'] = date('Y-m-d H:i:s');
679
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
902
+		    if (isset($value['name']) && $value['name'] != '') {
903
+		    	$data['source_name'] = $value['name'];
904
+		    }
680 905
 		    if ($line['icon'] == 'plane') {
681 906
 			$SI->add($data);
682 907
 		    //    print_r($data);
@@ -685,15 +910,25 @@  discard block
 block discarded – undo
685 910
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
686 911
 			$typec = substr($data['ident'],-3);
687 912
 			$data['type'] = '';
688
-			if ($typec == 'APP') $data['type'] = 'Approach';
689
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
690
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
691
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
692
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
693
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
694
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
695
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
696
-			else $data['type'] = 'Observer';
913
+			if ($typec == 'APP') {
914
+				$data['type'] = 'Approach';
915
+			} elseif ($typec == 'TWR') {
916
+				$data['type'] = 'Tower';
917
+			} elseif ($typec == 'OBS') {
918
+				$data['type'] = 'Observer';
919
+			} elseif ($typec == 'GND') {
920
+				$data['type'] = 'Ground';
921
+			} elseif ($typec == 'DEL') {
922
+				$data['type'] = 'Delivery';
923
+			} elseif ($typec == 'DEP') {
924
+				$data['type'] = 'Departure';
925
+			} elseif ($typec == 'FSS') {
926
+				$data['type'] = 'Flight Service Station';
927
+			} elseif ($typec == 'CTR') {
928
+				$data['type'] = 'Control Radar or Centre';
929
+			} else {
930
+				$data['type'] = 'Observer';
931
+			}
697 932
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
698 933
 		    }
699 934
 		    unset($data);
@@ -704,7 +939,9 @@  discard block
 block discarded – undo
704 939
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
705 940
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
706 941
 	    //$buffer = $Common->getData($hosts[$id]);
707
-	    if ($globalDebug) echo 'Get Data...'."\n";
942
+	    if ($globalDebug) {
943
+	    	echo 'Get Data...'."\n";
944
+	    }
708 945
 	    $buffer = $Common->getData($value['host']);
709 946
 	    $all_data = json_decode($buffer,true);
710 947
 	    if ($buffer != '' && is_array($all_data)) {
@@ -712,10 +949,16 @@  discard block
 block discarded – undo
712 949
 		foreach ($all_data as $line) {
713 950
 	    	    $data = array();
714 951
 	    	    //$data['id'] = $line['id']; // id not usable
715
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
952
+	    	    if (isset($line['pilotid'])) {
953
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
954
+	    	    }
716 955
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
717
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
718
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
956
+	    	    if (isset($line['pilotname'])) {
957
+	    	    	$data['pilot_name'] = $line['pilotname'];
958
+	    	    }
959
+	    	    if (isset($line['pilotid'])) {
960
+	    	    	$data['pilot_id'] = $line['pilotid'];
961
+	    	    }
719 962
 	    	    $data['ident'] = $line['flightnum']; // ident
720 963
 	    	    $data['altitude'] = $line['alt']; // altitude
721 964
 	    	    $data['speed'] = $line['gs']; // speed
@@ -733,27 +976,41 @@  discard block
 block discarded – undo
733 976
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
734 977
     		    $data['arrival_airport_time'] = $line['arrtime'];
735 978
     		    $data['registration'] = $line['aircraft'];
736
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
979
+		    if (isset($line['route'])) {
980
+		    	$data['waypoints'] = $line['route'];
981
+		    }
982
+		    // route
737 983
 		    if (isset($line['aircraftname'])) {
738 984
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
739 985
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
740 986
 	    		$aircraft_data = explode('-',$line['aircraftname']);
741
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
742
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
743
-	    		else {
987
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
988
+	    			$data['aircraft_icao'] = $aircraft_data[0];
989
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
990
+	    			$data['aircraft_icao'] = $aircraft_data[1];
991
+	    		} else {
744 992
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
745
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
746
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
993
+	    		    if (isset($aircraft_data[1])) {
994
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
995
+	    		    } else {
996
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
997
+	    		    }
747 998
 	    		}
748 999
 	    	    }
749
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1000
+    		    if (isset($line['route'])) {
1001
+    		    	$data['waypoints'] = $line['route'];
1002
+    		    }
750 1003
     		    $data['id_source'] = $id_source;
751 1004
 	    	    $data['format_source'] = 'phpvmacars';
752
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1005
+		    if (isset($value['name']) && $value['name'] != '') {
1006
+		    	$data['source_name'] = $value['name'];
1007
+		    }
753 1008
 		    $SI->add($data);
754 1009
 		    unset($data);
755 1010
 		}
756
-		if ($globalDebug) echo 'No more data...'."\n";
1011
+		if ($globalDebug) {
1012
+			echo 'No more data...'."\n";
1013
+		}
757 1014
 		unset($buffer);
758 1015
 		unset($all_data);
759 1016
 	    }
@@ -761,7 +1018,9 @@  discard block
 block discarded – undo
761 1018
     	    $last_exec[$id]['last'] = time();
762 1019
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
763 1020
 	    //$buffer = $Common->getData($hosts[$id]);
764
-	    if ($globalDebug) echo 'Get Data...'."\n";
1021
+	    if ($globalDebug) {
1022
+	    	echo 'Get Data...'."\n";
1023
+	    }
765 1024
 	    $buffer = $Common->getData($value['host']);
766 1025
 	    $all_data = json_decode($buffer,true);
767 1026
 	    if ($buffer != '' && is_array($all_data)) {
@@ -790,15 +1049,22 @@  discard block
 block discarded – undo
790 1049
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
791 1050
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
792 1051
     		    //$data['registration'] = $line['aircraft'];
793
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1052
+		    if (isset($line['route'])) {
1053
+		    	$data['waypoints'] = $line['route'];
1054
+		    }
1055
+		    // route
794 1056
 	    	    $data['aircraft_icao'] = $line['plane_type'];
795 1057
     		    $data['id_source'] = $id_source;
796 1058
 	    	    $data['format_source'] = 'vam';
797
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1059
+		    if (isset($value['name']) && $value['name'] != '') {
1060
+		    	$data['source_name'] = $value['name'];
1061
+		    }
798 1062
 		    $SI->add($data);
799 1063
 		    unset($data);
800 1064
 		}
801
-		if ($globalDebug) echo 'No more data...'."\n";
1065
+		if ($globalDebug) {
1066
+			echo 'No more data...'."\n";
1067
+		}
802 1068
 		unset($buffer);
803 1069
 		unset($all_data);
804 1070
 	    }
@@ -806,7 +1072,9 @@  discard block
 block discarded – undo
806 1072
     	    $last_exec[$id]['last'] = time();
807 1073
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
808 1074
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
809
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1075
+	    if (function_exists('pcntl_fork')) {
1076
+	    	pcntl_signal_dispatch();
1077
+	    }
810 1078
     	    //$last_exec[$id]['last'] = time();
811 1079
 
812 1080
 	    //$read = array( $sockets[$id] );
@@ -814,7 +1082,9 @@  discard block
 block discarded – undo
814 1082
 	    $write = NULL;
815 1083
 	    $e = NULL;
816 1084
 	    $n = socket_select($read, $write, $e, $timeout);
817
-	    if ($e != NULL) var_dump($e);
1085
+	    if ($e != NULL) {
1086
+	    	var_dump($e);
1087
+	    }
818 1088
 	    if ($n > 0) {
819 1089
 		$reset = 0;
820 1090
 		foreach ($read as $nb => $r) {
@@ -836,7 +1106,9 @@  discard block
 block discarded – undo
836 1106
 		    if ($buffer != '') {
837 1107
 			$tt[$format] = 0;
838 1108
 			if ($format == 'acarssbs3') {
839
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1109
+                    	    if ($globalDebug) {
1110
+                    	    	echo 'ACARS : '.$buffer."\n";
1111
+                    	    }
840 1112
 			    $ACARS->add(trim($buffer));
841 1113
 			    $ACARS->deleteLiveAcarsData();
842 1114
 			} elseif ($format == 'raw') {
@@ -845,9 +1117,15 @@  discard block
 block discarded – undo
845 1117
 			    if (is_array($data)) {
846 1118
 				$data['datetime'] = date('Y-m-d H:i:s');
847 1119
 				$data['format_source'] = 'raw';
848
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
849
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
850
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1120
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1121
+					$data['source_name'] = $globalSources[$nb]['name'];
1122
+				}
1123
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1124
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1125
+    				}
1126
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1127
+                                	$SI->add($data);
1128
+                                }
851 1129
                             }
852 1130
                         } elseif ($format == 'flightgearsp') {
853 1131
                     	    //echo $buffer."\n";
@@ -865,11 +1143,15 @@  discard block
 block discarded – undo
865 1143
 				$data['speed'] = round($line[5]*1.94384);
866 1144
 				$data['datetime'] = date('Y-m-d H:i:s');
867 1145
 				$data['format_source'] = 'flightgearsp';
868
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1146
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1147
+					$SI->add($data);
1148
+				}
869 1149
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
870 1150
 			    }
871 1151
                         } elseif ($format == 'acars') {
872
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1152
+                    	    if ($globalDebug) {
1153
+                    	    	echo 'ACARS : '.$buffer."\n";
1154
+                    	    }
873 1155
 			    $ACARS->add(trim($buffer));
874 1156
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
875 1157
 			    $ACARS->deleteLiveAcarsData();
@@ -890,7 +1172,9 @@  discard block
 block discarded – undo
890 1172
 				    $aircraft_type = $line[10];
891 1173
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
892 1174
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
893
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1175
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1176
+				    	$SI->add($data);
1177
+				    }
894 1178
 				}
895 1179
 			    }
896 1180
 			} elseif ($format == 'beast') {
@@ -906,21 +1190,43 @@  discard block
 block discarded – undo
906 1190
     				$data['hex'] = $lined['hexid'];
907 1191
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
908 1192
     				$data['datetime'] = date('Y-m-d H:i:s');;
909
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
910
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
911
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
912
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
913
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
914
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
915
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1193
+    				if (isset($lined['ident'])) {
1194
+    					$data['ident'] = $lined['ident'];
1195
+    				}
1196
+    				if (isset($lined['lat'])) {
1197
+    					$data['latitude'] = $lined['lat'];
1198
+    				}
1199
+    				if (isset($lined['lon'])) {
1200
+    					$data['longitude'] = $lined['lon'];
1201
+    				}
1202
+    				if (isset($lined['speed'])) {
1203
+    					$data['speed'] = $lined['speed'];
1204
+    				}
1205
+    				if (isset($lined['squawk'])) {
1206
+    					$data['squawk'] = $lined['squawk'];
1207
+    				}
1208
+    				if (isset($lined['alt'])) {
1209
+    					$data['altitude'] = $lined['alt'];
1210
+    				}
1211
+    				if (isset($lined['heading'])) {
1212
+    					$data['heading'] = $lined['heading'];
1213
+    				}
916 1214
     				$data['id_source'] = $id_source;
917 1215
     				$data['format_source'] = 'tsv';
918
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
919
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
920
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1216
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1217
+    					$data['source_name'] = $globalSources[$nb]['name'];
1218
+    				}
1219
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1220
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1221
+    				}
1222
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1223
+    					$SI->add($data);
1224
+    				}
921 1225
     				unset($lined);
922 1226
     				unset($data);
923
-    			    } else $error = true;
1227
+    			    } else {
1228
+    			    	$error = true;
1229
+    			    }
924 1230
 			} elseif ($format == 'aprs' && $use_aprs) {
925 1231
 			    if ($aprs_connect == 0) {
926 1232
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -946,29 +1252,44 @@  discard block
 block discarded – undo
946 1252
 				    $data['latitude'] = $line['latitude'];
947 1253
 				    $data['longitude'] = $line['longitude'];
948 1254
 				    //$data['verticalrate'] = $line[16];
949
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
950
-				    else $data['speed'] = 0;
1255
+				    if (isset($line['speed'])) {
1256
+				    	$data['speed'] = $line['speed'];
1257
+				    } else {
1258
+				    	$data['speed'] = 0;
1259
+				    }
951 1260
 				    $data['altitude'] = $line['altitude'];
952
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
1261
+				    if (isset($line['course'])) {
1262
+				    	$data['heading'] = $line['course'];
1263
+				    }
953 1264
 				    //else $data['heading'] = 0;
954 1265
 				    $data['aircraft_type'] = $line['stealth'];
955
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1266
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1267
+				    	$data['noarchive'] = true;
1268
+				    }
956 1269
     				    $data['id_source'] = $id_source;
957 1270
 				    $data['format_source'] = 'aprs';
958 1271
 				    $data['source_name'] = $line['source'];
959
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1272
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1273
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1274
+    				    }
960 1275
 				    $currentdate = date('Y-m-d H:i:s');
961 1276
 				    $aprsdate = strtotime($data['datetime']);
962 1277
 				    // Accept data if time <= system time + 20s
963
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
964
-				    else {
965
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
966
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1278
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1279
+				    	$send = $SI->add($data);
1280
+				    } else {
1281
+					if ($line['stealth'] != 0) {
1282
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1283
+					} else {
1284
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1285
+					}
967 1286
 				    }
968 1287
 				    unset($data);
969 1288
 				} 
970 1289
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
971
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1290
+				elseif ($line == true && $globalDebug) {
1291
+					echo '!! Failed : '.$buffer."!!\n";
1292
+				}
972 1293
 			    }
973 1294
 			} else {
974 1295
 			    $line = explode(',', $buffer);
@@ -997,25 +1318,42 @@  discard block
 block discarded – undo
997 1318
     				$data['ground'] = $line[21];
998 1319
     				$data['emergency'] = $line[19];
999 1320
     				$data['format_source'] = 'sbs';
1000
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1001
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1321
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1322
+					$data['source_name'] = $globalSources[$nb]['name'];
1323
+				}
1324
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1325
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1326
+    				}
1002 1327
     				$data['id_source'] = $id_source;
1003
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1004
-    				else $error = true;
1328
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1329
+    					$send = $SI->add($data);
1330
+    				} else {
1331
+    					$error = true;
1332
+    				}
1005 1333
     				unset($data);
1006
-    			    } else $error = true;
1334
+    			    } else {
1335
+    			    	$error = true;
1336
+    			    }
1007 1337
 			    if ($error) {
1008 1338
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1009
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1339
+					if ($globalDebug) {
1340
+						echo "Not a message. Ignoring... \n";
1341
+					}
1010 1342
 				} else {
1011
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1343
+					if ($globalDebug) {
1344
+						echo "Wrong line format. Ignoring... \n";
1345
+					}
1012 1346
 					if ($globalDebug) {
1013 1347
 						echo $buffer;
1014 1348
 						print_r($line);
1015 1349
 					}
1016 1350
 					//socket_close($r);
1017
-					if ($globalDebug) echo "Reconnect after an error...\n";
1018
-					if ($format == 'aprs') $aprs_connect = 0;
1351
+					if ($globalDebug) {
1352
+						echo "Reconnect after an error...\n";
1353
+					}
1354
+					if ($format == 'aprs') {
1355
+						$aprs_connect = 0;
1356
+					}
1019 1357
 					$sourceer[$nb] = $globalSources[$nb];
1020 1358
 					connect_all($sourceer);
1021 1359
 					$sourceer = array();
@@ -1023,10 +1361,14 @@  discard block
 block discarded – undo
1023 1361
 			    }
1024 1362
 			}
1025 1363
 			// Sleep for xxx microseconds
1026
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1364
+			if (isset($globalSBSSleep)) {
1365
+				usleep($globalSBSSleep);
1366
+			}
1027 1367
 		    } else {
1028 1368
 			if ($format == 'flightgearmp') {
1029
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1369
+			    	if ($globalDebug) {
1370
+			    		echo "Reconnect FlightGear MP...";
1371
+			    	}
1030 1372
 				//@socket_close($r);
1031 1373
 				sleep($globalMinFetch);
1032 1374
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1035,10 +1377,15 @@  discard block
 block discarded – undo
1035 1377
 				break;
1036 1378
 				
1037 1379
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1038
-			    if (isset($tt[$format])) $tt[$format]++;
1039
-			    else $tt[$format] = 0;
1380
+			    if (isset($tt[$format])) {
1381
+			    	$tt[$format]++;
1382
+			    } else {
1383
+			    	$tt[$format] = 0;
1384
+			    }
1040 1385
 			    if ($tt[$format] > 30) {
1041
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1386
+				if ($globalDebug) {
1387
+					echo "ERROR : Reconnect ".$format."...";
1388
+				}
1042 1389
 				//@socket_close($r);
1043 1390
 				sleep(2);
1044 1391
 				$aprs_connect = 0;
@@ -1054,12 +1401,18 @@  discard block
 block discarded – undo
1054 1401
 		}
1055 1402
 	    } else {
1056 1403
 		$error = socket_strerror(socket_last_error());
1057
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1404
+		if ($globalDebug) {
1405
+			echo "ERROR : socket_select give this error ".$error . "\n";
1406
+		}
1058 1407
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1059
-			if (isset($globalDebug)) echo "Restarting...\n";
1408
+			if (isset($globalDebug)) {
1409
+				echo "Restarting...\n";
1410
+			}
1060 1411
 			// Restart the script if possible
1061 1412
 			if (is_array($sockets)) {
1062
-			    if ($globalDebug) echo "Shutdown all sockets...";
1413
+			    if ($globalDebug) {
1414
+			    	echo "Shutdown all sockets...";
1415
+			    }
1063 1416
 			    
1064 1417
 			    foreach ($sockets as $sock) {
1065 1418
 				@socket_shutdown($sock,2);
@@ -1067,18 +1420,24 @@  discard block
 block discarded – undo
1067 1420
 			    }
1068 1421
 			    
1069 1422
 			}
1070
-			if ($globalDebug) echo "Restart all connections...";
1423
+			if ($globalDebug) {
1424
+				echo "Restart all connections...";
1425
+			}
1071 1426
 			sleep(2);
1072 1427
 			$time = time();
1073 1428
 			//connect_all($hosts);
1074 1429
 			$aprs_connect = 0;
1075
-			if ($reset > 40) exit('Too many attempts...');
1430
+			if ($reset > 40) {
1431
+				exit('Too many attempts...');
1432
+			}
1076 1433
 			connect_all($globalSources);
1077 1434
 		}
1078 1435
 	    }
1079 1436
 	}
1080 1437
 	if ($globalDaemon === false) {
1081
-	    if ($globalDebug) echo 'Check all...'."\n";
1438
+	    if ($globalDebug) {
1439
+	    	echo 'Check all...'."\n";
1440
+	    }
1082 1441
 	    $SI->checkAll();
1083 1442
 	}
1084 1443
     }
Please login to merge, or discard this patch.