Completed
Push — master ( d3bd74...23eace )
by Yannick
06: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.
require/class.SpotterArchive.php 1 patch
Indentation   +653 added lines, -653 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])) {
@@ -30,88 +30,88 @@  discard block
 block discarded – undo
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	foreach($filters as $flt) {
33
-	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
33
+		if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 		if ($flt['airlines'][0] != '') {
35
-		    if (isset($flt['source'])) {
35
+			if (isset($flt['source'])) {
36 36
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37
-		    } else {
37
+			} else {
38 38
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39
-		    }
39
+			}
40
+		}
40 41
 		}
41
-	    }
42
-	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
42
+		if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 		if (isset($flt['source'])) {
44
-		    $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";
44
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45 45
 		} else {
46
-		    $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";
46
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47 47
 		}
48
-	    }
49
-	    if (isset($flt['idents']) && !empty($flt['idents'])) {
48
+		}
49
+		if (isset($flt['idents']) && !empty($flt['idents'])) {
50 50
 		if (isset($flt['source'])) {
51
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
51
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52 52
 		} else {
53
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54
+		}
54 55
 		}
55
-	    }
56
-	    if (isset($flt['registrations']) && !empty($flt['registrations'])) {
56
+		if (isset($flt['registrations']) && !empty($flt['registrations'])) {
57 57
 		if (isset($flt['source'])) {
58
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
58
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59 59
 		} else {
60
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61
+		}
61 62
 		}
62
-	    }
63
-	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
63
+		if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
64 64
 		if (isset($flt['source'])) {
65
-		    $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";
65
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66
+		}
66 67
 		}
67
-	    }
68 68
 	}
69 69
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
70
-	    if ($filter['airlines'][0] != '') {
70
+		if ($filter['airlines'][0] != '') {
71 71
 		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72
-	    }
72
+		}
73 73
 	}
74 74
 	
75 75
 	if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
76
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
76
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 	}
78 78
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 	}
81 81
 	if (isset($filter['source']) && !empty($filter['source'])) {
82
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
82
+		$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
83 83
 	}
84 84
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
85
-	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
85
+		$filter_query_where .= " AND ident = '".$filter['ident']."'";
86 86
 	}
87 87
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
88 88
 		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
89 89
 	}
90 90
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
91
-	    $filter_query_date = '';
91
+		$filter_query_date = '';
92 92
 	    
93
-	    if (isset($filter['year']) && $filter['year'] != '') {
93
+		if (isset($filter['year']) && $filter['year'] != '') {
94 94
 		if ($globalDBdriver == 'mysql') {
95
-		    $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
95
+			$filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
96 96
 		} else {
97
-		    $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
97
+			$filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
98
+		}
98 99
 		}
99
-	    }
100
-	    if (isset($filter['month']) && $filter['month'] != '') {
100
+		if (isset($filter['month']) && $filter['month'] != '') {
101 101
 		if ($globalDBdriver == 'mysql') {
102
-		    $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
102
+			$filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
103 103
 		} else {
104
-		    $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
104
+			$filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
105 105
 		}
106
-	    }
107
-	    if (isset($filter['day']) && $filter['day'] != '') {
106
+		}
107
+		if (isset($filter['day']) && $filter['day'] != '') {
108 108
 		if ($globalDBdriver == 'mysql') {
109
-		    $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
109
+			$filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
110 110
 		} else {
111
-		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
111
+			$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
112
+		}
112 113
 		}
113
-	    }
114
-	    $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";
114
+		$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";
115 115
 	}
116 116
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
117 117
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 	$filter_query = $filter_query_join.$filter_query_where;
122 122
 	return $filter_query;
123
-    }
123
+	}
124 124
 
125 125
 	// Spotter_archive
