Completed
Push — master ( b8bc3a...1cdde9 )
by Yannick
13:28
created
statistics-year.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 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
 
14 14
 require_once('header.php');
Please login to merge, or discard this patch.
statistics-country.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 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
 
14 14
 require_once('header.php');
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
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.
statistics.php 1 patch
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.
header.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 ?>
169 169
 <?php 
170
-    if (isset($_POST['archive'])) {
170
+	if (isset($_POST['archive'])) {
171 171
 ?>
172 172
 <?php 
173
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
173
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
174 174
 ?>
175 175
 
176 176
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
177 177
 <?php    
178
-	    }
179
-    } else {
178
+		}
179
+	} else {
180 180
 ?>
181 181
 <?php
182 182
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 */
189 189
 ?>
190 190
 <?php 
191
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
191
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
192 192
 ?>
193 193
 <?php
194 194
 //		if (isset($globalBeta) && $globalBeta) {
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 ?>
200 200
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>"></script>
201 201
 <?php
202
-	    }
202
+		}
203 203
 ?>
204 204
 <?php
205 205
 //	}
206 206
 ?>
207 207
 <?php
208
-    }
208
+	}
209 209
 }
210 210
 ?>
211 211
 <?php
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
361 361
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
362 362
 <?php
363
-    if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
363
+	if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
364 364
 ?>
365 365
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
366 366
 <?php
367
-    } else {
367
+	} else {
368 368
 ?>
369 369
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
370 370
 <?php
371
-    }
371
+	}
372 372
 ?>
373 373
 			<li><hr /></li>
374 374
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -376,34 +376,34 @@  discard block
 block discarded – undo
376 376
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
377 377
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
378 378
             <?php
379
-        	if ($globalACARS) {
380
-        	    if (isset($globalDemo) && $globalDemo) {
381
-    	    ?>
379
+			if ($globalACARS) {
380
+				if (isset($globalDemo) && $globalDemo) {
381
+			?>
382 382
             <li><hr /></li>
383 383
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
384 384
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
385 385
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
386 386
             <?php
387
-        	    } else {
388
-    	    ?>
387
+				} else {
388
+			?>
389 389
             <li><hr /></li>
390 390
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
391 391
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
392 392
             <?php
393
-        	    }
394
-        	}
395
-    	    ?>
393
+				}
394
+			}
395
+			?>
396 396
     	    <?php
397
-    	        if (isset($globalAccidents) && $globalAccidents) {
398
-    	    ?>
397
+				if (isset($globalAccidents) && $globalAccidents) {
398
+			?>
399 399
             <li><hr /></li>
400 400
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
401 401
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
402 402
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
403 403
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
404 404
             <?php
405
-        	}
406
-    	    ?>
405
+			}
406
+			?>
407 407
             <li><hr /></li>
408 408
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
409 409
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -445,14 +445,14 @@  discard block
 block discarded – undo
445 445
   	    <form>
446 446
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
447 447
   		    <?php
448
-  		        $Language = new Language();
449
-  		        $alllang = $Language->getLanguages();
450
-  		        foreach ($alllang as $key => $lang) {
451
-  		            print '<option value="'.$key.'"';
452
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
453
-  		            print '>'.$lang[0].'</option>';
454
-  		        }
455
-  		    ?>
448
+  				$Language = new Language();
449
+  				$alllang = $Language->getLanguages();
450
+  				foreach ($alllang as $key => $lang) {
451
+  					print '<option value="'.$key.'"';
452
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
453
+  					print '>'.$lang[0].'</option>';
454
+  				}
455
+  			?>
456 456
   		</select>
457 457
   	    </form>
458 458
   	</div>
@@ -483,18 +483,18 @@  discard block
 block discarded – undo
483 483
 ?>
484 484
     <div class="top-header clear" role="main">
485 485
 <?php
486
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
486
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
487 487
 ?>
488 488
     <div id="archive-map"></div>
489 489
 <?php
490
-    }
490
+	}
491 491
 ?>
492 492
     </div>
493 493
 <?php
494 494
 }
495 495
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
496 496
 {
497
-    ?>
497
+	?>
498 498
     <div class="top-header clear" role="main">
499 499
         <div id="map"></div>
500 500
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -505,15 +505,15 @@  discard block
 block discarded – undo
505 505
         var zoom = 13;
506 506
 //create the map
507 507
 <?php
508
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
508
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
509 509
 ?>
510 510
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
511 511
 <?php
512
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
512
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
513 513
 ?>
514 514
   map = L.map('map', { zoomControl:true });
515 515
 <?php
516
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
516
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
517 517
 ?>
518 518
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
519 519
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -521,22 +521,22 @@  discard block
 block discarded – undo
521 521
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
522 522
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
523 523
 <?php
524
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
524
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
525 525
 ?>
526 526
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
527 527
 <?php
528
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
528
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
529 529
 ?>
530 530
   map = L.map('map', { zoomControl:true });
531 531
 <?php
532
-    }
532
+	}
533 533
 ?>
534 534
   //initialize the layer group for the aircrft markers
535 535
   var layer_data = L.layerGroup();
536 536
 
537 537
   //a few title layers
538 538
 <?php
539
-    if ($globalMapProvider == 'Mapbox') {
539
+	if ($globalMapProvider == 'Mapbox') {
540 540
 ?>
541 541
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
542 542
     maxZoom: 18,
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
     token : '<?php print $globalMapboxToken; ?>'
548 548
   }).addTo(map);
549 549
 <?php
550
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
550
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
551 551
 ?>
552 552
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
553 553
     maxZoom: 18,
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
556 556
   }).addTo(map);
557 557
 <?php
558
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
558
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
559 559
 ?>
560 560
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
561 561
     maxZoom: 18,
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
565 565
   }).addTo(map);
566 566
 <?php
567
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
567
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
568 568
 ?>
569 569
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
570 570
     maxZoom: 18,
@@ -573,27 +573,27 @@  discard block
 block discarded – undo
573 573
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
574 574
   }).addTo(map);
575 575
 <?php
576
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
576
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
577 577
 ?>
578 578
     var googleLayer = new L.Google('ROADMAP');
579 579
     map.addLayer(googleLayer);
580 580
 <?php
581
-    } elseif ($globalMapProvider == 'Google-Satellite') {
581
+	} elseif ($globalMapProvider == 'Google-Satellite') {
582 582
 ?>
583 583
     var googleLayer = new L.Google('SATELLITE');
584 584
     map.addLayer(googleLayer);
585 585
 <?php
586
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
586
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
587 587
 ?>
588 588
     var googleLayer = new L.Google('HYBRID');
589 589
     map.addLayer(googleLayer);
590 590
 <?php
591
-    } elseif ($globalMapProvider == 'Google-Terrain') {
591
+	} elseif ($globalMapProvider == 'Google-Terrain') {
592 592
 ?>
593 593
     var googleLayer = new L.Google('Terrain');
594 594
     map.addLayer(googleLayer);
595 595
 <?php
596
-    }
596
+	}
597 597
 ?>
598 598
         </script>
599 599
     </div>
Please login to merge, or discard this patch.
require/class.Spotter.php 1 patch
Indentation   +1457 added lines, -1457 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	/**
58
-	* Get SQL query part for filter used
59
-	* @param Array $filter the filter
60
-	* @return Array the SQL part
61
-	*/
58
+	 * Get SQL query part for filter used
59
+	 * @param Array $filter the filter
60
+	 * @return Array the SQL part
61
+	 */
62 62
 	public function getFilter($filter = array(),$where = false,$and = false) {
63 63
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
64 64
 		$filters = array();
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* Executes the SQL statements to get the spotter information
153
-	*
154
-	* @param String $query the SQL query
155
-	* @param Array $params parameter of the query
156
-	* @param String $limitQuery the limit query
157
-	* @return Array the spotter information
158
-	*
159
-	*/
152
+	 * Executes the SQL statements to get the spotter information
153
+	 *
154
+	 * @param String $query the SQL query
155
+	 * @param Array $params parameter of the query
156
+	 * @param String $limitQuery the limit query
157
+	 * @return Array the spotter information
158
+	 *
159
+	 */
160 160
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
161 161
 	{
162 162
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
324 324
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
325 325
 					} else $temp_array['aircraft_shadow'] = 'default.png';
326
-                                } else {
327
-                            		$temp_array['aircraft_shadow'] = 'default.png';
326
+								} else {
327
+									$temp_array['aircraft_shadow'] = 'default.png';
328 328
 					$temp_array['aircraft_name'] = 'N/A';
329 329
 					$temp_array['aircraft_manufacturer'] = 'N/A';
330
-                            	}
330
+								}
331 331
 			}
332 332
 			$fromsource = NULL;
333 333
 			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
 	
524 524
 	
525 525
 	/**
526
-	* Gets all the spotter information
527
-	*
528
-	* @return Array the spotter information
529
-	*
530
-	*/
526
+	 * Gets all the spotter information
527
+	 *
528
+	 * @return Array the spotter information
529
+	 *
530
+	 */
531 531
 	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
532 532
 	{
533 533
 		global $globalTimezone, $globalDBdriver;
@@ -874,11 +874,11 @@  discard block
 block discarded – undo
874 874
 	
875 875
 	
876 876
 	/**
877
-	* Gets all the spotter information based on the latest data entry
878
-	*
879
-	* @return Array the spotter information
880
-	*
881
-	*/
877
+	 * Gets all the spotter information based on the latest data entry
878
+	 *
879
+	 * @return Array the spotter information
880
+	 *
881
+	 */
882 882
 	public function getLatestSpotterData($limit = '', $sort = '', $filter = array())
883 883
 	{
884 884
 		global $global_query;
@@ -917,12 +917,12 @@  discard block
 block discarded – undo
917 917
 	}
918 918
     
919 919
     
920
-    /**
921
-	* Gets all the spotter information based on a user's latitude and longitude
922
-	*
923
-	* @return Array the spotter information
924
-	*
925
-	*/
920
+	/**
921
+	 * Gets all the spotter information based on a user's latitude and longitude
922
+	 *
923
+	 * @return Array the spotter information
924
+	 *
925
+	 */
926 926
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
927 927
 	{
928 928
 		date_default_timezone_set('UTC');
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 				return false;
951 951
 			}
952 952
 		}
953
-    		$additional_query = '';
953
+			$additional_query = '';
954 954
 		if ($interval != "")
955 955
 		{
956 956
 			if (!is_string($interval))
@@ -990,12 +990,12 @@  discard block
 block discarded – undo
990 990
 	}
991 991
     
992 992
     
993
-    /**
994
-	* Gets all the spotter information sorted by the newest aircraft type
995
-	*
996
-	* @return Array the spotter information
997
-	*
998
-	*/
993
+	/**
994
+	 * Gets all the spotter information sorted by the newest aircraft type
995
+	 *
996
+	 * @return Array the spotter information
997
+	 *
998
+	 */
999 999
 	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
1000 1000
 	{
1001 1001
 		global $global_query;
@@ -1036,11 +1036,11 @@  discard block
 block discarded – undo
1036 1036
     
1037 1037
     
1038 1038
 	/**
1039
-	* Gets all the spotter information sorted by the newest aircraft registration
1040
-	*
1041
-	* @return Array the spotter information
1042
-	*
1043
-	*/
1039
+	 * Gets all the spotter information sorted by the newest aircraft registration
1040
+	 *
1041
+	 * @return Array the spotter information
1042
+	 *
1043
+	 */
1044 1044
 	public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array())
1045 1045
 	{
1046 1046
 		global $global_query;
@@ -1080,11 +1080,11 @@  discard block
 block discarded – undo
1080 1080
 
1081 1081
 
1082 1082
 	/**
1083
-	* Gets all the spotter information sorted by the newest airline
1084
-	*
1085
-	* @return Array the spotter information
1086
-	*
1087
-	*/
1083
+	 * Gets all the spotter information sorted by the newest airline
1084
+	 *
1085
+	 * @return Array the spotter information
1086
+	 *
1087
+	 */
1088 1088
 	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1089 1089
 	{
1090 1090
 		global $global_query;
@@ -1123,12 +1123,12 @@  discard block
 block discarded – undo
1123 1123
 	}
1124 1124
     
1125 1125
     
1126
-    /**
1127
-	* Gets all the spotter information sorted by the newest departure airport
1128
-	*
1129
-	* @return Array the spotter information
1130
-	*
1131
-	*/
1126
+	/**
1127
+	 * Gets all the spotter information sorted by the newest departure airport
1128
+	 *
1129
+	 * @return Array the spotter information
1130
+	 *
1131
+	 */
1132 1132
 	public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array())
1133 1133
 	{
1134 1134
 		global $global_query;
@@ -1170,11 +1170,11 @@  discard block
 block discarded – undo
1170 1170
 
1171 1171
 
1172 1172
 	/**
1173
-	* Gets all the spotter information sorted by the newest arrival airport
1174
-	*
1175
-	* @return Array the spotter information
1176
-	*
1177
-	*/
1173
+	 * Gets all the spotter information sorted by the newest arrival airport
1174
+	 *
1175
+	 * @return Array the spotter information
1176
+	 *
1177
+	 */
1178 1178
 	public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array())