126 126
 	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 = '') {
@@ -151,44 +151,44 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 
153 153
 
154
-        /**
155
-        * Gets all the spotter information based on a particular callsign
156
-        *
157
-        * @return Array the spotter information
158
-        *
159
-        */
160
-        public function getLastArchiveSpotterDataByIdent($ident)
161
-        {
154
+		/**
155
+		 * Gets all the spotter information based on a particular callsign
156
+		 *
157
+		 * @return Array the spotter information
158
+		 *
159
+		 */
160
+		public function getLastArchiveSpotterDataByIdent($ident)
161
+		{
162 162
 		$Spotter = new Spotter($this->db);
163
-                date_default_timezone_set('UTC');
163
+				date_default_timezone_set('UTC');
164 164
 
165
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
166
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
167
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
165
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
166
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
167
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
168 168
 
169
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
169
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170 170
 
171
-                return $spotter_array;
172
-        }
171
+				return $spotter_array;
172
+		}
173 173
 
174 174
 
175
-        /**
176
-        * Gets last the spotter information based on a particular id
177
-        *
178
-        * @return Array the spotter information
179
-        *
180
-        */
181
-        public function getLastArchiveSpotterDataById($id)
182
-        {
183
-    		$Spotter = new Spotter($this->db);
184
-                date_default_timezone_set('UTC');
185
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
186
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
187
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
188
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
175
+		/**
176
+		 * Gets last the spotter information based on a particular id
177
+		 *
178
+		 * @return Array the spotter information
179
+		 *
180
+		 */
181
+		public function getLastArchiveSpotterDataById($id)
182
+		{
183
+			$Spotter = new Spotter($this->db);
184
+				date_default_timezone_set('UTC');
185
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
186
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
187
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
188
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
189 189
 
190 190
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
191
-                  /*
191
+				  /*
192 192
                 try {
193 193
                         $Connection = new Connection();
194 194
                         $sth = Connection->$db->prepare($query);
@@ -198,232 +198,232 @@  discard block
 block discarded – undo
198 198
                 }
199 199
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
200 200
                 */
201
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
-
203
-                return $spotter_array;
204
-        }
205
-
206
-        /**
207
-        * Gets all the spotter information based on a particular id
208
-        *
209
-        * @return Array the spotter information
210
-        *
211
-        */
212
-        public function getAllArchiveSpotterDataById($id)
213
-        {
214
-                date_default_timezone_set('UTC');
215
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
216
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
201
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
+
203
+				return $spotter_array;
204
+		}
205
+
206
+		/**
207
+		 * Gets all the spotter information based on a particular id
208
+		 *
209
+		 * @return Array the spotter information
210
+		 *
211
+		 */
212
+		public function getAllArchiveSpotterDataById($id)
213
+		{
214
+				date_default_timezone_set('UTC');
215
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
216
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
217 217
 
218 218
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
219 219
 
220
-                try {
221
-                        $sth = $this->db->prepare($query);
222
-                        $sth->execute(array(':id' => $id));
223
-                } catch(PDOException $e) {
224
-                        echo $e->getMessage();
225
-                        die;
226
-                }
227
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
228
-
229
-                return $spotter_array;
230
-        }
231
-
232
-        /**
233
-        * Gets coordinate & time spotter information based on a particular id
234
-        *
235
-        * @return Array the spotter information
236
-        *
237
-        */
238
-        public function getCoordArchiveSpotterDataById($id)
239
-        {
240
-                date_default_timezone_set('UTC');
241
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
242
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
220
+				try {
221
+						$sth = $this->db->prepare($query);
222
+						$sth->execute(array(':id' => $id));
223
+				} catch(PDOException $e) {
224
+						echo $e->getMessage();
225
+						die;
226
+				}
227
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
228
+
229
+				return $spotter_array;
230
+		}
231
+
232
+		/**
233
+		 * Gets coordinate & time spotter information based on a particular id
234
+		 *
235
+		 * @return Array the spotter information
236
+		 *
237
+		 */
238
+		public function getCoordArchiveSpotterDataById($id)
239
+		{
240
+				date_default_timezone_set('UTC');
241
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
242
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
243 243
 
244 244
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
245 245
 
246
-                try {
247
-                        $sth = $this->db->prepare($query);
248
-                        $sth->execute(array(':id' => $id));
249
-                } catch(PDOException $e) {
250
-                        echo $e->getMessage();
251
-                        die;
252
-                }
253
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
246
+				try {
247
+						$sth = $this->db->prepare($query);
248
+						$sth->execute(array(':id' => $id));
249
+				} catch(PDOException $e) {
250
+						echo $e->getMessage();
251
+						die;
252
+				}
253
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
254 254
 
255
-                return $spotter_array;
256
-        }
255
+				return $spotter_array;
256
+		}
257 257
 
258 258
 
259
-        /**
260
-        * Gets altitude information based on a particular callsign
261
-        *
262
-        * @return Array the spotter information
263
-        *
264
-        */
265
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
266
-        {
259
+		/**
260
+		 * Gets altitude information based on a particular callsign
261
+		 *
262
+		 * @return Array the spotter information
263
+		 *
264
+		 */
265
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
266
+		{
267 267
 
268
-                date_default_timezone_set('UTC');
268
+				date_default_timezone_set('UTC');
269 269
 
270
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
271
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
270
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
271
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
272 272
 
273
-                try {
274
-                        $sth = $this->db->prepare($query);
275
-                        $sth->execute(array(':ident' => $ident));
276
-                } catch(PDOException $e) {
277
-                        echo $e->getMessage();
278
-                        die;
279
-                }
280
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
273
+				try {
274
+						$sth = $this->db->prepare($query);
275
+						$sth->execute(array(':ident' => $ident));
276
+				} catch(PDOException $e) {
277
+						echo $e->getMessage();
278
+						die;
279
+				}
280
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
281 281
 
282
-                return $spotter_array;
283
-        }
282
+				return $spotter_array;
283
+		}
284 284
 
285
-        /**
286
-        * Gets altitude information based on a particular id
287
-        *
288
-        * @return Array the spotter information
289
-        *
290
-        */
291
-        public function getAltitudeArchiveSpotterDataById($id)
292
-        {
285
+		/**
286
+		 * Gets altitude information based on a particular id
287
+		 *
288
+		 * @return Array the spotter information
289
+		 *
290
+		 */
291
+		public function getAltitudeArchiveSpotterDataById($id)
292
+		{
293 293
 
294
-                date_default_timezone_set('UTC');
294
+				date_default_timezone_set('UTC');
295 295
 
296
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
297
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
296
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
297
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
298 298
 
299
-                try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute(array(':id' => $id));
302
-                } catch(PDOException $e) {
303
-                        echo $e->getMessage();
304
-                        die;
305
-                }
306
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
299
+				try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute(array(':id' => $id));
302
+				} catch(PDOException $e) {
303
+						echo $e->getMessage();
304
+						die;
305
+				}
306
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
307 307
 
308
-                return $spotter_array;
309
-        }
308
+				return $spotter_array;
309
+		}
310 310
 
311
-        /**
312
-        * Gets altitude & speed information based on a particular id
313
-        *
314
-        * @return Array the spotter information
315
-        *
316
-        */
317
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
318
-        {
311
+		/**
312
+		 * Gets altitude & speed information based on a particular id
313
+		 *
314
+		 * @return Array the spotter information
315
+		 *
316
+		 */
317
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
318
+		{
319 319
 
320
-                date_default_timezone_set('UTC');
320
+				date_default_timezone_set('UTC');
321 321
 
322
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
323
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
322
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
323
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
324 324
 
325
-                try {
326
-                        $sth = $this->db->prepare($query);
327
-                        $sth->execute(array(':id' => $id));
328
-                } catch(PDOException $e) {
329
-                        echo $e->getMessage();
330
-                        die;
331
-                }
332
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
325
+				try {
326
+						$sth = $this->db->prepare($query);
327
+						$sth->execute(array(':id' => $id));
328
+				} catch(PDOException $e) {
329
+						echo $e->getMessage();
330
+						die;
331
+				}
332
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
333 333
 
334
-                return $spotter_array;
335
-        }
334
+				return $spotter_array;
335
+		}
336 336
 
337 337
 
338
-        /**
339
-        * Gets altitude information based on a particular callsign
340
-        *
341
-        * @return Array the spotter information
342
-        *
343
-        */
344
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
345
-        {
338
+		/**
339
+		 * Gets altitude information based on a particular callsign
340
+		 *
341
+		 * @return Array the spotter information
342
+		 *
343
+		 */
344
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
345
+		{
346 346
 
347
-                date_default_timezone_set('UTC');
347
+				date_default_timezone_set('UTC');
348 348
 
349
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
350
-                $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";
349
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
350
+				$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";
351 351
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
352 352
 
353
-                try {
354
-                        $sth = $this->db->prepare($query);
355
-                        $sth->execute(array(':ident' => $ident));
356
-                } catch(PDOException $e) {
357
-                        echo $e->getMessage();
358
-                        die;
359
-                }
360
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
353
+				try {
354
+						$sth = $this->db->prepare($query);
355
+						$sth->execute(array(':ident' => $ident));
356
+				} catch(PDOException $e) {
357
+						echo $e->getMessage();
358
+						die;
359
+				}
360
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
361 361
 
362
-                return $spotter_array;
363
-        }
362
+				return $spotter_array;
363
+		}
364 364
 
365 365
 
366 366
 
367
-       /**
368
-        * Gets all the archive spotter information
369
-        *
370
-        * @return Array the spotter information
371
-        *
372
-        */
373
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
374
-        {
375
-    		$Spotter = new Spotter($this->db);
376
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
377
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.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";
367
+	   /**
368
+	    * Gets all the archive spotter information
369
+	    *
370
+	    * @return Array the spotter information
371
+	    *
372
+	    */
373
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
374
+		{
375
+			$Spotter = new Spotter($this->db);
376
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
377
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.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";
378 378
 
379
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
379
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
380 380
 
381
-                return $spotter_array;
382
-        }
381
+				return $spotter_array;
382
+		}
383 383
         
384
-        public function deleteSpotterArchiveTrackData()
385
-        {
384
+		public function deleteSpotterArchiveTrackData()
385
+		{
386 386
 		global $globalArchiveKeepTrackMonths;
387
-                date_default_timezone_set('UTC');
387
+				date_default_timezone_set('UTC');
388 388
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
389
-                try {
390
-                        $sth = $this->db->prepare($query);
391
-                        $sth->execute();
392
-                } catch(PDOException $e) {
393
-                        echo $e->getMessage();
394
-                        die;
395
-                }
389
+				try {
390
+						$sth = $this->db->prepare($query);
391
+						$sth->execute();
392
+				} catch(PDOException $e) {
393
+						echo $e->getMessage();
394
+						die;
395
+				}
396 396
 	}
397 397
 
398 398
 	/**
399
-        * Gets Minimal Live Spotter data
400
-        *
401
-        * @return Array the spotter information
402
-        *
403
-        */
404
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
405
-        {
406
-                global $globalDBdriver, $globalLiveInterval;
407
-                date_default_timezone_set('UTC');
408
-
409
-                $filter_query = '';
410
-                if (isset($filter['source']) && !empty($filter['source'])) {
411
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
412
-                }
413
-                // Use spotter_output also ?
414
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
415
-                        $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 ";
416
-                }
417
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
418
-                        $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 ";
419
-                }
420
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
421
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
-                }
423
-
424
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
425
-                if ($globalDBdriver == 'mysql') {
426
-                        /*
399
+	 * Gets Minimal Live Spotter data
400
+	 *
401
+	 * @return Array the spotter information
402
+	 *
403
+	 */
404
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
405
+		{
406
+				global $globalDBdriver, $globalLiveInterval;
407
+				date_default_timezone_set('UTC');
408
+
409
+				$filter_query = '';
410
+				if (isset($filter['source']) && !empty($filter['source'])) {
411
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
412
+				}
413
+				// Use spotter_output also ?
414
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
415
+						$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 ";
416
+				}
417
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
418
+						$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 ";
419
+				}
420
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
421
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
+				}
423
+
424
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
425
+				if ($globalDBdriver == 'mysql') {
426
+						/*
427 427
                         $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 
428 428
                     		    FROM spotter_archive 
429 429
                     		    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';
@@ -442,56 +442,56 @@  discard block
 block discarded – undo
442 442
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
443 443
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
444 444
                         	    '.$filter_query.' ORDER BY flightaware_id';
445
-                } else {
446
-                        //$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';
447
-                        $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 
445
+				} else {
446
+						//$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';
447
+						$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 
448 448
                         	    FROM spotter_archive 
449 449
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
450 450
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
451 451
                         	    '.$filter_query.' ORDER BY flightaware_id';
452
-                }
453
-                //echo $query;
454
-                try {
455
-                        $sth = $this->db->prepare($query);
456
-                        $sth->execute();
457
-                } catch(PDOException $e) {
458
-                        echo $e->getMessage();
459
-                        die;
460
-                }
461
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
462
-
463
-                return $spotter_array;
464
-        }
452
+				}
453
+				//echo $query;
454
+				try {
455
+						$sth = $this->db->prepare($query);
456
+						$sth->execute();
457
+				} catch(PDOException $e) {
458
+						echo $e->getMessage();
459
+						die;
460
+				}
461
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
462
+
463
+				return $spotter_array;
464
+		}
465 465
 
466 466
 	/**
467
-        * Gets Minimal Live Spotter data
468
-        *
469
-        * @return Array the spotter information
470
-        *
471
-        */
472
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
473
-        {
474
-                global $globalDBdriver, $globalLiveInterval;
475
-                date_default_timezone_set('UTC');
476
-
477
-                $filter_query = '';
478
-                if (isset($filter['source']) && !empty($filter['source'])) {
479
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
480
-                }
481
-                // Should use spotter_output also ?
482
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
483
-                        $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 ";
484
-                }
485
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
486
-                        $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 ";
487
-                }
488
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
489
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
490
-                }
491
-
492
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
493
-                if ($globalDBdriver == 'mysql') {
494
-                        /*
467
+	 * Gets Minimal Live Spotter data
468
+	 *
469
+	 * @return Array the spotter information
470
+	 *
471
+	 */
472
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
473
+		{
474
+				global $globalDBdriver, $globalLiveInterval;
475
+				date_default_timezone_set('UTC');
476
+
477
+				$filter_query = '';
478
+				if (isset($filter['source']) && !empty($filter['source'])) {
479
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
480
+				}
481
+				// Should use spotter_output also ?
482
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
483
+						$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 ";
484
+				}
485
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
486
+						$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 ";
487
+				}
488
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
489
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
490
+				}
491
+
492
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
493
+				if ($globalDBdriver == 'mysql') {
494
+						/*
495 495
                         $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 
496 496
                     		    FROM spotter_archive 
497 497
                     		    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';
@@ -502,95 +502,95 @@  discard block
 block discarded – undo
502 502
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
503 503
                         	    '.$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';
504 504
 
505
-                } else {
506
-                        //$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';
507
-                       /*
505
+				} else {
506
+						//$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';
507
+					   /*
508 508
                         $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
509 509
                         	    FROM spotter_archive_output 
510 510
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
511 511
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
512 512
                         	    '.$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';
513 513
                         */
514
-                        $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
514
+						$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
515 515
                         	    FROM spotter_archive_output 
516 516
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
517 517
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
518 518
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
519 519
 //                        	    .' 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';
520 520
                         	    
521
-                }
522
-                //echo $query;
523
-                try {
524
-                        $sth = $this->db->prepare($query);
525
-                        $sth->execute();
526
-                } catch(PDOException $e) {
527
-                        echo $e->getMessage();
528
-                        die;
529
-                }
530
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
531
-
532
-                return $spotter_array;
533
-        }
521
+				}
522
+				//echo $query;
523
+				try {
524
+						$sth = $this->db->prepare($query);
525
+						$sth->execute();
526
+				} catch(PDOException $e) {
527
+						echo $e->getMessage();
528
+						die;
529
+				}
530
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
531
+
532
+				return $spotter_array;
533
+		}
534 534
 
535 535
 	 /**
536
-        * Gets count Live Spotter data
537
-        *
538
-        * @return Array the spotter information
539
-        *
540
-        */
541
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
542
-        {
543
-                global $globalDBdriver, $globalLiveInterval;
544
-                date_default_timezone_set('UTC');
545
-
546
-                $filter_query = '';
547
-                if (isset($filter['source']) && !empty($filter['source'])) {
548
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
549
-                }
550
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
551
-                        $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 ";
552
-                }
553
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
554
-                        $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 ";
555
-                }
556
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
557
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
558
-                }
559
-
560
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
561
-                if ($globalDBdriver == 'mysql') {
536
+	  * Gets count Live Spotter data
537
+	  *
538
+	  * @return Array the spotter information
539
+	  *
540
+	  */
541
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
542
+		{
543
+				global $globalDBdriver, $globalLiveInterval;
544
+				date_default_timezone_set('UTC');
545
+
546
+				$filter_query = '';
547
+				if (isset($filter['source']) && !empty($filter['source'])) {
548
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
549
+				}
550
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
551
+						$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 ";
552
+				}
553
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
554
+						$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 ";
555
+				}
556
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
557
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
558
+				}
559
+
560
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
561
+				if ($globalDBdriver == 'mysql') {
562 562
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
563 563
 			FROM spotter_archive l 
564 564
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
565
-                } else {
565
+				} else {
566 566
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
567
-                }
568
-                //echo $query;
569
-                try {
570
-                        $sth = $this->db->prepare($query);
571
-                        $sth->execute();
572
-                } catch(PDOException $e) {
573
-                        echo $e->getMessage();
574
-                        die;
575
-                }
567
+				}
568
+				//echo $query;
569
+				try {
570
+						$sth = $this->db->prepare($query);
571
+						$sth->execute();
572
+				} catch(PDOException $e) {
573
+						echo $e->getMessage();
574
+						die;
575
+				}
576 576
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
577 577
 		$sth->closeCursor();