1179 1179
 	{
1180 1180
 		global $global_query;
@@ -1213,11 +1213,11 @@  discard block
 block discarded – undo
1213 1213
 	
1214 1214
 
1215 1215
 	/**
1216
-	* Gets all the spotter information based on the spotter id
1217
-	*
1218
-	* @return Array the spotter information
1219
-	*
1220
-	*/
1216
+	 * Gets all the spotter information based on the spotter id
1217
+	 *
1218
+	 * @return Array the spotter information
1219
+	 *
1220
+	 */
1221 1221
 	public function getSpotterDataByID($id = '')
1222 1222
 	{
1223 1223
 		global $global_query;
@@ -1239,11 +1239,11 @@  discard block
 block discarded – undo
1239 1239
 	
1240 1240
 	
1241 1241
 	/**
1242
-	* Gets all the spotter information based on the callsign
1243
-	*
1244
-	* @return Array the spotter information
1245
-	*
1246
-	*/
1242
+	 * Gets all the spotter information based on the callsign
1243
+	 *
1244
+	 * @return Array the spotter information
1245
+	 *
1246
+	 */
1247 1247
 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
1248 1248
 	{
1249 1249
 		global $global_query;
@@ -1295,11 +1295,11 @@  discard block
 block discarded – undo
1295 1295
 	}
1296 1296
 	
1297 1297
 	/**
1298
-	* Gets all the spotter information based on the owner
1299
-	*
1300
-	* @return Array the spotter information
1301
-	*
1302
-	*/
1298
+	 * Gets all the spotter information based on the owner
1299
+	 *
1300
+	 * @return Array the spotter information
1301
+	 *
1302
+	 */
1303 1303
 	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1304 1304
 	{
1305 1305
 		global $global_query;
@@ -1352,11 +1352,11 @@  discard block
 block discarded – undo
1352 1352
 	}
1353 1353
 	
1354 1354
 	/**
1355
-	* Gets all the spotter information based on the pilot
1356
-	*
1357
-	* @return Array the spotter information
1358
-	*
1359
-	*/
1355
+	 * Gets all the spotter information based on the pilot
1356
+	 *
1357
+	 * @return Array the spotter information
1358
+	 *
1359
+	 */
1360 1360
 	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1361 1361
 	{
1362 1362
 		global $global_query;
@@ -1405,11 +1405,11 @@  discard block
 block discarded – undo
1405 1405
 	
1406 1406
 	
1407 1407
 	/**
1408
-	* Gets all the spotter information based on the aircraft type
1409
-	*
1410
-	* @return Array the spotter information
1411
-	*
1412
-	*/
1408
+	 * Gets all the spotter information based on the aircraft type
1409
+	 *
1410
+	 * @return Array the spotter information
1411
+	 *
1412
+	 */
1413 1413
 	public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array())
1414 1414
 	{
1415 1415
 		global $global_query;
@@ -1463,11 +1463,11 @@  discard block
 block discarded – undo
1463 1463
 	
1464 1464
 	
1465 1465
 	/**
1466
-	* Gets all the spotter information based on the aircraft registration
1467
-	*
1468
-	* @return Array the spotter information
1469
-	*
1470
-	*/
1466
+	 * Gets all the spotter information based on the aircraft registration
1467
+	 *
1468
+	 * @return Array the spotter information
1469
+	 *
1470
+	 */
1471 1471
 	public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array())
1472 1472
 	{
1473 1473
 		global $global_query;
@@ -1524,11 +1524,11 @@  discard block
 block discarded – undo
1524 1524
 	
1525 1525
 	
1526 1526
 	/**
1527
-	* Gets all the spotter information based on the airline
1528
-	*
1529
-	* @return Array the spotter information
1530
-	*
1531
-	*/
1527
+	 * Gets all the spotter information based on the airline
1528
+	 *
1529
+	 * @return Array the spotter information
1530
+	 *
1531
+	 */
1532 1532
 	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1533 1533
 	{
1534 1534
 		global $global_query;
@@ -1581,11 +1581,11 @@  discard block
 block discarded – undo
1581 1581
 	
1582 1582
 	
1583 1583
 	/**
1584
-	* Gets all the spotter information based on the airport
1585
-	*
1586
-	* @return Array the spotter information
1587
-	*
1588
-	*/
1584
+	 * Gets all the spotter information based on the airport
1585
+	 *
1586
+	 * @return Array the spotter information
1587
+	 *
1588
+	 */
1589 1589
 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1590 1590
 	{
1591 1591
 		global $global_query;
@@ -1639,11 +1639,11 @@  discard block
 block discarded – undo
1639 1639
 
1640 1640
 
1641 1641
 	/**
1642
-	* Gets all the spotter information based on the date
1643
-	*
1644
-	* @return Array the spotter information
1645
-	*
1646
-	*/
1642
+	 * Gets all the spotter information based on the date
1643
+	 *
1644
+	 * @return Array the spotter information
1645
+	 *
1646
+	 */
1647 1647
 	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1648 1648
 	{
1649 1649
 		global $global_query, $globalTimezone, $globalDBdriver;
@@ -1707,11 +1707,11 @@  discard block
 block discarded – undo
1707 1707
 
1708 1708
 
1709 1709
 	/**
1710
-	* Gets all the spotter information based on the country name
1711
-	*
1712
-	* @return Array the spotter information
1713
-	*
1714
-	*/
1710
+	 * Gets all the spotter information based on the country name
1711
+	 *
1712
+	 * @return Array the spotter information
1713
+	 *
1714
+	 */
1715 1715
 	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1716 1716
 	{
1717 1717
 		global $global_query;
@@ -1765,11 +1765,11 @@  discard block
 block discarded – undo
1765 1765
 	
1766 1766
 	
1767 1767
 	/**
1768
-	* Gets all the spotter information based on the manufacturer name
1769
-	*
1770
-	* @return Array the spotter information
1771
-	*
1772
-	*/
1768
+	 * Gets all the spotter information based on the manufacturer name
1769
+	 *
1770
+	 * @return Array the spotter information
1771
+	 *
1772
+	 */
1773 1773
 	public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '', $filters = array())
1774 1774
 	{
1775 1775
 		global $global_query;
@@ -1825,13 +1825,13 @@  discard block
 block discarded – undo
1825 1825
   
1826 1826
   
1827 1827
 	/**
1828
-	* Gets a list of all aircraft that take a route
1829
-	*
1830
-	* @param String $departure_airport_icao ICAO code of departure airport
1831
-	* @param String $arrival_airport_icao ICAO code of arrival airport
1832
-	* @return Array the spotter information
1833
-	*
1834
-	*/
1828
+	 * Gets a list of all aircraft that take a route
1829
+	 *
1830
+	 * @param String $departure_airport_icao ICAO code of departure airport
1831
+	 * @param String $arrival_airport_icao ICAO code of arrival airport
1832
+	 * @return Array the spotter information
1833
+	 *
1834
+	 */
1835 1835
 	public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '', $filters = array())
1836 1836
 	{
1837 1837
 		global $global_query;
@@ -1900,11 +1900,11 @@  discard block
 block discarded – undo
1900 1900
 	
1901 1901
 	
1902 1902
 	/**
1903
-	* Gets all the spotter information based on the special column in the table
1904
-	*
1905
-	* @return Array the spotter information
1906
-	*
1907
-	*/
1903
+	 * Gets all the spotter information based on the special column in the table
1904
+	 *
1905
+	 * @return Array the spotter information
1906
+	 *
1907
+	 */
1908 1908
 	public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array())
1909 1909
 	{
1910 1910
 		global $global_query;
@@ -1943,11 +1943,11 @@  discard block
 block discarded – undo
1943 1943
 	}
1944 1944
 
1945 1945
 	/**
1946
-	* Gets all the highlight based on a aircraft registration
1947
-	*
1948
-	* @return String the highlight text
1949
-	*
1950
-	*/
1946
+	 * Gets all the highlight based on a aircraft registration
1947
+	 *
1948
+	 * @return String the highlight text
1949
+	 *
1950
+	 */
1951 1951
 	public function getHighlightByRegistration($registration,$filter = array())
1952 1952
 	{
1953 1953
 		global $global_query;
@@ -1969,13 +1969,13 @@  discard block
 block discarded – undo
1969 1969
 
1970 1970
 	
1971 1971
 	/**
1972
-	* Gets the squawk usage from squawk code
1973
-	*
1974
-	* @param String $squawk squawk code
1975
-	* @param String $country country
1976
-	* @return String usage
1977
-	*
1978
-	*/
1972
+	 * Gets the squawk usage from squawk code
1973
+	 *
1974
+	 * @param String $squawk squawk code
1975
+	 * @param String $country country
1976
+	 * @return String usage
1977
+	 *
1978
+	 */
1979 1979
 	public function getSquawkUsage($squawk = '',$country = 'FR')
1980 1980
 	{
1981 1981
 		
@@ -1996,12 +1996,12 @@  discard block
 block discarded – undo
1996 1996
 	}
1997 1997
 
1998 1998
 	/**
1999
-	* Gets the airport icao from the iata
2000
-	*
2001
-	* @param String $airport_iata the iata code of the airport
2002
-	* @return String airport iata
2003
-	*
2004
-	*/
1999
+	 * Gets the airport icao from the iata
2000
+	 *
2001
+	 * @param String $airport_iata the iata code of the airport
2002
+	 * @return String airport iata
2003
+	 *
2004
+	 */
2005 2005
 	public function getAirportIcao($airport_iata = '')
2006 2006
 	{
2007 2007
 		
@@ -2021,14 +2021,14 @@  discard block
 block discarded – undo
2021 2021
 	}
2022 2022
 
2023 2023
 	/**
2024
-	* Gets the airport distance
2025
-	*
2026
-	* @param String $airport_icao the icao code of the airport
2027
-	* @param Float $latitude the latitude
2028
-	* @param Float $longitude the longitude
2029
-	* @return Float distance to the airport
2030
-	*
2031
-	*/
2024
+	 * Gets the airport distance
2025
+	 *
2026
+	 * @param String $airport_icao the icao code of the airport
2027
+	 * @param Float $latitude the latitude
2028
+	 * @param Float $longitude the longitude
2029
+	 * @return Float distance to the airport
2030
+	 *
2031
+	 */
2032 2032
 	public function getAirportDistance($airport_icao,$latitude,$longitude)
2033 2033
 	{
2034 2034
 		
@@ -2049,12 +2049,12 @@  discard block
 block discarded – undo
2049 2049
 	}
2050 2050
 	
2051 2051
 	/**
2052
-	* Gets the airport info based on the icao
2053
-	*
2054
-	* @param String $airport the icao code of the airport
2055
-	* @return Array airport information
2056
-	*
2057
-	*/
2052
+	 * Gets the airport info based on the icao
2053
+	 *
2054
+	 * @param String $airport the icao code of the airport
2055
+	 * @return Array airport information
2056
+	 *
2057
+	 */
2058 2058
 	public function getAllAirportInfo($airport = '')
2059 2059
 	{
2060 2060
 		
@@ -2100,12 +2100,12 @@  discard block
 block discarded – undo
2100 2100
 	}
2101 2101
 	
2102 2102
 	/**
2103
-	* Gets the airport info based on the country
2104
-	*
2105
-	* @param Array $countries Airports countries
2106
-	* @return Array airport information
2107
-	*
2108
-	*/
2103
+	 * Gets the airport info based on the country
2104
+	 *
2105
+	 * @param Array $countries Airports countries
2106
+	 * @return Array airport information
2107
+	 *
2108
+	 */
2109 2109
 	public function getAllAirportInfobyCountry($countries)
2110 2110
 	{
2111 2111
 		$lst_countries = '';
@@ -2143,12 +2143,12 @@  discard block
 block discarded – undo
2143 2143
 	}
2144 2144
 	
2145 2145
 	/**
2146
-	* Gets airports info based on the coord
2147
-	*
2148
-	* @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
2149
-	* @return Array airport information
2150
-	*
2151
-	*/
2146
+	 * Gets airports info based on the coord
2147
+	 *
2148
+	 * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
2149
+	 * @return Array airport information
2150
+	 *
2151
+	 */
2152 2152
 	public function getAllAirportInfobyCoord($coord)
2153 2153
 	{
2154 2154
 		global $globalDBdriver;
@@ -2179,12 +2179,12 @@  discard block
 block discarded – undo
2179 2179
 	}
2180 2180
 
2181 2181
 	/**
2182
-	* Gets waypoints info based on the coord
2183
-	*
2184
-	* @param Array $coord waypoints coord
2185
-	* @return Array airport information
2186
-	*
2187
-	*/
2182
+	 * Gets waypoints info based on the coord
2183
+	 *
2184
+	 * @param Array $coord waypoints coord
2185
+	 * @return Array airport information
2186
+	 *
2187
+	 */
2188 2188
 	public function getAllWaypointsInfobyCoord($coord)
2189 2189
 	{
2190 2190
 		if (is_array($coord)) {
@@ -2218,12 +2218,12 @@  discard block
 block discarded – undo
2218 2218
 	
2219 2219
 	
2220 2220
 	/**
2221
-	* Gets the airline info based on the icao code or iata code
2222
-	*
2223
-	* @param String $airline_icao the iata code of the airport
2224
-	* @return Array airport information
2225
-	*
2226
-	*/
2221
+	 * Gets the airline info based on the icao code or iata code
2222
+	 *
2223
+	 * @param String $airline_icao the iata code of the airport
2224
+	 * @return Array airport information
2225
+	 *
2226
+	 */
2227 2227
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2228 2228
 	{
2229 2229
 		global $globalUseRealAirlines;
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 			} else {
2255 2255
 				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2256 2256
 			}
2257
-                        /*
2257
+						/*
2258 2258
 			$airline_array = array();
2259 2259
 			$temp_array = array();
2260 2260
 		
@@ -2287,12 +2287,12 @@  discard block
 block discarded – undo
2287 2287
 	}
2288 2288
 	
2289 2289
 	/**
2290
-	* Gets the airline info based on the airline name
2291
-	*
2292
-	* @param String $airline_name the name of the airline
2293
-	* @return Array airline information
2294
-	*
2295
-	*/
2290
+	 * Gets the airline info based on the airline name
2291
+	 *
2292
+	 * @param String $airline_name the name of the airline
2293
+	 * @return Array airline information
2294
+	 *
2295
+	 */
2296 2296
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2297 2297
 	{
2298 2298
 		global $globalUseRealAirlines;
@@ -2320,12 +2320,12 @@  discard block
 block discarded – undo
2320 2320
 	
2321 2321
 	
2322 2322
 	/**
2323
-	* Gets the aircraft info based on the aircraft type
2324
-	*
2325
-	* @param String $aircraft_type the aircraft type
2326
-	* @return Array aircraft information
2327
-	*
2328
-	*/
2323
+	 * Gets the aircraft info based on the aircraft type
2324
+	 *
2325
+	 * @param String $aircraft_type the aircraft type
2326
+	 * @return Array aircraft information
2327
+	 *
2328
+	 */
2329 2329
 	public function getAllAircraftInfo($aircraft_type)
2330 2330
 	{
2331 2331
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2357,12 +2357,12 @@  discard block
 block discarded – undo
2357 2357
 	}
2358 2358
 
2359 2359
 	/**
2360
-	* Gets the aircraft icao based on the aircraft name/type
2361
-	*
2362
-	* @param String $aircraft_type the aircraft type
2363
-	* @return String aircraft information
2364
-	*
2365
-	*/
2360
+	 * Gets the aircraft icao based on the aircraft name/type
2361
+	 *
2362
+	 * @param String $aircraft_type the aircraft type
2363
+	 * @return String aircraft information
2364
+	 *
2365
+	 */
2366 2366
 	public function getAircraftIcao($aircraft_type)
2367 2367
 	{
2368 2368
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2387,12 +2387,12 @@  discard block
 block discarded – undo
2387 2387
 	}
2388 2388
 	
2389 2389
 	/**
2390
-	* Gets the aircraft info based on the aircraft modes
2391
-	*
2392
-	* @param String $aircraft_modes the aircraft ident (hex)
2393
-	* @return String aircraft type
2394
-	*
2395
-	*/
2390
+	 * Gets the aircraft info based on the aircraft modes
2391
+	 *
2392
+	 * @param String $aircraft_modes the aircraft ident (hex)
2393
+	 * @return String aircraft type
2394
+	 *
2395
+	 */
2396 2396
 	public function getAllAircraftType($aircraft_modes)
2397 2397
 	{
2398 2398
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -2412,12 +2412,12 @@  discard block
 block discarded – undo
2412 2412
 	}
2413 2413
 
2414 2414
 	/**
2415
-	* Gets the aircraft info based on the aircraft registration
2416
-	*
2417
-	* @param String $registration the aircraft registration
2418
-	* @return String aircraft type
2419
-	*
2420
-	*/
2415
+	 * Gets the aircraft info based on the aircraft registration
2416
+	 *
2417
+	 * @param String $registration the aircraft registration
2418
+	 * @return String aircraft type
2419
+	 *
2420
+	 */
2421 2421
 	public function getAllAircraftTypeByRegistration($registration)
2422 2422
 	{
2423 2423
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2435,12 +2435,12 @@  discard block
 block discarded – undo
2435 2435
 	}
2436 2436
 
2437 2437
 	/**
2438
-	* Gets the spotter_id and flightaware_id based on the aircraft registration
2439
-	*
2440
-	* @param String $registration the aircraft registration
2441
-	* @return Array spotter_id and flightaware_id
2442
-	*
2443
-	*/
2438
+	 * Gets the spotter_id and flightaware_id based on the aircraft registration
2439
+	 *
2440
+	 * @param String $registration the aircraft registration
2441
+	 * @return Array spotter_id and flightaware_id
2442
+	 *
2443
+	 */
2444 2444
 	public function getAllIDByRegistration($registration)
2445 2445
 	{
2446 2446
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2459,12 +2459,12 @@  discard block
 block discarded – undo
2459 2459
 	}
2460 2460
 
2461 2461
 	/**
2462
-	* Gets correct aircraft operator code
2463
-	*
2464
-	* @param String $operator the aircraft operator code (callsign)
2465
-	* @return String aircraft operator code
2466
-	*
2467
-	*/
2462
+	 * Gets correct aircraft operator code
2463
+	 *
2464
+	 * @param String $operator the aircraft operator code (callsign)
2465
+	 * @return String aircraft operator code
2466
+	 *
2467
+	 */
2468 2468
 	public function getOperator($operator)
2469 2469
 	{
2470 2470
 		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
@@ -2481,16 +2481,16 @@  discard block
 block discarded – undo
2481 2481
 	}
2482 2482
 
2483 2483
 	/**
2484
-	* Gets the aircraft route based on the aircraft callsign
2485
-	*
2486
-	* @param String $callsign the aircraft callsign
2487
-	* @return Array aircraft type
2488
-	*
2489
-	*/
2484
+	 * Gets the aircraft route based on the aircraft callsign
2485
+	 *
2486
+	 * @param String $callsign the aircraft callsign
2487
+	 * @return Array aircraft type
2488
+	 *
2489
+	 */
2490 2490
 	public function getRouteInfo($callsign)
2491 2491
 	{
2492 2492
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2493
-                if ($callsign == '') return array();
2493
+				if ($callsign == '') return array();
2494 2494
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2495 2495
 		
2496 2496
 		$sth = $this->db->prepare($query);
@@ -2504,12 +2504,12 @@  discard block
 block discarded – undo
2504 2504
 	}
2505 2505
 	
2506 2506
 	/**
2507
-	* Gets the aircraft info based on the aircraft registration
2508
-	*
2509
-	* @param String $registration the aircraft registration
2510
-	* @return Array aircraft information
2511
-	*
2512
-	*/
2507
+	 * Gets the aircraft info based on the aircraft registration
2508
+	 *
2509
+	 * @param String $registration the aircraft registration
2510
+	 * @return Array aircraft information
2511
+	 *
2512
+	 */
2513 2513
 	public function getAircraftInfoByRegistration($registration)
2514 2514
 	{
2515 2515
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2536,12 +2536,12 @@  discard block
 block discarded – undo
2536 2536
 	}
2537 2537
 	
2538 2538
 	/**
2539
-	* Gets the aircraft owner & base based on the aircraft registration
2540
-	*
2541
-	* @param String $registration the aircraft registration
2542
-	* @return Array aircraft information
2543
-	*
2544
-	*/
2539
+	 * Gets the aircraft owner & base based on the aircraft registration
2540
+	 *
2541
+	 * @param String $registration the aircraft registration
2542
+	 * @return Array aircraft information
2543
+	 *
2544
+	 */
2545 2545
 	public function getAircraftOwnerByRegistration($registration)
2546 2546
 	{
2547 2547
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2558,11 +2558,11 @@  discard block
 block discarded – undo
2558 2558
 	
2559 2559
   
2560 2560
   /**
2561
-	* Gets all flights (but with only little info)
2562
-	*
2563
-	* @return Array basic flight information
2564
-	*
2565
-	*/
2561
+   * Gets all flights (but with only little info)
2562
+   *
2563
+   * @return Array basic flight information
2564
+   *
2565
+   */
2566 2566
 	public function getAllFlightsforSitemap()
2567 2567
 	{
2568 2568
 		//$query  = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT ";
@@ -2570,7 +2570,7 @@  discard block
 block discarded – undo
2570 2570
 		
2571 2571
 		$sth = $this->db->prepare($query);
2572 2572
 		$sth->execute();
2573
-                  /*
2573
+				  /*
2574 2574
 		$flight_array = array();
2575 2575
 		$temp_array = array();
2576 2576
 		
@@ -2592,11 +2592,11 @@  discard block
 block discarded – undo
2592 2592
 	}
2593 2593
   
2594 2594
 	/**
2595
-	* Gets a list of all aircraft manufacturers
2596
-	*
2597
-	* @return Array list of aircraft types
2598
-	*
2599
-	*/
2595
+	 * Gets a list of all aircraft manufacturers
2596
+	 *
2597
+	 * @return Array list of aircraft types
2598
+	 *
2599
+	 */
2600 2600
 	public function getAllManufacturers()
2601 2601
 	{
2602 2602
 		/*
@@ -2625,11 +2625,11 @@  discard block
 block discarded – undo
2625 2625
   
2626 2626
   
2627 2627
   /**
2628
-	* Gets a list of all aircraft types
2629
-	*
2630
-	* @return Array list of aircraft types
2631
-	*
2632
-	*/
2628
+   * Gets a list of all aircraft types
2629
+   *
2630
+   * @return Array list of aircraft types
2631
+   *
2632
+   */
2633 2633
 	public function getAllAircraftTypes($filters = array())
2634 2634
 	{
2635 2635
 		/*
@@ -2664,11 +2664,11 @@  discard block
 block discarded – undo
2664 2664
 	
2665 2665
 	
2666 2666
 	/**
2667
-	* Gets a list of all aircraft registrations
2668
-	*
2669
-	* @return Array list of aircraft registrations
2670
-	*
2671
-	*/
2667
+	 * Gets a list of all aircraft registrations
2668
+	 *
2669
+	 * @return Array list of aircraft registrations
2670
+	 *
2671
+	 */
2672 2672
 	public function getAllAircraftRegistrations($filters = array())
2673 2673
 	{
2674 2674
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2693,12 +2693,12 @@  discard block
 block discarded – undo
2693 2693
 	}
2694 2694
 
2695 2695
 	/**
2696
-	* Gets all source name
2697
-	*
2698
-	* @param String type format of source
2699
-	* @return Array list of source name
2700
-	*
2701
-	*/
2696
+	 * Gets all source name
2697
+	 *
2698
+	 * @param String type format of source
2699
+	 * @return Array list of source name
2700
+	 *
2701
+	 */
2702 2702
 	public function getAllSourceName($type = '',$filters = array())
2703 2703
 	{
2704 2704
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2729,11 +2729,11 @@  discard block
 block discarded – undo
2729 2729
 
2730 2730
 
2731 2731
 	/**
2732
-	* Gets a list of all airline names
2733
-	*
2734
-	* @return Array list of airline names
2735
-	*
2736
-	*/
2732
+	 * Gets a list of all airline names
2733
+	 *
2734
+	 * @return Array list of airline names
2735
+	 *
2736
+	 */
2737 2737
 	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2738 2738
 	{
2739 2739
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
@@ -2782,11 +2782,11 @@  discard block
 block discarded – undo
2782 2782
 	}
2783 2783
 	
2784 2784
 	/**
2785
-	* Gets a list of all alliance names
2786
-	*
2787
-	* @return Array list of alliance names
2788
-	*
2789
-	*/
2785
+	 * Gets a list of all alliance names
2786
+	 *
2787
+	 * @return Array list of alliance names
2788
+	 *
2789
+	 */
2790 2790
 	public function getAllAllianceNames($forsource = NULL,$filters = array())
2791 2791
 	{
2792 2792
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
@@ -2811,11 +2811,11 @@  discard block
 block discarded – undo
2811 2811
 	}
2812 2812
 	
2813 2813
 	/**
2814
-	* Gets a list of all airline countries
2815
-	*
2816
-	* @return Array list of airline countries
2817
-	*
2818
-	*/
2814
+	 * Gets a list of all airline countries
2815
+	 *
2816
+	 * @return Array list of airline countries
2817
+	 *
2818
+	 */
2819 2819
 	public function getAllAirlineCountries($filters = array())
2820 2820
 	{
2821 2821
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2843,11 +2843,11 @@  discard block
 block discarded – undo
2843 2843
 	
2844 2844
 	
2845 2845
 	/**
2846
-	* Gets a list of all departure & arrival names
2847
-	*
2848
-	* @return Array list of airport names
2849
-	*
2850
-	*/
2846
+	 * Gets a list of all departure & arrival names
2847
+	 *
2848
+	 * @return Array list of airport names
2849
+	 *
2850
+	 */
2851 2851
 	public function getAllAirportNames($filters = array())
2852 2852
 	{
2853 2853
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2895,11 +2895,11 @@  discard block
 block discarded – undo
2895 2895
 	} 
2896 2896
 
2897 2897
 	/**
2898
-	* Gets a list of all owner names
2899
-	*
2900
-	* @return Array list of owner names
2901
-	*
2902
-	*/
2898
+	 * Gets a list of all owner names
2899
+	 *
2900
+	 * @return Array list of owner names
2901
+	 *
2902
+	 */
2903 2903
 	public function getAllOwnerNames($filters = array())
2904 2904
 	{
2905 2905
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2913,11 +2913,11 @@  discard block
 block discarded – undo
2913 2913
 	} 
2914 2914
 
2915 2915
 	/**
2916
-	* Gets a list of all pilot names and pilot ids
2917
-	*
2918
-	* @return Array list of pilot names and pilot ids
2919
-	*
2920
-	*/
2916
+	 * Gets a list of all pilot names and pilot ids
2917
+	 *
2918
+	 * @return Array list of pilot names and pilot ids
2919
+	 *
2920
+	 */
2921 2921
 	public function getAllPilotNames($filters = array())
2922 2922
 	{
2923 2923
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2932,11 +2932,11 @@  discard block
 block discarded – undo
2932 2932
 	
2933 2933
 	
2934 2934
 	/**
2935
-	* Gets a list of all departure & arrival airport countries
2936
-	*
2937
-	* @return Array list of airport countries
2938
-	*
2939
-	*/
2935
+	 * Gets a list of all departure & arrival airport countries
2936
+	 *
2937
+	 * @return Array list of airport countries
2938
+	 *
2939
+	 */
2940 2940
 	public function getAllAirportCountries($filters = array())
2941 2941
 	{
2942 2942
 		$airport_array = array();
@@ -2984,11 +2984,11 @@  discard block
 block discarded – undo
2984 2984
 	
2985 2985
 	
2986 2986
 	/**
2987
-	* Gets a list of all countries (airline, departure airport & arrival airport)
2988
-	*
2989
-	* @return Array list of countries
2990
-	*
2991
-	*/
2987
+	 * Gets a list of all countries (airline, departure airport & arrival airport)
2988
+	 *
2989
+	 * @return Array list of countries
2990
+	 *
2991
+	 */
2992 2992
 	public function getAllCountries($filters = array())
2993 2993
 	{
2994 2994
 		$Connection= new Connection($this->db);
@@ -3065,11 +3065,11 @@  discard block
 block discarded – undo
3065 3065
 	
3066 3066
 	
3067 3067
 	/**
3068
-	* Gets a list of all idents/callsigns
3069
-	*
3070
-	* @return Array list of ident/callsign names
3071
-	*
3072
-	*/
3068
+	 * Gets a list of all idents/callsigns
3069
+	 *
3070
+	 * @return Array list of ident/callsign names
3071
+	 *
3072
+	 */
3073 3073
 	public function getAllIdents($filters = array())
3074 3074
 	{
3075 3075
 		$filter_query = $this->getFilter($filters,true,true);
@@ -3093,9 +3093,9 @@  discard block
 block discarded – undo
3093 3093
 	}
3094 3094
 
3095 3095
 	/**
3096
-	* Get a list of flights from airport since 7 days
3097
-	* @return Array number, icao, name and city of airports
3098
-	*/
3096
+	 * Get a list of flights from airport since 7 days
3097
+	 * @return Array number, icao, name and city of airports
3098
+	 */
3099 3099
 
3100 3100
 	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
3101 3101
 		global $globalTimezone, $globalDBdriver;
@@ -3126,9 +3126,9 @@  discard block
 block discarded – undo
3126 3126
 	}
3127 3127
 
3128 3128
 	/**
3129
-	* Get a list of flights from airport since 7 days
3130
-	* @return Array number, icao, name and city of airports
3131
-	*/
3129
+	 * Get a list of flights from airport since 7 days
3130
+	 * @return Array number, icao, name and city of airports
3131
+	 */
3132 3132
 
3133 3133
 	public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') {
3134 3134
 		global $globalTimezone, $globalDBdriver;
@@ -3158,9 +3158,9 @@  discard block
 block discarded – undo
3158 3158
 	}
3159 3159
 
3160 3160
 	/**
3161
-	* Get a list of flights from detected airport since 7 days
3162
-	* @return Array number, icao, name and city of airports
3163
-	*/
3161
+	 * Get a list of flights from detected airport since 7 days
3162
+	 * @return Array number, icao, name and city of airports
3163
+	 */
3164 3164
 
3165 3165
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
3166 3166
 		global $globalTimezone, $globalDBdriver;
@@ -3198,9 +3198,9 @@  discard block
 block discarded – undo
3198 3198
 	}
3199 3199
 
3200 3200
 	/**
3201
-	* Get a list of flights from detected airport since 7 days
3202
-	* @return Array number, icao, name and city of airports
3203
-	*/
3201
+	 * Get a list of flights from detected airport since 7 days
3202
+	 * @return Array number, icao, name and city of airports
3203
+	 */
3204 3204
 
3205 3205
 	public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') {
3206 3206
 		global $globalTimezone, $globalDBdriver;
@@ -3242,9 +3242,9 @@  discard block
 block discarded – undo
3242 3242
 
3243 3243
 
3244 3244
 	/**
3245
-	* Get a list of flights to airport since 7 days
3246
-	* @return Array number, icao, name and city of airports
3247
-	*/
3245
+	 * Get a list of flights to airport since 7 days
3246
+	 * @return Array number, icao, name and city of airports
3247
+	 */
3248 3248
 
3249 3249
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
3250 3250
 		global $globalTimezone, $globalDBdriver;
@@ -3277,9 +3277,9 @@  discard block
 block discarded – undo
3277 3277
 
3278 3278
 
3279 3279
 	/**
3280
-	* Get a list of flights detected to airport since 7 days
3281
-	* @return Array number, icao, name and city of airports
3282
-	*/
3280
+	 * Get a list of flights detected to airport since 7 days
3281
+	 * @return Array number, icao, name and city of airports
3282
+	 */
3283 3283
 
3284 3284
 	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
3285 3285
 		global $globalTimezone, $globalDBdriver;
@@ -3320,9 +3320,9 @@  discard block
 block discarded – undo
3320 3320
 
3321 3321
 
3322 3322
 	/**
3323
-	* Get a list of flights to airport since 7 days
3324
-	* @return Array number, icao, name and city of airports
3325
-	*/
3323
+	 * Get a list of flights to airport since 7 days
3324
+	 * @return Array number, icao, name and city of airports
3325
+	 */
3326 3326
 
3327 3327
 	public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') {
3328 3328
 		global $globalTimezone, $globalDBdriver;
@@ -3354,9 +3354,9 @@  discard block
 block discarded – undo
3354 3354
 
3355 3355
 
3356 3356
 	/**
3357
-	* Get a list of flights detected to airport since 7 days
3358
-	* @return Array number, icao, name and city of airports
3359
-	*/
3357
+	 * Get a list of flights detected to airport since 7 days
3358
+	 * @return Array number, icao, name and city of airports
3359
+	 */
3360 3360
 
3361 3361
 	public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') {
3362 3362
 		global $globalTimezone, $globalDBdriver;
@@ -3400,11 +3400,11 @@  discard block
 block discarded – undo
3400 3400
 
3401 3401
 
3402 3402
 	/**
3403
-	* Gets a list of all dates
3404
-	*
3405
-	* @return Array list of date names
3406
-	*
3407
-	*/
3403
+	 * Gets a list of all dates
3404
+	 *
3405
+	 * @return Array list of date names
3406
+	 *
3407
+	 */
3408 3408
 	public function getAllDates()
3409 3409
 	{
3410 3410
 		global $globalTimezone, $globalDBdriver;
@@ -3445,11 +3445,11 @@  discard block
 block discarded – undo
3445 3445
 	
3446 3446
 	
3447 3447
 	/**
3448
-	* Gets all route combinations
3449
-	*
3450
-	* @return Array the route list
3451
-	*
3452
-	*/
3448
+	 * Gets all route combinations
3449
+	 *
3450
+	 * @return Array the route list
3451
+	 *
3452
+	 */
3453 3453
 	public function getAllRoutes()
3454 3454
 	{
3455 3455
 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
@@ -3475,13 +3475,13 @@  discard block
 block discarded – undo
3475 3475
 	}
3476 3476
 
3477 3477
 	/**
3478
-	* Update ident spotter data
3479
-	*
3480
-	* @param String $flightaware_id the ID from flightaware
3481
-	* @param String $ident the flight ident
3482
-	* @return String success or false
3483
-	*
3484
-	*/	
3478
+	 * Update ident spotter data
3479
+	 *
3480
+	 * @param String $flightaware_id the ID from flightaware
3481
+	 * @param String $ident the flight ident
3482
+	 * @return String success or false
3483
+	 *
3484
+	 */	
3485 3485
 	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3486 3486
 	{
3487 3487
 		if (!is_numeric(substr($ident, 0, 3)))
@@ -3502,14 +3502,14 @@  discard block
 block discarded – undo
3502 3502
 		} else {
3503 3503
 			$airline_array = $this->getAllAirlineInfo("NA");
3504 3504
 		}
3505
-                $airline_name = $airline_array[0]['name'];
3506
-                $airline_icao = $airline_array[0]['icao'];
3507
-                $airline_country = $airline_array[0]['country'];
3508
-                $airline_type = $airline_array[0]['type'];
3505
+				$airline_name = $airline_array[0]['name'];
3506
+				$airline_icao = $airline_array[0]['icao'];
3507
+				$airline_country = $airline_array[0]['country'];
3508
+				$airline_type = $airline_array[0]['type'];
3509 3509
 
3510 3510
 
3511 3511
 		$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id';
3512
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
3512
+				$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
3513 3513
 
3514 3514
 		try {
3515 3515
 			$sth = $this->db->prepare($query);
@@ -3522,19 +3522,19 @@  discard block
 block discarded – undo
3522 3522
 
3523 3523
 	}
3524 3524
 	/**
3525
-	* Update latest spotter data
3526
-	*
3527
-	* @param String $flightaware_id the ID from flightaware
3528
-	* @param String $ident the flight ident
3529
-	* @param String $arrival_airport_icao the arrival airport
3530
-	* @return String success or false
3531
-	*
3532
-	*/	
3525
+	 * Update latest spotter data
3526
+	 *
3527
+	 * @param String $flightaware_id the ID from flightaware
3528
+	 * @param String $ident the flight ident
3529
+	 * @param String $arrival_airport_icao the arrival airport
3530
+	 * @return String success or false
3531
+	 *
3532
+	 */	
3533 3533
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3534 3534
 	{
3535 3535
 		if ($groundspeed == '') $groundspeed = NULL;
3536 3536
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3537
-                $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3537
+				$query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3538 3538
 
3539 3539
 		try {
3540 3540
 			$sth = $this->db->prepare($query);
@@ -3548,32 +3548,32 @@  discard block
 block discarded – undo
3548 3548
 	}
3549 3549
 
3550 3550
 	/**
3551
-	* Adds a new spotter data
3552
-	*
3553
-	* @param String $flightaware_id the ID from flightaware
3554
-	* @param String $ident the flight ident
3555
-	* @param String $aircraft_icao the aircraft type
3556
-	* @param String $departure_airport_icao the departure airport
3557
-	* @param String $arrival_airport_icao the arrival airport
3558
-	* @param String $latitude latitude of flight
3559
-	* @param String $longitude latitude of flight
3560
-	* @param String $waypoints waypoints of flight
3561
-	* @param String $altitude altitude of flight
3562
-	* @param String $heading heading of flight
3563
-	* @param String $groundspeed speed of flight
3564
-	* @param String $date date of flight
3565
-	* @param String $departure_airport_time departure time of flight
3566
-	* @param String $arrival_airport_time arrival time of flight
3567
-	* @param String $squawk squawk code of flight
3568
-	* @param String $route_stop route stop of flight
3569
-	* @param String $highlight highlight or not
3570
-	* @param String $ModeS ModesS code of flight
3571
-	* @param String $registration registration code of flight
3572
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
3573
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
3574
-	* @param String $verticalrate vertival rate of flight
3575
-	* @return String success or false
3576
-	*/
3551
+	 * Adds a new spotter data
3552
+	 *
3553
+	 * @param String $flightaware_id the ID from flightaware
3554
+	 * @param String $ident the flight ident
3555
+	 * @param String $aircraft_icao the aircraft type
3556
+	 * @param String $departure_airport_icao the departure airport
3557
+	 * @param String $arrival_airport_icao the arrival airport
3558
+	 * @param String $latitude latitude of flight
3559
+	 * @param String $longitude latitude of flight
3560
+	 * @param String $waypoints waypoints of flight
3561
+	 * @param String $altitude altitude of flight
3562
+	 * @param String $heading heading of flight
3563
+	 * @param String $groundspeed speed of flight
3564
+	 * @param String $date date of flight
3565
+	 * @param String $departure_airport_time departure time of flight
3566
+	 * @param String $arrival_airport_time arrival time of flight
3567
+	 * @param String $squawk squawk code of flight
3568
+	 * @param String $route_stop route stop of flight
3569
+	 * @param String $highlight highlight or not
3570
+	 * @param String $ModeS ModesS code of flight
3571
+	 * @param String $registration registration code of flight
3572
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
3573
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
3574
+	 * @param String $verticalrate vertival rate of flight
3575
+	 * @return String success or false
3576
+	 */
3577 3577
 	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '')
3578 3578
 	{
3579 3579
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
@@ -3788,8 +3788,8 @@  discard block
 block discarded – undo
3788 3788
     
3789 3789
 		if ($globalIVAO && $aircraft_icao != '')
3790 3790
 		{
3791
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3792
-            		else $airline_icao = '';
3791
+					if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3792
+					else $airline_icao = '';
3793 3793
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3794 3794
 			if (!isset($image_array[0]['registration']))
3795 3795
 			{
@@ -3820,53 +3820,53 @@  discard block
 block discarded – undo
3820 3820
 	
3821 3821
 		if (count($airline_array) == 0) 
3822 3822
 		{
3823
-                        $airline_array = $this->getAllAirlineInfo('NA');
3824
-                }
3825
-                if (count($aircraft_array) == 0) 
3826
-                {
3827
-                        $aircraft_array = $this->getAllAircraftInfo('NA');
3828
-                }
3829
-                if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') 
3830
-                {
3831
-                        $departure_airport_array = $this->getAllAirportInfo('NA');
3832
-                }
3833
-                if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') 
3834
-                {
3835
-                        $arrival_airport_array = $this->getAllAirportInfo('NA');
3836
-                }
3837
-                if ($registration == '') $registration = 'NA';
3838
-                if ($latitude == '' && $longitude == '') {
3839
-            		$latitude = 0;
3840
-            		$longitude = 0;
3841
-            	}
3842
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3843
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3844
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3845
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3846
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3847
-                $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3823
+						$airline_array = $this->getAllAirlineInfo('NA');
3824
+				}
3825
+				if (count($aircraft_array) == 0) 
3826
+				{
3827
+						$aircraft_array = $this->getAllAircraftInfo('NA');
3828
+				}
3829
+				if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') 
3830
+				{
3831
+						$departure_airport_array = $this->getAllAirportInfo('NA');
3832
+				}
3833
+				if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') 
3834
+				{
3835
+						$arrival_airport_array = $this->getAllAirportInfo('NA');
3836
+				}
3837
+				if ($registration == '') $registration = 'NA';
3838
+				if ($latitude == '' && $longitude == '') {
3839
+					$latitude = 0;
3840
+					$longitude = 0;
3841
+				}
3842
+				if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3843
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3844
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3845
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3846
+				if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3847
+				$query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3848 3848
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3849 3849
 
3850
-                $airline_name = $airline_array[0]['name'];
3851
-                $airline_icao = $airline_array[0]['icao'];
3852
-                $airline_country = $airline_array[0]['country'];
3853
-                $airline_type = $airline_array[0]['type'];
3850
+				$airline_name = $airline_array[0]['name'];
3851
+				$airline_icao = $airline_array[0]['icao'];
3852
+				$airline_country = $airline_array[0]['country'];
3853
+				$airline_type = $airline_array[0]['type'];
3854 3854
 		if ($airline_type == '') {
3855 3855
 			$timeelapsed = microtime(true);
3856 3856
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3857 3857
 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3858 3858
 		}
3859 3859
 		if ($airline_type == null) $airline_type = '';
3860
-                $aircraft_type = $aircraft_array[0]['type'];
3861
-                $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3862
-                $departure_airport_name = $departure_airport_array[0]['name'];
3863
-	        $departure_airport_city = $departure_airport_array[0]['city'];
3864
-            	$departure_airport_country = $departure_airport_array[0]['country'];
3860
+				$aircraft_type = $aircraft_array[0]['type'];
3861
+				$aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3862
+				$departure_airport_name = $departure_airport_array[0]['name'];
3863
+			$departure_airport_city = $departure_airport_array[0]['city'];
3864
+				$departure_airport_country = $departure_airport_array[0]['country'];
3865 3865
                 
3866
-                $arrival_airport_name = $arrival_airport_array[0]['name'];
3867
-                $arrival_airport_city = $arrival_airport_array[0]['city'];
3868
-                $arrival_airport_country = $arrival_airport_array[0]['country'];
3869
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3866
+				$arrival_airport_name = $arrival_airport_array[0]['name'];
3867
+				$arrival_airport_city = $arrival_airport_array[0]['city'];
3868
+				$arrival_airport_country = $arrival_airport_array[0]['country'];
3869
+				$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3870 3870
 
3871 3871
 		try {
3872 3872
 		        
@@ -3874,7 +3874,7 @@  discard block
 block discarded – undo
3874 3874
 			$sth->execute($query_values);
3875 3875
 			$this->db = null;
3876 3876
 		} catch (PDOException $e) {
3877
-		    return "error : ".$e->getMessage();
3877
+			return "error : ".$e->getMessage();
3878 3878
 		}
3879 3879
 		
3880 3880
 		return "success";
@@ -3883,11 +3883,11 @@  discard block
 block discarded – undo
3883 3883
 	
3884 3884
   
3885 3885
 	/**
3886
-	* Gets the aircraft ident within the last hour
3887
-	*
3888
-	* @return String the ident
3889
-	*
3890
-	*/
3886
+	 * Gets the aircraft ident within the last hour
3887
+	 *
3888
+	 * @return String the ident
3889
+	 *
3890
+	 */
3891 3891
 	public function getIdentFromLastHour($ident)
3892 3892
 	{
3893 3893
 		global $globalDBdriver, $globalTimezone;
@@ -3903,11 +3903,11 @@  discard block
 block discarded – undo
3903 3903
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3904 3904
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
3905 3905
 			$query_data = array(':ident' => $ident);
3906
-    		}
3906
+			}
3907 3907
 		
3908 3908
 		$sth = $this->db->prepare($query);
3909 3909
 		$sth->execute($query_data);
3910
-    		$ident_result='';
3910
+			$ident_result='';
3911 3911
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3912 3912
 		{
3913 3913
 			$ident_result = $row['ident'];
@@ -3918,11 +3918,11 @@  discard block
 block discarded – undo
3918 3918
 	
3919 3919
 	
3920 3920
 	/**
3921
-	* Gets the aircraft data from the last 20 seconds
3922
-	*
3923
-	* @return Array the spotter data
3924
-	*
3925
-	*/
3921
+	 * Gets the aircraft data from the last 20 seconds
3922
+	 *
3923
+	 * @return Array the spotter data
3924
+	 *
3925
+	 */
3926 3926
 	public function getRealTimeData($q = '')
3927 3927
 	{
3928 3928
 		global $globalDBdriver;
@@ -3966,11 +3966,11 @@  discard block
 block discarded – undo
3966 3966
 	
3967 3967
 	
3968 3968
 	 /**
3969
-	* Gets all airlines that have flown over
3970
-	*
3971
-	* @return Array the airline list
3972
-	*
3973
-	*/
3969
+	  * Gets all airlines that have flown over
3970
+	  *
3971
+	  * @return Array the airline list
3972
+	  *
3973
+	  */
3974 3974
 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '')
3975 3975
 	{
3976 3976
 		global $globalDBdriver;
@@ -3984,7 +3984,7 @@  discard block
 block discarded – undo
3984 3984
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
3985 3985
 			}
3986 3986
 		}
3987
-                if ($sincedate != '') {
3987
+				if ($sincedate != '') {
3988 3988
 			if ($globalDBdriver == 'mysql') {
3989 3989
 				$query .= " AND spotter_output.date > '".$sincedate."'";
3990 3990
 			} else {
@@ -4038,26 +4038,26 @@  discard block
 block discarded – undo
4038 4038
 	}
4039 4039
 
4040 4040
 	 /**
4041
-	* Gets all pilots that have flown over
4042
-	*
4043
-	* @return Array the pilots list
4044
-	*
4045
-	*/
4041
+	  * Gets all pilots that have flown over
4042
+	  *
4043
+	  * @return Array the pilots list
4044
+	  *
4045
+	  */
4046 4046
 	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '')
4047 4047
 	{
4048 4048
 		global $globalDBdriver;
4049 4049
 		$filter_query = $this->getFilter($filters,true,true);
4050 4050
 		$query  = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4051 4051
 			FROM spotter_output LEFT JOIN (SELECT DISTINCT pilot_id, pilot_name, max(date) as date FROM spotter_output GROUP BY pilot_id, pilot_name) s ON s.pilot_id = spotter_output.pilot_id".$filter_query." spotter_output.pilot_id <> ''";
4052
-                if ($olderthanmonths > 0) {
4053
-            		if ($globalDBdriver == 'mysql') {
4052
+				if ($olderthanmonths > 0) {
4053
+					if ($globalDBdriver == 'mysql') {
4054 4054
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
4055 4055
 			} else {
4056 4056
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4057 4057
 			}
4058 4058
 		}
4059
-                if ($sincedate != '') {
4060
-            		if ($globalDBdriver == 'mysql') {
4059
+				if ($sincedate != '') {
4060
+					if ($globalDBdriver == 'mysql') {
4061 4061
 				$query .= " AND spotter_output.date > '".$sincedate."'";
4062 4062
 			} else {
4063 4063
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4112,25 +4112,25 @@  discard block
 block discarded – undo
4112 4112
 	}
4113 4113
 	
4114 4114
 	/**
4115
-	* Gets all pilots that have flown over
4116
-	*
4117
-	* @return Array the pilots list
4118
-	*
4119
-	*/
4115
+	 * Gets all pilots that have flown over
4116
+	 *
4117
+	 * @return Array the pilots list
4118
+	 *
4119
+	 */
4120 4120
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4121 4121
 	{
4122 4122
 		global $globalDBdriver;
4123 4123
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4124 4124
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
4125
-                if ($olderthanmonths > 0) {
4126
-            		if ($globalDBdriver == 'mysql') {
4125
+				if ($olderthanmonths > 0) {
4126
+					if ($globalDBdriver == 'mysql') {
4127 4127
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4128 4128
 			} else {
4129 4129
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4130 4130
 			}
4131 4131
 		}
4132
-                if ($sincedate != '') {
4133
-            		if ($globalDBdriver == 'mysql') {
4132
+				if ($sincedate != '') {
4133
+					if ($globalDBdriver == 'mysql') {
4134 4134
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
4135 4135
 			} else {
4136 4136
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4159,26 +4159,26 @@  discard block
 block discarded – undo
4159 4159
 	}
4160 4160
 	
4161 4161
 	 /**
4162
-	* Gets all owner that have flown over
4163
-	*
4164
-	* @return Array the pilots list
4165
-	*
4166
-	*/
4162
+	  * Gets all owner that have flown over
4163
+	  *
4164
+	  * @return Array the pilots list
4165
+	  *
4166
+	  */
4167 4167
 	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
4168 4168
 	{
4169 4169
 		global $globalDBdriver;
4170 4170
 		$filter_query = $this->getFilter($filters,true,true);
4171 4171
 		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4172 4172
 					FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL";
4173
-                if ($olderthanmonths > 0) {
4174
-            		if ($globalDBdriver == 'mysql') {
4173
+				if ($olderthanmonths > 0) {
4174
+					if ($globalDBdriver == 'mysql') {
4175 4175
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
4176 4176
 			} else {
4177 4177
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4178 4178
 			}
4179 4179
 		}
4180
-                if ($sincedate != '') {
4181
-            		if ($globalDBdriver == 'mysql') {
4180
+				if ($sincedate != '') {
4181
+					if ($globalDBdriver == 'mysql') {
4182 4182
 				$query .= " AND spotter_output.date > '".$sincedate."' ";
4183 4183
 			} else {
4184 4184
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4229,26 +4229,26 @@  discard block
 block discarded – undo
4229 4229
 	}
4230 4230
 	
4231 4231
 	 /**
4232
-	* Gets all owner that have flown over
4233
-	*
4234
-	* @return Array the pilots list
4235
-	*
4236
-	*/
4232
+	  * Gets all owner that have flown over
4233
+	  *
4234
+	  * @return Array the pilots list
4235
+	  *
4236
+	  */
4237 4237
 	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
4238 4238
 	{
4239 4239
 		global $globalDBdriver;
4240 4240
 		$filter_query = $this->getFilter($filters,true,true);
4241 4241
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4242 4242
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
4243
-                if ($olderthanmonths > 0) {
4244
-            		if ($globalDBdriver == 'mysql') {
4243
+				if ($olderthanmonths > 0) {
4244
+					if ($globalDBdriver == 'mysql') {
4245 4245
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4246 4246
 			} else {
4247 4247
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4248 4248
 			}
4249 4249
 		}
4250
-                if ($sincedate != '') {
4251
-            		if ($globalDBdriver == 'mysql') {
4250
+				if ($sincedate != '') {
4251
+					if ($globalDBdriver == 'mysql') {
4252 4252
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
4253 4253
 			} else {
4254 4254
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4275,11 +4275,11 @@  discard block
 block discarded – undo
4275 4275
 	}
4276 4276
 
4277 4277
 	/**
4278
-	* Gets all airlines that have flown over by aircraft
4279
-	*
4280
-	* @return Array the airline list
4281
-	*
4282
-	*/
4278
+	 * Gets all airlines that have flown over by aircraft
4279
+	 *
4280
+	 * @return Array the airline list
4281
+	 *
4282
+	 */
4283 4283
 	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
4284 4284
 	{
4285 4285
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -4311,11 +4311,11 @@  discard block
 block discarded – undo
4311 4311
 
4312 4312
 
4313 4313
 	/**
4314
-	* Gets all airline countries that have flown over by aircraft
4315
-	*
4316
-	* @return Array the airline country list
4317
-	*
4318
-	*/
4314
+	 * Gets all airline countries that have flown over by aircraft
4315
+	 *
4316
+	 * @return Array the airline country list
4317
+	 *
4318
+	 */
4319 4319
 	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
4320 4320
 	{
4321 4321
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -4347,11 +4347,11 @@  discard block
 block discarded – undo
4347 4347
 	
4348 4348
 	
4349 4349
 	/**
4350
-	* Gets all airlines that have flown over by airport
4351
-	*
4352
-	* @return Array the airline list
4353
-	*
4354
-	*/
4350
+	 * Gets all airlines that have flown over by airport
4351
+	 *
4352
+	 * @return Array the airline list
4353
+	 *
4354
+	 */
4355 4355
 	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4356 4356
 	{
4357 4357
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4382,11 +4382,11 @@  discard block
 block discarded – undo
4382 4382
 
4383 4383
 
4384 4384
 	/**
4385
-	* Gets all airline countries that have flown over by airport icao
4386
-	*
4387
-	* @return Array the airline country list
4388
-	*
4389
-	*/
4385
+	 * Gets all airline countries that have flown over by airport icao
4386
+	 *
4387
+	 * @return Array the airline country list
4388
+	 *
4389
+	 */
4390 4390
 	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4391 4391
 	{
4392 4392
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4416,11 +4416,11 @@  discard block
 block discarded – undo
4416 4416
 
4417 4417
 
4418 4418
 	/**
4419
-	* Gets all airlines that have flown over by aircraft manufacturer
4420
-	*
4421
-	* @return Array the airline list
4422
-	*
4423
-	*/
4419
+	 * Gets all airlines that have flown over by aircraft manufacturer
4420
+	 *
4421
+	 * @return Array the airline list
4422
+	 *
4423
+	 */
4424 4424
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4425 4425
 	{
4426 4426
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4451,11 +4451,11 @@  discard block
 block discarded – undo
4451 4451
 
4452 4452
 
4453 4453
 	/**
4454
-	* Gets all airline countries that have flown over by aircraft manufacturer
4455
-	*
4456
-	* @return Array the airline country list
4457
-	*
4458
-	*/
4454
+	 * Gets all airline countries that have flown over by aircraft manufacturer
4455
+	 *
4456
+	 * @return Array the airline country list
4457
+	 *
4458
+	 */
4459 4459
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4460 4460
 	{
4461 4461
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4484,11 +4484,11 @@  discard block
 block discarded – undo
4484 4484
 
4485 4485
 
4486 4486
 	/**
4487
-	* Gets all airlines that have flown over by date
4488
-	*
4489
-	* @return Array the airline list
4490
-	*
4491
-	*/
4487
+	 * Gets all airlines that have flown over by date
4488
+	 *
4489
+	 * @return Array the airline list
4490
+	 *
4491
+	 */
4492 4492
 	public function countAllAirlinesByDate($date,$filters = array())
4493 4493
 	{
4494 4494
 		global $globalTimezone, $globalDBdriver;
@@ -4532,11 +4532,11 @@  discard block
 block discarded – undo
4532 4532
 	
4533 4533
 	
4534 4534
 	/**
4535
-	* Gets all airline countries that have flown over by date
4536
-	*
4537
-	* @return Array the airline country list
4538
-	*
4539
-	*/
4535
+	 * Gets all airline countries that have flown over by date
4536
+	 *
4537
+	 * @return Array the airline country list
4538
+	 *
4539
+	 */
4540 4540
 	public function countAllAirlineCountriesByDate($date,$filters = array())
4541 4541
 	{
4542 4542
 		global $globalTimezone, $globalDBdriver;
@@ -4579,11 +4579,11 @@  discard block
 block discarded – undo
4579 4579
 
4580 4580
 
4581 4581
 	/**
4582
-	* Gets all airlines that have flown over by ident/callsign
4583
-	*
4584
-	* @return Array the airline list
4585
-	*
4586
-	*/
4582
+	 * Gets all airlines that have flown over by ident/callsign
4583
+	 *
4584
+	 * @return Array the airline list
4585
+	 *
4586
+	 */
4587 4587
 	public function countAllAirlinesByIdent($ident,$filters = array())
4588 4588
 	{
4589 4589
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4600,11 +4600,11 @@  discard block
 block discarded – undo
4600 4600
 	}
4601 4601
 
4602 4602
 	/**
4603
-	* Gets all airlines by owner
4604
-	*
4605
-	* @return Array the airline list
4606
-	*
4607
-	*/
4603
+	 * Gets all airlines by owner
4604
+	 *
4605
+	 * @return Array the airline list
4606
+	 *
4607
+	 */
4608 4608
 	public function countAllAirlinesByOwner($owner,$filters = array())
4609 4609
 	{
4610 4610
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4621,11 +4621,11 @@  discard block
 block discarded – undo
4621 4621
 	}
4622 4622
 
4623 4623
 	/**
4624
-	* Gets flight duration by owner
4625
-	*
4626
-	* @return String Duration of all flights
4627
-	*
4628
-	*/
4624
+	 * Gets flight duration by owner
4625
+	 *
4626
+	 * @return String Duration of all flights
4627
+	 *
4628
+	 */
4629 4629
 	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4630 4630
 	{
4631 4631
 		global $globalDBdriver;
@@ -4670,11 +4670,11 @@  discard block
 block discarded – undo
4670 4670
 	}
4671 4671
 
4672 4672
 	/**
4673
-	* Count flights by owner
4674
-	*
4675
-	* @return String Duration of all flights
4676
-	*
4677
-	*/
4673
+	 * Count flights by owner
4674
+	 *
4675
+	 * @return String Duration of all flights
4676
+	 *
4677
+	 */
4678 4678
 	public function countFlightsByOwner($owner,$filters = array())
4679 4679
 	{
4680 4680
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4690,11 +4690,11 @@  discard block
 block discarded – undo
4690 4690
 	}
4691 4691
 
4692 4692
 	/**
4693
-	* Count flights by pilot
4694
-	*
4695
-	* @return String Duration of all flights
4696
-	*
4697
-	*/
4693
+	 * Count flights by pilot
4694
+	 *
4695
+	 * @return String Duration of all flights
4696
+	 *
4697
+	 */
4698 4698
 	public function countFlightsByPilot($pilot,$filters = array())
4699 4699
 	{
4700 4700
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4710,11 +4710,11 @@  discard block
 block discarded – undo
4710 4710
 	}
4711 4711
 
4712 4712
 	/**
4713
-	* Gets flight duration by pilot
4714
-	*
4715
-	* @return String Duration of all flights
4716
-	*
4717
-	*/
4713
+	 * Gets flight duration by pilot
4714
+	 *
4715
+	 * @return String Duration of all flights
4716
+	 *
4717
+	 */
4718 4718
 	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4719 4719
 	{
4720 4720
 		global $globalDBdriver;
@@ -4759,11 +4759,11 @@  discard block
 block discarded – undo
4759 4759
 	}
4760 4760
 
4761 4761
 	/**
4762
-	* Gets all airlines used by pilot
4763
-	*
4764
-	* @return Array the airline list
4765
-	*
4766
-	*/
4762
+	 * Gets all airlines used by pilot
4763
+	 *
4764
+	 * @return Array the airline list
4765
+	 *
4766
+	 */
4767 4767
 	public function countAllAirlinesByPilot($pilot,$filters = array())
4768 4768
 	{
4769 4769
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4780,11 +4780,11 @@  discard block
 block discarded – undo
4780 4780
 	}
4781 4781
 
4782 4782
 	/**
4783
-	* Gets all airlines that have flown over by route
4784
-	*
4785
-	* @return Array the airline list
4786
-	*
4787
-	*/
4783
+	 * Gets all airlines that have flown over by route
4784
+	 *
4785
+	 * @return Array the airline list
4786
+	 *
4787
+	 */
4788 4788
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4789 4789
 	{
4790 4790
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4816,11 +4816,11 @@  discard block
 block discarded – undo
4816 4816
 	}
4817 4817
 
4818 4818
 	/**
4819
-	* Gets all airline countries that have flown over by route
4820
-	*
4821
-	* @return Array the airline country list
4822
-	*
4823
-	*/
4819
+	 * Gets all airline countries that have flown over by route
4820
+	 *
4821
+	 * @return Array the airline country list
4822
+	 *
4823
+	 */
4824 4824
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4825 4825
 	{
4826 4826
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4852,11 +4852,11 @@  discard block
 block discarded – undo
4852 4852
 
4853 4853
 
4854 4854
 	/**
4855
-	* Gets all airlines that have flown over by country
4856
-	*
4857
-	* @return Array the airline list
4858
-	*
4859
-	*/
4855
+	 * Gets all airlines that have flown over by country
4856
+	 *
4857
+	 * @return Array the airline list
4858
+	 *
4859
+	 */
4860 4860
 	public function countAllAirlinesByCountry($country,$filters = array())
4861 4861
 	{
4862 4862
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4886,11 +4886,11 @@  discard block
 block discarded – undo
4886 4886
 
4887 4887
 
4888 4888
 	/**
4889
-	* Gets all airline countries that have flown over by country
4890
-	*
4891
-	* @return Array the airline country list
4892
-	*
4893
-	*/
4889
+	 * Gets all airline countries that have flown over by country
4890
+	 *
4891
+	 * @return Array the airline country list
4892
+	 *
4893
+	 */
4894 4894
 	public function countAllAirlineCountriesByCountry($country,$filters = array())
4895 4895
 	{
4896 4896
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4919,11 +4919,11 @@  discard block
 block discarded – undo
4919 4919
 
4920 4920
 
4921 4921
 	/**
4922
-	* Gets all airlines countries
4923
-	*
4924
-	* @return Array the airline country list
4925
-	*
4926
-	*/
4922
+	 * Gets all airlines countries
4923
+	 *
4924
+	 * @return Array the airline country list
4925
+	 *
4926
+	 */
4927 4927
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4928 4928
 	{
4929 4929
 		global $globalDBdriver;
@@ -4978,11 +4978,11 @@  discard block
 block discarded – undo
4978 4978
 	}
4979 4979
 
4980 4980
 	/**
4981
-	* Gets all number of flight over countries
4982
-	*
4983
-	* @return Array the airline country list
4984
-	*
4985
-	*/
4981
+	 * Gets all number of flight over countries
4982
+	 *
4983
+	 * @return Array the airline country list
4984
+	 *
4985
+	 */
4986 4986
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
4987 4987
 	{
4988 4988
 		global $globalDBdriver;
@@ -5004,15 +5004,15 @@  discard block
 block discarded – undo
5004 5004
 		$SpotterLive = new SpotterLive();
5005 5005
 		$filter_query = $SpotterLive->getFilter($filters,true,true);
5006 5006
 		$filter_query .= ' over_country IS NOT NULL';
5007
-                if ($olderthanmonths > 0) {
5007
+				if ($olderthanmonths > 0) {
5008 5008
 			if ($globalDBdriver == 'mysql') {
5009 5009
 				$filter_query .= ' AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5010 5010
 			} else {
5011 5011
 				$filter_query .= " AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
5012 5012
 			}
5013 5013
 		}
5014
-                if ($sincedate != '') {
5015
-            		if ($globalDBdriver == 'mysql') {
5014
+				if ($sincedate != '') {
5015
+					if ($globalDBdriver == 'mysql') {
5016 5016
 				$filter_query .= " AND spotter_live.date > '".$sincedate."' ";
5017 5017
 			} else {
5018 5018
 				$filter_query .= " AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -5042,11 +5042,11 @@  discard block
 block discarded – undo
5042 5042
 	
5043 5043
 	
5044 5044
 	/**
5045
-	* Gets all aircraft types that have flown over
5046
-	*
5047
-	* @return Array the aircraft list
5048
-	*
5049
-	*/
5045
+	 * Gets all aircraft types that have flown over
5046
+	 *
5047
+	 * @return Array the aircraft list
5048
+	 *
5049
+	 */
5050 5050
 	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5051 5051
 	{
5052 5052
 		global $globalDBdriver;
@@ -5116,11 +5116,11 @@  discard block
 block discarded – undo
5116 5116
 	}
5117 5117
 
5118 5118
 	/**
5119
-	* Gets all aircraft types that have flown over by airline
5120
-	*
5121
-	* @return Array the aircraft list
5122
-	*
5123
-	*/
5119
+	 * Gets all aircraft types that have flown over by airline
5120
+	 *
5121
+	 * @return Array the aircraft list
5122
+	 *
5123
+	 */
5124 5124
 	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5125 5125
 	{
5126 5126
 		global $globalDBdriver;
@@ -5191,11 +5191,11 @@  discard block
 block discarded – undo
5191 5191
 	}
5192 5192
 
5193 5193
 	/**
5194
-	* Gets all aircraft types that have flown over by months
5195
-	*
5196
-	* @return Array the aircraft list
5197
-	*
5198
-	*/
5194
+	 * Gets all aircraft types that have flown over by months
5195
+	 *
5196
+	 * @return Array the aircraft list
5197
+	 *
5198
+	 */
5199 5199
 	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5200 5200
 	{
5201 5201
 		global $globalDBdriver;
@@ -5239,11 +5239,11 @@  discard block
 block discarded – undo
5239 5239
 
5240 5240
 
5241 5241
 	/**
5242
-	* Gets all aircraft registration that have flown over by aircaft icao
5243
-	*
5244
-	* @return Array the aircraft list
5245
-	*
5246
-	*/
5242
+	 * Gets all aircraft registration that have flown over by aircaft icao
5243
+	 *
5244
+	 * @return Array the aircraft list
5245
+	 *
5246
+	 */
5247 5247
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5248 5248
 	{
5249 5249
 		$Image = new Image($this->db);
@@ -5282,11 +5282,11 @@  discard block
 block discarded – undo
5282 5282
 
5283 5283
 
5284 5284
 	/**
5285
-	* Gets all aircraft types that have flown over by airline icao
5286
-	*
5287
-	* @return Array the aircraft list
5288
-	*
5289
-	*/
5285
+	 * Gets all aircraft types that have flown over by airline icao
5286
+	 *
5287
+	 * @return Array the aircraft list
5288
+	 *
5289
+	 */
5290 5290
 	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5291 5291
 	{
5292 5292
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5315,11 +5315,11 @@  discard block
 block discarded – undo
5315 5315
 
5316 5316
 
5317 5317
 	/**
5318
-	* Gets all aircraft registration that have flown over by airline icao
5319
-	*
5320
-	* @return Array the aircraft list
5321
-	*
5322
-	*/
5318
+	 * Gets all aircraft registration that have flown over by airline icao
5319
+	 *
5320
+	 * @return Array the aircraft list
5321
+	 *
5322
+	 */
5323 5323
 	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5324 5324
 	{
5325 5325
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5357,11 +5357,11 @@  discard block
 block discarded – undo
5357 5357
 
5358 5358
 
5359 5359
 	/**
5360
-	* Gets all aircraft manufacturer that have flown over by airline icao
5361
-	*
5362
-	* @return Array the aircraft list
5363
-	*
5364
-	*/
5360
+	 * Gets all aircraft manufacturer that have flown over by airline icao
5361
+	 *
5362
+	 * @return Array the aircraft list
5363
+	 *
5364
+	 */
5365 5365
 	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5366 5366
 	{
5367 5367
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5389,11 +5389,11 @@  discard block
 block discarded – undo
5389 5389
 
5390 5390
 
5391 5391
 	/**
5392
-	* Gets all aircraft types that have flown over by airline icao
5393
-	*
5394
-	* @return Array the aircraft list
5395
-	*
5396
-	*/
5392
+	 * Gets all aircraft types that have flown over by airline icao
5393
+	 *
5394
+	 * @return Array the aircraft list
5395
+	 *
5396
+	 */
5397 5397
 	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5398 5398
 	{
5399 5399
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5422,11 +5422,11 @@  discard block
 block discarded – undo
5422 5422
 
5423 5423
 
5424 5424
 	/**
5425
-	* Gets all aircraft registration that have flown over by airport icao
5426
-	*
5427
-	* @return Array the aircraft list
5428
-	*
5429
-	*/
5425
+	 * Gets all aircraft registration that have flown over by airport icao
5426
+	 *
5427
+	 * @return Array the aircraft list
5428
+	 *
5429
+	 */
5430 5430
 	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5431 5431
 	{
5432 5432
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5463,11 +5463,11 @@  discard block
 block discarded – undo
5463 5463
 	
5464 5464
 	
5465 5465
 	/**
5466
-	* Gets all aircraft manufacturer that have flown over by airport icao
5467
-	*
5468
-	* @return Array the aircraft list
5469
-	*
5470
-	*/
5466
+	 * Gets all aircraft manufacturer that have flown over by airport icao
5467
+	 *
5468
+	 * @return Array the aircraft list
5469
+	 *
5470
+	 */
5471 5471
 	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5472 5472
 	{
5473 5473
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5493,11 +5493,11 @@  discard block
 block discarded – undo
5493 5493
 	}
5494 5494
 
5495 5495
 	/**
5496
-	* Gets all aircraft types that have flown over by aircraft manufacturer
5497
-	*
5498
-	* @return Array the aircraft list
5499
-	*
5500
-	*/
5496
+	 * Gets all aircraft types that have flown over by aircraft manufacturer
5497
+	 *
5498
+	 * @return Array the aircraft list
5499
+	 *
5500
+	 */
5501 5501
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5502 5502
 	{
5503 5503
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5524,11 +5524,11 @@  discard block
 block discarded – undo
5524 5524
 
5525 5525
 
5526 5526
 	/**
5527
-	* Gets all aircraft registration that have flown over by aircaft manufacturer
5528
-	*
5529
-	* @return Array the aircraft list
5530
-	*
5531
-	*/
5527
+	 * Gets all aircraft registration that have flown over by aircaft manufacturer
5528
+	 *
5529
+	 * @return Array the aircraft list
5530
+	 *
5531
+	 */
5532 5532
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5533 5533
 	{
5534 5534
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5564,11 +5564,11 @@  discard block
 block discarded – undo
5564 5564
 	}
5565 5565
 
5566 5566
 	/**
5567
-	* Gets all aircraft types that have flown over by date
5568
-	*
5569
-	* @return Array the aircraft list
5570
-	*
5571
-	*/
5567
+	 * Gets all aircraft types that have flown over by date
5568
+	 *
5569
+	 * @return Array the aircraft list
5570
+	 *
5571
+	 */
5572 5572
 	public function countAllAircraftTypesByDate($date,$filters = array())
5573 5573
 	{
5574 5574
 		global $globalTimezone, $globalDBdriver;
@@ -5610,11 +5610,11 @@  discard block
 block discarded – undo
5610 5610
 
5611 5611
 
5612 5612
 	/**
5613
-	* Gets all aircraft registration that have flown over by date
5614
-	*
5615
-	* @return Array the aircraft list
5616
-	*
5617
-	*/
5613
+	 * Gets all aircraft registration that have flown over by date
5614
+	 *
5615
+	 * @return Array the aircraft list
5616
+	 *
5617
+	 */
5618 5618
 	public function countAllAircraftRegistrationByDate($date,$filters = array())
5619 5619
 	{
5620 5620
 		global $globalTimezone, $globalDBdriver;
@@ -5665,11 +5665,11 @@  discard block
 block discarded – undo
5665 5665
 
5666 5666
 
5667 5667
 	/**
5668
-	* Gets all aircraft manufacturer that have flown over by date
5669
-	*
5670
-	* @return Array the aircraft manufacturer list
5671
-	*
5672
-	*/
5668
+	 * Gets all aircraft manufacturer that have flown over by date
5669
+	 *
5670
+	 * @return Array the aircraft manufacturer list
5671
+	 *
5672
+	 */
5673 5673
 	public function countAllAircraftManufacturerByDate($date,$filters = array())
5674 5674
 	{
5675 5675
 		global $globalTimezone, $globalDBdriver;
@@ -5711,11 +5711,11 @@  discard block
 block discarded – undo
5711 5711
 
5712 5712
 
5713 5713
 	/**
5714
-	* Gets all aircraft types that have flown over by ident/callsign
5715
-	*
5716
-	* @return Array the aircraft list
5717
-	*
5718
-	*/
5714
+	 * Gets all aircraft types that have flown over by ident/callsign
5715
+	 *
5716
+	 * @return Array the aircraft list
5717
+	 *
5718
+	 */
5719 5719
 	public function countAllAircraftTypesByIdent($ident,$filters = array())
5720 5720
 	{
5721 5721
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5743,11 +5743,11 @@  discard block
 block discarded – undo
5743 5743
 	}
5744 5744
 
5745 5745
 	/**
5746
-	* Gets all aircraft types that have flown over by pilot
5747
-	*
5748
-	* @return Array the aircraft list
5749
-	*
5750
-	*/
5746
+	 * Gets all aircraft types that have flown over by pilot
5747
+	 *
5748
+	 * @return Array the aircraft list
5749
+	 *
5750
+	 */
5751 5751
 	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5752 5752
 	{
5753 5753
 		global $globalDBdriver;
@@ -5793,11 +5793,11 @@  discard block
 block discarded – undo
5793 5793
 	}
5794 5794
 
5795 5795
 	/**
5796
-	* Gets all aircraft types that have flown over by owner
5797
-	*
5798
-	* @return Array the aircraft list
5799
-	*
5800
-	*/
5796
+	 * Gets all aircraft types that have flown over by owner
5797
+	 *
5798
+	 * @return Array the aircraft list
5799
+	 *
5800
+	 */
5801 5801
 	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5802 5802
 	{
5803 5803
 		global $globalDBdriver;
@@ -5842,11 +5842,11 @@  discard block
 block discarded – undo
5842 5842
 	}
5843 5843
 
5844 5844
 	/**
5845
-	* Gets all aircraft registration that have flown over by ident/callsign
5846
-	*
5847
-	* @return Array the aircraft list
5848
-	*
5849
-	*/
5845
+	 * Gets all aircraft registration that have flown over by ident/callsign
5846
+	 *
5847
+	 * @return Array the aircraft list
5848
+	 *
5849
+	 */
5850 5850
 	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5851 5851
 	{
5852 5852
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5885,11 +5885,11 @@  discard block
 block discarded – undo
5885 5885
 	}
5886 5886
 
5887 5887
 	/**
5888
-	* Gets all aircraft registration that have flown over by owner
5889
-	*
5890
-	* @return Array the aircraft list
5891
-	*
5892
-	*/
5888
+	 * Gets all aircraft registration that have flown over by owner
5889
+	 *
5890
+	 * @return Array the aircraft list
5891
+	 *
5892
+	 */
5893 5893
 	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5894 5894
 	{
5895 5895
 		global $globalDBdriver;
@@ -5960,11 +5960,11 @@  discard block
 block discarded – undo
5960 5960
 	}
5961 5961
 
5962 5962
 	/**
5963
-	* Gets all aircraft registration that have flown over by pilot
5964
-	*
5965
-	* @return Array the aircraft list
5966
-	*
5967
-	*/
5963
+	 * Gets all aircraft registration that have flown over by pilot
5964
+	 *
5965
+	 * @return Array the aircraft list
5966
+	 *
5967
+	 */
5968 5968
 	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5969 5969
 	{
5970 5970
 		global $globalDBdriver;
@@ -6036,11 +6036,11 @@  discard block
 block discarded – undo
6036 6036
 
6037 6037
 
6038 6038
 	/**
6039
-	* Gets all aircraft manufacturer that have flown over by ident/callsign
6040
-	*
6041
-	* @return Array the aircraft manufacturer list
6042
-	*
6043
-	*/
6039
+	 * Gets all aircraft manufacturer that have flown over by ident/callsign
6040
+	 *
6041
+	 * @return Array the aircraft manufacturer list
6042
+	 *
6043
+	 */
6044 6044
 	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6045 6045
 	{
6046 6046
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6065,11 +6065,11 @@  discard block
 block discarded – undo
6065 6065
 	}
6066 6066
 
6067 6067
 	/**
6068
-	* Gets all aircraft manufacturer that have flown over by owner
6069
-	*
6070
-	* @return Array the aircraft manufacturer list
6071
-	*
6072
-	*/
6068
+	 * Gets all aircraft manufacturer that have flown over by owner
6069
+	 *
6070
+	 * @return Array the aircraft manufacturer list
6071
+	 *
6072
+	 */
6073 6073
 	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6074 6074
 	{
6075 6075
 		global $globalDBdriver;
@@ -6117,11 +6117,11 @@  discard block
 block discarded – undo
6117 6117
 	}
6118 6118
 
6119 6119
 	/**
6120
-	* Gets all aircraft manufacturer that have flown over by pilot
6121
-	*
6122
-	* @return Array the aircraft manufacturer list
6123
-	*
6124
-	*/
6120
+	 * Gets all aircraft manufacturer that have flown over by pilot
6121
+	 *
6122
+	 * @return Array the aircraft manufacturer list
6123
+	 *
6124
+	 */
6125 6125
 	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6126 6126
 	{
6127 6127
 		global $globalDBdriver;
@@ -6170,11 +6170,11 @@  discard block
 block discarded – undo
6170 6170
 
6171 6171
 
6172 6172
 	/**
6173
-	* Gets all aircraft types that have flown over by route
6174
-	*
6175
-	* @return Array the aircraft list
6176
-	*
6177
-	*/
6173
+	 * Gets all aircraft types that have flown over by route
6174
+	 *
6175
+	 * @return Array the aircraft list
6176
+	 *
6177
+	 */
6178 6178
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6179 6179
 	{
6180 6180
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6203,11 +6203,11 @@  discard block
 block discarded – undo
6203 6203
 	}
6204 6204
 
6205 6205
 	/**
6206
-	* Gets all aircraft registration that have flown over by route
6207
-	*
6208
-	* @return Array the aircraft list
6209
-	*
6210
-	*/
6206
+	 * Gets all aircraft registration that have flown over by route
6207
+	 *
6208
+	 * @return Array the aircraft list
6209
+	 *
6210
+	 */
6211 6211
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6212 6212
 	{
6213 6213
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6249,11 +6249,11 @@  discard block
 block discarded – undo
6249 6249
 	
6250 6250
 	
6251 6251
 	/**
6252
-	* Gets all aircraft manufacturer that have flown over by route
6253
-	*
6254
-	* @return Array the aircraft manufacturer list
6255
-	*
6256
-	*/
6252
+	 * Gets all aircraft manufacturer that have flown over by route
6253
+	 *
6254
+	 * @return Array the aircraft manufacturer list
6255
+	 *
6256
+	 */
6257 6257
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6258 6258
 	{
6259 6259
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6287,11 +6287,11 @@  discard block
 block discarded – undo
6287 6287
 	
6288 6288
 	
6289 6289
 	/**
6290
-	* Gets all aircraft types that have flown over by country
6291
-	*
6292
-	* @return Array the aircraft list
6293
-	*
6294
-	*/
6290
+	 * Gets all aircraft types that have flown over by country
6291
+	 *
6292
+	 * @return Array the aircraft list
6293
+	 *
6294
+	 */
6295 6295
 	public function countAllAircraftTypesByCountry($country,$filters = array())
6296 6296
 	{
6297 6297
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6322,11 +6322,11 @@  discard block
 block discarded – undo
6322 6322
 
6323 6323
 
6324 6324
 	/**
6325
-	* Gets all aircraft registration that have flown over by country
6326
-	*
6327
-	* @return Array the aircraft list
6328
-	*
6329
-	*/
6325
+	 * Gets all aircraft registration that have flown over by country
6326
+	 *
6327
+	 * @return Array the aircraft list
6328
+	 *
6329
+	 */
6330 6330
 	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6331 6331
 	{
6332 6332
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6366,11 +6366,11 @@  discard block
 block discarded – undo
6366 6366
 	
6367 6367
 	
6368 6368
 	/**
6369
-	* Gets all aircraft manufacturer that have flown over by country
6370
-	*
6371
-	* @return Array the aircraft manufacturer list
6372
-	*
6373
-	*/
6369
+	 * Gets all aircraft manufacturer that have flown over by country
6370
+	 *
6371
+	 * @return Array the aircraft manufacturer list
6372
+	 *
6373
+	 */
6374 6374
 	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6375 6375
 	{
6376 6376
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6401,18 +6401,18 @@  discard block
 block discarded – undo
6401 6401
 	
6402 6402
 	
6403 6403
 	/**
6404
-	* Gets all aircraft manufacturers that have flown over
6405
-	*
6406
-	* @return Array the aircraft list
6407
-	*
6408
-	*/
6404
+	 * Gets all aircraft manufacturers that have flown over
6405
+	 *
6406
+	 * @return Array the aircraft list
6407
+	 *
6408
+	 */
6409 6409
 	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6410 6410
 	{
6411 6411
 		global $globalDBdriver;
6412 6412
 		$filter_query = $this->getFilter($filters,true,true);
6413 6413
 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6414 6414
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6415
-                $query_values = array();
6415
+				$query_values = array();
6416 6416
 		if ($year != '') {
6417 6417
 			if ($globalDBdriver == 'mysql') {
6418 6418
 				$query .= " AND YEAR(spotter_output.date) = :year";
@@ -6465,11 +6465,11 @@  discard block
 block discarded – undo
6465 6465
 	
6466 6466
 	
6467 6467
 	/**
6468
-	* Gets all aircraft registrations that have flown over
6469
-	*
6470
-	* @return Array the aircraft list
6471
-	*
6472
-	*/
6468
+	 * Gets all aircraft registrations that have flown over
6469
+	 *
6470
+	 * @return Array the aircraft list
6471
+	 *
6472
+	 */
6473 6473
 	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6474 6474
 	{
6475 6475
 		global $globalDBdriver;
@@ -6477,15 +6477,15 @@  discard block
 block discarded – undo
6477 6477
 		$filter_query = $this->getFilter($filters,true,true);
6478 6478
 		$query  = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
6479 6479
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6480
-                if ($olderthanmonths > 0) {
6481
-            		if ($globalDBdriver == 'mysql') {
6480
+				if ($olderthanmonths > 0) {
6481
+					if ($globalDBdriver == 'mysql') {
6482 6482
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6483 6483
 			} else {
6484 6484
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6485 6485
 			}
6486 6486
 		}
6487
-                if ($sincedate != '') {
6488
-            		if ($globalDBdriver == 'mysql') {
6487
+				if ($sincedate != '') {
6488
+					if ($globalDBdriver == 'mysql') {
6489 6489
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6490 6490
 			} else {
6491 6491
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6550,11 +6550,11 @@  discard block
 block discarded – undo
6550 6550
 
6551 6551
 
6552 6552
 	/**
6553
-	* Gets all aircraft registrations that have flown over
6554
-	*
6555
-	* @return Array the aircraft list
6556
-	*
6557
-	*/
6553
+	 * Gets all aircraft registrations that have flown over
6554
+	 *
6555
+	 * @return Array the aircraft list
6556
+	 *
6557
+	 */
6558 6558
 	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6559 6559
 	{
6560 6560
 		global $globalDBdriver;
@@ -6562,15 +6562,15 @@  discard block
 block discarded – undo
6562 6562
 		$Image = new Image($this->db);
6563 6563
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
6564 6564
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6565
-                if ($olderthanmonths > 0) {
6566
-            		if ($globalDBdriver == 'mysql') {
6565
+				if ($olderthanmonths > 0) {
6566
+					if ($globalDBdriver == 'mysql') {
6567 6567
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6568 6568
 			} else {
6569 6569
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6570 6570
 			}
6571 6571
 		}
6572
-                if ($sincedate != '') {
6573
-            		if ($globalDBdriver == 'mysql') {
6572
+				if ($sincedate != '') {
6573
+					if ($globalDBdriver == 'mysql') {
6574 6574
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6575 6575
 			} else {
6576 6576
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6579,7 +6579,7 @@  discard block
 block discarded – undo
6579 6579
 
6580 6580
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6581 6581
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6582
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6582
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6583 6583
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6584 6584
 		
6585 6585
 		$sth = $this->db->prepare($query);
@@ -6611,26 +6611,26 @@  discard block
 block discarded – undo
6611 6611
 	
6612 6612
 	
6613 6613
 	/**
6614
-	* Gets all departure airports of the airplanes that have flown over
6615
-	*
6616
-	* @return Array the airport list
6617
-	*
6618
-	*/
6614
+	 * Gets all departure airports of the airplanes that have flown over
6615
+	 *
6616
+	 * @return Array the airport list
6617
+	 *
6618
+	 */
6619 6619
 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6620 6620
 	{
6621 6621
 		global $globalDBdriver;
6622 6622
 		$filter_query = $this->getFilter($filters,true,true);
6623 6623
 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6624 6624
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6625
-                if ($olderthanmonths > 0) {
6626
-            		if ($globalDBdriver == 'mysql') {
6625
+				if ($olderthanmonths > 0) {
6626
+					if ($globalDBdriver == 'mysql') {
6627 6627
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6628 6628
 			} else {
6629 6629
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6630 6630
 			}
6631
-                }
6632
-                if ($sincedate != '') {
6633
-            		if ($globalDBdriver == 'mysql') {
6631
+				}
6632
+				if ($sincedate != '') {
6633
+					if ($globalDBdriver == 'mysql') {
6634 6634
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6635 6635
 			} else {
6636 6636
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6664,7 +6664,7 @@  discard block
 block discarded – undo
6664 6664
 				$query_values = array_merge($query_values,array(':day' => $day));
6665 6665
 			}
6666 6666
 		}
6667
-                $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6667
+				$query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6668 6668
 				ORDER BY airport_departure_icao_count DESC";
6669 6669
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6670 6670
 
@@ -6687,35 +6687,35 @@  discard block
 block discarded – undo
6687 6687
 	}
6688 6688
 
6689 6689
 	/**
6690
-	* Gets all departure airports of the airplanes that have flown over
6691
-	*
6692
-	* @return Array the airport list
6693
-	*
6694
-	*/
6690
+	 * Gets all departure airports of the airplanes that have flown over
6691
+	 *
6692
+	 * @return Array the airport list
6693
+	 *
6694
+	 */
6695 6695
 	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6696 6696
 	{
6697 6697
 		global $globalDBdriver;
6698 6698
 		$filter_query = $this->getFilter($filters,true,true);
6699 6699
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6700 6700
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' ";
6701
-                if ($olderthanmonths > 0) {
6702
-            		if ($globalDBdriver == 'mysql') {
6701
+				if ($olderthanmonths > 0) {
6702
+					if ($globalDBdriver == 'mysql') {
6703 6703
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6704 6704
 			} else {
6705 6705
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6706 6706
 			}
6707
-                }
6708
-                if ($sincedate != '') {
6709
-            		if ($globalDBdriver == 'mysql') {
6707
+				}
6708
+				if ($sincedate != '') {
6709
+					if ($globalDBdriver == 'mysql') {
6710 6710
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6711 6711
 			} else {
6712 6712
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6713 6713
 			}
6714 6714
 		}
6715 6715
 
6716
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6717
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6718
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6716
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6717
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6718
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6719 6719
 				ORDER BY airport_departure_icao_count DESC";
6720 6720
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6721 6721
       
@@ -6740,26 +6740,26 @@  discard block
 block discarded – undo
6740 6740
 	}
6741 6741
 
6742 6742
 	/**
6743
-	* Gets all detected departure airports of the airplanes that have flown over
6744
-	*
6745
-	* @return Array the airport list
6746
-	*
6747
-	*/
6743
+	 * Gets all detected departure airports of the airplanes that have flown over
6744
+	 *
6745
+	 * @return Array the airport list
6746
+	 *
6747
+	 */
6748 6748
 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6749 6749
 	{
6750 6750
 		global $globalDBdriver;
6751 6751
 		$filter_query = $this->getFilter($filters,true,true);
6752 6752
 		$query  = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
6753 6753
 				FROM airport, spotter_output".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao";
6754
-                if ($olderthanmonths > 0) {
6755
-            		if ($globalDBdriver == 'mysql') {
6754
+				if ($olderthanmonths > 0) {
6755
+					if ($globalDBdriver == 'mysql') {
6756 6756
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6757 6757
 			} else {
6758 6758
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6759 6759
 			}
6760
-                }
6761
-                if ($sincedate != '') {
6762
-            		if ($globalDBdriver == 'mysql') {
6760
+				}
6761
+				if ($sincedate != '') {
6762
+					if ($globalDBdriver == 'mysql') {
6763 6763
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6764 6764
 			} else {
6765 6765
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6793,10 +6793,10 @@  discard block
 block discarded – undo
6793 6793
 				$query_values = array_merge($query_values,array(':day' => $day));
6794 6794
 			}
6795 6795
 		}
6796
-                $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6796
+				$query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6797 6797
 				ORDER BY airport_departure_icao_count DESC";
6798 6798
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6799
-    		//echo $query;
6799
+			//echo $query;
6800 6800
 		$sth = $this->db->prepare($query);
6801 6801
 		$sth->execute($query_values);
6802 6802
       
@@ -6817,35 +6817,35 @@  discard block
 block discarded – undo
6817 6817
 	}
6818 6818
 	
6819 6819
 	/**
6820
-	* Gets all detected departure airports of the airplanes that have flown over
6821
-	*
6822
-	* @return Array the airport list
6823
-	*
6824
-	*/
6820
+	 * Gets all detected departure airports of the airplanes that have flown over
6821
+	 *
6822
+	 * @return Array the airport list
6823
+	 *
6824
+	 */
6825 6825
 	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6826 6826
 	{
6827 6827
 		global $globalDBdriver;
6828 6828
 		$filter_query = $this->getFilter($filters,true,true);
6829 6829
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
6830 6830
 				FROM airport, spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao ";
6831
-                if ($olderthanmonths > 0) {
6832
-            		if ($globalDBdriver == 'mysql') {
6831
+				if ($olderthanmonths > 0) {
6832
+					if ($globalDBdriver == 'mysql') {
6833 6833
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6834 6834
 			} else {
6835 6835
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6836 6836
 			}
6837
-                }
6838
-                if ($sincedate != '') {
6839
-            		if ($globalDBdriver == 'mysql') {
6837
+				}
6838
+				if ($sincedate != '') {
6839
+					if ($globalDBdriver == 'mysql') {
6840 6840
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6841 6841
 			} else {
6842 6842
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
6843 6843
 			}
6844 6844
 		}
6845 6845
 
6846
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6847
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6848
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6846
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6847
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6848
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6849 6849
 				ORDER BY airport_departure_icao_count DESC";
6850 6850
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6851 6851
       
@@ -6870,11 +6870,11 @@  discard block
 block discarded – undo
6870 6870
 	}	
6871 6871
 	
6872 6872
 	/**
6873
-	* Gets all departure airports of the airplanes that have flown over based on an airline icao
6874
-	*
6875
-	* @return Array the airport list
6876
-	*
6877
-	*/
6873
+	 * Gets all departure airports of the airplanes that have flown over based on an airline icao
6874
+	 *
6875
+	 * @return Array the airport list
6876
+	 *
6877
+	 */
6878 6878
 	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6879 6879
 	{
6880 6880
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6908,11 +6908,11 @@  discard block
 block discarded – undo
6908 6908
 	
6909 6909
 	
6910 6910
 	/**
6911
-	* Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6912
-	*
6913
-	* @return Array the airport list
6914
-	*
6915
-	*/
6911
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6912
+	 *
6913
+	 * @return Array the airport list
6914
+	 *
6915
+	 */
6916 6916
 	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6917 6917
 	{
6918 6918
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6943,11 +6943,11 @@  discard block
 block discarded – undo
6943 6943
 	
6944 6944
 	
6945 6945
 	/**
6946
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6947
-	*
6948
-	* @return Array the airport list
6949
-	*
6950
-	*/
6946
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6947
+	 *
6948
+	 * @return Array the airport list
6949
+	 *
6950
+	 */
6951 6951
 	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6952 6952
 	{
6953 6953
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6980,11 +6980,11 @@  discard block
 block discarded – undo
6980 6980
 	
6981 6981
 	
6982 6982
 	/**
6983
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
6984
-	*
6985
-	* @return Array the airport list
6986
-	*
6987
-	*/
6983
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
6984
+	 *
6985
+	 * @return Array the airport list
6986
+	 *
6987
+	 */
6988 6988
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
6989 6989
 	{
6990 6990
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7014,11 +7014,11 @@  discard block
 block discarded – undo
7014 7014
 	
7015 7015
 	
7016 7016
 	/**
7017
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7018
-	*
7019
-	* @return Array the airport list
7020
-	*
7021
-	*/
7017
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7018
+	 *
7019
+	 * @return Array the airport list
7020
+	 *
7021
+	 */
7022 7022
 	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7023 7023
 	{
7024 7024
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7051,11 +7051,11 @@  discard block
 block discarded – undo
7051 7051
 	
7052 7052
 	
7053 7053
 	/**
7054
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7055
-	*
7056
-	* @return Array the airport list
7057
-	*
7058
-	*/
7054
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7055
+	 *
7056
+	 * @return Array the airport list
7057
+	 *
7058
+	 */
7059 7059
 	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7060 7060
 	{
7061 7061
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7085,11 +7085,11 @@  discard block
 block discarded – undo
7085 7085
 	
7086 7086
 	
7087 7087
 	/**
7088
-	* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7089
-	*
7090
-	* @return Array the airport list
7091
-	*
7092
-	*/
7088
+	 * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7089
+	 *
7090
+	 * @return Array the airport list
7091
+	 *
7092
+	 */
7093 7093
 	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7094 7094
 	{
7095 7095
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7122,11 +7122,11 @@  discard block
 block discarded – undo
7122 7122
 	
7123 7123
 	
7124 7124
 	/**
7125
-	* Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7126
-	*
7127
-	* @return Array the airport list
7128
-	*
7129
-	*/
7125
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7126
+	 *
7127
+	 * @return Array the airport list
7128
+	 *
7129
+	 */
7130 7130
 	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7131 7131
 	{
7132 7132
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7157,11 +7157,11 @@  discard block
 block discarded – undo
7157 7157
 	
7158 7158
 	
7159 7159
 	/**
7160
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7161
-	*
7162
-	* @return Array the airport list
7163
-	*
7164
-	*/
7160
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7161
+	 *
7162
+	 * @return Array the airport list
7163
+	 *
7164
+	 */
7165 7165
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7166 7166
 	{
7167 7167
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7194,11 +7194,11 @@  discard block
 block discarded – undo
7194 7194
 	
7195 7195
 	
7196 7196
 	/**
7197
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7198
-	*
7199
-	* @return Array the airport list
7200
-	*
7201
-	*/
7197
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7198
+	 *
7199
+	 * @return Array the airport list
7200
+	 *
7201
+	 */
7202 7202
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7203 7203
 	{
7204 7204
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7228,11 +7228,11 @@  discard block
 block discarded – undo
7228 7228
 	
7229 7229
 	
7230 7230
 	/**
7231
-	* Gets all departure airports of the airplanes that have flown over based on a date
7232
-	*
7233
-	* @return Array the airport list
7234
-	*
7235
-	*/
7231
+	 * Gets all departure airports of the airplanes that have flown over based on a date
7232
+	 *
7233
+	 * @return Array the airport list
7234
+	 *
7235
+	 */
7236 7236
 	public function countAllDepartureAirportsByDate($date,$filters = array())
7237 7237
 	{
7238 7238
 		global $globalTimezone, $globalDBdriver;
@@ -7278,11 +7278,11 @@  discard block
 block discarded – undo
7278 7278
 	
7279 7279
 	
7280 7280
 	/**
7281
-	* Gets all departure airports by country of the airplanes that have flown over based on a date
7282
-	*
7283
-	* @return Array the airport list
7284
-	*
7285
-	*/
7281
+	 * Gets all departure airports by country of the airplanes that have flown over based on a date
7282
+	 *
7283
+	 * @return Array the airport list
7284
+	 *
7285
+	 */
7286 7286
 	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7287 7287
 	{
7288 7288
 		global $globalTimezone, $globalDBdriver;
@@ -7325,11 +7325,11 @@  discard block
 block discarded – undo
7325 7325
 	
7326 7326
 	
7327 7327
 	/**
7328
-	* Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7329
-	*
7330
-	* @return Array the airport list
7331
-	*
7332
-	*/
7328
+	 * Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7329
+	 *
7330
+	 * @return Array the airport list
7331
+	 *
7332
+	 */
7333 7333
 	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7334 7334
 	{
7335 7335
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7361,11 +7361,11 @@  discard block
 block discarded – undo
7361 7361
 	}
7362 7362
 	
7363 7363
 	/**
7364
-	* Gets all departure airports of the airplanes that have flown over based on a owner
7365
-	*
7366
-	* @return Array the airport list
7367
-	*
7368
-	*/
7364
+	 * Gets all departure airports of the airplanes that have flown over based on a owner
7365
+	 *
7366
+	 * @return Array the airport list
7367
+	 *
7368
+	 */
7369 7369
 	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7370 7370
 	{
7371 7371
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7397,11 +7397,11 @@  discard block
 block discarded – undo
7397 7397
 	}
7398 7398
 	
7399 7399
 	/**
7400
-	* Gets all departure airports of the airplanes that have flown over based on a pilot
7401
-	*
7402
-	* @return Array the airport list
7403
-	*
7404
-	*/
7400
+	 * Gets all departure airports of the airplanes that have flown over based on a pilot
7401
+	 *
7402
+	 * @return Array the airport list
7403
+	 *
7404
+	 */
7405 7405
 	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7406 7406
 	{
7407 7407
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7434,11 +7434,11 @@  discard block
 block discarded – undo
7434 7434
 	
7435 7435
 	
7436 7436
 	/**
7437
-	* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7438
-	*
7439
-	* @return Array the airport list
7440
-	*
7441
-	*/
7437
+	 * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7438
+	 *
7439
+	 * @return Array the airport list
7440
+	 *
7441
+	 */
7442 7442
 	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7443 7443
 	{
7444 7444
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7467,11 +7467,11 @@  discard block
 block discarded – undo
7467 7467
 	}
7468 7468
 	
7469 7469
 	/**
7470
-	* Gets all departure airports by country of the airplanes that have flown over based on owner
7471
-	*
7472
-	* @return Array the airport list
7473
-	*
7474
-	*/
7470
+	 * Gets all departure airports by country of the airplanes that have flown over based on owner
7471
+	 *
7472
+	 * @return Array the airport list
7473
+	 *
7474
+	 */
7475 7475
 	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7476 7476
 	{
7477 7477
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7487,11 +7487,11 @@  discard block
 block discarded – undo
7487 7487
 	}
7488 7488
 	
7489 7489
 	/**
7490
-	* Gets all departure airports by country of the airplanes that have flown over based on pilot
7491
-	*
7492
-	* @return Array the airport list
7493
-	*
7494
-	*/
7490
+	 * Gets all departure airports by country of the airplanes that have flown over based on pilot
7491
+	 *
7492
+	 * @return Array the airport list
7493
+	 *
7494
+	 */
7495 7495
 	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7496 7496
 	{
7497 7497
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7509,11 +7509,11 @@  discard block
 block discarded – undo
7509 7509
 	
7510 7510
 	
7511 7511
 	/**
7512
-	* Gets all departure airports of the airplanes that have flown over based on a country
7513
-	*
7514
-	* @return Array the airport list
7515
-	*
7516
-	*/
7512
+	 * Gets all departure airports of the airplanes that have flown over based on a country
7513
+	 *
7514
+	 * @return Array the airport list
7515
+	 *
7516
+	 */
7517 7517
 	public function countAllDepartureAirportsByCountry($country,$filters = array())
7518 7518
 	{
7519 7519
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7547,11 +7547,11 @@  discard block
 block discarded – undo
7547 7547
 
7548 7548
 
7549 7549
 	/**
7550
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7551
-	*
7552
-	* @return Array the airport list
7553
-	*
7554
-	*/
7550
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7551
+	 *
7552
+	 * @return Array the airport list
7553
+	 *
7554
+	 */
7555 7555
 	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7556 7556
 	{
7557 7557
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7581,31 +7581,31 @@  discard block
 block discarded – undo
7581 7581
 	
7582 7582
 
7583 7583
 	/**
7584
-	* Gets all arrival airports of the airplanes that have flown over
7585
-	*
7586
-	* @param Boolean $limit Limit result to 10 or not
7587
-	* @param Integer $olderthanmonths Only show result older than x months
7588
-	* @param String $sincedate Only show result since x date
7589
-	* @param Boolean $icaoaskey Show result by ICAO
7590
-	* @param Array $filters Filter used here
7591
-	* @return Array the airport list
7592
-	*
7593
-	*/
7584
+	 * Gets all arrival airports of the airplanes that have flown over
7585
+	 *
7586
+	 * @param Boolean $limit Limit result to 10 or not
7587
+	 * @param Integer $olderthanmonths Only show result older than x months
7588
+	 * @param String $sincedate Only show result since x date
7589
+	 * @param Boolean $icaoaskey Show result by ICAO
7590
+	 * @param Array $filters Filter used here
7591
+	 * @return Array the airport list
7592
+	 *
7593
+	 */
7594 7594
 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7595 7595
 	{
7596 7596
 		global $globalDBdriver;
7597 7597
 		$filter_query = $this->getFilter($filters,true,true);
7598 7598
 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7599 7599
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7600
-                if ($olderthanmonths > 0) {
7601
-            		if ($globalDBdriver == 'mysql') {
7600
+				if ($olderthanmonths > 0) {
7601
+					if ($globalDBdriver == 'mysql') {
7602 7602
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7603 7603
 			} else {
7604 7604
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7605 7605
 			}
7606 7606
 		}
7607
-                if ($sincedate != '') {
7608
-            		if ($globalDBdriver == 'mysql') {
7607
+				if ($sincedate != '') {
7608
+					if ($globalDBdriver == 'mysql') {
7609 7609
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7610 7610
 			} else {
7611 7611
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7639,7 +7639,7 @@  discard block
 block discarded – undo
7639 7639
 				$query_values = array_merge($query_values,array(':day' => $day));
7640 7640
 			}
7641 7641
 		}
7642
-                $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7642
+				$query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7643 7643
 					ORDER BY airport_arrival_icao_count DESC";
7644 7644
 		if ($limit) $query .= " LIMIT 10";
7645 7645
       
@@ -7668,35 +7668,35 @@  discard block
 block discarded – undo
7668 7668
 	}
7669 7669
 
7670 7670
 	/**
7671
-	* Gets all arrival airports of the airplanes that have flown over
7672
-	*
7673
-	* @return Array the airport list
7674
-	*
7675
-	*/
7671
+	 * Gets all arrival airports of the airplanes that have flown over
7672
+	 *
7673
+	 * @return Array the airport list
7674
+	 *
7675
+	 */
7676 7676
 	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7677 7677
 	{
7678 7678
 		global $globalDBdriver;
7679 7679
 		$filter_query = $this->getFilter($filters,true,true);
7680 7680
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7681 7681
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' ";
7682
-                if ($olderthanmonths > 0) {
7683
-            		if ($globalDBdriver == 'mysql') {
7682
+				if ($olderthanmonths > 0) {
7683
+					if ($globalDBdriver == 'mysql') {
7684 7684
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7685 7685
 			} else {
7686 7686
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7687 7687
 			}
7688 7688
 		}
7689
-                if ($sincedate != '') {
7690
-            		if ($globalDBdriver == 'mysql') {
7689
+				if ($sincedate != '') {
7690
+					if ($globalDBdriver == 'mysql') {
7691 7691
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7692 7692
 			} else {
7693 7693
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7694 7694
 			}
7695 7695
 		}
7696 7696
 
7697
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7698
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7699
-                $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7697
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7698
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7699
+				$query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7700 7700
 					ORDER BY airport_arrival_icao_count DESC";
7701 7701
 		if ($limit) $query .= " LIMIT 10";
7702 7702
       
@@ -7727,26 +7727,26 @@  discard block
 block discarded – undo
7727 7727
 
7728 7728
 
7729 7729
 	/**
7730
-	* Gets all detected arrival airports of the airplanes that have flown over
7731
-	*
7732
-	* @return Array the airport list
7733
-	*
7734
-	*/
7730
+	 * Gets all detected arrival airports of the airplanes that have flown over
7731
+	 *
7732
+	 * @return Array the airport list
7733
+	 *
7734
+	 */
7735 7735
 	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7736 7736
 	{
7737 7737
 		global $globalDBdriver;
7738 7738
 		$filter_query = $this->getFilter($filters,true,true);
7739 7739
 		$query  = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
7740 7740
 			FROM airport,spotter_output".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao";
7741
-                if ($olderthanmonths > 0) {
7742
-            		if ($globalDBdriver == 'mysql') {
7741
+				if ($olderthanmonths > 0) {
7742
+					if ($globalDBdriver == 'mysql') {
7743 7743
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7744 7744
 			} else {
7745 7745
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7746 7746
 			}
7747 7747
 		}
7748
-                if ($sincedate != '') {
7749
-            		if ($globalDBdriver == 'mysql') {
7748
+				if ($sincedate != '') {
7749
+					if ($globalDBdriver == 'mysql') {
7750 7750
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7751 7751
 			} else {
7752 7752
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7780,7 +7780,7 @@  discard block
 block discarded – undo
7780 7780
 				$query_values = array_merge($query_values,array(':day' => $day));
7781 7781
 			}
7782 7782
 		}
7783
-                $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7783
+				$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7784 7784
 					ORDER BY airport_arrival_icao_count DESC";
7785 7785
 		if ($limit) $query .= " LIMIT 10";
7786 7786
       
@@ -7808,35 +7808,35 @@  discard block
 block discarded – undo
7808 7808
 	}
7809 7809
 	
7810 7810
 	/**
7811
-	* Gets all detected arrival airports of the airplanes that have flown over
7812
-	*
7813
-	* @return Array the airport list
7814
-	*
7815
-	*/
7811
+	 * Gets all detected arrival airports of the airplanes that have flown over
7812
+	 *
7813
+	 * @return Array the airport list
7814
+	 *
7815
+	 */
7816 7816
 	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7817 7817
 	{
7818 7818
 		global $globalDBdriver;
7819 7819
 		$filter_query = $this->getFilter($filters,true,true);
7820 7820
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
7821 7821
 			FROM airport,spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao ";
7822
-                if ($olderthanmonths > 0) {
7823
-            		if ($globalDBdriver == 'mysql') {
7822
+				if ($olderthanmonths > 0) {
7823
+					if ($globalDBdriver == 'mysql') {
7824 7824
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7825 7825
 			} else {
7826 7826
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7827 7827
 			}
7828 7828
 		}
7829
-                if ($sincedate != '') {
7830
-            		if ($globalDBdriver == 'mysql') {
7829
+				if ($sincedate != '') {
7830
+					if ($globalDBdriver == 'mysql') {
7831 7831
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7832 7832
 			} else {
7833 7833
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7834 7834
 			}
7835 7835
 		}
7836 7836
 
7837
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7838
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7839
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7837
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7838
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7839
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7840 7840
 					ORDER BY airport_arrival_icao_count DESC";
7841 7841
 		if ($limit) $query .= " LIMIT 10";
7842 7842
       
@@ -7866,11 +7866,11 @@  discard block
 block discarded – undo
7866 7866
 	}	
7867 7867
 	
7868 7868
 	/**
7869
-	* Gets all arrival airports of the airplanes that have flown over based on an airline icao
7870
-	*
7871
-	* @return Array the airport list
7872
-	*
7873
-	*/
7869
+	 * Gets all arrival airports of the airplanes that have flown over based on an airline icao
7870
+	 *
7871
+	 * @return Array the airport list
7872
+	 *
7873
+	 */
7874 7874
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7875 7875
 	{
7876 7876
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7902,11 +7902,11 @@  discard block
 block discarded – undo
7902 7902
 	
7903 7903
 	
7904 7904
 	/**
7905
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7906
-	*
7907
-	* @return Array the airport list
7908
-	*
7909
-	*/
7905
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7906
+	 *
7907
+	 * @return Array the airport list
7908
+	 *
7909
+	 */
7910 7910
 	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7911 7911
 	{
7912 7912
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7937,11 +7937,11 @@  discard block
 block discarded – undo
7937 7937
 	
7938 7938
 	
7939 7939
 	/**
7940
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7941
-	*
7942
-	* @return Array the airport list
7943
-	*
7944
-	*/
7940
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7941
+	 *
7942
+	 * @return Array the airport list
7943
+	 *
7944
+	 */
7945 7945
 	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7946 7946
 	{
7947 7947
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7975,11 +7975,11 @@  discard block
 block discarded – undo
7975 7975
 	
7976 7976
 	
7977 7977
 	/**
7978
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
7979
-	*
7980
-	* @return Array the airport list
7981
-	*
7982
-	*/
7978
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
7979
+	 *
7980
+	 * @return Array the airport list
7981
+	 *
7982
+	 */
7983 7983
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
7984 7984
 	{
7985 7985
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8009,11 +8009,11 @@  discard block
 block discarded – undo
8009 8009
 	
8010 8010
 	
8011 8011
 	/**
8012
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8013
-	*
8014
-	* @return Array the airport list
8015
-	*
8016
-	*/
8012
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8013
+	 *
8014
+	 * @return Array the airport list
8015
+	 *
8016
+	 */
8017 8017
 	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8018 8018
 	{
8019 8019
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8047,11 +8047,11 @@  discard block
 block discarded – undo
8047 8047
 	
8048 8048
 	
8049 8049
 	/**
8050
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8051
-	*
8052
-	* @return Array the airport list
8053
-	*
8054
-	*/
8050
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8051
+	 *
8052
+	 * @return Array the airport list
8053
+	 *
8054
+	 */
8055 8055
 	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8056 8056
 	{
8057 8057
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8082,11 +8082,11 @@  discard block
 block discarded – undo
8082 8082
 	
8083 8083
 	
8084 8084
 	/**
8085
-	* Gets all arrival airports of the airplanes that have flown over based on an departure airport
8086
-	*
8087
-	* @return Array the airport list
8088
-	*
8089
-	*/
8085
+	 * Gets all arrival airports of the airplanes that have flown over based on an departure airport
8086
+	 *
8087
+	 * @return Array the airport list
8088
+	 *
8089
+	 */
8090 8090
 	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8091 8091
 	{
8092 8092
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8119,11 +8119,11 @@  discard block
 block discarded – undo
8119 8119
 	
8120 8120
 	
8121 8121
 	/**
8122
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8123
-	*
8124
-	* @return Array the airport list
8125
-	*
8126
-	*/
8122
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8123
+	 *
8124
+	 * @return Array the airport list
8125
+	 *
8126
+	 */
8127 8127
 	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8128 8128
 	{
8129 8129
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8153,11 +8153,11 @@  discard block
 block discarded – undo
8153 8153
 	
8154 8154
 	
8155 8155
 	/**
8156
-	* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8157
-	*
8158
-	* @return Array the airport list
8159
-	*
8160
-	*/
8156
+	 * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8157
+	 *
8158
+	 * @return Array the airport list
8159
+	 *
8160
+	 */
8161 8161
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8162 8162
 	{
8163 8163
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8191,11 +8191,11 @@  discard block
 block discarded – undo
8191 8191
 	
8192 8192
 	
8193 8193
 	/**
8194
-	* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8195
-	*
8196
-	* @return Array the airport list
8197
-	*
8198
-	*/
8194
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8195
+	 *
8196
+	 * @return Array the airport list
8197
+	 *
8198
+	 */
8199 8199
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8200 8200
 	{
8201 8201
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8226,11 +8226,11 @@  discard block
 block discarded – undo
8226 8226
 	
8227 8227
 	
8228 8228
 	/**
8229
-	* Gets all arrival airports of the airplanes that have flown over based on a date
8230
-	*
8231
-	* @return Array the airport list
8232
-	*
8233
-	*/
8229
+	 * Gets all arrival airports of the airplanes that have flown over based on a date
8230
+	 *
8231
+	 * @return Array the airport list
8232
+	 *
8233
+	 */
8234 8234
 	public function countAllArrivalAirportsByDate($date,$filters = array())
8235 8235
 	{
8236 8236
 		global $globalTimezone, $globalDBdriver;
@@ -8276,11 +8276,11 @@  discard block
 block discarded – undo
8276 8276
 	
8277 8277
 	
8278 8278
 	/**
8279
-	* Gets all arrival airports by country of the airplanes that have flown over based on a date
8280
-	*
8281
-	* @return Array the airport list
8282
-	*
8283
-	*/
8279
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a date
8280
+	 *
8281
+	 * @return Array the airport list
8282
+	 *
8283
+	 */
8284 8284
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8285 8285
 	{
8286 8286
 		global $globalTimezone, $globalDBdriver;
@@ -8323,11 +8323,11 @@  discard block
 block discarded – undo
8323 8323
 	
8324 8324
 	
8325 8325
 	/**
8326
-	* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8327
-	*
8328
-	* @return Array the airport list
8329
-	*
8330
-	*/
8326
+	 * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8327
+	 *
8328
+	 * @return Array the airport list
8329
+	 *
8330
+	 */
8331 8331
 	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8332 8332
 	{
8333 8333
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8359,11 +8359,11 @@  discard block
 block discarded – undo
8359 8359
 	}
8360 8360
 	
8361 8361
 	/**
8362
-	* Gets all arrival airports of the airplanes that have flown over based on a owner
8363
-	*
8364
-	* @return Array the airport list
8365
-	*
8366
-	*/
8362
+	 * Gets all arrival airports of the airplanes that have flown over based on a owner
8363
+	 *
8364
+	 * @return Array the airport list
8365
+	 *
8366
+	 */
8367 8367
 	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8368 8368
 	{
8369 8369
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8394,11 +8394,11 @@  discard block
 block discarded – undo
8394 8394
 	}
8395 8395
 
8396 8396
 	/**
8397
-	* Gets all arrival airports of the airplanes that have flown over based on a pilot
8398
-	*
8399
-	* @return Array the airport list
8400
-	*
8401
-	*/
8397
+	 * Gets all arrival airports of the airplanes that have flown over based on a pilot
8398
+	 *
8399
+	 * @return Array the airport list
8400
+	 *
8401
+	 */
8402 8402
 	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8403 8403
 	{
8404 8404
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8429,11 +8429,11 @@  discard block
 block discarded – undo
8429 8429
 	}
8430 8430
 	
8431 8431
 	/**
8432
-	* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8433
-	*
8434
-	* @return Array the airport list
8435
-	*
8436
-	*/
8432
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8433
+	 *
8434
+	 * @return Array the airport list
8435
+	 *
8436
+	 */
8437 8437
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8438 8438
 	{
8439 8439
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8462,11 +8462,11 @@  discard block
 block discarded – undo
8462 8462
 	}
8463 8463
 	
8464 8464
 	/**
8465
-	* Gets all arrival airports by country of the airplanes that have flown over based on a owner
8466
-	*
8467
-	* @return Array the airport list
8468
-	*
8469
-	*/
8465
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a owner
8466
+	 *
8467
+	 * @return Array the airport list
8468
+	 *
8469
+	 */
8470 8470
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8471 8471
 	{
8472 8472
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8482,11 +8482,11 @@  discard block
 block discarded – undo
8482 8482
 	}
8483 8483
 	
8484 8484
 	/**
8485
-	* Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8486
-	*
8487
-	* @return Array the airport list
8488
-	*
8489
-	*/
8485
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8486
+	 *
8487
+	 * @return Array the airport list
8488
+	 *
8489
+	 */
8490 8490
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8491 8491
 	{
8492 8492
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8504,11 +8504,11 @@  discard block
 block discarded – undo
8504 8504
 	
8505 8505
 	
8506 8506
 	/**
8507
-	* Gets all arrival airports of the airplanes that have flown over based on a country
8508
-	*
8509
-	* @return Array the airport list
8510
-	*
8511
-	*/
8507
+	 * Gets all arrival airports of the airplanes that have flown over based on a country
8508
+	 *
8509
+	 * @return Array the airport list
8510
+	 *
8511
+	 */
8512 8512
 	public function countAllArrivalAirportsByCountry($country,$filters = array())
8513 8513
 	{
8514 8514
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8541,11 +8541,11 @@  discard block
 block discarded – undo
8541 8541
 	
8542 8542
 	
8543 8543
 	/**
8544
-	* Gets all arrival airports by country of the airplanes that have flown over based on a country
8545
-	*
8546
-	* @return Array the airport list
8547
-	*
8548
-	*/
8544
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a country
8545
+	 *
8546
+	 * @return Array the airport list
8547
+	 *
8548
+	 */
8549 8549
 	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8550 8550
 	{
8551 8551
 		global $globalDBdriver;
@@ -8577,11 +8577,11 @@  discard block
 block discarded – undo
8577 8577
 
8578 8578
 
8579 8579
 	/**
8580
-	* Counts all airport departure countries
8581
-	*
8582
-	* @return Array the airport departure list
8583
-	*
8584
-	*/
8580
+	 * Counts all airport departure countries
8581
+	 *
8582
+	 * @return Array the airport departure list
8583
+	 *
8584
+	 */
8585 8585
 	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8586 8586
 	{
8587 8587
 		global $globalDBdriver;
@@ -8640,11 +8640,11 @@  discard block
 block discarded – undo
8640 8640
 	
8641 8641
 	
8642 8642
 	/**
8643
-	* Counts all airport arrival countries
8644
-	*
8645
-	* @return Array the airport arrival list
8646
-	*
8647
-	*/
8643
+	 * Counts all airport arrival countries
8644
+	 *
8645
+	 * @return Array the airport arrival list
8646
+	 *
8647
+	 */
8648 8648
 	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8649 8649
 	{
8650 8650
 		global $globalDBdriver;
@@ -8706,11 +8706,11 @@  discard block
 block discarded – undo
8706 8706
 
8707 8707
 
8708 8708
 	/**
8709
-	* Gets all route combinations
8710
-	*
8711
-	* @return Array the route list
8712
-	*
8713
-	*/
8709
+	 * Gets all route combinations
8710
+	 *
8711
+	 * @return Array the route list
8712
+	 *
8713
+	 */
8714 8714
 	public function countAllRoutes($filters = array())
8715 8715
 	{
8716 8716
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8749,11 +8749,11 @@  discard block
 block discarded – undo
8749 8749
 	
8750 8750
 	
8751 8751
 	/**
8752
-	* Gets all route combinations based on an aircraft
8753
-	*
8754
-	* @return Array the route list
8755
-	*
8756
-	*/
8752
+	 * Gets all route combinations based on an aircraft
8753
+	 *
8754
+	 * @return Array the route list
8755
+	 *
8756
+	 */
8757 8757
 	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8758 8758
 	{
8759 8759
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8789,11 +8789,11 @@  discard block
 block discarded – undo
8789 8789
 	
8790 8790
 	
8791 8791
 	/**
8792
-	* Gets all route combinations based on an aircraft registration
8793
-	*
8794
-	* @return Array the route list
8795
-	*
8796
-	*/
8792
+	 * Gets all route combinations based on an aircraft registration
8793
+	 *
8794
+	 * @return Array the route list
8795
+	 *
8796
+	 */
8797 8797
 	public function countAllRoutesByRegistration($registration, $filters = array())
8798 8798
 	{
8799 8799
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8831,11 +8831,11 @@  discard block
 block discarded – undo
8831 8831
 	
8832 8832
 	
8833 8833
 	/**
8834
-	* Gets all route combinations based on an airline
8835
-	*
8836
-	* @return Array the route list
8837
-	*
8838
-	*/
8834
+	 * Gets all route combinations based on an airline
8835
+	 *
8836
+	 * @return Array the route list
8837
+	 *
8838
+	 */
8839 8839
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8840 8840
 	{
8841 8841
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8873,11 +8873,11 @@  discard block
 block discarded – undo
8873 8873
 	
8874 8874
 	
8875 8875
 	/**
8876
-	* Gets all route combinations based on an airport
8877
-	*
8878
-	* @return Array the route list
8879
-	*
8880
-	*/
8876
+	 * Gets all route combinations based on an airport
8877
+	 *
8878
+	 * @return Array the route list
8879
+	 *
8880
+	 */
8881 8881
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8882 8882
 	{
8883 8883
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8914,11 +8914,11 @@  discard block
 block discarded – undo
8914 8914
 	
8915 8915
 	
8916 8916
 	/**
8917
-	* Gets all route combinations based on an country
8918
-	*
8919
-	* @return Array the route list
8920
-	*
8921
-	*/
8917
+	 * Gets all route combinations based on an country
8918
+	 *
8919
+	 * @return Array the route list
8920
+	 *
8921
+	 */
8922 8922
 	public function countAllRoutesByCountry($country, $filters = array())
8923 8923
 	{
8924 8924
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8954,11 +8954,11 @@  discard block
 block discarded – undo
8954 8954
 
8955 8955
 
8956 8956
 	/**
8957
-	* Gets all route combinations based on an date
8958
-	*
8959
-	* @return Array the route list
8960
-	*
8961
-	*/
8957
+	 * Gets all route combinations based on an date
8958
+	 *
8959
+	 * @return Array the route list
8960
+	 *
8961
+	 */
8962 8962
 	public function countAllRoutesByDate($date, $filters = array())
8963 8963
 	{
8964 8964
 		global $globalTimezone, $globalDBdriver;
@@ -9008,11 +9008,11 @@  discard block
 block discarded – undo
9008 9008
 	
9009 9009
 	
9010 9010
 	/**
9011
-	* Gets all route combinations based on an ident/callsign
9012
-	*
9013
-	* @return Array the route list
9014
-	*
9015
-	*/
9011
+	 * Gets all route combinations based on an ident/callsign
9012
+	 *
9013
+	 * @return Array the route list
9014
+	 *
9015
+	 */
9016 9016
 	public function countAllRoutesByIdent($ident, $filters = array())
9017 9017
 	{
9018 9018
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9048,11 +9048,11 @@  discard block
 block discarded – undo
9048 9048
 	}
9049 9049
 	
9050 9050
 	/**
9051
-	* Gets all route combinations based on an owner
9052
-	*
9053
-	* @return Array the route list
9054
-	*
9055
-	*/
9051
+	 * Gets all route combinations based on an owner
9052
+	 *
9053
+	 * @return Array the route list
9054
+	 *
9055
+	 */
9056 9056
 	public function countAllRoutesByOwner($owner,$filters = array())
9057 9057
 	{
9058 9058
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9088,11 +9088,11 @@  discard block
 block discarded – undo
9088 9088
 	}
9089 9089
 	
9090 9090
 	/**
9091
-	* Gets all route combinations based on a pilot
9092
-	*
9093
-	* @return Array the route list
9094
-	*
9095
-	*/
9091
+	 * Gets all route combinations based on a pilot
9092
+	 *
9093
+	 * @return Array the route list
9094
+	 *
9095
+	 */
9096 9096
 	public function countAllRoutesByPilot($pilot,$filters = array())
9097 9097
 	{
9098 9098
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9129,11 +9129,11 @@  discard block
 block discarded – undo
9129 9129
 	
9130 9130
 	
9131 9131
 	/**
9132
-	* Gets all route combinations based on an manufacturer
9133
-	*
9134
-	* @return Array the route list
9135
-	*
9136
-	*/
9132
+	 * Gets all route combinations based on an manufacturer
9133
+	 *
9134
+	 * @return Array the route list
9135
+	 *
9136
+	 */
9137 9137
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9138 9138
 	{
9139 9139
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9171,11 +9171,11 @@  discard block
 block discarded – undo
9171 9171
 	
9172 9172
 	
9173 9173
 	/**
9174
-	* Gets all route combinations with waypoints
9175
-	*
9176
-	* @return Array the route list
9177
-	*
9178
-	*/
9174
+	 * Gets all route combinations with waypoints
9175
+	 *
9176
+	 * @return Array the route list
9177
+	 *
9178
+	 */
9179 9179
 	public function countAllRoutesWithWaypoints($filters = array())
9180 9180
 	{
9181 9181
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9212,11 +9212,11 @@  discard block
 block discarded – undo
9212 9212
 	}
9213 9213
 	
9214 9214
 	/**
9215
-	* Gets all callsigns that have flown over
9216
-	*
9217
-	* @return Array the callsign list
9218
-	*
9219
-	*/
9215
+	 * Gets all callsigns that have flown over
9216
+	 *
9217
+	 * @return Array the callsign list
9218
+	 *
9219
+	 */
9220 9220
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9221 9221
 	{
9222 9222
 		global $globalDBdriver;
@@ -9282,11 +9282,11 @@  discard block
 block discarded – undo
9282 9282
 	}
9283 9283
 
9284 9284
 	/**
9285
-	* Gets all callsigns that have flown over
9286
-	*
9287
-	* @return Array the callsign list
9288
-	*
9289
-	*/
9285
+	 * Gets all callsigns that have flown over
9286
+	 *
9287
+	 * @return Array the callsign list
9288
+	 *
9289
+	 */
9290 9290
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9291 9291
 	{
9292 9292
 		global $globalDBdriver;
@@ -9327,11 +9327,11 @@  discard block
 block discarded – undo
9327 9327
 
9328 9328
 
9329 9329
 	/**
9330
-	* Counts all dates
9331
-	*
9332
-	* @return Array the date list
9333
-	*
9334
-	*/
9330
+	 * Counts all dates
9331
+	 *
9332
+	 * @return Array the date list
9333
+	 *
9334
+	 */
9335 9335
 	public function countAllDates($filters = array())
9336 9336
 	{
9337 9337
 		global $globalTimezone, $globalDBdriver;
@@ -9376,11 +9376,11 @@  discard block
 block discarded – undo
9376 9376
 	}
9377 9377
 	
9378 9378
 	/**
9379
-	* Counts all dates
9380
-	*
9381
-	* @return Array the date list
9382
-	*
9383
-	*/
9379
+	 * Counts all dates
9380
+	 *
9381
+	 * @return Array the date list
9382
+	 *
9383
+	 */
9384 9384
 	public function countAllDatesByAirlines($filters = array())
9385 9385
 	{
9386 9386
 		global $globalTimezone, $globalDBdriver;
@@ -9425,11 +9425,11 @@  discard block
 block discarded – undo
9425 9425
 	}	
9426 9426
 	
9427 9427
 	/**
9428
-	* Counts all dates during the last 7 days
9429
-	*
9430
-	* @return Array the date list
9431
-	*
9432
-	*/
9428
+	 * Counts all dates during the last 7 days
9429
+	 *
9430
+	 * @return Array the date list
9431
+	 *
9432
+	 */
9433 9433
 	public function countAllDatesLast7Days($filters = array())
9434 9434
 	{
9435 9435
 		global $globalTimezone, $globalDBdriver;
@@ -9451,7 +9451,7 @@  discard block
 block discarded – undo
9451 9451
 			$query .= " GROUP BY date_name 
9452 9452
 								ORDER BY date_name ASC";
9453 9453
 			$query_data = array(':offset' => $offset);
9454
-    		}
9454
+			}
9455 9455
 		
9456 9456
 		$sth = $this->db->prepare($query);
9457 9457
 		$sth->execute($query_data);
@@ -9471,11 +9471,11 @@  discard block
 block discarded – undo
9471 9471
 	}
9472 9472
 
9473 9473
 	/**
9474
-	* Counts all dates during the last month
9475
-	*
9476
-	* @return Array the date list
9477
-	*
9478
-	*/
9474
+	 * Counts all dates during the last month
9475
+	 *
9476
+	 * @return Array the date list
9477
+	 *
9478
+	 */
9479 9479
 	public function countAllDatesLastMonth($filters = array())
9480 9480
 	{
9481 9481
 		global $globalTimezone, $globalDBdriver;
@@ -9497,7 +9497,7 @@  discard block
 block discarded – undo
9497 9497
 			$query .= " GROUP BY date_name 
9498 9498
 								ORDER BY date_name ASC";
9499 9499
 			$query_data = array(':offset' => $offset);
9500
-    		}
9500
+			}
9501 9501
 		
9502 9502
 		$sth = $this->db->prepare($query);
9503 9503
 		$sth->execute($query_data);
@@ -9518,11 +9518,11 @@  discard block
 block discarded – undo
9518 9518
 
9519 9519
 
9520 9520
 	/**
9521
-	* Counts all dates during the last month
9522
-	*
9523
-	* @return Array the date list
9524
-	*
9525
-	*/
9521
+	 * Counts all dates during the last month
9522
+	 *
9523
+	 * @return Array the date list
9524
+	 *
9525
+	 */
9526 9526
 	public function countAllDatesLastMonthByAirlines($filters = array())
9527 9527
 	{
9528 9528
 		global $globalTimezone, $globalDBdriver;
@@ -9545,7 +9545,7 @@  discard block
 block discarded – undo
9545 9545
 								GROUP BY spotter_output.airline_icao, date_name 
9546 9546
 								ORDER BY date_name ASC";
9547 9547
 			$query_data = array(':offset' => $offset);
9548
-    		}
9548
+			}
9549 9549
 		
9550 9550
 		$sth = $this->db->prepare($query);
9551 9551
 		$sth->execute($query_data);
@@ -9567,11 +9567,11 @@  discard block
 block discarded – undo
9567 9567
 	
9568 9568
 
9569 9569
 	/**
9570
-	* Counts all month
9571
-	*
9572
-	* @return Array the month list
9573
-	*
9574
-	*/
9570
+	 * Counts all month
9571
+	 *
9572
+	 * @return Array the month list
9573
+	 *
9574
+	 */
9575 9575
 	public function countAllMonths($filters = array())
9576 9576
 	{
9577 9577
 		global $globalTimezone, $globalDBdriver;
@@ -9613,11 +9613,11 @@  discard block
 block discarded – undo
9613 9613
 	}
9614 9614
 
9615 9615
 	/**
9616
-	* Counts all month
9617
-	*
9618
-	* @return Array the month list
9619
-	*
9620
-	*/
9616
+	 * Counts all month
9617
+	 *
9618
+	 * @return Array the month list
9619
+	 *
9620
+	 */
9621 9621
 	public function countAllMonthsByAirlines($filters = array())
9622 9622
 	{
9623 9623
 		global $globalTimezone, $globalDBdriver;
@@ -9662,11 +9662,11 @@  discard block
 block discarded – undo
9662 9662
 	}
9663 9663
 
9664 9664
 	/**
9665
-	* Counts all military month
9666
-	*
9667
-	* @return Array the month list
9668
-	*
9669
-	*/
9665
+	 * Counts all military month
9666
+	 *
9667
+	 * @return Array the month list
9668
+	 *
9669
+	 */
9670 9670
 	public function countAllMilitaryMonths($filters = array())
9671 9671
 	{
9672 9672
 		global $globalTimezone, $globalDBdriver;
@@ -9707,11 +9707,11 @@  discard block
 block discarded – undo
9707 9707
 	}
9708 9708
 	
9709 9709
 	/**
9710
-	* Counts all month owners
9711
-	*
9712
-	* @return Array the month list
9713
-	*
9714
-	*/
9710
+	 * Counts all month owners
9711
+	 *
9712
+	 * @return Array the month list
9713
+	 *
9714
+	 */
9715 9715
 	public function countAllMonthsOwners($filters = array())
9716 9716
 	{
9717 9717
 		global $globalTimezone, $globalDBdriver;
@@ -9753,11 +9753,11 @@  discard block
 block discarded – undo
9753 9753
 	}
9754 9754
 	
9755 9755
 	/**
9756
-	* Counts all month owners
9757
-	*
9758
-	* @return Array the month list
9759
-	*
9760
-	*/
9756
+	 * Counts all month owners
9757
+	 *
9758
+	 * @return Array the month list
9759
+	 *
9760
+	 */
9761 9761
 	public function countAllMonthsOwnersByAirlines($filters = array())
9762 9762
 	{
9763 9763
 		global $globalTimezone, $globalDBdriver;
@@ -9800,11 +9800,11 @@  discard block
 block discarded – undo
9800 9800
 	}
9801 9801
 
9802 9802
 	/**
9803
-	* Counts all month pilot
9804
-	*
9805
-	* @return Array the month list
9806
-	*
9807
-	*/
9803
+	 * Counts all month pilot
9804
+	 *
9805
+	 * @return Array the month list
9806
+	 *
9807
+	 */
9808 9808
 	public function countAllMonthsPilots($filters = array())
9809 9809
 	{
9810 9810
 		global $globalTimezone, $globalDBdriver;
@@ -9846,11 +9846,11 @@  discard block
 block discarded – undo
9846 9846
 	}
9847 9847
 	
9848 9848
 	/**
9849
-	* Counts all month pilot
9850
-	*
9851
-	* @return Array the month list
9852
-	*
9853
-	*/
9849
+	 * Counts all month pilot
9850
+	 *
9851
+	 * @return Array the month list
9852
+	 *
9853
+	 */
9854 9854
 	public function countAllMonthsPilotsByAirlines($filters = array())
9855 9855
 	{
9856 9856
 		global $globalTimezone, $globalDBdriver;
@@ -9893,11 +9893,11 @@  discard block
 block discarded – undo
9893 9893
 	}
9894 9894
 
9895 9895
 	/**
9896
-	* Counts all month airline
9897
-	*
9898
-	* @return Array the month list
9899
-	*
9900
-	*/
9896
+	 * Counts all month airline
9897
+	 *
9898
+	 * @return Array the month list
9899
+	 *
9900
+	 */
9901 9901
 	public function countAllMonthsAirlines($filters = array())
9902 9902
 	{
9903 9903
 		global $globalTimezone, $globalDBdriver;
@@ -9939,11 +9939,11 @@  discard block
 block discarded – undo
9939 9939
 	}
9940 9940
 	
9941 9941
 	/**
9942
-	* Counts all month aircraft
9943
-	*
9944
-	* @return Array the month list
9945
-	*
9946
-	*/
9942
+	 * Counts all month aircraft
9943
+	 *
9944
+	 * @return Array the month list
9945
+	 *
9946
+	 */
9947 9947
 	public function countAllMonthsAircrafts($filters = array())
9948 9948
 	{
9949 9949
 		global $globalTimezone, $globalDBdriver;
@@ -9986,11 +9986,11 @@  discard block
 block discarded – undo
9986 9986
 	
9987 9987
 
9988 9988
 	/**
9989
-	* Counts all month aircraft
9990
-	*
9991
-	* @return Array the month list
9992
-	*
9993
-	*/
9989
+	 * Counts all month aircraft
9990
+	 *
9991
+	 * @return Array the month list
9992
+	 *
9993
+	 */
9994 9994
 	public function countAllMonthsAircraftsByAirlines($filters = array())
9995 9995
 	{
9996 9996
 		global $globalTimezone, $globalDBdriver;
@@ -10033,11 +10033,11 @@  discard block
 block discarded – undo
10033 10033
 	}
10034 10034
 
10035 10035
 	/**
10036
-	* Counts all month real arrival
10037
-	*
10038
-	* @return Array the month list
10039
-	*
10040
-	*/
10036
+	 * Counts all month real arrival
10037
+	 *
10038
+	 * @return Array the month list
10039
+	 *
10040
+	 */
10041 10041
 	public function countAllMonthsRealArrivals($filters = array())
10042 10042
 	{
10043 10043
 		global $globalTimezone, $globalDBdriver;
@@ -10080,11 +10080,11 @@  discard block
 block discarded – undo
10080 10080
 	
10081 10081
 
10082 10082
 	/**
10083
-	* Counts all month real arrival
10084
-	*
10085
-	* @return Array the month list
10086
-	*
10087
-	*/
10083
+	 * Counts all month real arrival
10084
+	 *
10085
+	 * @return Array the month list
10086
+	 *
10087
+	 */
10088 10088
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10089 10089
 	{
10090 10090
 		global $globalTimezone, $globalDBdriver;
@@ -10128,11 +10128,11 @@  discard block
 block discarded – undo
10128 10128
 	
10129 10129
 
10130 10130
 	/**
10131
-	* Counts all dates during the last year
10132
-	*
10133
-	* @return Array the date list
10134
-	*
10135
-	*/
10131
+	 * Counts all dates during the last year
10132
+	 *
10133
+	 * @return Array the date list
10134
+	 *
10135
+	 */
10136 10136
 	public function countAllMonthsLastYear($filters)
10137 10137
 	{
10138 10138
 		global $globalTimezone, $globalDBdriver;
@@ -10154,7 +10154,7 @@  discard block
 block discarded – undo
10154 10154
 			$query .= " GROUP BY year_name, month_name
10155 10155
 								ORDER BY year_name, month_name ASC";
10156 10156
 			$query_data = array(':offset' => $offset);
10157
-    		}
10157
+			}
10158 10158
 		
10159 10159
 		$sth = $this->db->prepare($query);
10160 10160
 		$sth->execute($query_data);
@@ -10177,11 +10177,11 @@  discard block
 block discarded – undo
10177 10177
 	
10178 10178
 	
10179 10179
 	/**
10180
-	* Counts all hours
10181
-	*
10182
-	* @return Array the hour list
10183
-	*
10184
-	*/
10180
+	 * Counts all hours
10181
+	 *
10182
+	 * @return Array the hour list
10183
+	 *
10184
+	 */
10185 10185
 	public function countAllHours($orderby,$filters = array())
10186 10186
 	{
10187 10187
 		global $globalTimezone, $globalDBdriver;
@@ -10242,11 +10242,11 @@  discard block
 block discarded – undo
10242 10242
 	}
10243 10243
 	
10244 10244
 	/**
10245
-	* Counts all hours
10246
-	*
10247
-	* @return Array the hour list
10248
-	*
10249
-	*/
10245
+	 * Counts all hours
10246
+	 *
10247
+	 * @return Array the hour list
10248
+	 *
10249
+	 */
10250 10250
 	public function countAllHoursByAirlines($orderby, $filters = array())
10251 10251
 	{
10252 10252
 		global $globalTimezone, $globalDBdriver;
@@ -10309,11 +10309,11 @@  discard block
 block discarded – undo
10309 10309
 
10310 10310
 
10311 10311
 	/**
10312
-	* Counts all hours by airline
10313
-	*
10314
-	* @return Array the hour list
10315
-	*
10316
-	*/
10312
+	 * Counts all hours by airline
10313
+	 *
10314
+	 * @return Array the hour list
10315
+	 *
10316
+	 */
10317 10317
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10318 10318
 	{
10319 10319
 		global $globalTimezone, $globalDBdriver;
@@ -10359,11 +10359,11 @@  discard block
 block discarded – undo
10359 10359
 	
10360 10360
 	
10361 10361
 	/**
10362
-	* Counts all hours by aircraft
10363
-	*
10364
-	* @return Array the hour list
10365
-	*
10366
-	*/
10362
+	 * Counts all hours by aircraft
10363
+	 *
10364
+	 * @return Array the hour list
10365
+	 *
10366
+	 */
10367 10367
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10368 10368
 	{
10369 10369
 		global $globalTimezone, $globalDBdriver;
@@ -10406,11 +10406,11 @@  discard block
 block discarded – undo
10406 10406
 	
10407 10407
 	
10408 10408
 	/**
10409
-	* Counts all hours by aircraft registration
10410
-	*
10411
-	* @return Array the hour list
10412
-	*
10413
-	*/
10409
+	 * Counts all hours by aircraft registration
10410
+	 *
10411
+	 * @return Array the hour list
10412
+	 *
10413
+	 */
10414 10414
 	public function countAllHoursByRegistration($registration, $filters = array())
10415 10415
 	{
10416 10416
 		global $globalTimezone, $globalDBdriver;
@@ -10453,11 +10453,11 @@  discard block
 block discarded – undo
10453 10453
 	
10454 10454
 	
10455 10455
 	/**
10456
-	* Counts all hours by airport
10457
-	*
10458
-	* @return Array the hour list
10459
-	*
10460
-	*/
10456
+	 * Counts all hours by airport
10457
+	 *
10458
+	 * @return Array the hour list
10459
+	 *
10460
+	 */
10461 10461
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10462 10462
 	{
10463 10463
 		global $globalTimezone, $globalDBdriver;
@@ -10501,11 +10501,11 @@  discard block
 block discarded – undo
10501 10501
 	
10502 10502
 	
10503 10503
 	/**
10504
-	* Counts all hours by manufacturer
10505
-	*
10506
-	* @return Array the hour list
10507
-	*
10508
-	*/
10504
+	 * Counts all hours by manufacturer
10505
+	 *
10506
+	 * @return Array the hour list
10507
+	 *
10508
+	 */
10509 10509
 	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10510 10510
 	{
10511 10511
 		global $globalTimezone, $globalDBdriver;
@@ -10549,11 +10549,11 @@  discard block
 block discarded – undo
10549 10549
 	
10550 10550
 	
10551 10551
 	/**
10552
-	* Counts all hours by date
10553
-	*
10554
-	* @return Array the hour list
10555
-	*
10556
-	*/
10552
+	 * Counts all hours by date
10553
+	 *
10554
+	 * @return Array the hour list
10555
+	 *
10556
+	 */
10557 10557
 	public function countAllHoursByDate($date, $filters = array())
10558 10558
 	{
10559 10559
 		global $globalTimezone, $globalDBdriver;
@@ -10597,11 +10597,11 @@  discard block
 block discarded – undo
10597 10597
 	
10598 10598
 	
10599 10599
 	/**
10600
-	* Counts all hours by a ident/callsign
10601
-	*
10602
-	* @return Array the hour list
10603
-	*
10604
-	*/
10600
+	 * Counts all hours by a ident/callsign
10601
+	 *
10602
+	 * @return Array the hour list
10603
+	 *
10604
+	 */
10605 10605
 	public function countAllHoursByIdent($ident, $filters = array())
10606 10606
 	{
10607 10607
 		global $globalTimezone, $globalDBdriver;
@@ -10644,11 +10644,11 @@  discard block
 block discarded – undo
10644 10644
 	}
10645 10645
 	
10646 10646
 	/**
10647
-	* Counts all hours by a owner
10648
-	*
10649
-	* @return Array the hour list
10650
-	*
10651
-	*/
10647
+	 * Counts all hours by a owner
10648
+	 *
10649
+	 * @return Array the hour list
10650
+	 *
10651
+	 */
10652 10652
 	public function countAllHoursByOwner($owner, $filters = array())
10653 10653
 	{
10654 10654
 		global $globalTimezone, $globalDBdriver;
@@ -10691,11 +10691,11 @@  discard block
 block discarded – undo
10691 10691
 	}
10692 10692
 	
10693 10693
 	/**
10694
-	* Counts all hours by a pilot
10695
-	*
10696
-	* @return Array the hour list
10697
-	*
10698
-	*/
10694
+	 * Counts all hours by a pilot
10695
+	 *
10696
+	 * @return Array the hour list
10697
+	 *
10698
+	 */
10699 10699
 	public function countAllHoursByPilot($pilot, $filters = array())
10700 10700
 	{
10701 10701
 		global $globalTimezone, $globalDBdriver;
@@ -10740,11 +10740,11 @@  discard block
 block discarded – undo
10740 10740
 	
10741 10741
 	
10742 10742
 	/**
10743
-	* Counts all hours by route
10744
-	*
10745
-	* @return Array the hour list
10746
-	*
10747
-	*/
10743
+	 * Counts all hours by route
10744
+	 *
10745
+	 * @return Array the hour list
10746
+	 *
10747
+	 */
10748 10748
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10749 10749
 	{
10750 10750
 		global $globalTimezone, $globalDBdriver;
@@ -10788,11 +10788,11 @@  discard block
 block discarded – undo
10788 10788
 	
10789 10789
 	
10790 10790
 	/**
10791
-	* Counts all hours by country
10792
-	*
10793
-	* @return Array the hour list
10794
-	*
10795
-	*/
10791
+	 * Counts all hours by country
10792
+	 *
10793
+	 * @return Array the hour list
10794
+	 *
10795
+	 */
10796 10796
 	public function countAllHoursByCountry($country, $filters = array())
10797 10797
 	{
10798 10798
 		global $globalTimezone, $globalDBdriver;
@@ -10837,11 +10837,11 @@  discard block
 block discarded – undo
10837 10837
 
10838 10838
 
10839 10839
 	/**
10840
-	* Counts all aircraft that have flown over
10841
-	*
10842
-	* @return Integer the number of aircrafts
10843
-	*
10844
-	*/
10840
+	 * Counts all aircraft that have flown over
10841
+	 *
10842
+	 * @return Integer the number of aircrafts
10843
+	 *
10844
+	 */
10845 10845
 	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10846 10846
 	{
10847 10847
 		global $globalDBdriver;
@@ -10874,11 +10874,11 @@  discard block
 block discarded – undo
10874 10874
 	}
10875 10875
 
10876 10876
 	/**
10877
-	* Counts all flight that really arrival
10878
-	*
10879
-	* @return Integer the number of aircrafts
10880
-	*
10881
-	*/
10877
+	 * Counts all flight that really arrival
10878
+	 *
10879
+	 * @return Integer the number of aircrafts
10880
+	 *
10881
+	 */
10882 10882
 	public function countOverallArrival($filters = array(),$year = '',$month = '')
10883 10883
 	{
10884 10884
 		global $globalDBdriver;
@@ -10911,11 +10911,11 @@  discard block
 block discarded – undo
10911 10911
 	}
10912 10912
 
10913 10913
 	/**
10914
-	* Counts all pilots that have flown over
10915
-	*
10916
-	* @return Integer the number of pilots
10917
-	*
10918
-	*/
10914
+	 * Counts all pilots that have flown over
10915
+	 *
10916
+	 * @return Integer the number of pilots
10917
+	 *
10918
+	 */
10919 10919
 	public function countOverallPilots($filters = array(),$year = '',$month = '')
10920 10920
 	{
10921 10921
 		global $globalDBdriver;
@@ -10947,11 +10947,11 @@  discard block
 block discarded – undo
10947 10947
 	}
10948 10948
 
10949 10949
 	/**
10950
-	* Counts all owners that have flown over
10951
-	*
10952
-	* @return Integer the number of owners
10953
-	*
10954
-	*/
10950
+	 * Counts all owners that have flown over
10951
+	 *
10952
+	 * @return Integer the number of owners
10953
+	 *
10954
+	 */
10955 10955
 	public function countOverallOwners($filters = array(),$year = '',$month = '')
10956 10956
 	{
10957 10957
 		global $globalDBdriver;
@@ -10984,11 +10984,11 @@  discard block
 block discarded – undo
10984 10984
 	
10985 10985
 	
10986 10986
 	/**
10987
-	* Counts all flights that have flown over
10988
-	*
10989
-	* @return Integer the number of flights
10990
-	*
10991
-	*/
10987
+	 * Counts all flights that have flown over
10988
+	 *
10989
+	 * @return Integer the number of flights
10990
+	 *
10991
+	 */
10992 10992
 	public function countOverallFlights($filters = array(),$year = '',$month = '')
10993 10993
 	{
10994 10994
 		global $globalDBdriver;
@@ -11022,11 +11022,11 @@  discard block
 block discarded – undo
11022 11022
 	}
11023 11023
 	
11024 11024
 	/**
11025
-	* Counts all military flights that have flown over
11026
-	*
11027
-	* @return Integer the number of flights
11028
-	*
11029
-	*/
11025
+	 * Counts all military flights that have flown over
11026
+	 *
11027
+	 * @return Integer the number of flights
11028
+	 *
11029
+	 */
11030 11030
 	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11031 11031
 	{
11032 11032
 		global $globalDBdriver;
@@ -11061,11 +11061,11 @@  discard block
 block discarded – undo
11061 11061
 	
11062 11062
 	
11063 11063
 	/**
11064
-	* Counts all airlines that have flown over
11065
-	*
11066
-	* @return Integer the number of airlines
11067
-	*
11068
-	*/
11064
+	 * Counts all airlines that have flown over
11065
+	 *
11066
+	 * @return Integer the number of airlines
11067
+	 *
11068
+	 */
11069 11069
 	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11070 11070
 	{
11071 11071
 		global $globalDBdriver;
@@ -11092,8 +11092,8 @@  discard block
 block discarded – undo
11092 11092
 				$query_values = array_merge($query_values,array(':month' => $month));
11093 11093
 			}
11094 11094
 		}
11095
-                if ($query == '') $queryi .= $this->getFilter($filters);
11096
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11095
+				if ($query == '') $queryi .= $this->getFilter($filters);
11096
+				else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11097 11097
 
11098 11098
 
11099 11099
 		$sth = $this->db->prepare($queryi);
@@ -11103,11 +11103,11 @@  discard block
 block discarded – undo
11103 11103
 
11104 11104
   
11105 11105
 	/**
11106
-	* Counts all hours of today
11107
-	*
11108
-	* @return Array the hour list
11109
-	*
11110
-	*/
11106
+	 * Counts all hours of today
11107
+	 *
11108
+	 * @return Array the hour list
11109
+	 *
11110
+	 */
11111 11111
 	public function countAllHoursFromToday($filters = array())
11112 11112
 	{
11113 11113
 		global $globalTimezone, $globalDBdriver;
@@ -11147,11 +11147,11 @@  discard block
 block discarded – undo
11147 11147
 	}
11148 11148
     
11149 11149
 	/**
11150
-	* Gets all the spotter information based on calculated upcoming flights
11151
-	*
11152
-	* @return Array the spotter information
11153
-	*
11154
-	*/
11150
+	 * Gets all the spotter information based on calculated upcoming flights
11151
+	 *
11152
+	 * @return Array the spotter information
11153
+	 *
11154
+	 */
11155 11155
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11156 11156
 	{
11157 11157
 		global $global_query, $globalDBdriver, $globalTimezone;
@@ -11226,12 +11226,12 @@  discard block
 block discarded – undo
11226 11226
 	}
11227 11227
     
11228 11228
     
11229
-     /**
11230
-	* Gets the Barrie Spotter ID based on the FlightAware ID
11231
-	*
11232
-	* @return Integer the Barrie Spotter ID
11229
+	 /**
11230
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
11231
+	  *
11232
+	  * @return Integer the Barrie Spotter ID
11233 11233
 q	*
11234
-	*/
11234
+	  */
11235 11235
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11236 11236
 	{
11237 11237
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -11252,13 +11252,13 @@  discard block
 block discarded – undo
11252 11252
   
11253 11253
  
11254 11254
 	/**
11255
-	* Parses a date string
11256
-	*
11257
-	* @param String $dateString the date string
11258
-	* @param String $timezone the timezone of a user
11259
-	* @return Array the time information
11260
-	*
11261
-	*/
11255
+	 * Parses a date string
11256
+	 *
11257
+	 * @param String $dateString the date string
11258
+	 * @param String $timezone the timezone of a user
11259
+	 * @return Array the time information
11260
+	 *
11261
+	 */
11262 11262
 	public function parseDateString($dateString, $timezone = '')
11263 11263
 	{
11264 11264
 		$time_array = array();
@@ -11294,12 +11294,12 @@  discard block
 block discarded – undo
11294 11294
 	
11295 11295
 	
11296 11296
 	/**
11297
-	* Parses the direction degrees to working
11298
-	*
11299
-	* @param Float $direction the direction in degrees
11300
-	* @return Array the direction information
11301
-	*
11302
-	*/
11297
+	 * Parses the direction degrees to working
11298
+	 *
11299
+	 * @param Float $direction the direction in degrees
11300
+	 * @return Array the direction information
11301
+	 *
11302
+	 */
11303 11303
 	public function parseDirection($direction = 0)
11304 11304
 	{
11305 11305
 		if ($direction == '') $direction = 0;
@@ -11378,12 +11378,12 @@  discard block
 block discarded – undo
11378 11378
 	
11379 11379
 	
11380 11380
 	/**
11381
-	* Gets the aircraft registration
11382
-	*
11383
-	* @param String $flightaware_id the flight aware id
11384
-	* @return String the aircraft registration
11385
-	*
11386
-	*/
11381
+	 * Gets the aircraft registration
11382
+	 *
11383
+	 * @param String $flightaware_id the flight aware id
11384
+	 * @return String the aircraft registration
11385
+	 *
11386
+	 */
11387 11387
 	
11388 11388
 	public function getAircraftRegistration($flightaware_id)
11389 11389
 	{
@@ -11412,12 +11412,12 @@  discard block
 block discarded – undo
11412 11412
 
11413 11413
 
11414 11414
 	/**
11415
-	* Gets the aircraft registration from ModeS
11416
-	*
11417
-	* @param String $aircraft_modes the flight ModeS in hex
11418
-	* @return String the aircraft registration
11419
-	*
11420
-	*/
11415
+	 * Gets the aircraft registration from ModeS
11416
+	 *
11417
+	 * @param String $aircraft_modes the flight ModeS in hex
11418
+	 * @return String the aircraft registration
11419
+	 *
11420
+	 */
11421 11421
 	public function getAircraftRegistrationBymodeS($aircraft_modes)
11422 11422
 	{
11423 11423
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11430,19 +11430,19 @@  discard block
 block discarded – undo
11430 11430
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11431 11431
 		$sth->closeCursor();
11432 11432
 		if (count($row) > 0) {
11433
-		    //return $row['Registration'];
11434
-		    return $row['registration'];
11433
+			//return $row['Registration'];
11434
+			return $row['registration'];
11435 11435
 		} else return '';
11436 11436
 	
11437 11437
 	}
11438 11438
 
11439 11439
 	/**
11440
-	* Gets the aircraft type from ModeS
11441
-	*
11442
-	* @param String $aircraft_modes the flight ModeS in hex
11443
-	* @return String the aircraft type
11444
-	*
11445
-	*/
11440
+	 * Gets the aircraft type from ModeS
11441
+	 *
11442
+	 * @param String $aircraft_modes the flight ModeS in hex
11443
+	 * @return String the aircraft type
11444
+	 *
11445
+	 */
11446 11446
 	public function getAircraftTypeBymodeS($aircraft_modes)
11447 11447
 	{
11448 11448
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11455,19 +11455,19 @@  discard block
 block discarded – undo
11455 11455
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11456 11456
 		$sth->closeCursor();
11457 11457
 		if (count($row) > 0) {
11458
-		    if ($row['type_flight'] == null) return '';
11459
-		    else return $row['type_flight'];
11458
+			if ($row['type_flight'] == null) return '';
11459
+			else return $row['type_flight'];
11460 11460
 		} else return '';
11461 11461
 	
11462 11462
 	}
11463 11463
 
11464 11464
 	/**
11465
-	* Gets Country from latitude/longitude
11466
-	*
11467
-	* @param Float $latitude latitute of the flight
11468
-	* @param Float $longitude longitute of the flight
11469
-	* @return String the countrie
11470
-	*/
11465
+	 * Gets Country from latitude/longitude
11466
+	 *
11467
+	 * @param Float $latitude latitute of the flight
11468
+	 * @param Float $longitude longitute of the flight
11469
+	 * @return String the countrie
11470
+	 */
11471 11471
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11472 11472
 	{
11473 11473
 		global $globalDBdriver, $globalDebug;
@@ -11504,11 +11504,11 @@  discard block
 block discarded – undo
11504 11504
 	}
11505 11505
 
11506 11506
 	/**
11507
-	* Gets Country from iso2
11508
-	*
11509
-	* @param String $iso2 ISO2 country code
11510
-	* @return String the countrie
11511
-	*/
11507
+	 * Gets Country from iso2
11508
+	 *
11509
+	 * @param String $iso2 ISO2 country code
11510
+	 * @return String the countrie
11511
+	 */
11512 11512
 	public function getCountryFromISO2($iso2)
11513 11513
 	{
11514 11514
 		global $globalDBdriver, $globalDebug;
@@ -11536,12 +11536,12 @@  discard block
 block discarded – undo
11536 11536
 	}
11537 11537
 
11538 11538
 	/**
11539
-	* converts the registration code using the country prefix
11540
-	*
11541
-	* @param String $registration the aircraft registration
11542
-	* @return String the aircraft registration
11543
-	*
11544
-	*/
11539
+	 * converts the registration code using the country prefix
11540
+	 *
11541
+	 * @param String $registration the aircraft registration
11542
+	 * @return String the aircraft registration
11543
+	 *
11544
+	 */
11545 11545
 	public function convertAircraftRegistration($registration)
11546 11546
 	{
11547 11547
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11593,12 +11593,12 @@  discard block
 block discarded – undo
11593 11593
 	}
11594 11594
 
11595 11595
 	/**
11596
-	* Country from the registration code
11597
-	*
11598
-	* @param String $registration the aircraft registration
11599
-	* @return String the country
11600
-	*
11601
-	*/
11596
+	 * Country from the registration code
11597
+	 *
11598
+	 * @param String $registration the aircraft registration
11599
+	 * @return String the country
11600
+	 *
11601
+	 */
11602 11602
 	public function countryFromAircraftRegistration($registration)
11603 11603
 	{
11604 11604
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11617,8 +11617,8 @@  discard block
 block discarded – undo
11617 11617
 				$country = $row['country'];
11618 11618
 			}
11619 11619
 		} else {
11620
-    			$registration_1 = substr($registration, 0, 1);
11621
-		        $registration_2 = substr($registration, 0, 2);
11620
+				$registration_1 = substr($registration, 0, 1);
11621
+				$registration_2 = substr($registration, 0, 2);
11622 11622
 
11623 11623
 			$country = '';
11624 11624
 			//first get the prefix based on two characters
@@ -11654,12 +11654,12 @@  discard block
 block discarded – undo
11654 11654
 	}
11655 11655
 
11656 11656
 	/**
11657
-	* Registration prefix from the registration code
11658
-	*
11659
-	* @param String $registration the aircraft registration
11660
-	* @return String the registration prefix
11661
-	*
11662
-	*/
11657
+	 * Registration prefix from the registration code
11658
+	 *
11659
+	 * @param String $registration the aircraft registration
11660
+	 * @return String the registration prefix
11661
+	 *
11662
+	 */
11663 11663
 	public function registrationPrefixFromAircraftRegistration($registration)
11664 11664
 	{
11665 11665
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11678,8 +11678,8 @@  discard block
 block discarded – undo
11678 11678
 				//$country = $row['country'];
11679 11679
 			}
11680 11680
 		} else {
11681
-    			$registration_1 = substr($registration, 0, 1);
11682
-		        $registration_2 = substr($registration, 0, 2);
11681
+				$registration_1 = substr($registration, 0, 1);
11682
+				$registration_2 = substr($registration, 0, 2);
11683 11683
 
11684 11684
 			//first get the prefix based on two characters
11685 11685
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
@@ -11715,12 +11715,12 @@  discard block
 block discarded – undo
11715 11715
 
11716 11716
 
11717 11717
 	/**
11718
-	* Country from the registration code
11719
-	*
11720
-	* @param String $registration the aircraft registration
11721
-	* @return String the country
11722
-	*
11723
-	*/
11718
+	 * Country from the registration code
11719
+	 *
11720
+	 * @param String $registration the aircraft registration
11721
+	 * @return String the country
11722
+	 *
11723
+	 */
11724 11724
 	public function countryFromAircraftRegistrationCode($registration)
11725 11725
 	{
11726 11726
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11737,11 +11737,11 @@  discard block
 block discarded – undo
11737 11737
 	}
11738 11738
 	
11739 11739
 	/**
11740
-	* Set a new highlight value for a flight
11741
-	*
11742
-	* @param String $flightaware_id flightaware_id from spotter_output table
11743
-	* @param String $highlight New highlight value
11744
-	*/
11740
+	 * Set a new highlight value for a flight
11741
+	 *
11742
+	 * @param String $flightaware_id flightaware_id from spotter_output table
11743
+	 * @param String $highlight New highlight value
11744
+	 */
11745 11745
 	public function setHighlightFlight($flightaware_id,$highlight) {
11746 11746
 		
11747 11747
 		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
@@ -11750,12 +11750,12 @@  discard block
 block discarded – undo
11750 11750
 	}
11751 11751
 
11752 11752
 	/**
11753
-	* Set a new highlight value for a flight by Registration
11754
-	*
11755
-	* @param String $registration Registration of the aircraft
11756
-	* @param String $date Date of spotted aircraft
11757
-	* @param String $highlight New highlight value
11758
-	*/
11753
+	 * Set a new highlight value for a flight by Registration
11754
+	 *
11755
+	 * @param String $registration Registration of the aircraft
11756
+	 * @param String $date Date of spotted aircraft
11757
+	 * @param String $highlight New highlight value
11758
+	 */
11759 11759
 	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11760 11760
 		if ($date == '') {
11761 11761
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
@@ -11769,12 +11769,12 @@  discard block
 block discarded – undo
11769 11769
 	}
11770 11770
 	
11771 11771
 	/**
11772
-	* Gets the short url from bit.ly
11773
-	*
11774
-	* @param String $url the full url
11775
-	* @return String the bit.ly url
11776
-	*
11777
-	*/
11772
+	 * Gets the short url from bit.ly
11773
+	 *
11774
+	 * @param String $url the full url
11775
+	 * @return String the bit.ly url
11776
+	 *
11777
+	 */
11778 11778
 	public function getBitlyURL($url)
11779 11779
 	{
11780 11780
 		global $globalBitlyAccessToken;
@@ -12063,11 +12063,11 @@  discard block
 block discarded – undo
12063 12063
 			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
12064 12064
 	                      FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
12065 12065
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
12066
-                } else {
12066
+				} else {
12067 12067
 			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
12068 12068
 	                      FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
12069 12069
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
12070
-    		}
12070
+			}
12071 12071
 		$sth = $this->db->prepare($query);
12072 12072
 		$sth->execute();
12073 12073
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	}
112 112
 
113 113
 	/**
114
-	* Gets all the spotter information based on the latest data entry
115
-	*
116
-	* @return Array the spotter information
117
-	*
118
-	*/
114
+	 * Gets all the spotter information based on the latest data entry
115
+	 *
116
+	 * @return Array the spotter information
117
+	 *
118
+	 */
119 119
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
120 120
 	{
121 121
 		global $globalDBdriver, $globalLiveInterval;
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	}
158 158
 
159 159
 	/**
160
-	* Gets Minimal Live Spotter data
161
-	*
162
-	* @return Array the spotter information
163
-	*
164
-	*/
160
+	 * Gets Minimal Live Spotter data
161
+	 *
162
+	 * @return Array the spotter information
163
+	 *
164
+	 */
165 165
 	public function getMinLiveSpotterData($filter = array())
166 166
 	{
167 167
 		global $globalDBdriver, $globalLiveInterval;
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
 	}
215 215
 
216 216
 	/**
217
-	* Gets Minimal Live Spotter data since xx seconds
218
-	*
219
-	* @return Array the spotter information
220
-	*
221
-	*/
217
+	 * Gets Minimal Live Spotter data since xx seconds
218
+	 *
219
+	 * @return Array the spotter information
220
+	 *
221
+	 */
222 222
 	public function getMinLastLiveSpotterData($filter = array())
223 223
 	{
224 224
 		global $globalDBdriver, $globalLiveInterval;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
237 237
 			FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
238 238
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
239
-                } else {
239
+				} else {
240 240
 /*
241 241
 			$query  = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
242 242
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 //			echo $query;
249 249
 		}
250 250
 
251
-    		try {
251
+			try {
252 252
 			$sth = $this->db->prepare($query);
253 253
 			$sth->execute();
254 254
 		} catch(PDOException $e) {
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 	}
261 261
 
262 262
 	/**
263
-	* Gets number of latest data entry
264
-	*
265
-	* @return String number of entry
266
-	*
267
-	*/
263
+	 * Gets number of latest data entry
264
+	 *
265
+	 * @return String number of entry
266
+	 *
267
+	 */
268 268
 	public function getLiveSpotterCount($filter = array())
269 269
 	{
270 270
 		global $globalDBdriver, $globalLiveInterval;
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 	}
292 292
 
293 293
 	/**
294
-	* Gets all the spotter information based on the latest data entry and coord
295
-	*
296
-	* @return Array the spotter information
297
-	*
298
-	*/
294
+	 * Gets all the spotter information based on the latest data entry and coord
295
+	 *
296
+	 * @return Array the spotter information
297
+	 *
298
+	 */
299 299
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
300 300
 	{
301 301
 		global $globalDBdriver, $globalLiveInterval;
@@ -320,11 +320,11 @@  discard block
 block discarded – undo
320 320
 	}
321 321
 
322 322
 	/**
323
-	* Gets all the spotter information based on a user's latitude and longitude
324
-	*
325
-	* @return Array the spotter information
326
-	*
327
-	*/
323
+	 * Gets all the spotter information based on a user's latitude and longitude
324
+	 *
325
+	 * @return Array the spotter information
326
+	 *
327
+	 */
328 328
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
329 329
 	{
330 330
 		$Spotter = new Spotter($this->db);
@@ -334,145 +334,145 @@  discard block
 block discarded – undo
334 334
 				return false;
335 335
 			}
336 336
 		}
337
-        if ($lng != '')
338
-                {
339
-                        if (!is_numeric($lng))
340
-                        {
341
-                                return false;
342
-                        }
343
-                }
344
-
345
-                if ($radius != '')
346
-                {
347
-                        if (!is_numeric($radius))
348
-                        {
349
-                                return false;
350
-                        }
351
-                }
337
+		if ($lng != '')
338
+				{
339
+						if (!is_numeric($lng))
340
+						{
341
+								return false;
342
+						}
343
+				}
344
+
345
+				if ($radius != '')
346
+				{
347
+						if (!is_numeric($radius))
348
+						{
349
+								return false;
350
+						}
351
+				}
352 352
 		$additional_query = '';
353
-        if ($interval != '')
354
-                {
355
-                        if (!is_string($interval))
356
-                        {
357
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
358
-			        return false;
359
-                        } else {
360
-                if ($interval == '1m')
361
-                {
362
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
363
-                } else if ($interval == '15m'){
364
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
365
-                } 
366
-            }
367
-                } else {
368
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
369
-        }
370
-
371
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
353
+		if ($interval != '')
354
+				{
355
+						if (!is_string($interval))
356
+						{
357
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
358
+					return false;
359
+						} else {
360
+				if ($interval == '1m')
361
+				{
362
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
363
+				} else if ($interval == '15m'){
364
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
365
+				} 
366
+			}
367
+				} else {
368
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
369
+		}
370
+
371
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
372 372
                    WHERE spotter_live.latitude <> '' 
373 373
                                    AND spotter_live.longitude <> '' 
374 374
                    ".$additional_query."
375 375
                    HAVING distance < :radius  
376 376
                                    ORDER BY distance";
377 377
 
378
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
378
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
379 379
 
380
-                return $spotter_array;
381
-        }
380
+				return $spotter_array;
381
+		}
382 382
 
383 383
     
384
-        /**
385
-	* Gets all the spotter information based on a particular callsign
386
-	*
387
-	* @return Array the spotter information
388
-	*
389
-	*/
384
+		/**
385
+		 * Gets all the spotter information based on a particular callsign
386
+		 *
387
+		 * @return Array the spotter information
388
+		 *
389
+		 */
390 390
 	public function getLastLiveSpotterDataByIdent($ident)
391 391
 	{
392 392
 		$Spotter = new Spotter($this->db);
393 393
 		date_default_timezone_set('UTC');
394 394
 
395 395
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
396
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
396
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
397 397
 
398 398
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
399 399
 
400 400
 		return $spotter_array;
401 401
 	}
402 402
 
403
-        /**
404
-	* Gets all the spotter information based on a particular callsign
405
-	*
406
-	* @return Array the spotter information
407
-	*
408
-	*/
403
+		/**
404
+		 * Gets all the spotter information based on a particular callsign
405
+		 *
406
+		 * @return Array the spotter information
407
+		 *
408
+		 */
409 409
 	public function getDateLiveSpotterDataByIdent($ident,$date)
410 410
 	{
411 411
 		$Spotter = new Spotter($this->db);
412 412
 		date_default_timezone_set('UTC');
413 413
 
414 414
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
415
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
415
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
416 416
 
417
-                $date = date('c',$date);
417
+				$date = date('c',$date);
418 418
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
419 419
 
420 420
 		return $spotter_array;
421 421
 	}
422 422
 
423
-        /**
424
-	* Gets last spotter information based on a particular callsign
425
-	*
426
-	* @return Array the spotter information
427
-	*
428
-	*/
423
+		/**
424
+		 * Gets last spotter information based on a particular callsign
425
+		 *
426
+		 * @return Array the spotter information
427
+		 *
428
+		 */
429 429
 	public function getLastLiveSpotterDataById($id)
430 430
 	{
431 431
 		$Spotter = new Spotter($this->db);
432 432
 		date_default_timezone_set('UTC');
433 433
 
434 434
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
435
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
435
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
436 436
 
437 437
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
438 438
 
439 439
 		return $spotter_array;
440 440
 	}
441 441
 
442
-        /**
443
-	* Gets last spotter information based on a particular callsign
444
-	*
445
-	* @return Array the spotter information
446
-	*
447
-	*/
442
+		/**
443
+		 * Gets last spotter information based on a particular callsign
444
+		 *
445
+		 * @return Array the spotter information
446
+		 *
447
+		 */
448 448
 	public function getDateLiveSpotterDataById($id,$date)
449 449
 	{
450 450
 		$Spotter = new Spotter($this->db);
451 451
 		date_default_timezone_set('UTC');
452 452
 
453 453
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
454
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
455
-                $date = date('c',$date);
454
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
455
+				$date = date('c',$date);
456 456
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
457 457
 
458 458
 		return $spotter_array;
459 459
 	}
460 460
 
461
-        /**
462
-	* Gets altitude information based on a particular callsign
463
-	*
464
-	* @return Array the spotter information
465
-	*
466
-	*/
461
+		/**
462
+		 * Gets altitude information based on a particular callsign
463
+		 *
464
+		 * @return Array the spotter information
465
+		 *
466
+		 */
467 467
 	public function getAltitudeLiveSpotterDataByIdent($ident)
468 468
 	{
469 469
 
470 470
 		date_default_timezone_set('UTC');
471 471
 
472 472
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
473
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
473
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
474 474
 
475
-    		try {
475
+			try {
476 476
 			
477 477
 			$sth = $this->db->prepare($query);
478 478
 			$sth->execute(array(':ident' => $ident));
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 		return $spotter_array;
486 486
 	}
487 487
 
488
-        /**
489
-	* Gets all the spotter information based on a particular id
490
-	*
491
-	* @return Array the spotter information
492
-	*
493
-	*/
488
+		/**
489
+		 * Gets all the spotter information based on a particular id
490
+		 *
491
+		 * @return Array the spotter information
492
+		 *
493
+		 */
494 494
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
495 495
 	{
496 496
 		global $globalDBdriver, $globalLiveInterval;
@@ -518,18 +518,18 @@  discard block
 block discarded – undo
518 518
 		return $spotter_array;
519 519
 	}
520 520
 
521
-        /**
522
-	* Gets all the spotter information based on a particular ident
523
-	*
524
-	* @return Array the spotter information
525
-	*
526
-	*/
521
+		/**
522
+		 * Gets all the spotter information based on a particular ident
523
+		 *
524
+		 * @return Array the spotter information
525
+		 *
526
+		 */
527 527
 	public function getAllLiveSpotterDataByIdent($ident)
528 528
 	{
529 529
 		date_default_timezone_set('UTC');
530 530
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
531 531
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
532
-    		try {
532
+			try {
533 533
 			
534 534
 			$sth = $this->db->prepare($query);
535 535
 			$sth->execute(array(':ident' => $ident));
@@ -543,23 +543,23 @@  discard block
 block discarded – undo
543 543
 
544 544
 
545 545
 	/**
546
-	* Deletes all info in the table
547
-	*
548
-	* @return String success or false
549
-	*
550
-	*/
546
+	 * Deletes all info in the table
547
+	 *
548
+	 * @return String success or false
549
+	 *
550
+	 */
551 551
 	public function deleteLiveSpotterData()
552 552
 	{
553 553
 		global $globalDBdriver;
554 554
 		if ($globalDBdriver == 'mysql') {
555 555
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
556 556
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
557
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
557
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
558 558
 		} else {
559 559
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
560 560
 		}
561 561
         
562
-    		try {
562
+			try {
563 563
 			
564 564
 			$sth = $this->db->prepare($query);
565 565
 			$sth->execute();
@@ -571,18 +571,18 @@  discard block
 block discarded – undo
571 571
 	}
572 572
 
573 573
 	/**
574
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
575
-	*
576
-	* @return String success or false
577
-	*
578
-	*/
574
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
575
+	 *
576
+	 * @return String success or false
577
+	 *
578
+	 */
579 579
 	public function deleteLiveSpotterDataNotUpdated()
580 580
 	{
581 581
 		global $globalDBdriver, $globalDebug;
582 582
 		if ($globalDBdriver == 'mysql') {
583 583
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
584
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
585
-    			try {
584
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
585
+				try {
586 586
 				
587 587
 				$sth = $this->db->prepare($query);
588 588
 				$sth->execute();
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 				return "error";
591 591
 			}
592 592
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
593
-                        $i = 0;
594
-                        $j =0;
593
+						$i = 0;
594
+						$j =0;
595 595
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
596 596
 			foreach($all as $row)
597 597
 			{
@@ -599,20 +599,20 @@  discard block
 block discarded – undo
599 599
 				$j++;
600 600
 				if ($j == 30) {
601 601
 					if ($globalDebug) echo ".";
602
-				    	try {
602
+						try {
603 603
 						
604 604
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
605 605
 						$sth->execute();
606 606
 					} catch(PDOException $e) {
607 607
 						return "error";
608 608
 					}
609
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
610
-                                	$j = 0;
609
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
610
+									$j = 0;
611 611
 				}
612 612
 				$query_delete .= "'".$row['flightaware_id']."',";
613 613
 			}
614 614
 			if ($i > 0) {
615
-    				try {
615
+					try {
616 616
 					
617 617
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
618 618
 					$sth->execute();
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
 			return "success";
624 624
 		} elseif ($globalDBdriver == 'pgsql') {
625 625
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
626
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
627
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
628
-    			try {
626
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
627
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
628
+				try {
629 629
 				
630 630
 				$sth = $this->db->prepare($query);
631 631
 				$sth->execute();
@@ -669,17 +669,17 @@  discard block
 block discarded – undo
669 669
 	}
670 670
 
671 671
 	/**
672
-	* Deletes all info in the table for an ident
673
-	*
674
-	* @return String success or false
675
-	*
676
-	*/
672
+	 * Deletes all info in the table for an ident
673
+	 *
674
+	 * @return String success or false
675
+	 *
676
+	 */
677 677
 	public function deleteLiveSpotterDataByIdent($ident)
678 678
 	{
679 679
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680 680
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
681 681
         
682
-    		try {
682
+			try {
683 683
 			
684 684
 			$sth = $this->db->prepare($query);
685 685
 			$sth->execute(array(':ident' => $ident));
@@ -691,17 +691,17 @@  discard block
 block discarded – undo
691 691
 	}
692 692
 
693 693
 	/**
694
-	* Deletes all info in the table for an id
695
-	*
696
-	* @return String success or false
697
-	*
698
-	*/
694
+	 * Deletes all info in the table for an id
695
+	 *
696
+	 * @return String success or false
697
+	 *
698
+	 */
699 699
 	public function deleteLiveSpotterDataById($id)
700 700
 	{
701 701
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
702 702
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
703 703
         
704
-    		try {
704
+			try {
705 705
 			
706 706
 			$sth = $this->db->prepare($query);
707 707
 			$sth->execute(array(':id' => $id));
@@ -714,11 +714,11 @@  discard block
 block discarded – undo
714 714
 
715 715
 
716 716
 	/**
717
-	* Gets the aircraft ident within the last hour
718
-	*
719
-	* @return String the ident
720
-	*
721
-	*/
717
+	 * Gets the aircraft ident within the last hour
718
+	 *
719
+	 * @return String the ident
720
+	 *
721
+	 */
722 722
 	public function getIdentFromLastHour($ident)
723 723
 	{
724 724
 		global $globalDBdriver, $globalTimezone;
@@ -744,14 +744,14 @@  discard block
 block discarded – undo
744 744
 			$ident_result = $row['ident'];
745 745
 		}
746 746
 		return $ident_result;
747
-        }
747
+		}
748 748
 
749 749
 	/**
750
-	* Check recent aircraft
751
-	*
752
-	* @return String the ident
753
-	*
754
-	*/
750
+	 * Check recent aircraft
751
+	 *
752
+	 * @return String the ident
753
+	 *
754
+	 */
755 755
 	public function checkIdentRecent($ident)
756 756
 	{
757 757
 		global $globalDBdriver, $globalTimezone;
@@ -777,14 +777,14 @@  discard block
 block discarded – undo
777 777
 			$ident_result = $row['flightaware_id'];
778 778
 		}
779 779
 		return $ident_result;
780
-        }
780
+		}
781 781
 
782 782
 	/**
783
-	* Check recent aircraft by id
784
-	*
785
-	* @return String the ident
786
-	*
787
-	*/
783
+	 * Check recent aircraft by id
784
+	 *
785
+	 * @return String the ident
786
+	 *
787
+	 */
788 788
 	public function checkIdRecent($id)
789 789
 	{
790 790
 		global $globalDBdriver, $globalTimezone;
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
 			$ident_result = $row['flightaware_id'];
811 811
 		}
812 812
 		return $ident_result;
813
-        }
813
+		}
814 814
 
815 815
 	/**
816
-	* Check recent aircraft by ModeS
817
-	*
818
-	* @return String the ModeS
819
-	*
820
-	*/
816
+	 * Check recent aircraft by ModeS
817
+	 *
818
+	 * @return String the ModeS
819
+	 *
820
+	 */
821 821
 	public function checkModeSRecent($modes)
822 822
 	{
823 823
 		global $globalDBdriver, $globalTimezone;
@@ -844,19 +844,19 @@  discard block
 block discarded – undo
844 844
 			$ident_result = $row['flightaware_id'];
845 845
 		}
846 846
 		return $ident_result;
847
-        }
847
+		}
848 848
 
849 849
 	/**
850
-	* Adds a new spotter data
851
-	*
852
-	* @param String $flightaware_id the ID from flightaware
853
-	* @param String $ident the flight ident
854
-	* @param String $aircraft_icao the aircraft type
855
-	* @param String $departure_airport_icao the departure airport
856
-	* @param String $arrival_airport_icao the arrival airport
857
-	* @return String success or false
858
-	*
859
-	*/
850
+	 * Adds a new spotter data
851
+	 *
852
+	 * @param String $flightaware_id the ID from flightaware
853
+	 * @param String $ident the flight ident
854
+	 * @param String $aircraft_icao the aircraft type
855
+	 * @param String $departure_airport_icao the departure airport
856
+	 * @param String $arrival_airport_icao the arrival airport
857
+	 * @return String success or false
858
+	 *
859
+	 */
860 860
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
861 861
 	{
862 862
 		global $globalURL, $globalArchive, $globalDebug;
@@ -991,10 +991,10 @@  discard block
 block discarded – undo
991 991
 		$arrival_airport_country = '';
992 992
 		
993 993
             	
994
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
995
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
996
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
997
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
994
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
995
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
996
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
997
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
998 998
             	
999 999
 		$query  = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
1000 1000
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
@@ -1004,14 +1004,14 @@  discard block
 block discarded – undo
1004 1004
 			
1005 1005
 			$sth = $this->db->prepare($query);
1006 1006
 			$sth->execute($query_values);
1007
-                } catch(PDOException $e) {
1008
-                	return "error : ".$e->getMessage();
1009
-                }
1007
+				} catch(PDOException $e) {
1008
+					return "error : ".$e->getMessage();
1009
+				}
1010 1010
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1011
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1012
-		    $SpotterArchive = new SpotterArchive($this->db);
1013
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1014
-		    if ($globalDebug) echo $result.')';
1011
+			if ($globalDebug) echo '(Add to SBS archive : ';
1012
+			$SpotterArchive = new SpotterArchive($this->db);
1013
+			$result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1014
+			if ($globalDebug) echo $result.')';
1015 1015
 		}
1016 1016
 		return "success";
1017 1017
 
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Indentation   +645 added lines, -645 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
 		$this->db = $Connection->db;
9 9
 	}
10 10
 
11
-    /**
12
-    * Get SQL query part for filter used
13
-    * @param Array $filter the filter
14
-    * @return Array the SQL part
15
-    */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
11
+	/**
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16
+	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
@@ -27,74 +27,74 @@  discard block
 block discarded – undo
27 27
 	$filter_query_join = '';
28 28
 	$filter_query_where = '';
29 29
 	foreach($filters as $flt) {
30
-	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
30
+		if (isset($flt['airlines']) && !empty($flt['airlines'])) {
31 31
 		if ($flt['airlines'][0] != '') {
32
-		    if (isset($flt['source'])) {
32
+			if (isset($flt['source'])) {
33 33
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
34
-		    } else {
34
+			} else {
35 35
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
36
-		    }
36
+			}
37
+		}
37 38
 		}
38
-	    }
39
-	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
39
+		if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
40 40
 		if (isset($flt['source'])) {
41
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
41
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
42 42
 		} else {
43
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
43
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
44 44
 		}
45
-	    }
46
-	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
45
+		}
46
+		if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
47 47
 		if (isset($flt['source'])) {
48
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
48
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
49
+		}
49 50
 		}
50
-	    }
51 51
 	}
52 52
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
53
-	    if ($filter['airlines'][0] != '') {
53
+		if ($filter['airlines'][0] != '') {
54 54
 		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
55
-	    }
55
+		}
56 56
 	}
57 57
 	
58 58
 	if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
59
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
59
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
60 60
 	}
61 61
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
62
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
62
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
63 63
 	}
64 64
 	if (isset($filter['source']) && !empty($filter['source'])) {
65
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
65
+		$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
66 66
 	}
67 67
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
68
-	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
68
+		$filter_query_where .= " AND ident = '".$filter['ident']."'";
69 69
 	}
70 70
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
71 71
 		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
72 72
 	}
73 73
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
74
-	    $filter_query_date = '';
74
+		$filter_query_date = '';
75 75
 	    
76
-	    if (isset($filter['year']) && $filter['year'] != '') {
76
+		if (isset($filter['year']) && $filter['year'] != '') {
77 77
 		if ($globalDBdriver == 'mysql') {
78
-		    $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
78
+			$filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
79 79
 		} else {
80
-		    $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
80
+			$filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
81 81
 		}
82
-	    }
83
-	    if (isset($filter['month']) && $filter['month'] != '') {
82
+		}
83
+		if (isset($filter['month']) && $filter['month'] != '') {
84 84
 		if ($globalDBdriver == 'mysql') {
85
-		    $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
85
+			$filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
86 86
 		} else {
87
-		    $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
87
+			$filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
88
+		}
88 89
 		}
89
-	    }
90
-	    if (isset($filter['day']) && $filter['day'] != '') {
90
+		if (isset($filter['day']) && $filter['day'] != '') {
91 91
 		if ($globalDBdriver == 'mysql') {
92
-		    $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
92
+			$filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
93 93
 		} else {
94
-		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
94
+			$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
95
+		}
95 96
 		}
96
-	    }
97
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
97
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
98 98
 	}
99 99
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
100 100
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	}
104 104
 	$filter_query = $filter_query_join.$filter_query_where;
105 105
 	return $filter_query;
106
-    }
106
+	}
107 107
 
108 108
 	// Spotter_archive
109 109
 	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
@@ -134,44 +134,44 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 
137
-        /**
138
-        * Gets all the spotter information based on a particular callsign
139
-        *
140
-        * @return Array the spotter information
141
-        *
142
-        */
143
-        public function getLastArchiveSpotterDataByIdent($ident)
144
-        {
137
+		/**
138
+		 * Gets all the spotter information based on a particular callsign
139
+		 *
140
+		 * @return Array the spotter information
141
+		 *
142
+		 */
143
+		public function getLastArchiveSpotterDataByIdent($ident)
144
+		{
145 145
 		$Spotter = new Spotter($this->db);
146
-                date_default_timezone_set('UTC');
146
+				date_default_timezone_set('UTC');
147 147
 
148
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
149
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
150
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
148
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
149
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
150
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
151 151
 
152
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
152
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
153 153
 
154
-                return $spotter_array;
155
-        }
154
+				return $spotter_array;
155
+		}
156 156
 
157 157
 
158
-        /**
159
-        * Gets last the spotter information based on a particular id
160
-        *
161
-        * @return Array the spotter information
162
-        *
163
-        */
164
-        public function getLastArchiveSpotterDataById($id)
165
-        {
166
-    		$Spotter = new Spotter($this->db);
167
-                date_default_timezone_set('UTC');
168
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
169
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
170
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
171
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
158
+		/**
159
+		 * Gets last the spotter information based on a particular id
160
+		 *
161
+		 * @return Array the spotter information
162
+		 *
163
+		 */
164
+		public function getLastArchiveSpotterDataById($id)
165
+		{
166
+			$Spotter = new Spotter($this->db);
167
+				date_default_timezone_set('UTC');
168
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
169
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
170
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
171
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
172 172
 
173 173
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
174
-                  /*
174
+				  /*
175 175
                 try {
176 176
                         $Connection = new Connection();
177 177
                         $sth = Connection->$db->prepare($query);
@@ -181,232 +181,232 @@  discard block
 block discarded – undo
181 181
                 }
182 182
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
183 183
                 */
184
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
185
-
186
-                return $spotter_array;
187
-        }
188
-
189
-        /**
190
-        * Gets all the spotter information based on a particular id
191
-        *
192
-        * @return Array the spotter information
193
-        *
194
-        */
195
-        public function getAllArchiveSpotterDataById($id)
196
-        {
197
-                date_default_timezone_set('UTC');
198
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
199
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
184
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
185
+
186
+				return $spotter_array;
187
+		}
188
+
189
+		/**
190
+		 * Gets all the spotter information based on a particular id
191
+		 *
192
+		 * @return Array the spotter information
193
+		 *
194
+		 */
195
+		public function getAllArchiveSpotterDataById($id)
196
+		{
197
+				date_default_timezone_set('UTC');
198
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
199
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
200 200
 
201 201
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
202 202
 
203
-                try {
204
-                        $sth = $this->db->prepare($query);
205
-                        $sth->execute(array(':id' => $id));
206
-                } catch(PDOException $e) {
207
-                        echo $e->getMessage();
208
-                        die;
209
-                }
210
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
211
-
212
-                return $spotter_array;
213
-        }
214
-
215
-        /**
216
-        * Gets coordinate & time spotter information based on a particular id
217
-        *
218
-        * @return Array the spotter information
219
-        *
220
-        */
221
-        public function getCoordArchiveSpotterDataById($id)
222
-        {
223
-                date_default_timezone_set('UTC');
224
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
225
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
203
+				try {
204
+						$sth = $this->db->prepare($query);
205
+						$sth->execute(array(':id' => $id));
206
+				} catch(PDOException $e) {
207
+						echo $e->getMessage();
208
+						die;
209
+				}
210
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
211
+
212
+				return $spotter_array;
213
+		}
214
+
215
+		/**
216
+		 * Gets coordinate & time spotter information based on a particular id
217
+		 *
218
+		 * @return Array the spotter information
219
+		 *
220
+		 */
221
+		public function getCoordArchiveSpotterDataById($id)
222
+		{
223
+				date_default_timezone_set('UTC');
224
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
225
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
226 226
 
227 227
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
228 228
 
229
-                try {
230
-                        $sth = $this->db->prepare($query);
231
-                        $sth->execute(array(':id' => $id));
232
-                } catch(PDOException $e) {
233
-                        echo $e->getMessage();
234
-                        die;
235
-                }
236
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
+				try {
230
+						$sth = $this->db->prepare($query);
231
+						$sth->execute(array(':id' => $id));
232
+				} catch(PDOException $e) {
233
+						echo $e->getMessage();
234
+						die;
235
+				}
236
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
237 237
 
238
-                return $spotter_array;
239
-        }
238
+				return $spotter_array;
239
+		}
240 240
 
241 241
 
242
-        /**
243
-        * Gets altitude information based on a particular callsign
244
-        *
245
-        * @return Array the spotter information
246
-        *
247
-        */
248
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
249
-        {
242
+		/**
243
+		 * Gets altitude information based on a particular callsign
244
+		 *
245
+		 * @return Array the spotter information
246
+		 *
247
+		 */
248
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
249
+		{
250 250
 
251
-                date_default_timezone_set('UTC');
251
+				date_default_timezone_set('UTC');
252 252
 
253
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
254
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
253
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
254
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
255 255
 
256
-                try {
257
-                        $sth = $this->db->prepare($query);
258
-                        $sth->execute(array(':ident' => $ident));
259
-                } catch(PDOException $e) {
260
-                        echo $e->getMessage();
261
-                        die;
262
-                }
263
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
256
+				try {
257
+						$sth = $this->db->prepare($query);
258
+						$sth->execute(array(':ident' => $ident));
259
+				} catch(PDOException $e) {
260
+						echo $e->getMessage();
261
+						die;
262
+				}
263
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
 
265
-                return $spotter_array;
266
-        }
265
+				return $spotter_array;
266
+		}
267 267
 
268
-        /**
269
-        * Gets altitude information based on a particular id
270
-        *
271
-        * @return Array the spotter information
272
-        *
273
-        */
274
-        public function getAltitudeArchiveSpotterDataById($id)
275
-        {
268
+		/**
269
+		 * Gets altitude information based on a particular id
270
+		 *
271
+		 * @return Array the spotter information
272
+		 *
273
+		 */
274
+		public function getAltitudeArchiveSpotterDataById($id)
275
+		{
276 276
 
277
-                date_default_timezone_set('UTC');
277
+				date_default_timezone_set('UTC');
278 278
 
279
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
280
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
279
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
280
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
281 281
 
282
-                try {
283
-                        $sth = $this->db->prepare($query);
284
-                        $sth->execute(array(':id' => $id));
285
-                } catch(PDOException $e) {
286
-                        echo $e->getMessage();
287
-                        die;
288
-                }
289
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
282
+				try {
283
+						$sth = $this->db->prepare($query);
284
+						$sth->execute(array(':id' => $id));
285
+				} catch(PDOException $e) {
286
+						echo $e->getMessage();
287
+						die;
288
+				}
289
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
290 290
 
291
-                return $spotter_array;
292
-        }
291
+				return $spotter_array;
292
+		}
293 293
 
294
-        /**
295
-        * Gets altitude & speed information based on a particular id
296
-        *
297
-        * @return Array the spotter information
298
-        *
299
-        */
300
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
301
-        {
294
+		/**
295
+		 * Gets altitude & speed information based on a particular id
296
+		 *
297
+		 * @return Array the spotter information
298
+		 *
299
+		 */
300
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
301
+		{
302 302
 
303
-                date_default_timezone_set('UTC');
303
+				date_default_timezone_set('UTC');
304 304
 
305
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
306
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
305
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
306
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
307 307
 
308
-                try {
309
-                        $sth = $this->db->prepare($query);
310
-                        $sth->execute(array(':id' => $id));
311
-                } catch(PDOException $e) {
312
-                        echo $e->getMessage();
313
-                        die;
314
-                }
315
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
308
+				try {
309
+						$sth = $this->db->prepare($query);
310
+						$sth->execute(array(':id' => $id));
311
+				} catch(PDOException $e) {
312
+						echo $e->getMessage();
313
+						die;
314
+				}
315
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
316 316
 
317
-                return $spotter_array;
318
-        }
317
+				return $spotter_array;
318
+		}
319 319
 
320 320
 
321
-        /**
322
-        * Gets altitude information based on a particular callsign
323
-        *
324
-        * @return Array the spotter information
325
-        *
326
-        */
327
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
328
-        {
321
+		/**
322
+		 * Gets altitude information based on a particular callsign
323
+		 *
324
+		 * @return Array the spotter information
325
+		 *
326
+		 */
327
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
328
+		{
329 329
 
330
-                date_default_timezone_set('UTC');
330
+				date_default_timezone_set('UTC');
331 331
 
332
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
332
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
334 334
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
335 335
 
336
-                try {
337
-                        $sth = $this->db->prepare($query);
338
-                        $sth->execute(array(':ident' => $ident));
339
-                } catch(PDOException $e) {
340
-                        echo $e->getMessage();
341
-                        die;
342
-                }
343
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
336
+				try {
337
+						$sth = $this->db->prepare($query);
338
+						$sth->execute(array(':ident' => $ident));
339
+				} catch(PDOException $e) {
340
+						echo $e->getMessage();
341
+						die;
342
+				}
343
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
344 344
 
345
-                return $spotter_array;
346
-        }
345
+				return $spotter_array;
346
+		}
347 347
 
348 348
 
349 349
 
350
-       /**
351
-        * Gets all the archive spotter information
352
-        *
353
-        * @return Array the spotter information
354
-        *
355
-        */
356
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
357
-        {
358
-    		$Spotter = new Spotter($this->db);
359
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
360
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
350
+	   /**
351
+	    * Gets all the archive spotter information
352
+	    *
353
+	    * @return Array the spotter information
354
+	    *
355
+	    */
356
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
357
+		{
358
+			$Spotter = new Spotter($this->db);
359
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
360
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
361 361
 
362
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
362
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
363 363
 
364
-                return $spotter_array;
365
-        }
364
+				return $spotter_array;
365
+		}
366 366
         
367
-        public function deleteSpotterArchiveTrackData()
368
-        {
367
+		public function deleteSpotterArchiveTrackData()
368
+		{
369 369
 		global $globalArchiveKeepTrackMonths;
370
-                date_default_timezone_set('UTC');
370
+				date_default_timezone_set('UTC');
371 371
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
372
-                try {
373
-                        $sth = $this->db->prepare($query);
374
-                        $sth->execute();
375
-                } catch(PDOException $e) {
376
-                        echo $e->getMessage();
377
-                        die;
378
-                }
372
+				try {
373
+						$sth = $this->db->prepare($query);
374
+						$sth->execute();
375
+				} catch(PDOException $e) {
376
+						echo $e->getMessage();
377
+						die;
378
+				}
379 379
 	}
380 380
 
381 381
 	/**
382
-        * Gets Minimal Live Spotter data
383
-        *
384
-        * @return Array the spotter information
385
-        *
386
-        */
387
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
388
-        {
389
-                global $globalDBdriver, $globalLiveInterval;
390
-                date_default_timezone_set('UTC');
391
-
392
-                $filter_query = '';
393
-                if (isset($filter['source']) && !empty($filter['source'])) {
394
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
395
-                }
396
-                // Use spotter_output also ?
397
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
398
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
399
-                }
400
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
401
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
402
-                }
403
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
404
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
405
-                }
406
-
407
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
408
-                if ($globalDBdriver == 'mysql') {
409
-                        /*
382
+	 * Gets Minimal Live Spotter data
383
+	 *
384
+	 * @return Array the spotter information
385
+	 *
386
+	 */
387
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
388
+		{
389
+				global $globalDBdriver, $globalLiveInterval;
390
+				date_default_timezone_set('UTC');
391
+
392
+				$filter_query = '';
393
+				if (isset($filter['source']) && !empty($filter['source'])) {
394
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
395
+				}
396
+				// Use spotter_output also ?
397
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
398
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
399
+				}
400
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
401
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
402
+				}
403
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
404
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
405
+				}
406
+
407
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
408
+				if ($globalDBdriver == 'mysql') {
409
+						/*
410 410
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
411 411
                     		    FROM spotter_archive 
412 412
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -425,56 +425,56 @@  discard block
 block discarded – undo
425 425
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
426 426
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
427 427
                         	    '.$filter_query.' ORDER BY flightaware_id';
428
-                } else {
429
-                        //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
430
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
428
+				} else {
429
+						//$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
430
+						$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
431 431
                         	    FROM spotter_archive 
432 432
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
433 433
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
434 434
                         	    '.$filter_query.' ORDER BY flightaware_id';
435
-                }
436
-                //echo $query;
437
-                try {
438
-                        $sth = $this->db->prepare($query);
439
-                        $sth->execute();
440
-                } catch(PDOException $e) {
441
-                        echo $e->getMessage();
442
-                        die;
443
-                }
444
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
445
-
446
-                return $spotter_array;
447
-        }
435
+				}
436
+				//echo $query;
437
+				try {
438
+						$sth = $this->db->prepare($query);
439
+						$sth->execute();
440
+				} catch(PDOException $e) {
441
+						echo $e->getMessage();
442
+						die;
443
+				}
444
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
445
+
446
+				return $spotter_array;
447
+		}
448 448
 
449 449
 	/**
450
-        * Gets Minimal Live Spotter data
451
-        *
452
-        * @return Array the spotter information
453
-        *
454
-        */
455
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
456
-        {
457
-                global $globalDBdriver, $globalLiveInterval;
458
-                date_default_timezone_set('UTC');
459
-
460
-                $filter_query = '';
461
-                if (isset($filter['source']) && !empty($filter['source'])) {
462
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
463
-                }
464
-                // Should use spotter_output also ?
465
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
466
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
467
-                }
468
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
469
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
470
-                }
471
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
472
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
473
-                }
474
-
475
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
476
-                if ($globalDBdriver == 'mysql') {
477
-                        /*
450
+	 * Gets Minimal Live Spotter data
451
+	 *
452
+	 * @return Array the spotter information
453
+	 *
454
+	 */
455
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
456
+		{
457
+				global $globalDBdriver, $globalLiveInterval;
458
+				date_default_timezone_set('UTC');
459
+
460
+				$filter_query = '';
461
+				if (isset($filter['source']) && !empty($filter['source'])) {
462
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
463
+				}
464
+				// Should use spotter_output also ?
465
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
466
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
467
+				}
468
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
469
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
470
+				}
471
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
472
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
473
+				}
474
+
475
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
476
+				if ($globalDBdriver == 'mysql') {
477
+						/*
478 478
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
479 479
                     		    FROM spotter_archive 
480 480
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -485,95 +485,95 @@  discard block
 block discarded – undo
485 485
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
486 486
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
487 487
 
488
-                } else {
489
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
490
-                       /*
488
+				} else {
489
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
490
+					   /*
491 491
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
492 492
                         	    FROM spotter_archive_output 
493 493
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
494 494
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
495 495
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
496 496
                         */
497
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
497
+						$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
498 498
                         	    FROM spotter_archive_output 
499 499
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
500 500
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
501 501
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
502 502
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
503 503
                         	    
504
-                }
505
-                //echo $query;
506
-                try {
507
-                        $sth = $this->db->prepare($query);
508
-                        $sth->execute();
509
-                } catch(PDOException $e) {
510
-                        echo $e->getMessage();
511
-                        die;
512
-                }
513
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
514
-
515
-                return $spotter_array;
516
-        }
504
+				}
505
+				//echo $query;
506
+				try {
507
+						$sth = $this->db->prepare($query);
508
+						$sth->execute();
509
+				} catch(PDOException $e) {
510
+						echo $e->getMessage();
511
+						die;
512
+				}
513
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
514
+
515
+				return $spotter_array;
516
+		}
517 517
 
518 518
 	 /**
519
-        * Gets count Live Spotter data
520
-        *
521
-        * @return Array the spotter information
522
-        *
523
-        */
524
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
525
-        {
526
-                global $globalDBdriver, $globalLiveInterval;
527
-                date_default_timezone_set('UTC');
528
-
529
-                $filter_query = '';
530
-                if (isset($filter['source']) && !empty($filter['source'])) {
531
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
532
-                }
533
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
534
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
535
-                }
536
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
537
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
538
-                }
539
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
540
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
541
-                }
542
-
543
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
544
-                if ($globalDBdriver == 'mysql') {
519
+	  * Gets count Live Spotter data
520
+	  *
521
+	  * @return Array the spotter information
522
+	  *
523
+	  */
524
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
525
+		{
526
+				global $globalDBdriver, $globalLiveInterval;
527
+				date_default_timezone_set('UTC');
528
+
529
+				$filter_query = '';
530
+				if (isset($filter['source']) && !empty($filter['source'])) {
531
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
532
+				}
533
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
534
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
535
+				}
536
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
537
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
538
+				}
539
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
540
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
541
+				}
542
+
543
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
544
+				if ($globalDBdriver == 'mysql') {
545 545
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
546 546
 			FROM spotter_archive l 
547 547
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
548
-                } else {
548
+				} else {
549 549
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
550
-                }
551
-                //echo $query;
552
-                try {
553
-                        $sth = $this->db->prepare($query);
554
-                        $sth->execute();
555
-                } catch(PDOException $e) {
556
-                        echo $e->getMessage();
557
-                        die;
558
-                }
550
+				}
551
+				//echo $query;
552
+				try {
553
+						$sth = $this->db->prepare($query);
554
+						$sth->execute();
555
+				} catch(PDOException $e) {
556
+						echo $e->getMessage();
557
+						die;
558
+				}
559 559
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
560 560
 		$sth->closeCursor();
561
-                return $result['nb'];
561
+				return $result['nb'];
562 562
 
563
-        }
563
+		}
564 564
 
565 565
 
566 566
 
567 567
 	// Spotter_Archive_output
568 568
 	
569
-    /**
570
-    * Gets all the spotter information
571
-    *
572
-    * @return Array the spotter information
573
-    *
574
-    */
575
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
576
-    {
569
+	/**
570
+	 * Gets all the spotter information
571
+	 *
572
+	 * @return Array the spotter information
573
+	 *
574
+	 */
575
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
576
+	{
577 577
 	global $globalTimezone, $globalDBdriver;
578 578
 	require_once(dirname(__FILE__).'/class.Translation.php');
579 579
 	$Translation = new Translation();
@@ -587,159 +587,159 @@  discard block
 block discarded – undo
587 587
 	$filter_query = $this->getFilter($filters);
588 588
 	if ($q != "")
589 589
 	{
590
-	    if (!is_string($q))
591
-	    {
590
+		if (!is_string($q))
591
+		{
592 592
 		return false;
593
-	    } else {
593
+		} else {
594 594
 	        
595 595
 		$q_array = explode(" ", $q);
596 596
 		
597 597
 		foreach ($q_array as $q_item){
598
-		    $additional_query .= " AND (";
599
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
600
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
601
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
602
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
603
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
604
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
605
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
606
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
607
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
608
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
609
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
610
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
611
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
612
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
613
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
614
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
615
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
616
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
617
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
618
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
619
-		    $translate = $Translation->ident2icao($q_item);
620
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
621
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
622
-		    $additional_query .= ")";
623
-		}
624
-	    }
598
+			$additional_query .= " AND (";
599
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
600
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
601
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
602
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
603
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
604
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
605
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
606
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
607
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
608
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
609
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
610
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
611
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
612
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
613
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
614
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
615
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
616
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
617
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
618
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
619
+			$translate = $Translation->ident2icao($q_item);
620
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
621
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
622
+			$additional_query .= ")";
623
+		}
624
+		}
625 625
 	}
626 626
 	
627 627
 	if ($registration != "")
628 628
 	{
629
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
630
-	    if (!is_string($registration))
631
-	    {
629
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
630
+		if (!is_string($registration))
631
+		{
632 632
 		return false;
633
-	    } else {
633
+		} else {
634 634
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
635
-	    }
635
+		}
636 636
 	}
637 637
 	
638 638
 	if ($aircraft_icao != "")
639 639
 	{
640
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
641
-	    if (!is_string($aircraft_icao))
642
-	    {
640
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
641
+		if (!is_string($aircraft_icao))
642
+		{
643 643
 		return false;
644
-	    } else {
644
+		} else {
645 645
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
646
-	    }
646
+		}
647 647
 	}
648 648
 	
649 649
 	if ($aircraft_manufacturer != "")
650 650
 	{
651
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
652
-	    if (!is_string($aircraft_manufacturer))
653
-	    {
651
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
652
+		if (!is_string($aircraft_manufacturer))
653
+		{
654 654
 		return false;
655
-	    } else {
655
+		} else {
656 656
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
657
-	    }
657
+		}
658 658
 	}
659 659
 	
660 660
 	if ($highlights == "true")
661 661
 	{
662
-	    if (!is_string($highlights))
663
-	    {
662
+		if (!is_string($highlights))
663
+		{
664 664
 		return false;
665
-	    } else {
665
+		} else {
666 666
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
667
-	    }
667
+		}
668 668
 	}
669 669
 	
670 670
 	if ($airline_icao != "")
671 671
 	{
672
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
673
-	    if (!is_string($airline_icao))
674
-	    {
672
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
673
+		if (!is_string($airline_icao))
674
+		{
675 675
 		return false;
676
-	    } else {
676
+		} else {
677 677
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
678
-	    }
678
+		}
679 679
 	}
680 680
 	
681 681
 	if ($airline_country != "")
682 682
 	{
683
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
684
-	    if (!is_string($airline_country))
685
-	    {
683
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
684
+		if (!is_string($airline_country))
685
+		{
686 686
 		return false;
687
-	    } else {
687
+		} else {
688 688
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
689
-	    }
689
+		}
690 690
 	}
691 691
 	
692 692
 	if ($airline_type != "")
693 693
 	{
694
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
695
-	    if (!is_string($airline_type))
696
-	    {
694
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
695
+		if (!is_string($airline_type))
696
+		{
697 697
 		return false;
698
-	    } else {
698
+		} else {
699 699
 		if ($airline_type == "passenger")
700 700
 		{
701
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
701
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
702 702
 		}
703 703
 		if ($airline_type == "cargo")
704 704
 		{
705
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
705
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
706 706
 		}
707 707
 		if ($airline_type == "military")
708 708
 		{
709
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
709
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
710
+		}
710 711
 		}
711
-	    }
712 712
 	}
713 713
 	
714 714
 	if ($airport != "")
715 715
 	{
716
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
717
-	    if (!is_string($airport))
718
-	    {
716
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
717
+		if (!is_string($airport))
718
+		{
719 719
 		return false;
720
-	    } else {
720
+		} else {
721 721
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
722
-	    }
722
+		}
723 723
 	}
724 724
 	
725 725
 	if ($airport_country != "")
726 726
 	{
727
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
728
-	    if (!is_string($airport_country))
729
-	    {
727
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
728
+		if (!is_string($airport_country))
729
+		{
730 730
 		return false;
731
-	    } else {
731
+		} else {
732 732
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
733
-	    }
733
+		}
734 734
 	}
735 735
     
736 736
 	if ($callsign != "")
737 737
 	{
738
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
739
-	    if (!is_string($callsign))
740
-	    {
738
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
739
+		if (!is_string($callsign))
740
+		{
741 741
 		return false;
742
-	    } else {
742
+		} else {
743 743
 		$translate = $Translation->ident2icao($callsign);
744 744
 		if ($translate != $callsign) {
745 745
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -747,99 +747,99 @@  discard block
 block discarded – undo
747 747
 		} else {
748 748
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
749 749
 		}
750
-	    }
750
+		}
751 751
 	}
752 752
 
753 753
 	if ($owner != "")
754 754
 	{
755
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
756
-	    if (!is_string($owner))
757
-	    {
755
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
756
+		if (!is_string($owner))
757
+		{
758 758
 		return false;
759
-	    } else {
759
+		} else {
760 760
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
761
-	    }
761
+		}
762 762
 	}
763 763
 
764 764
 	if ($pilot_name != "")
765 765
 	{
766
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
767
-	    if (!is_string($pilot_name))
768
-	    {
766
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
767
+		if (!is_string($pilot_name))
768
+		{
769 769
 		return false;
770
-	    } else {
770
+		} else {
771 771
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
772
-	    }
772
+		}
773 773
 	}
774 774
 	
775 775
 	if ($pilot_id != "")
776 776
 	{
777
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
778
-	    if (!is_string($pilot_id))
779
-	    {
777
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
778
+		if (!is_string($pilot_id))
779
+		{
780 780
 		return false;
781
-	    } else {
781
+		} else {
782 782
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
783
-	    }
783
+		}
784 784
 	}
785 785
 	
786 786
 	if ($departure_airport_route != "")
787 787
 	{
788
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
789
-	    if (!is_string($departure_airport_route))
790
-	    {
788
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
789
+		if (!is_string($departure_airport_route))
790
+		{
791 791
 		return false;
792
-	    } else {
792
+		} else {
793 793
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
794
-	    }
794
+		}
795 795
 	}
796 796
 	
797 797
 	if ($arrival_airport_route != "")
798 798
 	{
799
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
800
-	    if (!is_string($arrival_airport_route))
801
-	    {
799
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
800
+		if (!is_string($arrival_airport_route))
801
+		{
802 802
 		return false;
803
-	    } else {
803
+		} else {
804 804
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
805
-	    }
805
+		}
806 806
 	}
807 807
 	
808 808
 	if ($altitude != "")
809 809
 	{
810
-	    $altitude_array = explode(",", $altitude);
810
+		$altitude_array = explode(",", $altitude);
811 811
 	    
812
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
813
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
812
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
813
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
814 814
 	    
815 815
 
816
-	    if ($altitude_array[1] != "")
817
-	    {                
816
+		if ($altitude_array[1] != "")
817
+		{                
818 818
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
819 819
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
820 820
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
821
-	    } else {
821
+		} else {
822 822
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
823 823
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
824
-	    }
824
+		}
825 825
 	}
826 826
 	
827 827
 	if ($date_posted != "")
828 828
 	{
829
-	    $date_array = explode(",", $date_posted);
829
+		$date_array = explode(",", $date_posted);
830 830
 	    
831
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
832
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
831
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
832
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
833 833
 	    
834
-	    if ($globalTimezone != '') {
834
+		if ($globalTimezone != '') {
835 835
 		date_default_timezone_set($globalTimezone);
836 836
 		$datetime = new DateTime();
837 837
 		$offset = $datetime->format('P');
838
-	    } else $offset = '+00:00';
838
+		} else $offset = '+00:00';
839 839
 
840 840
 
841
-	    if ($date_array[1] != "")
842
-	    {                
841
+		if ($date_array[1] != "")
842
+		{                
843 843
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
844 844
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
845 845
 		if ($globalDBdriver == 'mysql') {
@@ -847,28 +847,28 @@  discard block
 block discarded – undo
847 847
 		} else {
848 848
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
849 849
 		}
850
-	    } else {
850
+		} else {
851 851
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
852
-                if ($globalDBdriver == 'mysql') {
852
+				if ($globalDBdriver == 'mysql') {
853 853
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
854 854
 		} else {
855 855
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
856 856
 		}
857
-	    }
857
+		}
858 858
 	}
859 859
 	
860 860
 	if ($limit != "")
861 861
 	{
862
-	    $limit_array = explode(",", $limit);
862
+		$limit_array = explode(",", $limit);
863 863
 	    
864
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
865
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
864
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
865
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
866 866
 	    
867
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
868
-	    {
867
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
868
+		{
869 869
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
870 870
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
871
-	    }
871
+		}
872 872
 	}
873 873
 	
874 874
 
@@ -899,33 +899,33 @@  discard block
 block discarded – undo
899 899
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
900 900
 
901 901
 	return $spotter_array;
902
-    }
902
+	}
903 903
 
904
-    public function deleteSpotterArchiveData()
905
-    {
904
+	public function deleteSpotterArchiveData()
905
+	{
906 906
 		global $globalArchiveKeepMonths, $globalDBdriver;
907
-                date_default_timezone_set('UTC');
908
-                if ($globalDBdriver == 'mysql') {
907
+				date_default_timezone_set('UTC');
908
+				if ($globalDBdriver == 'mysql') {
909 909
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
910 910
 		} else {
911 911
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
912 912
 		}
913
-                try {
914
-                        $sth = $this->db->prepare($query);
915
-                        $sth->execute();
916
-                } catch(PDOException $e) {
917
-                        return "error";
918
-                }
913
+				try {
914
+						$sth = $this->db->prepare($query);
915
+						$sth->execute();
916
+				} catch(PDOException $e) {
917
+						return "error";
918
+				}
919 919
 	}
920 920
 
921
-    /**
922
-    * Gets all the spotter information based on the callsign
923
-    *
924
-    * @return Array the spotter information
925
-    *
926
-    */
927
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
928
-    {
921
+	/**
922
+	 * Gets all the spotter information based on the callsign
923
+	 *
924
+	 * @return Array the spotter information
925
+	 *
926
+	 */
927
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
928
+	{
929 929
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
930 930
 	
931 931
 	date_default_timezone_set('UTC');
@@ -937,35 +937,35 @@  discard block
 block discarded – undo
937 937
 	
938 938
 	if ($ident != "")
939 939
 	{
940
-	    if (!is_string($ident))
941
-	    {
940
+		if (!is_string($ident))
941
+		{
942 942
 		return false;
943
-	    } else {
943
+		} else {
944 944
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
945 945
 		$query_values = array(':ident' => $ident);
946
-	    }
946
+		}
947 947
 	}
948 948
 	
949 949
 	if ($limit != "")
950 950
 	{
951
-	    $limit_array = explode(",", $limit);
951
+		$limit_array = explode(",", $limit);
952 952
 	    
953
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
954
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
953
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
954
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
955 955
 	    
956
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
957
-	    {
956
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
957
+		{
958 958
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
959 959
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
960
-	    }
960
+		}
961 961
 	}
962 962
 
963 963
 	if ($sort != "")
964 964
 	{
965
-	    $search_orderby_array = $Spotter->getOrderBy();
966
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
965
+		$search_orderby_array = $Spotter->getOrderBy();
966
+		$orderby_query = $search_orderby_array[$sort]['sql'];
967 967
 	} else {
968
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
968
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
969 969
 	}
970 970
 
971 971
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -973,17 +973,17 @@  discard block
 block discarded – undo
973 973
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
974 974
 
975 975
 	return $spotter_array;
976
-    }
976
+	}
977 977
 
978 978
 
979
-    /**
980
-    * Gets all the spotter information based on the owner
981
-    *
982
-    * @return Array the spotter information
983
-    *
984
-    */
985
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
986
-    {
979
+	/**
980
+	 * Gets all the spotter information based on the owner
981
+	 *
982
+	 * @return Array the spotter information
983
+	 *
984
+	 */
985
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
986
+	{
987 987
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
988 988
 	
989 989
 	date_default_timezone_set('UTC');
@@ -996,35 +996,35 @@  discard block
 block discarded – undo
996 996
 	
997 997
 	if ($owner != "")
998 998
 	{
999
-	    if (!is_string($owner))
1000
-	    {
999
+		if (!is_string($owner))
1000
+		{
1001 1001
 		return false;
1002
-	    } else {
1002
+		} else {
1003 1003
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
1004 1004
 		$query_values = array(':owner' => $owner);
1005
-	    }
1005
+		}
1006 1006
 	}
1007 1007
 	
1008 1008
 	if ($limit != "")
1009 1009
 	{
1010
-	    $limit_array = explode(",", $limit);
1010
+		$limit_array = explode(",", $limit);
1011 1011
 	    
1012
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1013
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1012
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1013
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1014 1014
 	    
1015
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1016
-	    {
1015
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1016
+		{
1017 1017
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1018 1018
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1019
-	    }
1019
+		}
1020 1020
 	}
1021 1021
 
1022 1022
 	if ($sort != "")
1023 1023
 	{
1024
-	    $search_orderby_array = $Spotter->getOrderBy();
1025
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1024
+		$search_orderby_array = $Spotter->getOrderBy();
1025
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1026 1026
 	} else {
1027
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1027
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1028 1028
 	}
1029 1029
 
1030 1030
 	$query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1032,16 +1032,16 @@  discard block
 block discarded – undo
1032 1032
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1033 1033
 
1034 1034
 	return $spotter_array;
1035
-    }
1036
-
1037
-    /**
1038
-    * Gets all the spotter information based on the pilot
1039
-    *
1040
-    * @return Array the spotter information
1041
-    *
1042
-    */
1043
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1044
-    {
1035
+	}
1036
+
1037
+	/**
1038
+	 * Gets all the spotter information based on the pilot
1039
+	 *
1040
+	 * @return Array the spotter information
1041
+	 *
1042
+	 */
1043
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1044
+	{
1045 1045
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1046 1046
 	
1047 1047
 	date_default_timezone_set('UTC');
@@ -1060,24 +1060,24 @@  discard block
 block discarded – undo
1060 1060
 	
1061 1061
 	if ($limit != "")
1062 1062
 	{
1063
-	    $limit_array = explode(",", $limit);
1063
+		$limit_array = explode(",", $limit);
1064 1064
 	    
1065
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1066
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1065
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1066
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1067 1067
 	    
1068
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1069
-	    {
1068
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1069
+		{
1070 1070
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1071 1071
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1072
-	    }
1072
+		}
1073 1073
 	}
1074 1074
 
1075 1075
 	if ($sort != "")
1076 1076
 	{
1077
-	    $search_orderby_array = $Spotter->getOrderBy();
1078
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1077
+		$search_orderby_array = $Spotter->getOrderBy();
1078
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1079 1079
 	} else {
1080
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1080
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1081 1081
 	}
1082 1082
 
1083 1083
 	$query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1085,16 +1085,16 @@  discard block
 block discarded – undo
1085 1085
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1086 1086
 
1087 1087
 	return $spotter_array;
1088
-    }
1089
-
1090
-    /**
1091
-    * Gets all number of flight over countries
1092
-    *
1093
-    * @return Array the airline country list
1094
-    *
1095
-    */
1096
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1097
-    {
1088
+	}
1089
+
1090
+	/**
1091
+	 * Gets all number of flight over countries
1092
+	 *
1093
+	 * @return Array the airline country list
1094
+	 *
1095
+	 */
1096
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1097
+	{
1098 1098
 	global $globalDBdriver;
1099 1099
 	/*
1100 1100
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1104,14 +1104,14 @@  discard block
 block discarded – undo
1104 1104
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1105 1105
 		    FROM countries c, spotter_archive s
1106 1106
 		    WHERE c.iso2 = s.over_country ";
1107
-                if ($olderthanmonths > 0) {
1108
-            		if ($globalDBdriver == 'mysql') {
1107
+				if ($olderthanmonths > 0) {
1108
+					if ($globalDBdriver == 'mysql') {
1109 1109
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1110 1110
 			} else {
1111 1111
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1112 1112
 			}
1113 1113
 		}
1114
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1114
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1115 1115
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1116 1116
 	if ($limit) $query .= " LIMIT 0,10";
1117 1117
       
@@ -1124,23 +1124,23 @@  discard block
 block discarded – undo
1124 1124
         
1125 1125
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1126 1126
 	{
1127
-	    $temp_array['flight_count'] = $row['nb'];
1128
-	    $temp_array['flight_country'] = $row['name'];
1129
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1130
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1131
-	    $flight_array[] = $temp_array;
1127
+		$temp_array['flight_count'] = $row['nb'];
1128
+		$temp_array['flight_country'] = $row['name'];
1129
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1130
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1131
+		$flight_array[] = $temp_array;
1132 1132
 	}
1133 1133
 	return $flight_array;
1134
-    }
1135
-
1136
-    /**
1137
-    * Gets all number of flight over countries
1138
-    *
1139
-    * @return Array the airline country list
1140
-    *
1141
-    */
1142
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1143
-    {
1134
+	}
1135
+
1136
+	/**
1137
+	 * Gets all number of flight over countries
1138
+	 *
1139
+	 * @return Array the airline country list
1140
+	 *
1141
+	 */
1142
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1143
+	{
1144 1144
 	global $globalDBdriver;
1145 1145
 	/*
1146 1146
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1150,14 +1150,14 @@  discard block
 block discarded – undo
1150 1150
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1151 1151
 		    FROM countries c, spotter_archive s, spotter_output o
1152 1152
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1153
-                if ($olderthanmonths > 0) {
1154
-            		if ($globalDBdriver == 'mysql') {
1153
+				if ($olderthanmonths > 0) {
1154
+					if ($globalDBdriver == 'mysql') {
1155 1155
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1156 1156
 			} else {
1157 1157
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1158 1158
 			}
1159 1159
 		}
1160
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1160
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1161 1161
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1162 1162
 	if ($limit) $query .= " LIMIT 0,10";
1163 1163
       
@@ -1170,24 +1170,24 @@  discard block
 block discarded – undo
1170 1170
         
1171 1171
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1172 1172
 	{
1173
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1174
-	    $temp_array['flight_count'] = $row['nb'];
1175
-	    $temp_array['flight_country'] = $row['name'];
1176
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1177
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1178
-	    $flight_array[] = $temp_array;
1173
+		$temp_array['airline_icao'] = $row['airline_icao'];
1174
+		$temp_array['flight_count'] = $row['nb'];
1175
+		$temp_array['flight_country'] = $row['name'];
1176
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1177
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1178
+		$flight_array[] = $temp_array;
1179 1179
 	}
1180 1180
 	return $flight_array;
1181
-    }
1182
-
1183
-    /**
1184
-    * Gets last spotter information based on a particular callsign
1185
-    *
1186
-    * @return Array the spotter information
1187
-    *
1188
-    */
1189
-    public function getDateArchiveSpotterDataById($id,$date)
1190
-    {
1181
+	}
1182
+
1183
+	/**
1184
+	 * Gets last spotter information based on a particular callsign
1185
+	 *
1186
+	 * @return Array the spotter information
1187
+	 *
1188
+	 */
1189
+	public function getDateArchiveSpotterDataById($id,$date)
1190
+	{
1191 1191
 	$Spotter = new Spotter($this->db);
1192 1192
 	date_default_timezone_set('UTC');
1193 1193
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1195,16 +1195,16 @@  discard block
 block discarded – undo
1195 1195
 	$date = date('c',$date);
1196 1196
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1197 1197
 	return $spotter_array;
1198
-    }
1199
-
1200
-    /**
1201
-    * Gets all the spotter information based on a particular callsign
1202
-    *
1203
-    * @return Array the spotter information
1204
-    *
1205
-    */
1206
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1207
-    {
1198
+	}
1199
+
1200
+	/**
1201
+	 * Gets all the spotter information based on a particular callsign
1202
+	 *
1203
+	 * @return Array the spotter information
1204
+	 *
1205
+	 */
1206
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1207
+	{
1208 1208
 	$Spotter = new Spotter($this->db);
1209 1209
 	date_default_timezone_set('UTC');
1210 1210
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1212,16 +1212,16 @@  discard block
 block discarded – undo
1212 1212
 	$date = date('c',$date);
1213 1213
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1214 1214
 	return $spotter_array;
1215
-    }
1216
-
1217
-    /**
1218
-    * Gets all the spotter information based on the airport
1219
-    *
1220
-    * @return Array the spotter information
1221
-    *
1222
-    */
1223
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1224
-    {
1215
+	}
1216
+
1217
+	/**
1218
+	 * Gets all the spotter information based on the airport
1219
+	 *
1220
+	 * @return Array the spotter information
1221
+	 *
1222
+	 */
1223
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1224
+	{
1225 1225
 	global $global_query;
1226 1226
 	$Spotter = new Spotter();
1227 1227
 	date_default_timezone_set('UTC');
@@ -1232,35 +1232,35 @@  discard block
 block discarded – undo
1232 1232
 	
1233 1233
 	if ($airport != "")
1234 1234
 	{
1235
-	    if (!is_string($airport))
1236
-	    {
1235
+		if (!is_string($airport))
1236
+		{
1237 1237
 		return false;
1238
-	    } else {
1238
+		} else {
1239 1239
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1240 1240
 		$query_values = array(':airport' => $airport);
1241
-	    }
1241
+		}
1242 1242
 	}
1243 1243
 	
1244 1244
 	if ($limit != "")
1245 1245
 	{
1246
-	    $limit_array = explode(",", $limit);
1246
+		$limit_array = explode(",", $limit);
1247 1247
 	    
1248
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1249
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1248
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1249
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1250 1250
 	    
1251
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1252
-	    {
1251
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1252
+		{
1253 1253
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1254 1254
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1255
-	    }
1255
+		}
1256 1256
 	}
1257 1257
 	
1258 1258
 	if ($sort != "")
1259 1259
 	{
1260
-	    $search_orderby_array = $Spotter->getOrderBy();
1261
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1260
+		$search_orderby_array = $Spotter->getOrderBy();
1261
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1262 1262
 	} else {
1263
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1263
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1264 1264
 	}
1265 1265
 
1266 1266
 	$query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1268,6 +1268,6 @@  discard block
 block discarded – undo
1268 1268
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1269 1269
 
1270 1270
 	return $spotter_array;
1271
-    }
1271
+	}
1272 1272
 }
1273 1273
 ?>
1274 1274
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class SpotterImport {
12
-    private $all_flights = array();
13
-    private $last_delete_hourly = 0;
14
-    private $last_delete = 0;
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_location = array();
18
-    public $db = null;
19
-    public $nb = 0;
20
-
21
-    public function __construct($dbc = null) {
12
+	private $all_flights = array();
13
+	private $last_delete_hourly = 0;
14
+	private $last_delete = 0;
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_location = array();
18
+	public $db = null;
19
+	public $nb = 0;
20
+
21
+	public function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db();
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
33
-	    	$type = $srcst['stats_type'];
32
+		foreach($sourcestat as $srcst) {
33
+			$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35
-		    $source = $srcst['source_name'];
36
-		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
-	        }
39
-	    }
35
+			$source = $srcst['source_name'];
36
+			$data = $srcst['source_data'];
37
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
+			}
39
+		}
40
+	}
40 41
 	}
41
-    }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+	public function get_Schedule($id,$ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -60,42 +60,42 @@  discard block
 block discarded – undo
60 60
 	$operator = $Spotter->getOperator($ident);
61 61
 	$scheduleexist = false;
62 62
 	if ($Schedule->checkSchedule($operator) == 0) {
63
-	    $operator = $Translation->checkTranslation($ident);
64
-	    if ($Schedule->checkSchedule($operator) == 0) {
63
+		$operator = $Translation->checkTranslation($ident);
64
+		if ($Schedule->checkSchedule($operator) == 0) {
65 65
 		$schedule = $Schedule->fetchSchedule($operator);
66 66
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
70
-		    // Should also check if route schedule = route from DB
71
-		    if ($schedule['DepartureAirportIATA'] != '') {
67
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
70
+			// Should also check if route schedule = route from DB
71
+			if ($schedule['DepartureAirportIATA'] != '') {
72 72
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
73
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
74
-			    if (trim($airport_icao) != '') {
73
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
74
+				if (trim($airport_icao) != '') {
75 75
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
76 76
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
77
-			    }
77
+				}
78
+			}
78 79
 			}
79
-		    }
80
-		    if ($schedule['ArrivalAirportIATA'] != '') {
80
+			if ($schedule['ArrivalAirportIATA'] != '') {
81 81
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
82
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
83
-			    if (trim($airport_icao) != '') {
82
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
83
+				if (trim($airport_icao) != '') {
84 84
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
85 85
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
86
-			    }
86
+				}
87
+			}
87 88
 			}
88
-		    }
89
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
89
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
90 90
 		}
91
-	    } else $scheduleexist = true;
91
+		} else $scheduleexist = true;
92 92
 	} else $scheduleexist = true;
93 93
 	// close connection, at least one way will work ?
94
-       if ($scheduleexist) {
94
+	   if ($scheduleexist) {
95 95
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
96
-    		$sch = $Schedule->getSchedule($operator);
96
+			$sch = $Schedule->getSchedule($operator);
97 97
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
98
-       }
98
+	   }
99 99
 	$Spotter->db = null;
100 100
 	$Schedule->db = null;
101 101
 	$Translation->db = null;
@@ -110,92 +110,92 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 	  */
112 112
 	}
113
-    }
113
+	}
114 114
 
115
-    public function checkAll() {
115
+	public function checkAll() {
116 116
 	global $globalDebug;
117 117
 	if ($globalDebug) echo "Update last seen flights data...\n";
118 118
 	foreach ($this->all_flights as $key => $flight) {
119
-	    if (isset($this->all_flights[$key]['id'])) {
119
+		if (isset($this->all_flights[$key]['id'])) {
120 120
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
121
-    		$Spotter = new Spotter($this->db);
122
-        	$real_arrival = $this->arrival($key);
123
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
124
-            }
121
+			$Spotter = new Spotter($this->db);
122
+			$real_arrival = $this->arrival($key);
123
+			$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
124
+			}
125
+	}
125 126
 	}
126
-    }
127 127
 
128
-    public function arrival($key) {
128
+	public function arrival($key) {
129 129
 	global $globalClosestMinDist, $globalDebug;
130 130
 	if ($globalDebug) echo 'Update arrival...'."\n";
131 131
 	$Spotter = new Spotter($this->db);
132
-        $airport_icao = '';
133
-        $airport_time = '';
134
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
132
+		$airport_icao = '';
133
+		$airport_time = '';
134
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
135 135
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
137
-    	    if (isset($closestAirports[0])) {
138
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139
-        	    $airport_icao = $closestAirports[0]['icao'];
140
-        	    $airport_time = $this->all_flights[$key]['datetime'];
141
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
142
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
143
-        	    foreach ($closestAirports as $airport) {
144
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
145
-        		    $airport_icao = $airport['icao'];
146
-        		    $airport_time = $this->all_flights[$key]['datetime'];
147
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
148
-        		    break;
149
-        		}
150
-        	    }
151
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
152
-        		$airport_icao = $closestAirports[0]['icao'];
153
-        		$airport_time = $this->all_flights[$key]['datetime'];
154
-        	} else {
155
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
156
-        	}
157
-    	    } else {
158
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
159
-    	    }
160
-
161
-        } else {
162
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
163
-        }
164
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
165
-    }
166
-
167
-
168
-
169
-    public function del() {
136
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
137
+			if (isset($closestAirports[0])) {
138
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139
+				$airport_icao = $closestAirports[0]['icao'];
140
+				$airport_time = $this->all_flights[$key]['datetime'];
141
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
142
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
143
+				foreach ($closestAirports as $airport) {
144
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
145
+					$airport_icao = $airport['icao'];
146
+					$airport_time = $this->all_flights[$key]['datetime'];
147
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
148
+					break;
149
+				}
150
+				}
151
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
152
+				$airport_icao = $closestAirports[0]['icao'];
153
+				$airport_time = $this->all_flights[$key]['datetime'];
154
+			} else {
155
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
156
+			}
157
+			} else {
158
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
159
+			}
160
+
161
+		} else {
162
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
163
+		}
164
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
165
+	}
166
+
167
+
168
+
169
+	public function del() {
170 170
 	global $globalDebug;
171 171
 	// Delete old infos
172 172
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
173 173
 	foreach ($this->all_flights as $key => $flight) {
174
-    	    if (isset($flight['lastupdate'])) {
175
-        	if ($flight['lastupdate'] < (time()-3000)) {
176
-            	    if (isset($this->all_flights[$key]['id'])) {
177
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
174
+			if (isset($flight['lastupdate'])) {
175
+			if ($flight['lastupdate'] < (time()-3000)) {
176
+					if (isset($this->all_flights[$key]['id'])) {
177
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
178 178
 			/*
179 179
 			$SpotterLive = new SpotterLive();
180 180
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
181 181
 			$SpotterLive->db = null;
182 182
 			*/
183
-            		$real_arrival = $this->arrival($key);
184
-            		$Spotter = new Spotter($this->db);
185
-            		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
183
+					$real_arrival = $this->arrival($key);
184
+					$Spotter = new Spotter($this->db);
185
+					if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186 186
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
187 187
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188 188
 			}
189 189
 			// Put in archive
190 190
 //			$Spotter->db = null;
191
-            	    }
192
-            	    unset($this->all_flights[$key]);
193
-    	        }
194
-	    }
195
-        }
196
-    }
197
-
198
-    public function add($line) {
191
+					}
192
+					unset($this->all_flights[$key]);
193
+				}
194
+		}
195
+		}
196
+	}
197
+
198
+	public function add($line) {
199 199
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights;
200 200
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
201 201
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
 	
221 221
 	// SBS format is CSV format
222 222
 	if(is_array($line) && isset($line['hex'])) {
223
-	    //print_r($line);
224
-  	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
223
+		//print_r($line);
224
+  		if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
225 225
 
226 226
 		// Increment message number
227 227
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
228
-		    $current_date = date('Y-m-d');
229
-		    $source = $line['source_name'];
230
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
231
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
232
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
233
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
234
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
228
+			$current_date = date('Y-m-d');
229
+			$source = $line['source_name'];
230
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
231
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
232
+				$this->stats[$current_date][$source]['msg']['date'] = time();
233
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
234
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
235 235
 		}
236 236
 		
237 237
 		/*
@@ -247,17 +247,17 @@  discard block
 block discarded – undo
247 247
 		//$this->db = $dbc;
248 248
 
249 249
 		$hex = trim($line['hex']);
250
-	        if (!isset($line['id'])) $id = trim($line['hex']);
251
-	        else $id = trim($line['id']);
250
+			if (!isset($line['id'])) $id = trim($line['hex']);
251
+			else $id = trim($line['id']);
252 252
 		
253 253
 		//print_r($this->all_flights);
254 254
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
255
-		    $this->all_flights[$id] = array('hex' => $hex);
256
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
257
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
255
+			$this->all_flights[$id] = array('hex' => $hex);
256
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
257
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
258 258
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
259
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
260
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
259
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
260
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
261 261
 
262 262
 			$timeelapsed = microtime(true);
263 263
 			$Spotter = new Spotter($this->db);
@@ -266,39 +266,39 @@  discard block
 block discarded – undo
266 266
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
267 267
 
268 268
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
269
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
270
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
271
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
269
+				if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
270
+				elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
271
+				elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272
+				elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
273 273
 			}
274 274
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
275
-		    } else if (isset($line['aircraft_name'])) {
275
+			} else if (isset($line['aircraft_name'])) {
276 276
 			// Get aircraft ICAO from aircraft name
277 277
 			$Spotter = new Spotter($this->db);
278 278
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
279 279
 			$Spotter->db = null;
280 280
 			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
281 281
 			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
282
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
283
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
284
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
285
-		    if (!isset($line['id'])) {
282
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
283
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
284
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
285
+			if (!isset($line['id'])) {
286 286
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
287 287
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
288 288
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289 289
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
290
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
292 292
 
293
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
293
+			if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294
+			if ($globalAllFlights !== FALSE) $dataFound = true;
295 295
 		}
296 296
 		
297 297
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
298 298
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
299
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
299
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
300 300
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301
-		    } else {
301
+			} else {
302 302
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
303 303
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
304 304
 				/*
@@ -307,41 +307,41 @@  discard block
 block discarded – undo
307 307
 				print_r($line);
308 308
 				*/
309 309
 				return '';
310
-		    }
310
+			}
311 311
 		} else {
312 312
 			date_default_timezone_set('UTC');
313 313
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
314 314
 		}
315 315
 
316 316
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
317
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
317
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
318 318
 		}
319 319
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
320
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
321 321
 		}
322 322
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
323
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
323
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
324 324
 		}
325 325
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
326
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
326
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
327 327
 		}
328 328
  
329 329
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
330
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
331
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
330
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
331
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
332 332
 			$timeelapsed = microtime(true);
333
-            		$Spotter = new Spotter($this->db);
334
-            		$fromsource = NULL;
335
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
336
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
333
+					$Spotter = new Spotter($this->db);
334
+					$fromsource = NULL;
335
+					if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
336
+					elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
337 337
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
338 338
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
339 339
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
340
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
340
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
341 341
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
342 342
 			$Spotter->db = null;
343 343
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
344
-		    }
344
+			}
345 345
 
346 346
 /*
347 347
 		    if (!isset($line['id'])) {
@@ -351,26 +351,26 @@  discard block
 block discarded – undo
351 351
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
352 352
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
353 353
   */
354
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
354
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
355 355
 
356
-		    //$putinarchive = true;
357
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
356
+			//$putinarchive = true;
357
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
358 358
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
359
-		    }
360
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
359
+			}
360
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
361 361
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
362
-		    }
363
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
364
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
365
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
362
+			}
363
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
364
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
365
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
366 366
 				$timeelapsed = microtime(true);
367 367
 				$Spotter = new Spotter($this->db);
368 368
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
369 369
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
370
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
370
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
371 371
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
372 372
 
373
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
373
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
374 374
 			$timeelapsed = microtime(true);
375 375
 			$Spotter = new Spotter($this->db);
376 376
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -384,43 +384,43 @@  discard block
 block discarded – undo
384 384
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
385 385
 
386 386
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
387
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
388
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
387
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
388
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
389 389
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
390
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
391
-		    	    }
390
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
391
+					}
392 392
 			}
393 393
 			if (!isset($globalFork)) $globalFork = TRUE;
394 394
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
395 395
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
396 396
 			}
397
-		    }
397
+			}
398 398
 		}
399 399
 
400 400
 		if (isset($line['speed']) && $line['speed'] != '') {
401 401
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
402
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
403
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
404
-		    //$dataFound = true;
402
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
403
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
404
+			//$dataFound = true;
405 405
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
406
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
407
-		    if ($distance > 1000 && $distance < 10000) {
408
-		    // use datetime
406
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
407
+			if ($distance > 1000 && $distance < 10000) {
408
+			// use datetime
409 409
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
410 410
 			$speed = $speed*3.6;
411 411
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
412 412
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
413
-		    }
413
+			}
414 414
 		}
415 415
 
416 416
 
417 417
 
418
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
419
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
420
-	    	    else unset($timediff);
421
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
418
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
419
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
420
+				else unset($timediff);
421
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
422 422
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
423
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
423
+				if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
424 424
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
425 425
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
426 426
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -434,16 +434,16 @@  discard block
 block discarded – undo
434 434
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
435 435
 				$this->tmd = 0;
436 436
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
437
-			    }
437
+				}
438 438
 			}
439 439
 
440 440
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
441
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
441
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
442 442
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
443 443
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
444
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
445
-				    $dataFound = true;
446
-				    $this->all_flights[$id]['time_last_coord'] = time();
444
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
445
+					$dataFound = true;
446
+					$this->all_flights[$id]['time_last_coord'] = time();
447 447
 				}
448 448
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
449 449
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -454,20 +454,20 @@  discard block
 block discarded – undo
454 454
 				    //$putinarchive = true;
455 455
 				}
456 456
 				*/
457
-			    /*
457
+				/*
458 458
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
459 459
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
460 460
 			    }
461 461
 			    */
462 462
 			}
463 463
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
464
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
465
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
464
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
465
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
466 466
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
467 467
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
468
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
469
-				    $dataFound = true;
470
-				    $this->all_flights[$id]['time_last_coord'] = time();
468
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
469
+					$dataFound = true;
470
+					$this->all_flights[$id]['time_last_coord'] = time();
471 471
 				}
472 472
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
473 473
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -485,54 +485,54 @@  discard block
 block discarded – undo
485 485
 			    */
486 486
 			}
487 487
 
488
-		    } else if ($globalDebug && $timediff > 20) {
488
+			} else if ($globalDebug && $timediff > 20) {
489 489
 			$this->tmd = $this->tmd + 1;
490 490
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
491 491
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
492 492
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
493 493
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
494
-		    }
494
+			}
495 495
 		}
496 496
 		if (isset($line['last_update']) && $line['last_update'] != '') {
497
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
498
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
497
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
498
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
499 499
 		}
500 500
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
501
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
502
-		    //$dataFound = true;
501
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
502
+			//$dataFound = true;
503 503
 		}
504 504
 		if (isset($line['format_source']) && $line['format_source'] != '') {
505
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
505
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
506 506
 		}
507 507
 		if (isset($line['source_name']) && $line['source_name'] != '') {
508
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
508
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
509 509
 		}
510 510
 		if (isset($line['emergency']) && $line['emergency'] != '') {
511
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
512
-		    //$dataFound = true;
511
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
512
+			//$dataFound = true;
513 513
 		}
514 514
 		if (isset($line['ground']) && $line['ground'] != '') {
515
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
515
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
516 516
 			// Here we force archive of flight because after ground it's a new one (or should be)
517 517
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
518 518
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
519 519
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
520
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
520
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
521 521
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
522
-		    }
523
-		    if ($line['ground'] != 1) $line['ground'] = 0;
524
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
525
-		    //$dataFound = true;
522
+			}
523
+			if ($line['ground'] != 1) $line['ground'] = 0;
524
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
525
+			//$dataFound = true;
526 526
 		}
527 527
 		if (isset($line['squawk']) && $line['squawk'] != '') {
528
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
529
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
530
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
531
-			    $highlight = '';
532
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
533
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
534
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
535
-			    if ($highlight != '') {
528
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
529
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
530
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
531
+				$highlight = '';
532
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
533
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
534
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
535
+				if ($highlight != '') {
536 536
 				$timeelapsed = microtime(true);
537 537
 				$Spotter = new Spotter($this->db);
538 538
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -541,38 +541,38 @@  discard block
 block discarded – undo
541 541
 
542 542
 				//$putinarchive = true;
543 543
 				//$highlight = '';
544
-			    }
544
+				}
545 545
 			    
546
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
547
-		    //$dataFound = true;
546
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
547
+			//$dataFound = true;
548 548
 		}
549 549
 
550 550
 		if (isset($line['altitude']) && $line['altitude'] != '') {
551
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
551
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
552 552
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
553 553
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
554 554
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
555 555
 			//$dataFound = true;
556
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
556
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
557 557
   		}
558 558
 
559 559
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
560
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
560
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
561 561
 		}
562 562
 		
563 563
 		if (isset($line['heading']) && $line['heading'] != '') {
564
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
565
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
566
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
567
-		    //$dataFound = true;
564
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
565
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
566
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
567
+			//$dataFound = true;
568 568
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
569
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
570
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
571
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
572
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
569
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
570
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
571
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
572
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
573 573
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
574
-  		    // If not enough messages and ACARS set heading to 0
575
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
574
+  			// If not enough messages and ACARS set heading to 0
575
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
576 576
   		}
577 577
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
578 578
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -583,119 +583,119 @@  discard block
 block discarded – undo
583 583
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
584 584
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
585 585
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
586
-		    $this->all_flights[$id]['lastupdate'] = time();
587
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
588
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
589
-			    //print_r($this->all_flights);
590
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
591
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
592
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
586
+			$this->all_flights[$id]['lastupdate'] = time();
587
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
588
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
589
+				//print_r($this->all_flights);
590
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
591
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
592
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
593 593
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
594 594
 				$timeelapsed = microtime(true);
595 595
 				$SpotterLive = new SpotterLive($this->db);
596 596
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
597
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
598
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
597
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
598
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
599 599
 				} elseif (isset($line['id'])) {
600
-				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
601
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
600
+					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
601
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
602 602
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
603
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
604
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
603
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
604
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
605 605
 				} else $recent_ident = '';
606 606
 				$SpotterLive->db=null;
607 607
 
608 608
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
609 609
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
610
-			    } else {
610
+				} else {
611 611
 				$recent_ident = '';
612 612
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
613
-			    }
614
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
615
-			    if($recent_ident == "")
616
-			    {
613
+				}
614
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
615
+				if($recent_ident == "")
616
+				{
617 617
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
618 618
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
619 619
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
620 620
 				//adds the spotter data for the archive
621 621
 				$ignoreImport = false;
622 622
 				foreach($globalAirportIgnore as $airportIgnore) {
623
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
623
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
624 624
 					$ignoreImport = true;
625
-				    }
625
+					}
626 626
 				}
627 627
 				if (count($globalAirportAccept) > 0) {
628
-				    $ignoreImport = true;
629
-				    foreach($globalAirportIgnore as $airportIgnore) {
628
+					$ignoreImport = true;
629
+					foreach($globalAirportIgnore as $airportIgnore) {
630 630
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
631
-					    $ignoreImport = false;
631
+						$ignoreImport = false;
632
+					}
632 633
 					}
633
-				    }
634 634
 				}
635 635
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
636
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
636
+					foreach($globalAirlineIgnore as $airlineIgnore) {
637 637
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
638
-					    $ignoreImport = true;
638
+						$ignoreImport = true;
639
+					}
639 640
 					}
640
-				    }
641 641
 				}
642 642
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
643
-				    $ignoreImport = true;
644
-				    foreach($globalAirlineAccept as $airlineAccept) {
643
+					$ignoreImport = true;
644
+					foreach($globalAirlineAccept as $airlineAccept) {
645 645
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
646
-					    $ignoreImport = false;
646
+						$ignoreImport = false;
647
+					}
647 648
 					}
648
-				    }
649 649
 				}
650 650
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
651
-				    $ignoreImport = true;
652
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
651
+					$ignoreImport = true;
652
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
653 653
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
654
-					    $ignoreImport = false;
654
+						$ignoreImport = false;
655
+					}
655 656
 					}
656
-				    }
657 657
 				}
658 658
 				
659 659
 				if (!$ignoreImport) {
660
-				    $highlight = '';
661
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
662
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
663
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
664
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
665
-				    $timeelapsed = microtime(true);
666
-				    $Spotter = new Spotter($this->db);
667
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
668
-				    $Spotter->db = null;
669
-				    if ($globalDebug && isset($result)) echo $result."\n";
670
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
660
+					$highlight = '';
661
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
662
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
663
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
664
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
665
+					$timeelapsed = microtime(true);
666
+					$Spotter = new Spotter($this->db);
667
+					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
668
+					$Spotter->db = null;
669
+					if ($globalDebug && isset($result)) echo $result."\n";
670
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
671 671
 				    
672
-				    // Add source stat in DB
673
-				    $Stats = new Stats($this->db);
674
-				    if (!empty($this->stats)) {
672
+					// Add source stat in DB
673
+					$Stats = new Stats($this->db);
674
+					if (!empty($this->stats)) {
675 675
 					if ($globalDebug) echo 'Add source stats : ';
676
-				        foreach($this->stats as $date => $data) {
677
-					    foreach($data as $source => $sourced) {
678
-					        //print_r($sourced);
679
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
680
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
681
-				    		if (isset($sourced['msg'])) {
682
-				    		    if (time() - $sourced['msg']['date'] > 10) {
683
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
684
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
685
-			    			        unset($this->stats[$date][$source]['msg']);
686
-			    			    }
687
-			    			}
688
-			    		    }
689
-			    		    if ($date != date('Y-m-d')) {
690
-			    			unset($this->stats[$date]);
691
-			    		    }
692
-				    	}
693
-				    	if ($globalDebug) echo 'Done'."\n";
694
-
695
-				    }
696
-				    $Stats->db = null;
676
+						foreach($this->stats as $date => $data) {
677
+						foreach($data as $source => $sourced) {
678
+							//print_r($sourced);
679
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
680
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
681
+							if (isset($sourced['msg'])) {
682
+								if (time() - $sourced['msg']['date'] > 10) {
683
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
684
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
685
+									unset($this->stats[$date][$source]['msg']);
686
+								}
687
+							}
688
+							}
689
+							if ($date != date('Y-m-d')) {
690
+							unset($this->stats[$date]);
691
+							}
692
+						}
693
+						if ($globalDebug) echo 'Done'."\n";
694
+
695
+					}
696
+					$Stats->db = null;
697 697
 				    
698
-				    $this->del();
698
+					$this->del();
699 699
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
700 700
 				//$ignoreImport = false;
701 701
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -713,18 +713,18 @@  discard block
 block discarded – undo
713 713
 			*/
714 714
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
715 715
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
716
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
717
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
718
-				    $SpotterLive = new SpotterLive($this->db);
719
-				    $SpotterLive->deleteLiveSpotterData();
720
-				    $SpotterLive->db=null;
721
-				    if ($globalDebug) echo " Done\n";
722
-				    $this->last_delete = time();
716
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
717
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
718
+					$SpotterLive = new SpotterLive($this->db);
719
+					$SpotterLive->deleteLiveSpotterData();
720
+					$SpotterLive->db=null;
721
+					if ($globalDebug) echo " Done\n";
722
+					$this->last_delete = time();
723 723
 				}
724
-			    } else {
724
+				} else {
725 725
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
726
-				    $this->all_flights[$id]['id'] = $recent_ident;
727
-				    $this->all_flights[$id]['addedSpotter'] = 1;
726
+					$this->all_flights[$id]['id'] = $recent_ident;
727
+					$this->all_flights[$id]['addedSpotter'] = 1;
728 728
 				}
729 729
 				if (isset($globalDaemon) && !$globalDaemon) {
730 730
 					$Spotter = new Spotter($this->db);
@@ -732,14 +732,14 @@  discard block
 block discarded – undo
732 732
 					$Spotter->db = null;
733 733
 				}
734 734
 				
735
-			    }
735
+				}
736
+			}
736 737
 			}
737
-		    }
738
-		    //adds the spotter LIVE data
739
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
740
-		    //echo "\nAdd in Live !! \n";
741
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
742
-		    if ($globalDebug) {
738
+			//adds the spotter LIVE data
739
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
740
+			//echo "\nAdd in Live !! \n";
741
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
742
+			if ($globalDebug) {
743 743
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
744 744
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
745 745
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -747,49 +747,49 @@  discard block
 block discarded – undo
747 747
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
748 748
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
749 749
 			}
750
-		    }
751
-		    $ignoreImport = false;
752
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
753
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
750
+			}
751
+			$ignoreImport = false;
752
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
753
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
754 754
 
755
-		    foreach($globalAirportIgnore as $airportIgnore) {
756
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
757
-			    $ignoreImport = true;
755
+			foreach($globalAirportIgnore as $airportIgnore) {
756
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
757
+				$ignoreImport = true;
758
+			}
758 759
 			}
759
-		    }
760
-		    if (count($globalAirportAccept) > 0) {
761
-		        $ignoreImport = true;
762
-		        foreach($globalAirportIgnore as $airportIgnore) {
763
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
760
+			if (count($globalAirportAccept) > 0) {
761
+				$ignoreImport = true;
762
+				foreach($globalAirportIgnore as $airportIgnore) {
763
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
764 764
 				$ignoreImport = false;
765
-			    }
765
+				}
766 766
 			}
767
-		    }
768
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
767
+			}
768
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
769 769
 			foreach($globalAirlineIgnore as $airlineIgnore) {
770
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
770
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
771 771
 				$ignoreImport = true;
772
-			    }
772
+				}
773 773
 			}
774
-		    }
775
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
774
+			}
775
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
776 776
 			$ignoreImport = true;
777 777
 			foreach($globalAirlineAccept as $airlineAccept) {
778
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
778
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
779 779
 				$ignoreImport = false;
780
-			    }
780
+				}
781 781
 			}
782
-		    }
783
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
782
+			}
783
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
784 784
 			$ignoreImport = true;
785 785
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
786
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
787
-			        $ignoreImport = false;
788
-			    }
786
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
787
+					$ignoreImport = false;
788
+				}
789
+			}
789 790
 			}
790
-		    }
791 791
 
792
-		    if (!$ignoreImport) {
792
+			if (!$ignoreImport) {
793 793
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
794 794
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
795 795
 				$timeelapsed = microtime(true);
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 					if ($stats_heading == 16) $stats_heading = 0;
829 829
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
830 830
 						for ($i=0;$i<=15;$i++) {
831
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
831
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
832 832
 						}
833 833
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
834 834
 					} else {
@@ -841,11 +841,11 @@  discard block
 block discarded – undo
841 841
 					//var_dump($this->stats);
842 842
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
843 843
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
844
-						    end($this->stats[$current_date][$source]['hist']);
845
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
844
+							end($this->stats[$current_date][$source]['hist']);
845
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
846 846
 						} else $mini = 0;
847 847
 						for ($i=$mini;$i<=$distance;$i+=10) {
848
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
848
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
849 849
 						}
850 850
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
851 851
 					} else {
@@ -862,22 +862,22 @@  discard block
 block discarded – undo
862 862
 			
863 863
 			
864 864
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
865
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
866
-			    $SpotterLive = new SpotterLive($this->db);
867
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
868
-			    $SpotterLive->db = null;
869
-			    //SpotterLive->deleteLiveSpotterData();
870
-			    if ($globalDebug) echo " Done\n";
871
-			    $this->last_delete_hourly = time();
865
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
866
+				$SpotterLive = new SpotterLive($this->db);
867
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
868
+				$SpotterLive->db = null;
869
+				//SpotterLive->deleteLiveSpotterData();
870
+				if ($globalDebug) echo " Done\n";
871
+				$this->last_delete_hourly = time();
872 872
 			}
873 873
 			
874
-		    }
875
-		    //$ignoreImport = false;
874
+			}
875
+			//$ignoreImport = false;
876 876
 		}
877 877
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
878 878
 		if ($send) return $this->all_flights[$id];
879
-	    }
879
+		}
880
+	}
880 881
 	}
881
-    }
882 882
 }
883 883
 ?>
Please login to merge, or discard this patch.