578
-                return $result['nb'];
578
+				return $result['nb'];
579 579
 
580
-        }
580
+		}
581 581
 
582 582
 
583 583
 
584 584
 	// Spotter_Archive_output
585 585
 	
586
-    /**
587
-    * Gets all the spotter information
588
-    *
589
-    * @return Array the spotter information
590
-    *
591
-    */
592
-    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())
593
-    {
586
+	/**
587
+	 * Gets all the spotter information
588
+	 *
589
+	 * @return Array the spotter information
590
+	 *
591
+	 */
592
+	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())
593
+	{
594 594
 	global $globalTimezone, $globalDBdriver;
595 595
 	require_once(dirname(__FILE__).'/class.Translation.php');
596 596
 	$Translation = new Translation();
@@ -604,159 +604,159 @@  discard block
 block discarded – undo
604 604
 	$filter_query = $this->getFilter($filters);
605 605
 	if ($q != "")
606 606
 	{
607
-	    if (!is_string($q))
608
-	    {
607
+		if (!is_string($q))
608
+		{
609 609
 		return false;
610
-	    } else {
610
+		} else {
611 611
 	        
612 612
 		$q_array = explode(" ", $q);
613 613
 		
614 614
 		foreach ($q_array as $q_item){
615
-		    $additional_query .= " AND (";
616
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
617
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
618
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
619
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
620
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
621
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
622
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
623
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
624
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
625
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
626
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
627
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
628
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
629
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
630
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
631
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
632
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
633
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
634
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
635
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
636
-		    $translate = $Translation->ident2icao($q_item);
637
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
638
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
639
-		    $additional_query .= ")";
640
-		}
641
-	    }
615
+			$additional_query .= " AND (";
616
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
617
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
618
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
619
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
620
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
621
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
622
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
623
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
624
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
625
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
626
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
627
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
628
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
629
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
630
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
631
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
632
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
633
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
634
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
635
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
636
+			$translate = $Translation->ident2icao($q_item);
637
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
638
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
639
+			$additional_query .= ")";
640
+		}
641
+		}
642 642
 	}
643 643
 	
644 644
 	if ($registration != "")
645 645
 	{
646
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
647
-	    if (!is_string($registration))
648
-	    {
646
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
647
+		if (!is_string($registration))
648
+		{
649 649
 		return false;
650
-	    } else {
650
+		} else {
651 651
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
652
-	    }
652
+		}
653 653
 	}
654 654
 	
655 655
 	if ($aircraft_icao != "")
656 656
 	{
657
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
658
-	    if (!is_string($aircraft_icao))
659
-	    {
657
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
658
+		if (!is_string($aircraft_icao))
659
+		{
660 660
 		return false;
661
-	    } else {
661
+		} else {
662 662
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
663
-	    }
663
+		}
664 664
 	}
665 665
 	
666 666
 	if ($aircraft_manufacturer != "")
667 667
 	{
668
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
669
-	    if (!is_string($aircraft_manufacturer))
670
-	    {
668
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
669
+		if (!is_string($aircraft_manufacturer))
670
+		{
671 671
 		return false;
672
-	    } else {
672
+		} else {
673 673
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
674
-	    }
674
+		}
675 675
 	}
676 676
 	
677 677
 	if ($highlights == "true")
678 678
 	{
679
-	    if (!is_string($highlights))
680
-	    {
679
+		if (!is_string($highlights))
680
+		{
681 681
 		return false;
682
-	    } else {
682
+		} else {
683 683
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
684
-	    }
684
+		}
685 685
 	}
686 686
 	
687 687
 	if ($airline_icao != "")
688 688
 	{
689
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
690
-	    if (!is_string($airline_icao))
691
-	    {
689
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
690
+		if (!is_string($airline_icao))
691
+		{
692 692
 		return false;
693
-	    } else {
693
+		} else {
694 694
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
695
-	    }
695
+		}
696 696
 	}
697 697
 	
698 698
 	if ($airline_country != "")
699 699
 	{
700
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
701
-	    if (!is_string($airline_country))
702
-	    {
700
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
701
+		if (!is_string($airline_country))
702
+		{
703 703
 		return false;
704
-	    } else {
704
+		} else {
705 705
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
706
-	    }
706
+		}
707 707
 	}
708 708
 	
709 709
 	if ($airline_type != "")
710 710
 	{
711
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
712
-	    if (!is_string($airline_type))
713
-	    {
711
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
712
+		if (!is_string($airline_type))
713
+		{
714 714
 		return false;
715
-	    } else {
715
+		} else {
716 716
 		if ($airline_type == "passenger")
717 717
 		{
718
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
718
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
719 719
 		}
720 720
 		if ($airline_type == "cargo")
721 721
 		{
722
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
722
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
723 723
 		}
724 724
 		if ($airline_type == "military")
725 725
 		{
726
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
726
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
727
+		}
727 728
 		}
728
-	    }
729 729
 	}
730 730
 	
731 731
 	if ($airport != "")
732 732
 	{
733
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
734
-	    if (!is_string($airport))
735
-	    {
733
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
734
+		if (!is_string($airport))
735
+		{
736 736
 		return false;
737
-	    } else {
737
+		} else {
738 738
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
739
-	    }
739
+		}
740 740
 	}
741 741
 	
742 742
 	if ($airport_country != "")
743 743
 	{
744
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
745
-	    if (!is_string($airport_country))
746
-	    {
744
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
745
+		if (!is_string($airport_country))
746
+		{
747 747
 		return false;
748
-	    } else {
748
+		} else {
749 749
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
750
-	    }
750
+		}
751 751
 	}
752 752
     
753 753
 	if ($callsign != "")
754 754
 	{
755
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
756
-	    if (!is_string($callsign))
757
-	    {
755
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
756
+		if (!is_string($callsign))
757
+		{
758 758
 		return false;
759
-	    } else {
759
+		} else {
760 760
 		$translate = $Translation->ident2icao($callsign);
761 761
 		if ($translate != $callsign) {
762 762
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -764,99 +764,99 @@  discard block
 block discarded – undo
764 764
 		} else {
765 765
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
766 766
 		}
767
-	    }
767
+		}
768 768
 	}
769 769
 
770 770
 	if ($owner != "")
771 771
 	{
772
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
773
-	    if (!is_string($owner))
774
-	    {
772
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
773
+		if (!is_string($owner))
774
+		{
775 775
 		return false;
776
-	    } else {
776
+		} else {
777 777
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
778
-	    }
778
+		}
779 779
 	}
780 780
 
781 781
 	if ($pilot_name != "")
782 782
 	{
783
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
784
-	    if (!is_string($pilot_name))
785
-	    {
783
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
784
+		if (!is_string($pilot_name))
785
+		{
786 786
 		return false;
787
-	    } else {
787
+		} else {
788 788
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
789
-	    }
789
+		}
790 790
 	}
791 791
 	
792 792
 	if ($pilot_id != "")
793 793
 	{
794
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
795
-	    if (!is_string($pilot_id))
796
-	    {
794
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
795
+		if (!is_string($pilot_id))
796
+		{
797 797
 		return false;
798
-	    } else {
798
+		} else {
799 799
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
800
-	    }
800
+		}
801 801
 	}
802 802
 	
803 803
 	if ($departure_airport_route != "")
804 804
 	{
805
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
806
-	    if (!is_string($departure_airport_route))
807
-	    {
805
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
806
+		if (!is_string($departure_airport_route))
807
+		{
808 808
 		return false;
809
-	    } else {
809
+		} else {
810 810
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
811
-	    }
811
+		}
812 812
 	}
813 813
 	
814 814
 	if ($arrival_airport_route != "")
815 815
 	{
816
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
817
-	    if (!is_string($arrival_airport_route))
818
-	    {
816
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
817
+		if (!is_string($arrival_airport_route))
818
+		{
819 819
 		return false;
820
-	    } else {
820
+		} else {
821 821
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
822
-	    }
822
+		}
823 823
 	}
824 824
 	
825 825
 	if ($altitude != "")
826 826
 	{
827
-	    $altitude_array = explode(",", $altitude);
827
+		$altitude_array = explode(",", $altitude);
828 828
 	    
829
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
829
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
831 831
 	    
832 832
 
833
-	    if ($altitude_array[1] != "")
834
-	    {                
833
+		if ($altitude_array[1] != "")
834
+		{                
835 835
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
836 836
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
837 837
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
838
-	    } else {
838
+		} else {
839 839
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
840 840
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
841
-	    }
841
+		}
842 842
 	}
843 843
 	
844 844
 	if ($date_posted != "")
845 845
 	{
846
-	    $date_array = explode(",", $date_posted);
846
+		$date_array = explode(",", $date_posted);
847 847
 	    
848
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
849
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
848
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
849
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
850 850
 	    
851
-	    if ($globalTimezone != '') {
851
+		if ($globalTimezone != '') {
852 852
 		date_default_timezone_set($globalTimezone);
853 853
 		$datetime = new DateTime();
854 854
 		$offset = $datetime->format('P');
855
-	    } else $offset = '+00:00';
855
+		} else $offset = '+00:00';
856 856
 
857 857
 
858
-	    if ($date_array[1] != "")
859
-	    {                
858
+		if ($date_array[1] != "")
859
+		{                
860 860
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
861 861
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
862 862
 		if ($globalDBdriver == 'mysql') {
@@ -864,28 +864,28 @@  discard block
 block discarded – undo
864 864
 		} else {
865 865
 			$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) ";
866 866
 		}
867
-	    } else {
867
+		} else {
868 868
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
869
-                if ($globalDBdriver == 'mysql') {
869
+				if ($globalDBdriver == 'mysql') {
870 870
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
871 871
 		} else {
872 872
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
873 873
 		}
874
-	    }
874
+		}
875 875
 	}
876 876
 	
877 877
 	if ($limit != "")
878 878
 	{
879
-	    $limit_array = explode(",", $limit);
879
+		$limit_array = explode(",", $limit);
880 880
 	    
881
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
881
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
883 883
 	    
884
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
885
-	    {
884
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
885
+		{
886 886
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
887 887
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
888
-	    }
888
+		}
889 889
 	}
890 890
 	
891 891
 
@@ -916,33 +916,33 @@  discard block
 block discarded – undo
916 916
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
917 917
 
918 918
 	return $spotter_array;
919
-    }
919
+	}
920 920
 
921
-    public function deleteSpotterArchiveData()
922
-    {
921
+	public function deleteSpotterArchiveData()
922
+	{
923 923
 		global $globalArchiveKeepMonths, $globalDBdriver;
924
-                date_default_timezone_set('UTC');
925
-                if ($globalDBdriver == 'mysql') {
924
+				date_default_timezone_set('UTC');
925
+				if ($globalDBdriver == 'mysql') {
926 926
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
927 927
 		} else {
928 928
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
929 929
 		}
930
-                try {
931
-                        $sth = $this->db->prepare($query);
932
-                        $sth->execute();
933
-                } catch(PDOException $e) {
934
-                        return "error";
935
-                }
930
+				try {
931
+						$sth = $this->db->prepare($query);
932
+						$sth->execute();
933
+				} catch(PDOException $e) {
934
+						return "error";
935
+				}
936 936
 	}
937 937
 
938
-    /**
939
-    * Gets all the spotter information based on the callsign
940
-    *
941
-    * @return Array the spotter information
942
-    *
943
-    */
944
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
945
-    {
938
+	/**
939
+	 * Gets all the spotter information based on the callsign
940
+	 *
941
+	 * @return Array the spotter information
942
+	 *
943
+	 */
944
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
945
+	{
946 946
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
947 947
 	
948 948
 	date_default_timezone_set('UTC');
@@ -954,35 +954,35 @@  discard block
 block discarded – undo
954 954
 	
955 955
 	if ($ident != "")
956 956
 	{
957
-	    if (!is_string($ident))
958
-	    {
957
+		if (!is_string($ident))
958
+		{
959 959
 		return false;
960
-	    } else {
960
+		} else {
961 961
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
962 962
 		$query_values = array(':ident' => $ident);
963
-	    }
963
+		}
964 964
 	}
965 965
 	
966 966
 	if ($limit != "")
967 967
 	{
968
-	    $limit_array = explode(",", $limit);
968
+		$limit_array = explode(",", $limit);
969 969
 	    
970
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
971
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
970
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
971
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
972 972
 	    
973
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
974
-	    {
973
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
974
+		{
975 975
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
976 976
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
977
-	    }
977
+		}
978 978
 	}
979 979
 
980 980
 	if ($sort != "")
981 981
 	{
982
-	    $search_orderby_array = $Spotter->getOrderBy();
983
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
982
+		$search_orderby_array = $Spotter->getOrderBy();
983
+		$orderby_query = $search_orderby_array[$sort]['sql'];
984 984
 	} else {
985
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
985
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
986 986
 	}
987 987
 
988 988
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -990,17 +990,17 @@  discard block
 block discarded – undo
990 990
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
991 991
 
992 992
 	return $spotter_array;
993
-    }
993
+	}
994 994
 
995 995
 
996
-    /**
997
-    * Gets all the spotter information based on the owner
998
-    *
999
-    * @return Array the spotter information
1000
-    *
1001
-    */
1002
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1003
-    {
996
+	/**
997
+	 * Gets all the spotter information based on the owner
998
+	 *
999
+	 * @return Array the spotter information
1000
+	 *
1001
+	 */
1002
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1003
+	{
1004 1004
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1005 1005
 	
1006 1006
 	date_default_timezone_set('UTC');
@@ -1013,35 +1013,35 @@  discard block
 block discarded – undo
1013 1013
 	
1014 1014
 	if ($owner != "")
1015 1015
 	{
1016
-	    if (!is_string($owner))
1017
-	    {
1016
+		if (!is_string($owner))
1017
+		{
1018 1018
 		return false;
1019
-	    } else {
1019
+		} else {
1020 1020
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
1021 1021
 		$query_values = array(':owner' => $owner);
1022
-	    }
1022
+		}
1023 1023
 	}
1024 1024
 	
1025 1025
 	if ($limit != "")
1026 1026
 	{
1027
-	    $limit_array = explode(",", $limit);
1027
+		$limit_array = explode(",", $limit);
1028 1028
 	    
1029
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1030
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1029
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1030
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1031 1031
 	    
1032
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1033
-	    {
1032
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1033
+		{
1034 1034
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1035 1035
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1036
-	    }
1036
+		}
1037 1037
 	}
1038 1038
 
1039 1039
 	if ($sort != "")
1040 1040
 	{
1041
-	    $search_orderby_array = $Spotter->getOrderBy();
1042
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1041
+		$search_orderby_array = $Spotter->getOrderBy();
1042
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1043 1043
 	} else {
1044
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1044
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1045 1045
 	}
1046 1046
 
1047 1047
 	$query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1049,16 +1049,16 @@  discard block
 block discarded – undo
1049 1049
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1050 1050
 
1051 1051
 	return $spotter_array;
1052
-    }
1053
-
1054
-    /**
1055
-    * Gets all the spotter information based on the pilot
1056
-    *
1057
-    * @return Array the spotter information
1058
-    *
1059
-    */
1060
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1061
-    {
1052
+	}
1053
+
1054
+	/**
1055
+	 * Gets all the spotter information based on the pilot
1056
+	 *
1057
+	 * @return Array the spotter information
1058
+	 *
1059
+	 */
1060
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1061
+	{
1062 1062
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1063 1063
 	
1064 1064
 	date_default_timezone_set('UTC');
@@ -1077,24 +1077,24 @@  discard block
 block discarded – undo
1077 1077
 	
1078 1078
 	if ($limit != "")
1079 1079
 	{
1080
-	    $limit_array = explode(",", $limit);
1080
+		$limit_array = explode(",", $limit);
1081 1081
 	    
1082
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1083
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1082
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1083
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1084 1084
 	    
1085
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1086
-	    {
1085
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1086
+		{
1087 1087
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1088 1088
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1089
-	    }
1089
+		}
1090 1090
 	}
1091 1091
 
1092 1092
 	if ($sort != "")
1093 1093
 	{
1094
-	    $search_orderby_array = $Spotter->getOrderBy();
1095
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1094
+		$search_orderby_array = $Spotter->getOrderBy();
1095
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1096 1096
 	} else {
1097
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1097
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1098 1098
 	}
1099 1099
 
1100 1100
 	$query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1102,16 +1102,16 @@  discard block
 block discarded – undo
1102 1102
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1103 1103
 
1104 1104
 	return $spotter_array;
1105
-    }
1106
-
1107
-    /**
1108
-    * Gets all number of flight over countries
1109
-    *
1110
-    * @return Array the airline country list
1111
-    *
1112
-    */
1113
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1114
-    {
1105
+	}
1106
+
1107
+	/**
1108
+	 * Gets all number of flight over countries
1109
+	 *
1110
+	 * @return Array the airline country list
1111
+	 *
1112
+	 */
1113
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1114
+	{
1115 1115
 	global $globalDBdriver;
1116 1116
 	/*
1117 1117
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1121,14 +1121,14 @@  discard block
 block discarded – undo
1121 1121
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1122 1122
 		    FROM countries c, spotter_archive s
1123 1123
 		    WHERE c.iso2 = s.over_country ";
1124
-                if ($olderthanmonths > 0) {
1125
-            		if ($globalDBdriver == 'mysql') {
1124
+				if ($olderthanmonths > 0) {
1125
+					if ($globalDBdriver == 'mysql') {
1126 1126
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1127 1127
 			} else {
1128 1128
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1129 1129
 			}
1130 1130
 		}
1131
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1131
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1132 1132
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1133 1133
 	if ($limit) $query .= " LIMIT 0,10";
1134 1134
       
@@ -1141,23 +1141,23 @@  discard block
 block discarded – undo
1141 1141
         
1142 1142
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1143 1143
 	{
1144
-	    $temp_array['flight_count'] = $row['nb'];
1145
-	    $temp_array['flight_country'] = $row['name'];
1146
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1147
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1148
-	    $flight_array[] = $temp_array;
1144
+		$temp_array['flight_count'] = $row['nb'];
1145
+		$temp_array['flight_country'] = $row['name'];
1146
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1147
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1148
+		$flight_array[] = $temp_array;
1149 1149
 	}
1150 1150
 	return $flight_array;
1151
-    }
1152
-
1153
-    /**
1154
-    * Gets all number of flight over countries
1155
-    *
1156
-    * @return Array the airline country list
1157
-    *
1158
-    */
1159
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1160
-    {
1151
+	}
1152
+
1153
+	/**
1154
+	 * Gets all number of flight over countries
1155
+	 *
1156
+	 * @return Array the airline country list
1157
+	 *
1158
+	 */
1159
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1160
+	{
1161 1161
 	global $globalDBdriver;
1162 1162
 	/*
1163 1163
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1167,14 +1167,14 @@  discard block
 block discarded – undo
1167 1167
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1168 1168
 		    FROM countries c, spotter_archive s, spotter_output o
1169 1169
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1170
-                if ($olderthanmonths > 0) {
1171
-            		if ($globalDBdriver == 'mysql') {
1170
+				if ($olderthanmonths > 0) {
1171
+					if ($globalDBdriver == 'mysql') {
1172 1172
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1173 1173
 			} else {
1174 1174
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1175 1175
 			}
1176 1176
 		}
1177
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1177
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1178 1178
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1179 1179
 	if ($limit) $query .= " LIMIT 0,10";
1180 1180
       
@@ -1187,24 +1187,24 @@  discard block
 block discarded – undo
1187 1187
         
1188 1188
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1189 1189
 	{
1190
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1191
-	    $temp_array['flight_count'] = $row['nb'];
1192
-	    $temp_array['flight_country'] = $row['name'];
1193
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1194
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1195
-	    $flight_array[] = $temp_array;
1190
+		$temp_array['airline_icao'] = $row['airline_icao'];
1191
+		$temp_array['flight_count'] = $row['nb'];
1192
+		$temp_array['flight_country'] = $row['name'];
1193
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1194
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1195
+		$flight_array[] = $temp_array;
1196 1196
 	}
1197 1197
 	return $flight_array;
1198
-    }
1199
-
1200
-    /**
1201
-    * Gets last spotter information based on a particular callsign
1202
-    *
1203
-    * @return Array the spotter information
1204
-    *
1205
-    */
1206
-    public function getDateArchiveSpotterDataById($id,$date)
1207
-    {
1198
+	}
1199
+
1200
+	/**
1201
+	 * Gets last spotter information based on a particular callsign
1202
+	 *
1203
+	 * @return Array the spotter information
1204
+	 *
1205
+	 */
1206
+	public function getDateArchiveSpotterDataById($id,$date)
1207
+	{
1208 1208
 	$Spotter = new Spotter($this->db);
1209 1209
 	date_default_timezone_set('UTC');
1210 1210
 	$id = filter_var($id, 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(':id' => $id,':date' => $date));
1214 1214
 	return $spotter_array;
1215
-    }
1216
-
1217
-    /**
1218
-    * Gets all the spotter information based on a particular callsign
1219
-    *
1220
-    * @return Array the spotter information
1221
-    *
1222
-    */
1223
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1224
-    {
1215
+	}
1216
+
1217
+	/**
1218
+	 * Gets all the spotter information based on a particular callsign
1219
+	 *
1220
+	 * @return Array the spotter information
1221
+	 *
1222
+	 */
1223
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1224
+	{
1225 1225
 	$Spotter = new Spotter($this->db);
1226 1226
 	date_default_timezone_set('UTC');
1227 1227
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1229,16 +1229,16 @@  discard block
 block discarded – undo
1229 1229
 	$date = date('c',$date);
1230 1230
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1231 1231
 	return $spotter_array;
1232
-    }
1233
-
1234
-    /**
1235
-    * Gets all the spotter information based on the airport
1236
-    *
1237
-    * @return Array the spotter information
1238
-    *
1239
-    */
1240
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1241
-    {
1232
+	}
1233
+
1234
+	/**
1235
+	 * Gets all the spotter information based on the airport
1236
+	 *
1237
+	 * @return Array the spotter information
1238
+	 *
1239
+	 */
1240
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1241
+	{
1242 1242
 	global $global_query;
1243 1243
 	$Spotter = new Spotter();
1244 1244
 	date_default_timezone_set('UTC');
@@ -1249,35 +1249,35 @@  discard block
 block discarded – undo
1249 1249
 	
1250 1250
 	if ($airport != "")
1251 1251
 	{
1252
-	    if (!is_string($airport))
1253
-	    {
1252
+		if (!is_string($airport))
1253
+		{
1254 1254
 		return false;
1255
-	    } else {
1255
+		} else {
1256 1256
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1257 1257
 		$query_values = array(':airport' => $airport);
1258
-	    }
1258
+		}
1259 1259
 	}
1260 1260
 	
1261 1261
 	if ($limit != "")
1262 1262
 	{
1263
-	    $limit_array = explode(",", $limit);
1263
+		$limit_array = explode(",", $limit);
1264 1264
 	    
1265
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1266
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1265
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1266
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1267 1267
 	    
1268
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1269
-	    {
1268
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1269
+		{
1270 1270
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1271 1271
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1272
-	    }
1272
+		}
1273 1273
 	}
1274 1274
 	
1275 1275
 	if ($sort != "")
1276 1276
 	{
1277
-	    $search_orderby_array = $Spotter->getOrderBy();
1278
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1277
+		$search_orderby_array = $Spotter->getOrderBy();
1278
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1279 1279
 	} else {
1280
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1280
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1281 1281
 	}
1282 1282
 
1283 1283
 	$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;
@@ -1285,6 +1285,6 @@  discard block
 block discarded – undo
1285 1285
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1286 1286
 
1287 1287
 	return $spotter_array;
1288
-    }
1288
+	}
1289 1289
 }
1290 1290
 ?>
1291 1291
\ No newline at end of file
Please login to merge, or discard this patch.
js/map-marine.2d.js.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 			}
517 517
                     }
518 518
 		    <?php
519
-            		} else {
520
-            	    ?>
519
+					} else {
520
+					?>
521 521
 		    if (map.getZoom() > 7) {
522 522
                 	var style = {
523 523
                     	    "color": "#1a3151",
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
                 	layer_marine_data.addLayer(layer);
537 537
 		    }
538 538
 <?php
539
-            		}
539
+					}
540 540
 ?>
541 541
 				}
542 542
 			    }
Please login to merge, or discard this patch.
js/map-tracker.2d.js.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 			}
518 518
                     }
519 519
 		    <?php
520
-            		} else {
521
-            	    ?>
520
+					} else {
521
+					?>
522 522
 		    if (map.getZoom() > 7) {
523 523
                 	var style = {
524 524
                     	    "color": "#1a3151",
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
                 	layer_tracker_data.addLayer(layer);
538 538
 		    }
539 539
 <?php
540
-            		}
540
+					}
541 541
 ?>
542 542
 				}
543 543
 			    }
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 	});
353 353
 update_locationsLayer();
354 354
 <?php
355
-    // Add support for custom json via $globalMapJson
356
-    if (isset($globalMapJson) && is_array($globalMapJson)) {
355
+	// Add support for custom json via $globalMapJson
356
+	if (isset($globalMapJson) && is_array($globalMapJson)) {
357 357
 	foreach ($globalMapJson as $json) {
358
-	    if (isset($json['url'])) {
358
+		if (isset($json['url'])) {
359 359
 ?>
360 360
 update_genLayer('<?php print $json['url']; ?>');
361 361
 <?php
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 setInterval(function(){update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>);
365 365
 <?php
366 366
 		}
367
-	    }
367
+		}
368
+	}
368 369
 	}
369
-    }
370 370
 
371 371
 ?>
372 372
 //adds the bootstrap tooltip to the map icons
Please login to merge, or discard this patch.
live-czml.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -34,30 +34,30 @@  discard block
 block discarded – undo
34 34
 
35 35
 
36 36
 function quaternionrotate($heading, $attitude = 0, $bank = 0) {
37
-    // Assuming the angles are in radians.
38
-    $c1 = cos($heading/2);
39
-    $s1 = sin($heading/2);
40
-    $c2 = cos($attitude/2);
41
-    $s2 = sin($attitude/2);
42
-    $c3 = cos($bank/2);
43
-    $s3 = sin($bank/2);
44
-    $c1c2 = $c1*$c2;
45
-    $s1s2 = $s1*$s2;
46
-    $w =$c1c2*$c3 - $s1s2*$s3;
47
-    $x =$c1c2*$s3 + $s1s2*$c3;
48
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
49
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
50
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
37
+	// Assuming the angles are in radians.
38
+	$c1 = cos($heading/2);
39
+	$s1 = sin($heading/2);
40
+	$c2 = cos($attitude/2);
41
+	$s2 = sin($attitude/2);
42
+	$c3 = cos($bank/2);
43
+	$s3 = sin($bank/2);
44
+	$c1c2 = $c1*$c2;
45
+	$s1s2 = $s1*$s2;
46
+	$w =$c1c2*$c3 - $s1s2*$s3;
47
+	$x =$c1c2*$s3 + $s1s2*$c3;
48
+	$y =$s1*$c2*$c3 + $c1*$s2*$s3;
49
+	$z =$c1*$s2*$c3 - $s1*$c2*$s3;
50
+	return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
51 51
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
52 52
 
53 53
 }
54 54
 
55 55
 
56 56
 if (isset($_GET['download'])) {
57
-    if ($_GET['download'] == "true")
58
-    {
57
+	if ($_GET['download'] == "true")
58
+	{
59 59
 	header('Content-disposition: attachment; filename="flightairmap.json"');
60
-    }
60
+	}
61 61
 }
62 62
 header('Content-Type: text/javascript');
63 63
 
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 			$image = "images/placeholder_thumb.png";
221 221
 		}
222 222
 
223
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
224
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
225
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
226
-                if ($prev_flightaware_id != $id) {
223
+				if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
224
+				elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
225
+				elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
226
+				if ($prev_flightaware_id != $id) {
227 227
 			if ($prev_flightaware_id != '') {
228 228
 				$output .= ']';
229 229
 				$output .= '}';
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]);
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
 	}
169 169
 ?>
170 170
 <?php 
171
-    if (isset($_POST['archive'])) {
171
+	if (isset($_POST['archive'])) {
172 172
 ?>
173 173
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
174 174
 <?php 
175
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
175
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
176 176
 ?>
177 177
 
178 178
 <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>
179 179
 <?php    
180
-	    }
181
-    } else {
180
+		}
181
+	} else {
182 182
 ?>
183 183
 <?php
184 184
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 */
191 191
 ?>
192 192
 <?php 
193
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
193
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
194 194
 ?>
195 195
 <?php
196 196
 //		if (isset($globalBeta) && $globalBeta) {
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script>
218 218
 <?php
219 219
 		}
220
-	    }
220
+		}
221 221
 ?>
222 222
 <?php
223 223
 //	}
224 224
 ?>
225 225
 <?php
226
-    }
226
+	}
227 227
 }
228 228
 ?>
229 229
 <?php
@@ -380,15 +380,15 @@  discard block
 block discarded – undo
380 380
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
381 381
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
382 382
 <?php
383
-    if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
383
+	if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
384 384
 ?>
385 385
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
386 386
 <?php
387
-    } else {
387
+	} else {
388 388
 ?>
389 389
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
390 390
 <?php
391
-    }
391
+	}
392 392
 ?>
393 393
 			<li><hr /></li>
394 394
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -396,34 +396,34 @@  discard block
 block discarded – undo
396 396
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
397 397
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
398 398
             <?php
399
-        	if ($globalACARS) {
400
-        	    if (isset($globalDemo) && $globalDemo) {
401
-    	    ?>
399
+			if ($globalACARS) {
400
+				if (isset($globalDemo) && $globalDemo) {
401
+			?>
402 402
             <li><hr /></li>
403 403
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
404 404
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
405 405
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
406 406
             <?php
407
-        	    } else {
408
-    	    ?>
407
+				} else {
408
+			?>
409 409
             <li><hr /></li>
410 410
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
411 411
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
412 412
             <?php
413
-        	    }
414
-        	}
415
-    	    ?>
413
+				}
414
+			}
415
+			?>
416 416
     	    <?php
417
-    	        if (isset($globalAccidents) && $globalAccidents) {
418
-    	    ?>
417
+				if (isset($globalAccidents) && $globalAccidents) {
418
+			?>
419 419
             <li><hr /></li>
420 420
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
421 421
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
422 422
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
423 423
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
424 424
             <?php
425
-        	}
426
-    	    ?>
425
+			}
426
+			?>
427 427
             <li><hr /></li>
428 428
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
429 429
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -465,14 +465,14 @@  discard block
 block discarded – undo
465 465
   	    <form>
466 466
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
467 467
   		    <?php
468
-  		        $Language = new Language();
469
-  		        $alllang = $Language->getLanguages();
470
-  		        foreach ($alllang as $key => $lang) {
471
-  		            print '<option value="'.$key.'"';
472
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
473
-  		            print '>'.$lang[0].'</option>';
474
-  		        }
475
-  		    ?>
468
+  				$Language = new Language();
469
+  				$alllang = $Language->getLanguages();
470
+  				foreach ($alllang as $key => $lang) {
471
+  					print '<option value="'.$key.'"';
472
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
473
+  					print '>'.$lang[0].'</option>';
474
+  				}
475
+  			?>
476 476
   		</select>
477 477
   	    </form>
478 478
   	</div>
@@ -503,18 +503,18 @@  discard block
 block discarded – undo
503 503
 ?>
504 504
     <div class="top-header clear" role="main">
505 505
 <?php
506
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
506
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
507 507
 ?>
508 508
     <div id="archive-map"></div>
509 509
 <?php
510
-    }
510
+	}
511 511
 ?>
512 512
     </div>
513 513
 <?php
514 514
 }
515 515
 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))
516 516
 {
517
-    ?>
517
+	?>
518 518
     <div class="top-header clear" role="main">
519 519
         <div id="map"></div>
520 520
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -525,15 +525,15 @@  discard block
 block discarded – undo
525 525
         var zoom = 13;
526 526
 //create the map
527 527
 <?php
528
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
528
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
529 529
 ?>
530 530
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
531 531
 <?php
532
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
532
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
533 533
 ?>
534 534
   map = L.map('map', { zoomControl:true });
535 535
 <?php
536
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
536
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
537 537
 ?>
538 538
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
539 539
     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);
@@ -541,22 +541,22 @@  discard block
 block discarded – undo
541 541
     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);
542 542
     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);
543 543
 <?php
544
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
544
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
545 545
 ?>
546 546
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
547 547
 <?php
548
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
548
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
549 549
 ?>
550 550
   map = L.map('map', { zoomControl:true });
551 551
 <?php
552
-    }
552
+	}
553 553
 ?>
554 554
   //initialize the layer group for the aircrft markers
555 555
   var layer_data = L.layerGroup();
556 556
 
557 557
   //a few title layers
558 558
 <?php
559
-    if ($globalMapProvider == 'Mapbox') {
559
+	if ($globalMapProvider == 'Mapbox') {
560 560
 ?>
561 561
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
562 562
     maxZoom: 18,
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
     token : '<?php print $globalMapboxToken; ?>'
568 568
   }).addTo(map);
569 569
 <?php
570
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
570
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
571 571
 ?>
572 572
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
573 573
     maxZoom: 18,
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
576 576
   }).addTo(map);
577 577
 <?php
578
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
578
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
579 579
 ?>
580 580
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
581 581
     maxZoom: 18,
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
585 585
   }).addTo(map);
586 586
 <?php
587
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
587
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
588 588
 ?>
589 589
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
590 590
     maxZoom: 18,
@@ -593,27 +593,27 @@  discard block
 block discarded – undo
593 593
       '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"'
594 594
   }).addTo(map);
595 595
 <?php
596
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
596
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
597 597
 ?>
598 598
     var googleLayer = new L.Google('ROADMAP');
599 599
     map.addLayer(googleLayer);
600 600
 <?php
601
-    } elseif ($globalMapProvider == 'Google-Satellite') {
601
+	} elseif ($globalMapProvider == 'Google-Satellite') {
602 602
 ?>
603 603
     var googleLayer = new L.Google('SATELLITE');
604 604
     map.addLayer(googleLayer);
605 605
 <?php
606
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
606
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
607 607
 ?>
608 608
     var googleLayer = new L.Google('HYBRID');
609 609
     map.addLayer(googleLayer);
610 610
 <?php
611
-    } elseif ($globalMapProvider == 'Google-Terrain') {
611
+	} elseif ($globalMapProvider == 'Google-Terrain') {
612 612
 ?>
613 613
     var googleLayer = new L.Google('Terrain');
614 614
     map.addLayer(googleLayer);
615 615
 <?php
616
-    }
616
+	}
617 617
 ?>
618 618
         </script>
619 619
     </div>
Please login to merge, or discard this patch.