Completed
Push — master ( c440c8...ed2ab5 )
by Yannick
08:09
created
require/class.Stats.php 1 patch
Spacing   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 		$this->db = $Connection->db();
19 19
         }
20 20
               
21
-	public function addLastStatsUpdate($type,$stats_date) {
21
+	public function addLastStatsUpdate($type, $stats_date) {
22 22
                 $query = "DELETE FROM config WHERE name = :type;
23 23
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
24
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
25 25
                  try {
26 26
                         $sth = $this->db->prepare($query);
27 27
                         $sth->execute($query_values);
28
-                } catch(PDOException $e) {
28
+                } catch (PDOException $e) {
29 29
                         return "error : ".$e->getMessage();
30 30
                 }
31 31
         }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                  try {
36 36
                         $sth = $this->db->prepare($query);
37 37
                         $sth->execute(array(':type' => $type));
38
-                } catch(PDOException $e) {
38
+                } catch (PDOException $e) {
39 39
                         echo "error : ".$e->getMessage();
40 40
                 }
41 41
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                  try {
56 56
                         $sth = $this->db->prepare($query);
57 57
                         $sth->execute(array(':filter_name' => $filter_name));
58
-                } catch(PDOException $e) {
58
+                } catch (PDOException $e) {
59 59
                         return "error : ".$e->getMessage();
60 60
                 }
61 61
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                  try {
69 69
                         $sth = $this->db->prepare($query);
70 70
                         $sth->execute();
71
-                } catch(PDOException $e) {
71
+                } catch (PDOException $e) {
72 72
                         return "error : ".$e->getMessage();
73 73
                 }
74 74
                 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                  try {
77 77
                         $sth = $this->db->prepare($query);
78 78
                         $sth->execute(array(':filter_name' => $filter_name));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
         }
@@ -86,69 +86,69 @@  discard block
 block discarded – undo
86 86
                  try {
87 87
                         $sth = $this->db->prepare($query);
88 88
                         $sth->execute(array(':filter_name' => $filter_name));
89
-                } catch(PDOException $e) {
89
+                } catch (PDOException $e) {
90 90
                         echo "error : ".$e->getMessage();
91 91
                 }
92 92
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
93 93
                 return $all;
94 94
         }
95
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
95
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
96 96
 		if ($filter_name == '') $filter_name = $this->filter_name;
97 97
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98 98
                  try {
99 99
                         $sth = $this->db->prepare($query);
100
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
101
-                } catch(PDOException $e) {
100
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
101
+                } catch (PDOException $e) {
102 102
                         echo "error : ".$e->getMessage();
103 103
                 }
104 104
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
105 105
                 return $all;
106 106
         }
107
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
107
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
108 108
 		if ($filter_name == '') $filter_name = $this->filter_name;
109 109
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
110 110
                  try {
111 111
                         $sth = $this->db->prepare($query);
112
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
113
-                } catch(PDOException $e) {
112
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
113
+                } catch (PDOException $e) {
114 114
                         echo "error : ".$e->getMessage();
115 115
                 }
116 116
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
117 117
                 return $all;
118 118
         }
119
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
119
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
120 120
 		if ($filter_name == '') $filter_name = $this->filter_name;
121 121
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
122 122
                  try {
123 123
                         $sth = $this->db->prepare($query);
124
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
125
-                } catch(PDOException $e) {
124
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
125
+                } catch (PDOException $e) {
126 126
                         echo "error : ".$e->getMessage();
127 127
                 }
128 128
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
129 129
                 return $all;
130 130
         }
131 131
 
132
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
132
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
133 133
 		if ($filter_name == '') $filter_name = $this->filter_name;
134 134
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
135 135
                  try {
136 136
                         $sth = $this->db->prepare($query);
137
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
138
-                } catch(PDOException $e) {
137
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
138
+                } catch (PDOException $e) {
139 139
                         echo "error : ".$e->getMessage();
140 140
                 }
141 141
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
142 142
                 return $all;
143 143
         }
144 144
 
145
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
145
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
146 146
 		if ($filter_name == '') $filter_name = $this->filter_name;
147 147
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148 148
                  try {
149 149
                         $sth = $this->db->prepare($query);
150
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
151
-                } catch(PDOException $e) {
150
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
151
+                } catch (PDOException $e) {
152 152
                         echo "error : ".$e->getMessage();
153 153
                 }
154 154
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         }
157 157
 
158 158
 
159
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
159
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
160 160
 		global $globalStatsFilters;
161 161
 		if ($filter_name == '') $filter_name = $this->filter_name;
162 162
 		if ($year == '' && $month == '') {
@@ -164,24 +164,24 @@  discard block
 block discarded – undo
164 164
 			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
165 165
 			try {
166 166
 				$sth = $this->db->prepare($query);
167
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
168
-			} catch(PDOException $e) {
167
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
168
+			} catch (PDOException $e) {
169 169
 				echo "error : ".$e->getMessage();
170 170
 			}
171 171
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
172 172
 		} else $all = array();
173 173
                 if (empty($all)) {
174
-            	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
174
+            	    $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
175 175
             	    if ($filter_name != '') {
176
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
176
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
177 177
             	    }
178 178
             	    $Spotter = new Spotter($this->db);
179 179
             	    //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
180
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
180
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
181 181
                 }
182 182
                 return $all;
183 183
 	}
184
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
184
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
185 185
 		global $globalStatsFilters;
186 186
 		if ($filter_name == '') $filter_name = $this->filter_name;
187 187
 		if ($year == '' && $month == '') {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 			try {
191 191
 				$sth = $this->db->prepare($query);
192 192
 				$sth->execute(array(':filter_name' => $filter_name));
193
-			} catch(PDOException $e) {
193
+			} catch (PDOException $e) {
194 194
 				echo "error : ".$e->getMessage();
195 195
 			}
196 196
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
                 if (empty($all)) {
199 199
             		$Spotter = new Spotter($this->db);
200 200
             		$filters = array();
201
-            		$filters = array('year' => $year,'month' => $month);
201
+            		$filters = array('year' => $year, 'month' => $month);
202 202
             		if ($filter_name != '') {
203
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
203
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
204 204
 			}
205 205
             		//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
206
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
206
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
207 207
                 }
208 208
                 return $all;
209 209
 	}
210
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
210
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
211 211
 		global $globalStatsFilters;
212 212
 		if ($filter_name == '') $filter_name = $this->filter_name;
213 213
 		if ($year == '' && $month == '') {
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
216 216
 			try {
217 217
 				$sth = $this->db->prepare($query);
218
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
219
-			} catch(PDOException $e) {
218
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
219
+			} catch (PDOException $e) {
220 220
 				echo "error : ".$e->getMessage();
221 221
 			}
222 222
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
223 223
 		} else $all = array();
224 224
 		if (empty($all)) {
225
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
225
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
226 226
 			if ($filter_name != '') {
227
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
227
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
228 228
 			}
229 229
 			$Spotter = new Spotter($this->db);
230 230
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		return $all;
234 234
 	}
235 235
 
236
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
236
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
237 237
 		global $globalStatsFilters;
238 238
 		if ($filter_name == '') $filter_name = $this->filter_name;
239 239
 		if ($year == '' && $month == '') {
@@ -241,20 +241,20 @@  discard block
 block discarded – undo
241 241
 			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
242 242
 			try {
243 243
 				$sth = $this->db->prepare($query);
244
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
245
-			} catch(PDOException $e) {
244
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
245
+			} catch (PDOException $e) {
246 246
 				echo "error : ".$e->getMessage();
247 247
 			}
248 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
249 249
 		} else $all = array();
250 250
                 if (empty($all)) {
251
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
251
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
252 252
 			if ($filter_name != '') {
253
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
253
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
254 254
 			}
255 255
 			$Spotter = new Spotter($this->db);
256 256
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
257
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
257
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
258 258
                 }
259 259
                 return $all;
260 260
 	}
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
266 266
                  try {
267 267
                         $sth = $this->db->prepare($query);
268
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
269
-                } catch(PDOException $e) {
268
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
269
+                } catch (PDOException $e) {
270 270
                         echo "error : ".$e->getMessage();
271 271
                 }
272 272
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
273 273
                 if (empty($all)) {
274
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
274
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
275 275
 			if ($filter_name != '') {
276
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
276
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
277 277
 			}
278 278
 			$Spotter = new Spotter($this->db);
279 279
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 return $all;
283 283
 	}
284 284
 
285
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
285
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
286 286
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
287 287
 		if ($filter_name == '') $filter_name = $this->filter_name;
288 288
 		if ($year == '' && $month == '') {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			if (isset($forsource)) {
292 292
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
293 293
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
294
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
294
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
295 295
 			} else {
296 296
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
297 297
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 			try {
301 301
 				$sth = $this->db->prepare($query);
302 302
 				$sth->execute($query_values);
303
-			} catch(PDOException $e) {
303
+			} catch (PDOException $e) {
304 304
 				echo "error : ".$e->getMessage();
305 305
 			}
306 306
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
                 if (empty($all)) {
309 309
 	                $Spotter = new Spotter($this->db);
310 310
             		$filters = array();
311
-			$filters = array('year' => $year,'month' => $month);
311
+			$filters = array('year' => $year, 'month' => $month);
312 312
             		if ($filter_name != '') {
313
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
313
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
314 314
 			}
315 315
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
316
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
316
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
317 317
                 }
318 318
                 return $all;
319 319
 	}
320
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
320
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
321 321
 		global $globalStatsFilters;
322 322
 		if ($filter_name == '') $filter_name = $this->filter_name;
323 323
 		if ($year == '' && $month == '') {
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
 			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
326 326
 			try {
327 327
 				$sth = $this->db->prepare($query);
328
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
329
-			} catch(PDOException $e) {
328
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
329
+			} catch (PDOException $e) {
330 330
 				echo "error : ".$e->getMessage();
331 331
 			}
332 332
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
333 333
 		} else $all = array();
334 334
                 if (empty($all)) {
335
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
335
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
336 336
 			if ($filter_name != '') {
337
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
337
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
338 338
 			}
339 339
 	                $Spotter = new Spotter($this->db);
340 340
     		        //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
341
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
341
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
342 342
                 }
343 343
                 return $all;
344 344
 	}
345
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
345
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
346 346
 		global $globalStatsFilters;
347 347
 		if ($filter_name == '') $filter_name = $this->filter_name;
348 348
 		if ($year == '' && $month == '') {
@@ -350,24 +350,24 @@  discard block
 block discarded – undo
350 350
 			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
351 351
 			 try {
352 352
 				$sth = $this->db->prepare($query);
353
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
354
-			} catch(PDOException $e) {
353
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
354
+			} catch (PDOException $e) {
355 355
 				echo "error : ".$e->getMessage();
356 356
 			}
357 357
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
358 358
 		} else $all = array();
359 359
 		if (empty($all)) {
360
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
360
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
361 361
 			if ($filter_name != '') {
362
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
362
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
363 363
 			}
364 364
 			$Spotter = new Spotter($this->db);
365 365
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
366
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
366
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
367 367
 		}
368 368
 		return $all;
369 369
 	}
370
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
370
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
371 371
 		$Connection = new Connection();
372 372
 		if ($filter_name == '') $filter_name = $this->filter_name;
373 373
 		if ($Connection->tableExists('countries')) {
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
377 377
 				 try {
378 378
 					$sth = $this->db->prepare($query);
379
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
380
-				} catch(PDOException $e) {
379
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
380
+				} catch (PDOException $e) {
381 381
 					echo "error : ".$e->getMessage();
382 382
 				}
383 383
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			return array();
394 394
 		}
395 395
 	}
396
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
396
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
397 397
 		global $globalStatsFilters;
398 398
 		if ($filter_name == '') $filter_name = $this->filter_name;
399 399
 		if ($year == '' && $month == '') {
@@ -401,25 +401,25 @@  discard block
 block discarded – undo
401 401
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
402 402
 			try {
403 403
 				$sth = $this->db->prepare($query);
404
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
405
-			} catch(PDOException $e) {
404
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
405
+			} catch (PDOException $e) {
406 406
 				echo "error : ".$e->getMessage();
407 407
 			}
408 408
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
409 409
 		} else $all = array();
410 410
 		if (empty($all)) {
411
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
411
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
412 412
 			if ($filter_name != '') {
413
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
413
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
414 414
 			}
415 415
 			$Spotter = new Spotter($this->db);
416 416
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
417
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
417
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
418 418
 		}
419 419
 		return $all;
420 420
 	}
421 421
 
422
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
422
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
423 423
 		global $globalStatsFilters;
424 424
 		if ($filter_name == '') $filter_name = $this->filter_name;
425 425
 		if ($year == '' && $month == '') {
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
 			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
428 428
 			try {
429 429
 				$sth = $this->db->prepare($query);
430
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
431
-			} catch(PDOException $e) {
430
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
431
+			} catch (PDOException $e) {
432 432
 				echo "error : ".$e->getMessage();
433 433
 			}
434 434
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
435 435
 		} else $all = array();
436 436
                 if (empty($all)) {
437
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
437
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
438 438
 			if ($filter_name != '') {
439
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
439
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
440 440
 			}
441 441
             		$Spotter = new Spotter($this->db);
442 442
             		//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
443
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
443
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
444 444
                 }
445 445
                 return $all;
446 446
 	}
447
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
448 448
 		global $globalStatsFilters;
449 449
 		if ($filter_name == '') $filter_name = $this->filter_name;
450 450
 		if ($year == '' && $month == '') {
@@ -452,22 +452,22 @@  discard block
 block discarded – undo
452 452
 			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
453 453
 			try {
454 454
 				$sth = $this->db->prepare($query);
455
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
456
-			} catch(PDOException $e) {
455
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
456
+			} catch (PDOException $e) {
457 457
 				echo "error : ".$e->getMessage();
458 458
 			}
459 459
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
460 460
 		} else $all = array();
461 461
                 if (empty($all)) {
462
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
462
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
463 463
             		if ($filter_name != '') {
464
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
464
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
465 465
 			}
466 466
             		$Spotter = new Spotter($this->db);
467 467
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
468 468
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
469
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
470
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
469
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
470
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
471 471
         		$all = array();
472 472
         		foreach ($pall as $value) {
473 473
         			$icao = $value['airport_departure_icao'];
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
         		foreach ($all as $key => $row) {
485 485
         			$count[$key] = $row['airport_departure_icao_count'];
486 486
         		}
487
-        		array_multisort($count,SORT_DESC,$all);
487
+        		array_multisort($count, SORT_DESC, $all);
488 488
                 }
489 489
                 return $all;
490 490
 	}
491
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
491
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
492 492
 		global $globalStatsFilters;
493 493
 		if ($filter_name == '') $filter_name = $this->filter_name;
494 494
 		if ($year == '' && $month == '') {
@@ -496,22 +496,22 @@  discard block
 block discarded – undo
496 496
 			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
497 497
 			try {
498 498
 				$sth = $this->db->prepare($query);
499
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
500
-			} catch(PDOException $e) {
499
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
500
+			} catch (PDOException $e) {
501 501
 				echo "error : ".$e->getMessage();
502 502
 			}
503 503
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
504 504
 		} else $all = array();
505 505
 		if (empty($all)) {
506
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
506
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
507 507
 			if ($filter_name != '') {
508
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
508
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
509 509
 			}
510 510
 			$Spotter = new Spotter($this->db);
511 511
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
512 512
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
513
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
514
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
513
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
514
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
515 515
         		$all = array();
516 516
         		foreach ($pall as $value) {
517 517
         			$icao = $value['airport_arrival_icao'];
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
         		foreach ($all as $key => $row) {
529 529
         			$count[$key] = $row['airport_arrival_icao_count'];
530 530
         		}
531
-        		array_multisort($count,SORT_DESC,$all);
531
+        		array_multisort($count, SORT_DESC, $all);
532 532
                 }
533 533
  
534 534
                 return $all;
535 535
 	}
536
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
536
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
537 537
 		global $globalDBdriver, $globalStatsFilters;
538 538
 		if ($filter_name == '') $filter_name = $this->filter_name;
539 539
 		if ($globalDBdriver == 'mysql') {
@@ -543,18 +543,18 @@  discard block
 block discarded – undo
543 543
 			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
544 544
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
545 545
 		}
546
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
546
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
547 547
                  try {
548 548
                         $sth = $this->db->prepare($query);
549 549
                         $sth->execute($query_data);
550
-                } catch(PDOException $e) {
550
+                } catch (PDOException $e) {
551 551
                         echo "error : ".$e->getMessage();
552 552
                 }
553 553
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
554 554
                 if (empty($all)) {
555 555
 			$filters = array('airlines' => array($stats_airline));
556 556
 			if ($filter_name != '') {
557
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
557
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
558 558
 			}
559 559
             		$Spotter = new Spotter($this->db);
560 560
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -563,29 +563,29 @@  discard block
 block discarded – undo
563 563
                 return $all;
564 564
 	}
565 565
 	
566
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
566
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
567 567
 		global $globalStatsFilters;
568 568
 		if ($filter_name == '') $filter_name = $this->filter_name;
569 569
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
570
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
570
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
571 571
                  try {
572 572
                         $sth = $this->db->prepare($query);
573 573
                         $sth->execute($query_data);
574
-                } catch(PDOException $e) {
574
+                } catch (PDOException $e) {
575 575
                         echo "error : ".$e->getMessage();
576 576
                 }
577 577
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
578 578
                 if (empty($all)) {
579 579
 			$filters = array('airlines' => array($stats_airline));
580 580
 			if ($filter_name != '') {
581
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
581
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
582 582
 			}
583 583
             		$Spotter = new Spotter($this->db);
584 584
             		$all = $Spotter->countAllDatesLastMonth($filters);
585 585
                 }
586 586
                 return $all;
587 587
 	}
588
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
588
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
589 589
 		global $globalDBdriver, $globalStatsFilters;
590 590
 		if ($filter_name == '') $filter_name = $this->filter_name;
591 591
 		if ($globalDBdriver == 'mysql') {
@@ -593,40 +593,40 @@  discard block
 block discarded – undo
593 593
 		} else {
594 594
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
595 595
 		}
596
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
596
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
597 597
                  try {
598 598
                         $sth = $this->db->prepare($query);
599 599
                         $sth->execute($query_data);
600
-                } catch(PDOException $e) {
600
+                } catch (PDOException $e) {
601 601
                         echo "error : ".$e->getMessage();
602 602
                 }
603 603
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
604 604
                 if (empty($all)) {
605 605
 			$filters = array('airlines' => array($stats_airline));
606 606
 			if ($filter_name != '') {
607
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
607
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
608 608
 			}
609 609
             		$Spotter = new Spotter($this->db);
610 610
             		$all = $Spotter->countAllDatesLast7Days($filters);
611 611
                 }
612 612
                 return $all;
613 613
 	}
614
-	public function countAllDates($stats_airline = '',$filter_name = '') {
614
+	public function countAllDates($stats_airline = '', $filter_name = '') {
615 615
 		global $globalStatsFilters;
616 616
 		if ($filter_name == '') $filter_name = $this->filter_name;
617 617
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC";
618
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
618
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
619 619
                  try {
620 620
                         $sth = $this->db->prepare($query);
621 621
                         $sth->execute($query_data);
622
-                } catch(PDOException $e) {
622
+                } catch (PDOException $e) {
623 623
                         echo "error : ".$e->getMessage();
624 624
                 }
625 625
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
626 626
                 if (empty($all)) {
627 627
 			$filters = array('airlines' => array($stats_airline));
628 628
 			if ($filter_name != '') {
629
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
629
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
630 630
 			}
631 631
             		$Spotter = new Spotter($this->db);
632 632
             		$all = $Spotter->countAllDates($filters);
@@ -641,21 +641,21 @@  discard block
 block discarded – undo
641 641
                  try {
642 642
                         $sth = $this->db->prepare($query);
643 643
                         $sth->execute($query_data);
644
-                } catch(PDOException $e) {
644
+                } catch (PDOException $e) {
645 645
                         echo "error : ".$e->getMessage();
646 646
                 }
647 647
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
648 648
                 if (empty($all)) {
649 649
             		$filters = array();
650 650
             		if ($filter_name != '') {
651
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
651
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
652 652
 			}
653 653
             		$Spotter = new Spotter($this->db);
654 654
             		$all = $Spotter->countAllDatesByAirlines($filters);
655 655
                 }
656 656
                 return $all;
657 657
 	}
658
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
658
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
659 659
 		global $globalStatsFilters, $globalDBdriver;
660 660
 		if ($filter_name == '') $filter_name = $this->filter_name;
661 661
 		if ($globalDBdriver == 'mysql') {
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
                  try {
667 667
                         $sth = $this->db->prepare($query);
668 668
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
669
-                } catch(PDOException $e) {
669
+                } catch (PDOException $e) {
670 670
                         echo "error : ".$e->getMessage();
671 671
                 }
672 672
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                 if (empty($all)) {
675 675
 			$filters = array('airlines' => array($stats_airline));
676 676
 			if ($filter_name != '') {
677
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
677
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
678 678
 			}
679 679
             		$Spotter = new Spotter($this->db);
680 680
             		$all = $Spotter->countAllMonths($filters);
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
                  try {
693 693
                         $sth = $this->db->prepare($query);
694 694
                         $sth->execute();
695
-                } catch(PDOException $e) {
695
+                } catch (PDOException $e) {
696 696
                         echo "error : ".$e->getMessage();
697 697
                 }
698 698
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
                  try {
714 714
                         $sth = $this->db->prepare($query);
715 715
                         $sth->execute();
716
-                } catch(PDOException $e) {
716
+                } catch (PDOException $e) {
717 717
                         echo "error : ".$e->getMessage();
718 718
                 }
719 719
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -731,21 +731,21 @@  discard block
 block discarded – undo
731 731
                  try {
732 732
                         $sth = $this->db->prepare($query);
733 733
                         $sth->execute(array(':filter_name' => $filter_name));
734
-                } catch(PDOException $e) {
734
+                } catch (PDOException $e) {
735 735
                         echo "error : ".$e->getMessage();
736 736
                 }
737 737
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
738 738
                 if (empty($all)) {
739 739
             		$filters = array();
740 740
             		if ($filter_name != '') {
741
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
741
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
742 742
 			}
743 743
             		$Spotter = new Spotter($this->db);
744 744
             		$all = $Spotter->countAllMilitaryMonths($filters);
745 745
                 }
746 746
                 return $all;
747 747
 	}
748
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
748
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
749 749
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
750 750
 		if ($filter_name == '') $filter_name = $this->filter_name;
751 751
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -762,30 +762,30 @@  discard block
 block discarded – undo
762 762
                  try {
763 763
                         $sth = $this->db->prepare($query);
764 764
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
765
-                } catch(PDOException $e) {
765
+                } catch (PDOException $e) {
766 766
                         echo "error : ".$e->getMessage();
767 767
                 }
768 768
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
769 769
                 if (empty($all)) {
770 770
 			$filters = array('airlines' => array($stats_airline));
771 771
 			if ($filter_name != '') {
772
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
772
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
773 773
 			}
774 774
             		$Spotter = new Spotter($this->db);
775
-            		$all = $Spotter->countAllHours($orderby,$filters);
775
+            		$all = $Spotter->countAllHours($orderby, $filters);
776 776
                 }
777 777
                 return $all;
778 778
 	}
779 779
 	
780
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
780
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
781 781
 		global $globalStatsFilters;
782 782
 		if ($filter_name == '') $filter_name = $this->filter_name;
783 783
 		if ($year == '') $year = date('Y');
784
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
784
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
785 785
 		if (empty($all)) {
786
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
786
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
787 787
 			if ($filter_name != '') {
788
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
788
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
789 789
 			}
790 790
 			$Spotter = new Spotter($this->db);
791 791
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -793,16 +793,16 @@  discard block
 block discarded – undo
793 793
 		}
794 794
 		return $all;
795 795
 	}
796
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
796
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
797 797
 		global $globalStatsFilters;
798 798
 		if ($filter_name == '') $filter_name = $this->filter_name;
799 799
 		if ($year == '') $year = date('Y');
800
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
800
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
801 801
 		if (empty($all)) {
802 802
 		        $filters = array();
803
-			$filters = array('year' => $year,'month' => $month);
803
+			$filters = array('year' => $year, 'month' => $month);
804 804
             		if ($filter_name != '') {
805
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
805
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
806 806
 			}
807 807
 			$Spotter = new Spotter($this->db);
808 808
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
 		}
811 811
 		return $all;
812 812
 	}
813
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
813
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
814 814
 		global $globalStatsFilters;
815 815
 		if ($filter_name == '') $filter_name = $this->filter_name;
816 816
 		if ($year == '') $year = date('Y');
817
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
817
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
818 818
 		if (empty($all)) {
819
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
819
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
820 820
 			if ($filter_name != '') {
821
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
821
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
822 822
 			}
823 823
 			$Spotter = new Spotter($this->db);
824 824
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -826,24 +826,24 @@  discard block
 block discarded – undo
826 826
 		}
827 827
 		return $all;
828 828
 	}
829
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
829
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
830 830
 		global $globalStatsFilters;
831 831
 		if ($filter_name == '') $filter_name = $this->filter_name;
832 832
 		if ($year == '' && $month == '') {
833 833
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
834 834
 			try {
835 835
 				$sth = $this->db->prepare($query);
836
-				$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
837
-			} catch(PDOException $e) {
836
+				$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
837
+			} catch (PDOException $e) {
838 838
 				echo "error : ".$e->getMessage();
839 839
 			}
840 840
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
841 841
 			$all = $result[0]['nb'];
842
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
842
+		} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
843 843
 		if (empty($all)) {
844
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
844
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
845 845
 			if ($filter_name != '') {
846
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
846
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
847 847
 			}
848 848
 			$Spotter = new Spotter($this->db);
849 849
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 		}
852 852
 		return $all;
853 853
 	}
854
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
854
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
855 855
 		global $globalStatsFilters;
856 856
 		if ($filter_name == '') $filter_name = $this->filter_name;
857 857
 		if ($year == '' && $month == '') {
@@ -859,17 +859,17 @@  discard block
 block discarded – undo
859 859
 			try {
860 860
 				$sth = $this->db->prepare($query);
861 861
 				$sth->execute(array(':filter_name' => $filter_name));
862
-			} catch(PDOException $e) {
862
+			} catch (PDOException $e) {
863 863
 				echo "error : ".$e->getMessage();
864 864
 			}
865 865
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
866 866
 			$all = $result[0]['nb_airline'];
867
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
867
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
868 868
 		if (empty($all)) {
869 869
             		$filters = array();
870
-			$filters = array('year' => $year,'month' => $month);
870
+			$filters = array('year' => $year, 'month' => $month);
871 871
             		if ($filter_name != '') {
872
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
872
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
873 873
 			}
874 874
 			$Spotter = new Spotter($this->db);
875 875
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 		}
878 878
 		return $all;
879 879
 	}
880
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
880
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
881 881
 		global $globalStatsFilters;
882 882
 		if ($filter_name == '') $filter_name = $this->filter_name;
883 883
 		if ($year == '' && $month == '') {
@@ -886,18 +886,18 @@  discard block
 block discarded – undo
886 886
 			try {
887 887
 				$sth = $this->db->prepare($query);
888 888
 				$sth->execute($query_values);
889
-			} catch(PDOException $e) {
889
+			} catch (PDOException $e) {
890 890
 				echo "error : ".$e->getMessage();
891 891
 			}
892 892
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
893 893
 			$all = $result[0]['nb'];
894 894
 		} else {
895
-			$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
895
+			$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
896 896
 		}
897 897
 		if (empty($all)) {
898
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
898
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
899 899
 			if ($filter_name != '') {
900
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
900
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
901 901
 			}
902 902
 			$Spotter = new Spotter($this->db);
903 903
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 		}
906 906
 		return $all;
907 907
 	}
908
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
908
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
909 909
 		global $globalStatsFilters;
910 910
 		if ($filter_name == '') $filter_name = $this->filter_name;
911 911
 		//if ($year == '') $year = date('Y');
@@ -915,18 +915,18 @@  discard block
 block discarded – undo
915 915
 			try {
916 916
 				$sth = $this->db->prepare($query);
917 917
 				$sth->execute($query_values);
918
-			} catch(PDOException $e) {
918
+			} catch (PDOException $e) {
919 919
 				echo "error : ".$e->getMessage();
920 920
 			}
921 921
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
922 922
 			$all = $result[0]['nb'];
923 923
 		} else {
924
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
924
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
925 925
 		}
926 926
 		if (empty($all)) {
927
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
927
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
928 928
 			if ($filter_name != '') {
929
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
929
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
930 930
 			}
931 931
 			$Spotter = new Spotter($this->db);
932 932
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -935,67 +935,67 @@  discard block
 block discarded – undo
935 935
 		return $all;
936 936
 	}
937 937
 
938
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
938
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940 940
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
941
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
941
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
942 942
                  try {
943 943
                         $sth = $this->db->prepare($query);
944 944
                         $sth->execute($query_values);
945
-                } catch(PDOException $e) {
945
+                } catch (PDOException $e) {
946 946
                         echo "error : ".$e->getMessage();
947 947
                 }
948 948
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
949 949
                 return $all;
950 950
 	}
951
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
951
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
952 952
 		if ($filter_name == '') $filter_name = $this->filter_name;
953 953
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
954
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
955 955
                  try {
956 956
                         $sth = $this->db->prepare($query);
957 957
                         $sth->execute($query_values);
958
-                } catch(PDOException $e) {
958
+                } catch (PDOException $e) {
959 959
                         echo "error : ".$e->getMessage();
960 960
                 }
961 961
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
962 962
                 return $all;
963 963
         }
964
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
964
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
965 965
 		if ($filter_name == '') $filter_name = $this->filter_name;
966 966
                 $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
967
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
968 968
                  try {
969 969
                         $sth = $this->db->prepare($query);
970 970
                         $sth->execute($query_values);
971
-                } catch(PDOException $e) {
971
+                } catch (PDOException $e) {
972 972
                         echo "error : ".$e->getMessage();
973 973
                 }
974 974
         }
975
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
975
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
976 976
 		if ($filter_name == '') $filter_name = $this->filter_name;
977 977
     		global $globalArchiveMonths, $globalDBdriver;
978 978
     		if ($globalDBdriver == 'mysql') {
979 979
     			if ($month == '') {
980 980
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
981
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
981
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
982 982
 			} else {
983 983
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
984
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
984
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
985 985
 			}
986 986
 		} else {
987 987
 			if ($month == '') {
988 988
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
989
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
989
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
990 990
 			} else {
991 991
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
992
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
992
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
993 993
 			}
994 994
                 }
995 995
                  try {
996 996
                         $sth = $this->db->prepare($query);
997 997
                         $sth->execute($query_values);
998
-                } catch(PDOException $e) {
998
+                } catch (PDOException $e) {
999 999
                         echo "error : ".$e->getMessage();
1000 1000
                 }
1001 1001
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
                  try {
1014 1014
                         $sth = $this->db->prepare($query);
1015 1015
                         $sth->execute($query_values);
1016
-                } catch(PDOException $e) {
1016
+                } catch (PDOException $e) {
1017 1017
                         echo "error : ".$e->getMessage();
1018 1018
                 }
1019 1019
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
                  try {
1031 1031
                         $sth = $this->db->prepare($query);
1032 1032
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1033
-                } catch(PDOException $e) {
1033
+                } catch (PDOException $e) {
1034 1034
                         echo "error : ".$e->getMessage();
1035 1035
                 }
1036 1036
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
                  try {
1048 1048
                         $sth = $this->db->prepare($query);
1049 1049
                         $sth->execute(array(':filter_name' => $filter_name));
1050
-                } catch(PDOException $e) {
1050
+                } catch (PDOException $e) {
1051 1051
                         echo "error : ".$e->getMessage();
1052 1052
                 }
1053 1053
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1064,20 +1064,20 @@  discard block
 block discarded – undo
1064 1064
                  try {
1065 1065
                         $sth = $this->db->prepare($query);
1066 1066
                         $sth->execute(array(':filter_name' => $filter_name));
1067
-                } catch(PDOException $e) {
1067
+                } catch (PDOException $e) {
1068 1068
                         echo "error : ".$e->getMessage();
1069 1069
                 }
1070 1070
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1071 1071
                 return $all[0]['total'];
1072 1072
         }
1073
-	public function getStatsOwner($owner_name,$filter_name = '') {
1073
+	public function getStatsOwner($owner_name, $filter_name = '') {
1074 1074
     		global $globalArchiveMonths, $globalDBdriver;
1075 1075
 		if ($filter_name == '') $filter_name = $this->filter_name;
1076 1076
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1077 1077
                  try {
1078 1078
                         $sth = $this->db->prepare($query);
1079
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1080
-                } catch(PDOException $e) {
1079
+                        $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1080
+                } catch (PDOException $e) {
1081 1081
                         echo "error : ".$e->getMessage();
1082 1082
                 }
1083 1083
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1095,20 +1095,20 @@  discard block
 block discarded – undo
1095 1095
                  try {
1096 1096
                         $sth = $this->db->prepare($query);
1097 1097
                         $sth->execute(array(':filter_name' => $filter_name));
1098
-                } catch(PDOException $e) {
1098
+                } catch (PDOException $e) {
1099 1099
                         echo "error : ".$e->getMessage();
1100 1100
                 }
1101 1101
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1102 1102
                 return $all[0]['total'];
1103 1103
         }
1104
-	public function getStatsPilot($pilot,$filter_name = '') {
1104
+	public function getStatsPilot($pilot, $filter_name = '') {
1105 1105
     		global $globalArchiveMonths, $globalDBdriver;
1106 1106
 		if ($filter_name == '') $filter_name = $this->filter_name;
1107 1107
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1108 1108
                  try {
1109 1109
                         $sth = $this->db->prepare($query);
1110
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1111
-                } catch(PDOException $e) {
1110
+                        $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1111
+                } catch (PDOException $e) {
1112 1112
                         echo "error : ".$e->getMessage();
1113 1113
                 }
1114 1114
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
                 else return 0;
1117 1117
         }
1118 1118
 
1119
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1119
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1120 1120
 		global $globalDBdriver;
1121 1121
 		if ($filter_name == '') $filter_name = $this->filter_name;
1122 1122
 		if ($globalDBdriver == 'mysql') {
@@ -1124,15 +1124,15 @@  discard block
 block discarded – undo
1124 1124
                 } else {
1125 1125
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1126 1126
 		}
1127
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1127
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1128 1128
                  try {
1129 1129
                         $sth = $this->db->prepare($query);
1130 1130
                         $sth->execute($query_values);
1131
-                } catch(PDOException $e) {
1131
+                } catch (PDOException $e) {
1132 1132
                         return "error : ".$e->getMessage();
1133 1133
                 }
1134 1134
         }
1135
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1135
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1136 1136
 		global $globalDBdriver;
1137 1137
 		if ($filter_name == '') $filter_name = $this->filter_name;
1138 1138
 		if ($globalDBdriver == 'mysql') {
@@ -1141,11 +1141,11 @@  discard block
 block discarded – undo
1141 1141
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1142 1142
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1143 1143
                 }
1144
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1144
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1145 1145
                  try {
1146 1146
                         $sth = $this->db->prepare($query);
1147 1147
                         $sth->execute($query_values);
1148
-                } catch(PDOException $e) {
1148
+                } catch (PDOException $e) {
1149 1149
                         return "error : ".$e->getMessage();
1150 1150
                 }
1151 1151
         }
@@ -1169,75 +1169,75 @@  discard block
 block discarded – undo
1169 1169
         }
1170 1170
         */
1171 1171
 
1172
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1172
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1173 1173
 		global $globalDBdriver;
1174 1174
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1175 1175
 		$query_values = array();
1176 1176
 		if ($globalDBdriver == 'mysql') {
1177 1177
 			if ($year != '') {
1178 1178
 				$query .= ' AND YEAR(stats_date) = :year';
1179
-				$query_values = array_merge($query_values,array(':year' => $year));
1179
+				$query_values = array_merge($query_values, array(':year' => $year));
1180 1180
 			}
1181 1181
 			if ($month != '') {
1182 1182
 				$query .= ' AND MONTH(stats_date) = :month';
1183
-				$query_values = array_merge($query_values,array(':month' => $month));
1183
+				$query_values = array_merge($query_values, array(':month' => $month));
1184 1184
 			}
1185 1185
 			if ($day != '') {
1186 1186
 				$query .= ' AND DAY(stats_date) = :day';
1187
-				$query_values = array_merge($query_values,array(':day' => $day));
1187
+				$query_values = array_merge($query_values, array(':day' => $day));
1188 1188
 			}
1189 1189
 		} else {
1190 1190
 			if ($year != '') {
1191 1191
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1192
-				$query_values = array_merge($query_values,array(':year' => $year));
1192
+				$query_values = array_merge($query_values, array(':year' => $year));
1193 1193
 			}
1194 1194
 			if ($month != '') {
1195 1195
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1196
-				$query_values = array_merge($query_values,array(':month' => $month));
1196
+				$query_values = array_merge($query_values, array(':month' => $month));
1197 1197
 			}
1198 1198
 			if ($day != '') {
1199 1199
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1200
-				$query_values = array_merge($query_values,array(':day' => $day));
1200
+				$query_values = array_merge($query_values, array(':day' => $day));
1201 1201
 			}
1202 1202
 		}
1203 1203
 		$query .= " ORDER BY source_name";
1204
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1204
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1205 1205
 		try {
1206 1206
 			$sth = $this->db->prepare($query);
1207 1207
 			$sth->execute($query_values);
1208
-		} catch(PDOException $e) {
1208
+		} catch (PDOException $e) {
1209 1209
 			echo "error : ".$e->getMessage();
1210 1210
 		}
1211 1211
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1212 1212
 		return $all;
1213 1213
 	}
1214 1214
 
1215
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1215
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1216 1216
 		global $globalDBdriver;
1217 1217
 		if ($globalDBdriver == 'mysql') {
1218 1218
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1219 1219
 		} else {
1220 1220
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1221 1221
                 }
1222
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1222
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1223 1223
                  try {
1224 1224
                         $sth = $this->db->prepare($query);
1225 1225
                         $sth->execute($query_values);
1226
-                } catch(PDOException $e) {
1226
+                } catch (PDOException $e) {
1227 1227
                         return "error : ".$e->getMessage();
1228 1228
                 }
1229 1229
         }
1230
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1230
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1231 1231
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1232
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1232
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1233 1233
                  try {
1234 1234
                         $sth = $this->db->prepare($query);
1235 1235
                         $sth->execute($query_values);
1236
-                } catch(PDOException $e) {
1236
+                } catch (PDOException $e) {
1237 1237
                         return "error : ".$e->getMessage();
1238 1238
                 }
1239 1239
         }
1240
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1240
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1241 1241
 		global $globalDBdriver;
1242 1242
 		if ($globalDBdriver == 'mysql') {
1243 1243
 			if ($reset) {
@@ -1252,15 +1252,15 @@  discard block
 block discarded – undo
1252 1252
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1253 1253
 			}
1254 1254
 		}
1255
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1255
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1256 1256
                  try {
1257 1257
                         $sth = $this->db->prepare($query);
1258 1258
                         $sth->execute($query_values);
1259
-                } catch(PDOException $e) {
1259
+                } catch (PDOException $e) {
1260 1260
                         return "error : ".$e->getMessage();
1261 1261
                 }
1262 1262
         }
1263
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1263
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1264 1264
 		global $globalDBdriver;
1265 1265
 		if ($globalDBdriver == 'mysql') {
1266 1266
 			if ($reset) {
@@ -1275,15 +1275,15 @@  discard block
 block discarded – undo
1275 1275
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1276 1276
 			}
1277 1277
 		}
1278
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1278
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1279 1279
                  try {
1280 1280
                         $sth = $this->db->prepare($query);
1281 1281
                         $sth->execute($query_values);
1282
-                } catch(PDOException $e) {
1282
+                } catch (PDOException $e) {
1283 1283
                         return "error : ".$e->getMessage();
1284 1284
                 }
1285 1285
         }
1286
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1286
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1287 1287
 		global $globalDBdriver;
1288 1288
 		if ($globalDBdriver == 'mysql') {
1289 1289
 			if ($reset) {
@@ -1298,15 +1298,15 @@  discard block
 block discarded – undo
1298 1298
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1299 1299
 			}
1300 1300
 		}
1301
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1301
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1302 1302
                  try {
1303 1303
                         $sth = $this->db->prepare($query);
1304 1304
                         $sth->execute($query_values);
1305
-                } catch(PDOException $e) {
1305
+                } catch (PDOException $e) {
1306 1306
                         return "error : ".$e->getMessage();
1307 1307
                 }
1308 1308
         }
1309
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1309
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1310 1310
 		global $globalDBdriver;
1311 1311
 		if ($globalDBdriver == 'mysql') {
1312 1312
 			if ($reset) {
@@ -1321,15 +1321,15 @@  discard block
 block discarded – undo
1321 1321
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1322 1322
 			}
1323 1323
 		}
1324
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1324
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1325 1325
                  try {
1326 1326
                         $sth = $this->db->prepare($query);
1327 1327
                         $sth->execute($query_values);
1328
-                } catch(PDOException $e) {
1328
+                } catch (PDOException $e) {
1329 1329
                         return "error : ".$e->getMessage();
1330 1330
                 }
1331 1331
         }
1332
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1332
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1333 1333
 		global $globalDBdriver;
1334 1334
 		if ($globalDBdriver == 'mysql') {
1335 1335
 			if ($reset) {
@@ -1344,15 +1344,15 @@  discard block
 block discarded – undo
1344 1344
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1345 1345
 			}
1346 1346
 		}
1347
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1347
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1348 1348
                  try {
1349 1349
                         $sth = $this->db->prepare($query);
1350 1350
                         $sth->execute($query_values);
1351
-                } catch(PDOException $e) {
1351
+                } catch (PDOException $e) {
1352 1352
                         return "error : ".$e->getMessage();
1353 1353
                 }
1354 1354
         }
1355
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1355
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1356 1356
 		global $globalDBdriver;
1357 1357
 		if ($globalDBdriver == 'mysql') {
1358 1358
 			if ($reset) {
@@ -1367,15 +1367,15 @@  discard block
 block discarded – undo
1367 1367
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1368 1368
 			}
1369 1369
 		}
1370
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1370
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1371 1371
                  try {
1372 1372
                         $sth = $this->db->prepare($query);
1373 1373
                         $sth->execute($query_values);
1374
-                } catch(PDOException $e) {
1374
+                } catch (PDOException $e) {
1375 1375
                         return "error : ".$e->getMessage();
1376 1376
                 }
1377 1377
         }
1378
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1378
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1379 1379
 		global $globalDBdriver;
1380 1380
 		if ($globalDBdriver == 'mysql') {
1381 1381
 			if ($reset) {
@@ -1390,15 +1390,15 @@  discard block
 block discarded – undo
1390 1390
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1391 1391
 			}
1392 1392
 		}
1393
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1393
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1394 1394
                  try {
1395 1395
                         $sth = $this->db->prepare($query);
1396 1396
                         $sth->execute($query_values);
1397
-                } catch(PDOException $e) {
1397
+                } catch (PDOException $e) {
1398 1398
                         return "error : ".$e->getMessage();
1399 1399
                 }
1400 1400
         }
1401
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1401
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1402 1402
 		global $globalDBdriver;
1403 1403
 		if ($airport_icao != '') {
1404 1404
 			if ($globalDBdriver == 'mysql') {
@@ -1414,16 +1414,16 @@  discard block
 block discarded – undo
1414 1414
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1415 1415
 				}
1416 1416
 			}
1417
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1417
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1418 1418
 			try {
1419 1419
 				$sth = $this->db->prepare($query);
1420 1420
 				$sth->execute($query_values);
1421
-			} catch(PDOException $e) {
1421
+			} catch (PDOException $e) {
1422 1422
 				return "error : ".$e->getMessage();
1423 1423
 			}
1424 1424
                 }
1425 1425
         }
1426
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1426
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1427 1427
 		global $globalDBdriver;
1428 1428
 		if ($airport_icao != '') {
1429 1429
 			if ($globalDBdriver == 'mysql') {
@@ -1431,16 +1431,16 @@  discard block
 block discarded – undo
1431 1431
 			} else {
1432 1432
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1433 1433
 			}
1434
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1434
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1435 1435
 			 try {
1436 1436
 				$sth = $this->db->prepare($query);
1437 1437
 				$sth->execute($query_values);
1438
-			} catch(PDOException $e) {
1438
+			} catch (PDOException $e) {
1439 1439
 				return "error : ".$e->getMessage();
1440 1440
 			}
1441 1441
                 }
1442 1442
         }
1443
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1443
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1444 1444
 		global $globalDBdriver;
1445 1445
 		if ($airport_icao != '') {
1446 1446
 			if ($globalDBdriver == 'mysql') {
@@ -1456,16 +1456,16 @@  discard block
 block discarded – undo
1456 1456
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1457 1457
 				}
1458 1458
 			}
1459
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1459
+	                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1460 1460
 			 try {
1461 1461
                     		$sth = $this->db->prepare($query);
1462 1462
 	                        $sth->execute($query_values);
1463
-    		        } catch(PDOException $e) {
1463
+    		        } catch (PDOException $e) {
1464 1464
             		        return "error : ".$e->getMessage();
1465 1465
 	                }
1466 1466
 	        }
1467 1467
         }
1468
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1468
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1469 1469
 		global $globalDBdriver;
1470 1470
 		if ($airport_icao != '') {
1471 1471
 			if ($globalDBdriver == 'mysql') {
@@ -1473,11 +1473,11 @@  discard block
 block discarded – undo
1473 1473
 			} else {
1474 1474
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1475 1475
 			}
1476
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1476
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1477 1477
 			try {
1478 1478
 				$sth = $this->db->prepare($query);
1479 1479
 				$sth->execute($query_values);
1480
-			} catch(PDOException $e) {
1480
+			} catch (PDOException $e) {
1481 1481
 				return "error : ".$e->getMessage();
1482 1482
 			}
1483 1483
                 }
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
                  try {
1490 1490
                         $sth = $this->db->prepare($query);
1491 1491
                         $sth->execute($query_values);
1492
-                } catch(PDOException $e) {
1492
+                } catch (PDOException $e) {
1493 1493
                         return "error : ".$e->getMessage();
1494 1494
                 }
1495 1495
         }
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
                  try {
1500 1500
                         $sth = $this->db->prepare($query);
1501 1501
                         $sth->execute($query_values);
1502
-                } catch(PDOException $e) {
1502
+                } catch (PDOException $e) {
1503 1503
                         return "error : ".$e->getMessage();
1504 1504
                 }
1505 1505
         }
@@ -1509,13 +1509,13 @@  discard block
 block discarded – undo
1509 1509
                  try {
1510 1510
                         $sth = $this->db->prepare($query);
1511 1511
                         $sth->execute($query_values);
1512
-                } catch(PDOException $e) {
1512
+                } catch (PDOException $e) {
1513 1513
                         return "error : ".$e->getMessage();
1514 1514
                 }
1515 1515
         }
1516 1516
         
1517 1517
         public function addOldStats() {
1518
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
1518
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
1519 1519
     		$Common = new Common();
1520 1520
     		$Connection = new Connection();
1521 1521
     		date_default_timezone_set('UTC');
@@ -1533,41 +1533,41 @@  discard block
 block discarded – undo
1533 1533
 			$Spotter = new Spotter($this->db);
1534 1534
 
1535 1535
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1536
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1536
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1537 1537
 			foreach ($alldata as $number) {
1538
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1538
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1539 1539
 			}
1540 1540
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1541
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1541
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1542 1542
 			foreach ($alldata as $number) {
1543
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1543
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1544 1544
 			}
1545 1545
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1546
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1546
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1547 1547
 			foreach ($alldata as $number) {
1548
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1548
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1549 1549
 			}
1550 1550
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1551
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1551
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1552 1552
 			foreach ($alldata as $number) {
1553
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1553
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1554 1554
 			}
1555 1555
 			if ($globalDebug) echo 'Count all owners...'."\n";
1556
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1556
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1557 1557
 			foreach ($alldata as $number) {
1558
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1558
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1559 1559
 			}
1560 1560
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1561
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1561
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1562 1562
 			foreach ($alldata as $number) {
1563 1563
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
1564
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1564
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1565 1565
 			}
1566 1566
 			
1567 1567
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1568
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1568
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1569 1569
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1570
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1570
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1571 1571
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1572 1572
 	        	$alldata = array();
1573 1573
 	        	
@@ -1585,14 +1585,14 @@  discard block
 block discarded – undo
1585 1585
     			foreach ($alldata as $key => $row) {
1586 1586
     				$count[$key] = $row['airport_departure_icao_count'];
1587 1587
         		}
1588
-			array_multisort($count,SORT_DESC,$alldata);
1588
+			array_multisort($count, SORT_DESC, $alldata);
1589 1589
 			foreach ($alldata as $number) {
1590
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1590
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
1591 1591
 			}
1592 1592
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1593
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1593
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1594 1594
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1595
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1595
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1596 1596
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1597 1597
 	        	$alldata = array();
1598 1598
     			foreach ($pall as $value) {
@@ -1609,18 +1609,18 @@  discard block
 block discarded – undo
1609 1609
         		foreach ($alldata as $key => $row) {
1610 1610
         			$count[$key] = $row['airport_arrival_icao_count'];
1611 1611
 	        	}
1612
-    			array_multisort($count,SORT_DESC,$alldata);
1612
+    			array_multisort($count, SORT_DESC, $alldata);
1613 1613
                         foreach ($alldata as $number) {
1614
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1614
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
1615 1615
 			}
1616 1616
 			if ($Connection->tableExists('countries')) {
1617 1617
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1618 1618
 				//$SpotterArchive = new SpotterArchive();
1619 1619
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1620 1620
 				$Spotter = new Spotter($this->db);
1621
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
1621
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
1622 1622
 				foreach ($alldata as $number) {
1623
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1623
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1624 1624
 				}
1625 1625
 			}
1626 1626
 			
@@ -1630,12 +1630,12 @@  discard block
 block discarded – undo
1630 1630
 				$this->deleteStatsByType('fatalities_byyear');
1631 1631
 				$alldata = $Accident->countFatalitiesByYear();
1632 1632
 				foreach ($alldata as $number) {
1633
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
1633
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
1634 1634
 				}
1635 1635
 				$this->deleteStatsByType('fatalities_bymonth');
1636 1636
 				$alldata = $Accident->countFatalitiesLast12Months();
1637 1637
 				foreach ($alldata as $number) {
1638
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
1638
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
1639 1639
 				}
1640 1640
 			}
1641 1641
 
@@ -1651,37 +1651,37 @@  discard block
 block discarded – undo
1651 1651
 			$lastyear = false;
1652 1652
 			foreach ($alldata as $number) {
1653 1653
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1654
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1654
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1655 1655
 			}
1656 1656
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1657 1657
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
1658 1658
 			foreach ($alldata as $number) {
1659
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1659
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1660 1660
 			}
1661 1661
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1662 1662
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
1663 1663
 			foreach ($alldata as $number) {
1664
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1664
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1665 1665
 			}
1666 1666
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1667 1667
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
1668 1668
 			foreach ($alldata as $number) {
1669
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1669
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1670 1670
 			}
1671 1671
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1672 1672
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
1673 1673
 			foreach ($alldata as $number) {
1674
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1674
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1675 1675
 			}
1676 1676
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1677 1677
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
1678 1678
 			foreach ($alldata as $number) {
1679
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1679
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1680 1680
 			}
1681 1681
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1682 1682
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
1683 1683
 			foreach ($alldata as $number) {
1684
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1684
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1685 1685
 			}
1686 1686
 			if ($globalDebug) echo 'Airports data...'."\n";
1687 1687
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
     			}
1727 1727
     			$alldata = $pall;
1728 1728
 			foreach ($alldata as $number) {
1729
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1729
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1730 1730
 			}
1731 1731
 			echo '...Arrival'."\n";
1732 1732
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
     			}
1769 1769
     			$alldata = $pall;
1770 1770
 			foreach ($alldata as $number) {
1771
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1771
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1772 1772
 			}
1773 1773
 
1774 1774
 			echo 'Flights data...'."\n";
@@ -1776,28 +1776,28 @@  discard block
 block discarded – undo
1776 1776
 			echo '-> countAllDatesLastMonth...'."\n";
1777 1777
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
1778 1778
 			foreach ($alldata as $number) {
1779
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1779
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1780 1780
 			}
1781 1781
 			echo '-> countAllDates...'."\n";
1782 1782
 			$previousdata = $this->countAllDates();
1783 1783
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1784 1784
 			$this->deleteStatFlight('date');
1785
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
1785
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
1786 1786
 			$values = array();
1787 1787
 			foreach ($alldata as $cnt) {
1788 1788
 				$values[] = $cnt['date_count'];
1789 1789
 			}
1790
-			array_multisort($values,SORT_DESC,$alldata);
1791
-			array_splice($alldata,11);
1790
+			array_multisort($values, SORT_DESC, $alldata);
1791
+			array_splice($alldata, 11);
1792 1792
 			foreach ($alldata as $number) {
1793
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1793
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1794 1794
 			}
1795 1795
 			
1796 1796
 			$this->deleteStatFlight('hour');
1797 1797
 			echo '-> countAllHours...'."\n";
1798
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
1798
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
1799 1799
 			foreach ($alldata as $number) {
1800
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1800
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1801 1801
 			}
1802 1802
 
1803 1803
 
@@ -1808,42 +1808,42 @@  discard block
 block discarded – undo
1808 1808
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1809 1809
 				$SpotterArchive = new SpotterArchive();
1810 1810
 				//$Spotter = new Spotter($this->db);
1811
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1811
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1812 1812
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1813 1813
 				foreach ($alldata as $number) {
1814
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1814
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1815 1815
 				}
1816 1816
 			}
1817 1817
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1818 1818
 			$Spotter = new Spotter($this->db);
1819
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1819
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1820 1820
 			foreach ($alldata as $number) {
1821
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1821
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1822 1822
 			}
1823 1823
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1824
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1824
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1825 1825
 			foreach ($alldata as $number) {
1826
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1826
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1827 1827
 			}
1828 1828
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1829
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1829
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1830 1830
 			foreach ($alldata as $number) {
1831
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1831
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1832 1832
 			}
1833 1833
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1834
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1834
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1835 1835
 			foreach ($alldata as $number) {
1836
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1836
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1837 1837
 			}
1838 1838
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1839
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1839
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1840 1840
 			foreach ($alldata as $number) {
1841
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1841
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1842 1842
 			}
1843 1843
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1844
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1844
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1845 1845
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1846
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1846
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1847 1847
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1848 1848
 	        	//$alldata = array();
1849 1849
     			foreach ($dall as $value) {
@@ -1863,12 +1863,12 @@  discard block
 block discarded – undo
1863 1863
     			}
1864 1864
     			$alldata = $pall;
1865 1865
 			foreach ($alldata as $number) {
1866
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1866
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
1867 1867
 			}
1868 1868
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1869
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1869
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1870 1870
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1871
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1871
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1872 1872
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1873 1873
 	        	//$alldata = array();
1874 1874
     			foreach ($dall as $value) {
@@ -1888,7 +1888,7 @@  discard block
 block discarded – undo
1888 1888
     			}
1889 1889
     			$alldata = $pall;
1890 1890
                         foreach ($alldata as $number) {
1891
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
1891
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
1892 1892
 			}
1893 1893
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1894 1894
 			$Spotter = new Spotter($this->db);
@@ -1896,27 +1896,27 @@  discard block
 block discarded – undo
1896 1896
 			$lastyear = false;
1897 1897
 			foreach ($alldata as $number) {
1898 1898
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1899
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1899
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1900 1900
 			}
1901 1901
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1902 1902
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
1903 1903
 			foreach ($alldata as $number) {
1904
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1904
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1905 1905
 			}
1906 1906
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1907 1907
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
1908 1908
 			foreach ($alldata as $number) {
1909
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1909
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1910 1910
 			}
1911 1911
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1912 1912
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
1913 1913
 			foreach ($alldata as $number) {
1914
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1914
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1915 1915
 			}
1916 1916
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1917 1917
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
1918 1918
 			foreach ($alldata as $number) {
1919
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1919
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1920 1920
 			}
1921 1921
 			if ($globalDebug) echo '...Departure'."\n";
1922 1922
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1939,7 +1939,7 @@  discard block
 block discarded – undo
1939 1939
     			}
1940 1940
     			$alldata = $pall;
1941 1941
 			foreach ($alldata as $number) {
1942
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1942
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']);
1943 1943
 			}
1944 1944
 			if ($globalDebug) echo '...Arrival'."\n";
1945 1945
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1962,32 +1962,32 @@  discard block
 block discarded – undo
1962 1962
     			}
1963 1963
     			$alldata = $pall;
1964 1964
 			foreach ($alldata as $number) {
1965
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1965
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']);
1966 1966
 			}
1967 1967
 
1968 1968
 			if ($globalDebug) echo 'Flights data...'."\n";
1969 1969
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1970 1970
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
1971 1971
 			foreach ($alldata as $number) {
1972
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1972
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1973 1973
 			}
1974 1974
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1975 1975
 			//$previousdata = $this->countAllDatesByAirlines();
1976
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
1976
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
1977 1977
 			$values = array();
1978 1978
 			foreach ($alldata as $cnt) {
1979 1979
 				$values[] = $cnt['date_count'];
1980 1980
 			}
1981
-			array_multisort($values,SORT_DESC,$alldata);
1982
-			array_splice($alldata,11);
1981
+			array_multisort($values, SORT_DESC, $alldata);
1982
+			array_splice($alldata, 11);
1983 1983
 			foreach ($alldata as $number) {
1984
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1984
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1985 1985
 			}
1986 1986
 			
1987 1987
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1988
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
1988
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
1989 1989
 			foreach ($alldata as $number) {
1990
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1990
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1991 1991
 			}
1992 1992
 			
1993 1993
 
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
 						$last_update_day = date('Y').'-01-01 00:00:00';
2012 2012
 					}
2013 2013
 				}
2014
-				if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
2014
+				if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
2015 2015
 					$last_update_day = date('Y').'-01-01 00:00:00';
2016 2016
 					$reset = true;
2017 2017
 				}
@@ -2020,32 +2020,32 @@  discard block
 block discarded – undo
2020 2020
 				// Count by filter
2021 2021
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2022 2022
 				$Spotter = new Spotter($this->db);
2023
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2023
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
2024 2024
 				foreach ($alldata as $number) {
2025
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2025
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
2026 2026
 				}
2027
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2027
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
2028 2028
 				foreach ($alldata as $number) {
2029
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2029
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
2030 2030
 				}
2031
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2031
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
2032 2032
 				foreach ($alldata as $number) {
2033
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2033
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
2034 2034
 				}
2035
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2035
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
2036 2036
 				foreach ($alldata as $number) {
2037
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2037
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
2038 2038
 				}
2039
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2039
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
2040 2040
 				foreach ($alldata as $number) {
2041
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2041
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
2042 2042
 				}
2043
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2043
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
2044 2044
 				foreach ($alldata as $number) {
2045
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2045
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
2046 2046
 				}
2047
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2048
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2047
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
2048
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
2049 2049
 		        	$alldata = array();
2050 2050
 	    			foreach ($pall as $value) {
2051 2051
 		        		$icao = $value['airport_departure_icao'];
@@ -2061,12 +2061,12 @@  discard block
 block discarded – undo
2061 2061
     				foreach ($alldata as $key => $row) {
2062 2062
     					$count[$key] = $row['airport_departure_icao_count'];
2063 2063
     				}
2064
-				array_multisort($count,SORT_DESC,$alldata);
2064
+				array_multisort($count, SORT_DESC, $alldata);
2065 2065
 				foreach ($alldata as $number) {
2066
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2066
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
2067 2067
 				}
2068
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2069
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2068
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
2069
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
2070 2070
 				$alldata = array();
2071 2071
     				foreach ($pall as $value) {
2072 2072
 		        		$icao = $value['airport_arrival_icao'];
@@ -2082,40 +2082,40 @@  discard block
 block discarded – undo
2082 2082
         			foreach ($alldata as $key => $row) {
2083 2083
     					$count[$key] = $row['airport_arrival_icao_count'];
2084 2084
 		        	}
2085
-        			array_multisort($count,SORT_DESC,$alldata);
2085
+        			array_multisort($count, SORT_DESC, $alldata);
2086 2086
 				foreach ($alldata as $number) {
2087
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2087
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
2088 2088
 				}
2089 2089
 				$Spotter = new Spotter($this->db);
2090 2090
 				$alldata = $Spotter->countAllMonths($filter);
2091 2091
 				$lastyear = false;
2092 2092
 				foreach ($alldata as $number) {
2093 2093
 					if ($number['year_name'] != date('Y')) $lastyear = true;
2094
-					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2094
+					$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2095 2095
 				}
2096 2096
 				$alldata = $Spotter->countAllMonthsOwners($filter);
2097 2097
 				foreach ($alldata as $number) {
2098
-					$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2098
+					$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2099 2099
 				}
2100 2100
 				$alldata = $Spotter->countAllMonthsPilots($filter);
2101 2101
 				foreach ($alldata as $number) {
2102
-					$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2102
+					$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2103 2103
 				}
2104 2104
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
2105 2105
 				foreach ($alldata as $number) {
2106
-					$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2106
+					$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2107 2107
 				}
2108 2108
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
2109 2109
 				foreach ($alldata as $number) {
2110
-					$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2110
+					$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2111 2111
 				}
2112 2112
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2113 2113
 				foreach ($alldata as $number) {
2114
-					$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2114
+					$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
2115 2115
 				}
2116 2116
 				echo '...Departure'."\n";
2117
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
2118
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
2117
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
2118
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
2119 2119
 				foreach ($dall as $value) {
2120 2120
     					$icao = $value['departure_airport_icao'];
2121 2121
     					$ddate = $value['date'];
@@ -2133,11 +2133,11 @@  discard block
 block discarded – undo
2133 2133
     				}
2134 2134
 	    			$alldata = $pall;
2135 2135
 				foreach ($alldata as $number) {
2136
-					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
2136
+					$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
2137 2137
 				}
2138 2138
 				echo '...Arrival'."\n";
2139
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2140
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2139
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
2140
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
2141 2141
 				foreach ($dall as $value) {
2142 2142
 					$icao = $value['arrival_airport_icao'];
2143 2143
 					$ddate = $value['date'];
@@ -2155,40 +2155,40 @@  discard block
 block discarded – undo
2155 2155
     				}
2156 2156
     				$alldata = $pall;
2157 2157
 				foreach ($alldata as $number) {
2158
-					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
2158
+					$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
2159 2159
 				}
2160 2160
     
2161 2161
 				echo 'Flights data...'."\n";
2162 2162
 				echo '-> countAllDatesLastMonth...'."\n";
2163 2163
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
2164 2164
 				foreach ($alldata as $number) {
2165
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
2165
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
2166 2166
 				}
2167 2167
 				echo '-> countAllDates...'."\n";
2168
-				$previousdata = $this->countAllDates('',$filter_name);
2169
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
2168
+				$previousdata = $this->countAllDates('', $filter_name);
2169
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
2170 2170
 				$values = array();
2171 2171
 				foreach ($alldata as $cnt) {
2172 2172
 					$values[] = $cnt['date_count'];
2173 2173
 				}
2174
-				array_multisort($values,SORT_DESC,$alldata);
2175
-				array_splice($alldata,11);
2174
+				array_multisort($values, SORT_DESC, $alldata);
2175
+				array_splice($alldata, 11);
2176 2176
 				foreach ($alldata as $number) {
2177
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
2177
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
2178 2178
 				}
2179 2179
 				
2180 2180
 				echo '-> countAllHours...'."\n";
2181
-				$alldata = $Spotter->countAllHours('hour',$filter);
2181
+				$alldata = $Spotter->countAllHours('hour', $filter);
2182 2182
 				foreach ($alldata as $number) {
2183
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2183
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2184 2184
 				}
2185 2185
 				echo 'Insert last stats update date...'."\n";
2186 2186
 				date_default_timezone_set('UTC');
2187
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2187
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2188 2188
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2189
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2189
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2190 2190
 						$this->deleteOldStats($filter_name);
2191
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2191
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2192 2192
 					}
2193 2193
 				}
2194 2194
 
@@ -2201,16 +2201,16 @@  discard block
 block discarded – undo
2201 2201
 				// SUM all previous month to put as year
2202 2202
 				$previous_year = date('Y');
2203 2203
 				$previous_year--;
2204
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2205
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2206
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2207
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2204
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2205
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2206
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2207
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2208 2208
 				$allairlines = $this->getAllAirlineNames();
2209 2209
 				foreach ($allairlines as $data) {
2210
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2211
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2212
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2213
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2210
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2211
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2212
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2213
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2214 2214
 				}
2215 2215
 				
2216 2216
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2219,7 +2219,7 @@  discard block
 block discarded – undo
2219 2219
 						try {
2220 2220
 							$sth = $this->db->prepare($query);
2221 2221
 							$sth->execute();
2222
-						} catch(PDOException $e) {
2222
+						} catch (PDOException $e) {
2223 2223
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2224 2224
 						}
2225 2225
 					}
@@ -2228,15 +2228,15 @@  discard block
 block discarded – undo
2228 2228
 					try {
2229 2229
 						$sth = $this->db->prepare($query);
2230 2230
 						$sth->execute();
2231
-					} catch(PDOException $e) {
2231
+					} catch (PDOException $e) {
2232 2232
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2233 2233
 					}
2234 2234
 				}
2235 2235
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2236 2236
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2237
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2237
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2238 2238
 						$this->deleteOldStats();
2239
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2239
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2240 2240
 						$lastyearupdate = true;
2241 2241
 					}
2242 2242
 				}
@@ -2258,7 +2258,7 @@  discard block
 block discarded – undo
2258 2258
 					try {
2259 2259
 						$sth = $this->db->prepare($query);
2260 2260
 						$sth->execute();
2261
-					} catch(PDOException $e) {
2261
+					} catch (PDOException $e) {
2262 2262
 						return "error : ".$e->getMessage();
2263 2263
 					}
2264 2264
 				}
@@ -2272,14 +2272,14 @@  discard block
 block discarded – undo
2272 2272
 				try {
2273 2273
 					$sth = $this->db->prepare($query);
2274 2274
 					$sth->execute();
2275
-				} catch(PDOException $e) {
2275
+				} catch (PDOException $e) {
2276 2276
 					return "error : ".$e->getMessage();
2277 2277
 				}
2278 2278
 			}
2279 2279
 			if (!isset($lastyearupdate)) {
2280 2280
 				echo 'Insert last stats update date...'."\n";
2281 2281
 				date_default_timezone_set('UTC');
2282
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2282
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2283 2283
 			}
2284 2284
 			if ($globalStatsResetYear) {
2285 2285
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 require_once('require/class.Satellite.php');
6 6
 
7
-$trackident = filter_input(INPUT_GET,'trackid',FILTER_SANITIZE_STRING);
7
+$trackident = filter_input(INPUT_GET, 'trackid', FILTER_SANITIZE_STRING);
8 8
 if ($trackident != '') {
9 9
 	require_once('require/class.SpotterLive.php');
10 10
 	$SpotterLive = new SpotterLive();
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		$spotterid = $Spotter->getSpotterIDBasedOnFlightAwareID($trackident);
15 15
 		header('Location: '.$globalURL.'/flightid/'.$spotterid);
16 16
 	} else {
17
-		setcookie('MapTrack',$resulttrackident[0]['flightaware_id']);
17
+		setcookie('MapTrack', $resulttrackident[0]['flightaware_id']);
18 18
 	}
19 19
 } else {
20 20
 	unset($_COOKIE['MapTrack']);
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		        <div class="form-group">
190 190
 			    <label>From (UTC):</label>
191 191
 		            <div class='input-group date' id='datetimepicker1'>
192
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
192
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a", $_COOKIE['archive_begin']); ?>" required />
193 193
 		                <span class="input-group-addon">
194 194
             			    <span class="glyphicon glyphicon-calendar"></span>
195 195
 		                </span>
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 		        <div class="form-group">
199 199
 			    <label>To (UTC):</label>
200 200
 		            <div class='input-group date' id='datetimepicker2'>
201
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
201
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a", $_COOKIE['archive_end']); ?>" />
202 202
             			<span class="input-group-addon">
203 203
 		                    <span class="glyphicon glyphicon-calendar"></span>
204 204
             			</span>
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 		    <li><?php echo _("Type of Terrain:"); ?>
324 324
 			<select  class="selectpicker" onchange="terrainType(this);">
325 325
 			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
326
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
327
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
328
-			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option>
326
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected'; ?>>ellipsoid</option>
327
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected'; ?>>vr terrain</option>
328
+			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected'; ?>>ArticDEM</option>
329 329
 			</select>
330 330
 		    </li>
331 331
 <?php
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
352 352
 <?php
353 353
     }
354
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
354
+    if (time() > mktime(0, 0, 0, 12, 1, date("Y")) && time() < mktime(0, 0, 0, 12, 31, date("Y"))) {
355 355
 ?>
356 356
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
357 357
 <?php
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 					$Spotter = new Spotter();
508 508
 					$allairlinenames = $Spotter->getAllAirlineNames();
509 509
 				}
510
-				foreach($allairlinenames as $airline) {
510
+				foreach ($allairlinenames as $airline) {
511 511
 					$airline_name = $airline['airline_name'];
512
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
513
-					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
512
+					if (strlen($airline_name) > 30) $airline_name = substr($airline_name, 0, 30).'...';
513
+					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'], explode(',', $_COOKIE['filter_Airlines']))) {
514 514
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
515 515
 					} else {
516 516
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
530 530
 			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
531 531
 			    <?php
532
-				foreach($allalliancenames as $alliance) {
532
+				foreach ($allalliancenames as $alliance) {
533 533
 					$alliance_name = $alliance['alliance'];
534 534
 					if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] == $alliance_name) {
535 535
 						echo '<option value="'.$alliance_name.'" selected>'.$alliance_name.'</option>';
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 			<select class="selectpicker" multiple onchange="sources(this);">
554 554
 			    <?php
555 555
 				$Spotter = new Spotter();
556
-				foreach($Spotter->getAllSourceName('aprs') as $source) {
557
-					if (isset($_COOKIE['filter_Sources']) && in_array($source['source_name'],explode(',',$_COOKIE['filter_Sources']))) {
556
+				foreach ($Spotter->getAllSourceName('aprs') as $source) {
557
+					if (isset($_COOKIE['filter_Sources']) && in_array($source['source_name'], explode(',', $_COOKIE['filter_Sources']))) {
558 558
 						echo '<option value="'.$source['source_name'].'" selected>'.$source['source_name'].'</option>';
559 559
 					} else {
560 560
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
633 633
 					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
634 634
 					
635
-					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
635
+					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'], explode(',', $_COOKIE['sattypes']))) {
636 636
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
637 637
 					} else {
638 638
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
Please login to merge, or discard this patch.
import/callback.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/../require/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
11 11
 require_once(dirname(__FILE__).'/../require/class.Common.php');
12
-$Common=new Common();
12
+$Common = new Common();
13 13
 $authorize = false;
14 14
 $params = array();
15 15
 $userip = $Common->getUserIP();
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 			$authorize = true;
21 21
 			break;
22 22
 		}
23
-		if ($userip != '' && isset($cb['host']) && in_array($userip,explode(',',$cb['host']))) {
23
+		if ($userip != '' && isset($cb['host']) && in_array($userip, explode(',', $cb['host']))) {
24 24
 			$params = $globalSources[$key];
25 25
 			$authorize = true;
26 26
 			break;
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 
47 47
 if (isset($globalServer) && $globalServer) {
48 48
 	if ($globalDebug) echo "Using Server Mode\n";
49
-	$SI=new SpotterServer();
50
-} else $SI=new SpotterImport($Connection->db);
49
+	$SI = new SpotterServer();
50
+} else $SI = new SpotterImport($Connection->db);
51 51
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
52 52
 if (isset($globalMarine) && $globalMarine) {
53 53
 	$AIS = new AIS();
54 54
 	$MI = new MarineImport($Connection->db);
55 55
 }
56
-$Source=new Source($Connection->db);
56
+$Source = new Source($Connection->db);
57 57
 date_default_timezone_set('UTC');
58 58
 
59 59
 $buffer = '';
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	$data['altitude'] = round($buffer['altitude']*3.28084);
67 67
 	$data['speed'] = $buffer['speed'];
68 68
 	//$data['heading'] = $buffer['cap']; // Only N/S/E/W
69
-	$data['datetime'] = date('Y-m-d H:i:s',$buffer['timestamp']);
69
+	$data['datetime'] = date('Y-m-d H:i:s', $buffer['timestamp']);
70 70
 	$data['comment'] = '';
71 71
 	if (isset($buffer['battery']) && $buffer['battery'] != '') $data['comment'] .= 'Battery: '.$buffer['battery'].'% ';
72 72
 	//if (isset($buffer['snr']) && $buffer['snr'] != '') $data['comment'] .= 'SNR: '.$buffer['snr'].' ';
Please login to merge, or discard this patch.
tools-geoid.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 
13 13
 $page_url = $globalURL.'/tools-geoid';
14 14
 
15
-$latitude = filter_input(INPUT_POST,'latitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
16
-$longitude = filter_input(INPUT_POST,'longitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
17
-$altitude = filter_input(INPUT_POST,'altitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
15
+$latitude = filter_input(INPUT_POST, 'latitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
16
+$longitude = filter_input(INPUT_POST, 'longitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
17
+$altitude = filter_input(INPUT_POST, 'altitude', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
18 18
 
19 19
 print '<div class="info column">';
20 20
 print '<h1>'._("Geoid Height Calculator").'</h1>';
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 
52 52
 if ($latitude != '' && $longitude != '') {
53 53
 	$globalDebug = FALSE;
54
-	$geoid = $GeoidHeight->get($latitude,$longitude);
54
+	$geoid = $GeoidHeight->get($latitude, $longitude);
55 55
 	print '<div class="row">';
56 56
 	print '<div class="col-md-3 col-md-offset-5">';
57 57
 	print '<div class="col-sm-6"><b>Geoid</b></div>';
58 58
 	print '<div class="col-sm-6">'.$geoid.'</div>';
59 59
 	if ($altitude != '') {
60 60
 		print '<div class="col-sm-6"><b>AMSL Elevation</b></div>';
61
-		print '<div class="col-sm-6">'.round($altitude-$geoid,3).'</div>';
61
+		print '<div class="col-sm-6">'.round($altitude - $geoid, 3).'</div>';
62 62
 	}
63 63
 	print '<div class="col-sm-6"><b>Earth Gravity Model</b></div>';
64 64
 	if (isset($globalGeoidSource) && $globalGeoidSource != '') $geoidsource = $globalGeoidSource;
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Spacing   +313 added lines, -313 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		fclose($fp);
26 26
 	}
27 27
 
28
-	public static function gunzip($in_file,$out_file_name = '') {
28
+	public static function gunzip($in_file, $out_file_name = '') {
29 29
 		//echo $in_file.' -> '.$out_file_name."\n";
30 30
 		$buffer_size = 4096; // read 4kb at a time
31 31
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32 32
 		if ($in_file != '' && file_exists($in_file)) {
33 33
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
34
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
35
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
36 36
 			else {
37 37
 				echo 'gzopen not available';
38 38
 				die;
39 39
 			}
40 40
 			$out_file = fopen($out_file_name, 'wb'); 
41
-			while(!gzeof($file)) {
41
+			while (!gzeof($file)) {
42 42
 				fwrite($out_file, gzread($file, $buffer_size));
43 43
 			}  
44 44
 			fclose($out_file);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			self::$db_sqlite = new PDO('sqlite:'.$database);
64 64
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79 79
                         $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         return "error : ".$e->getMessage();
82 82
                 }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		try {
89 89
                         $sth = update_db::$db_sqlite->prepare($query);
90 90
                         $sth->execute();
91
-                } catch(PDOException $e) {
91
+                } catch (PDOException $e) {
92 92
                         return "error : ".$e->getMessage();
93 93
                 }
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100 100
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104 104
             		}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
126 126
     		if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129
-		if ($fh = fopen($database_file,"r")) {
129
+		if ($fh = fopen($database_file, "r")) {
130 130
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 131
 			$Connection = new Connection();
132 132
 			$sth_dest = $Connection->db->prepare($query_dest);
133 133
 			if ($globalTransaction) $Connection->db->beginTransaction();
134 134
 			while (!feof($fh)) {
135
-				$line = fgetcsv($fh,9999,',');
135
+				$line = fgetcsv($fh, 9999, ',');
136 136
 				if ($line[0] != '') {
137 137
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
138 138
 						try {
139
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
140 140
 							$sth_dest->execute($query_dest_values);
141
-						} catch(PDOException $e) {
141
+						} catch (PDOException $e) {
142 142
 							if ($globalTransaction) $Connection->db->rollBack(); 
143 143
 							return "error : ".$e->getMessage();
144 144
 						}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162 162
                         $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         return "error : ".$e->getMessage();
165 165
                 }
166 166
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
171
-		if ($fh = fopen($database_file,"r")) {
171
+		if ($fh = fopen($database_file, "r")) {
172 172
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
173 173
 			$Connection = new Connection();
174 174
 			$sth_dest = $Connection->db->prepare($query_dest);
175 175
 			try {
176 176
 				if ($globalTransaction) $Connection->db->beginTransaction();
177 177
 				while (!feof($fh)) {
178
-					$line = fgetcsv($fh,9999,',');
178
+					$line = fgetcsv($fh, 9999, ',');
179 179
 					if ($line[0] != '') {
180
-						$datebe = explode('  -  ',$line[2]);
180
+						$datebe = explode('  -  ', $line[2]);
181 181
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
182
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
182
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
183 183
 							$sth_dest->execute($query_dest_values);
184 184
 						}
185 185
 					}
186 186
 				}
187 187
 				if ($globalTransaction) $Connection->db->commit();
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				if ($globalTransaction) $Connection->db->rollBack(); 
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202 202
                         $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         return "error : ".$e->getMessage();
205 205
                 }
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210 210
                         $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         return "error : ".$e->getMessage();
213 213
                 }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		try {
218 218
                         $sth = update_db::$db_sqlite->prepare($query);
219 219
                         $sth->execute();
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
241 241
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243 243
             		}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245
-		} catch(PDOException $e) {
245
+		} catch (PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
247 247
 		}
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254 254
                         $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
255
+                } catch (PDOException $e) {
256 256
                         return "error : ".$e->getMessage();
257 257
                 }
258 258
 		return '';
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269 269
                         $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
270
+                } catch (PDOException $e) {
271 271
                         return "error : ".$e->getMessage();
272 272
                 }
273 273
 		
274
-		if ($fh = fopen($database_file,"r")) {
274
+		if ($fh = fopen($database_file, "r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
276 276
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
277 277
 		
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282 282
             			while (!feof($fh)) {
283 283
             				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
284
+            				$line = $Common->hex2str(fgets($fh, 9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
286
+            				$values['ModeS'] = substr($line, 0, 6);
287
+            				$values['Registration'] = trim(substr($line, 69, 6));
288
+            				$aircraft_name = trim(substr($line, 48, 6));
289 289
             				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
+            				$aircraft_name_split = explode(' ', $aircraft_name);
291 291
             				$search_more = '';
292 292
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293 293
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	            				if (isset($result['icao']) && $result['icao'] != '') {
300 300
 	            				    $values['ICAOTypeCode'] = $result['icao'];
301 301
 	            				} 
302
-					} catch(PDOException $e) {
302
+					} catch (PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
305 305
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
306 306
 					// Add data to db
307 307
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 308
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
309
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
309
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
310 310
 						//print_r($query_dest_values);
311 311
 						$sth_dest->execute($query_dest_values);
312 312
 					}
313 313
 				}
314 314
 				if ($globalTransaction) $Connection->db->commit();
315
-			} catch(PDOException $e) {
315
+			} catch (PDOException $e) {
316 316
 				return "error : ".$e->getMessage();
317 317
 			}
318 318
 		}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324 324
                         $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
325
+                } catch (PDOException $e) {
326 326
                         return "error : ".$e->getMessage();
327 327
                 }
328 328
 		return '';
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338 338
                         $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
339
+                } catch (PDOException $e) {
340 340
                         return "error : ".$e->getMessage();
341 341
                 }
342 342
 		
343
-		if ($fh = fopen($database_file,"r")) {
343
+		if ($fh = fopen($database_file, "r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
345 345
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
346 346
 		
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 			$sth_dest = $Connection->db->prepare($query_dest);
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351
-				$tmp = fgetcsv($fh,9999,',',"'");
351
+				$tmp = fgetcsv($fh, 9999, ',', "'");
352 352
             			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
353
+            				$line = fgetcsv($fh, 9999, ',', "'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             				$values['ICAOTypeCode'] = '';
360 360
             				$aircraft_name = $line[2];
361 361
             				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
362
+            				$aircraft_name_split = explode(' ', $aircraft_name);
363 363
             				$search_more = '';
364 364
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365 365
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
                                     		$sth_search->execute();
369 369
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370 370
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371
-					} catch(PDOException $e) {
371
+					} catch (PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
374 374
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375 375
 					// Add data to db
376 376
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
377 377
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
378
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
378
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
379 379
 						//print_r($query_dest_values);
380 380
 						$sth_dest->execute($query_dest_values);
381 381
 					}
382 382
 				}
383 383
 				if ($globalTransaction) $Connection->db->commit();
384
-			} catch(PDOException $e) {
384
+			} catch (PDOException $e) {
385 385
 				return "error : ".$e->getMessage();
386 386
 			}
387 387
 		}
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
                         $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
394
+                } catch (PDOException $e) {
395 395
                         return "error : ".$e->getMessage();
396 396
                 }
397 397
 		return '';
398 398
 	}
399 399
 
400
-	public static function retrieve_owner($database_file,$country = 'F') {
400
+	public static function retrieve_owner($database_file, $country = 'F') {
401 401
 		global $globalTransaction, $globalMasterSource;
402 402
 		//$query = 'TRUNCATE TABLE aircraft_modes';
403 403
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407 407
                         $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
408
+                } catch (PDOException $e) {
409 409
                         return "error : ".$e->getMessage();
410 410
                 }
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413
-		if ($fh = fopen($database_file,"r")) {
413
+		if ($fh = fopen($database_file, "r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416 416
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 			$sth_modes = $Connection->db->prepare($query_modes);
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423
-				$tmp = fgetcsv($fh,9999,',','"');
423
+				$tmp = fgetcsv($fh, 9999, ',', '"');
424 424
             			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
425
+            				$line = fgetcsv($fh, 9999, ',', '"');
426 426
             				$values = array();
427 427
             				//print_r($line);
428 428
             				if ($country == 'F') {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             				    $values['base'] = $line[4];
431 431
             				    $values['owner'] = $line[5];
432 432
             				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
433
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
434 434
 					    $values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436 436
 					    // TODO : add modeS & reg to aircraft_modes
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             				    $values['base'] = $line[3];
439 439
             				    $values['owner'] = $line[2];
440 440
             				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
441
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
442 442
 					    $values['cancel'] = '';
443 443
 					    $values['modes'] = $line[7];
444 444
 					    $values['icao'] = $line[8];
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             				    $values['base'] = null;
459 459
             				    $values['owner'] = $line[5];
460 460
             				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
461
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
462 462
 					    $values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464 464
 					    // TODO : add modeS & reg to aircraft_modes
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             				    $values['base'] = null;
467 467
             				    $values['owner'] = $line[12];
468 468
             				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
469
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
470 470
 
471 471
 					    $values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -486,28 +486,28 @@  discard block
 block discarded – undo
486 486
             				    $values['base'] = null;
487 487
             				    $values['owner'] = $line[8];
488 488
             				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
489
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
490 490
 					    $values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492 492
             				    $values['registration'] = $line[0];
493 493
             				    $values['base'] = null;
494 494
             				    $values['owner'] = $line[4];
495 495
             				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
497 497
 					    $values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499 499
             				    $values['registration'] = $line[0];
500 500
             				    $values['base'] = null;
501 501
             				    $values['owner'] = $line[4];
502 502
             				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
503
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
504 504
 					    $values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506 506
             				    $values['registration'] = $line[0];
507 507
             				    $values['base'] = null;
508 508
             				    $values['owner'] = $line[3];
509 509
             				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
510
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
511 511
 					    $values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513 513
             				    $values['registration'] = $line[0];
@@ -521,18 +521,18 @@  discard block
 block discarded – undo
521 521
             				    $values['registration'] = $line[0];
522 522
             				    $values['base'] = null;
523 523
             				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
525
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
526 526
 					    $values['modes'] = $line[4];
527 527
 					    $values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529 529
             				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
530
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
531 531
 					    $values['modes'] = $line[5];
532 532
 					    $values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534 534
             				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
535
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
536 536
 					    $values['modes'] = $line[4];
537 537
 					    $values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
 					    $values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
546
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
547 547
 						$sth_dest->execute($query_dest_values);
548 548
 					}
549 549
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
550 550
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
551
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
551
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
552 552
 						$sth_modes->execute($query_modes_values);
553 553
 					}
554 554
 				}
555 555
 				if ($globalTransaction) $Connection->db->commit();
556
-			} catch(PDOException $e) {
556
+			} catch (PDOException $e) {
557 557
 				return "error : ".$e->getMessage();
558 558
 			}
559 559
 		}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		if ($globalTransaction) $Connection->db->beginTransaction();
692 692
   
693 693
 		$i = 0;
694
-		while($row = sparql_fetch_array($result))
694
+		while ($row = sparql_fetch_array($result))
695 695
 		{
696 696
 			if ($i >= 1) {
697 697
 			//print_r($row);
@@ -711,33 +711,33 @@  discard block
 block discarded – undo
711 711
 				$row['image'] = '';
712 712
 				$row['image_thumb'] = '';
713 713
 			} else {
714
-				$image = str_replace(' ','_',$row['image']);
714
+				$image = str_replace(' ', '_', $row['image']);
715 715
 				$digest = md5($image);
716
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
717
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
718
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
719
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
716
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
717
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
718
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
719
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
720 720
 			}
721 721
 			
722
-			$country = explode('-',$row['country']);
722
+			$country = explode('-', $row['country']);
723 723
 			$row['country'] = $country[0];
724 724
 			
725 725
 			$row['type'] = trim($row['type']);
726
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
726
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
727 727
 				$row['type'] = 'military';
728 728
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
729 729
 				$row['type'] = 'small_airport';
730 730
 			}
731 731
 			
732
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
733
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
732
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
733
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
734 734
 			//print_r($query_dest_values);
735 735
 			
736 736
 			if ($row['icao'] != '') {
737 737
 				try {
738 738
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
739 739
 					$sth->execute(array(':icao' => $row['icao']));
740
-				} catch(PDOException $e) {
740
+				} catch (PDOException $e) {
741 741
 					return "error : ".$e->getMessage();
742 742
 				}
743 743
 					if ($sth->fetchColumn() > 0) {
@@ -745,15 +745,15 @@  discard block
 block discarded – undo
745 745
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
746 746
 						try {
747 747
 							$sth = $Connection->db->prepare($query);
748
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
749
-						} catch(PDOException $e) {
748
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
749
+						} catch (PDOException $e) {
750 750
 							return "error : ".$e->getMessage();
751 751
 						}
752 752
 						echo $row['icao'].' : '.$row['type']."\n";
753 753
 					} else {
754 754
 						try {
755 755
 							$sth_dest->execute($query_dest_values);
756
-						} catch(PDOException $e) {
756
+						} catch (PDOException $e) {
757 757
 							return "error : ".$e->getMessage();
758 758
 						}
759 759
 					}
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		echo "Download data from ourairports.com...\n";
805 805
 		$delimiter = ',';
806 806
 		$out_file = $tmp_dir.'airports.csv';
807
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
807
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
808 808
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
809 809
 		echo "Add data from ourairports.com...\n";
810 810
 
@@ -815,33 +815,33 @@  discard block
 block discarded – undo
815 815
 			//$Connection->db->beginTransaction();
816 816
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 817
 			{
818
-				if(!$header) $header = $row;
818
+				if (!$header) $header = $row;
819 819
 				else {
820 820
 					$data = array();
821 821
 					$data = array_combine($header, $row);
822 822
 					try {
823 823
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
824 824
 						$sth->execute(array(':icao' => $data['ident']));
825
-					} catch(PDOException $e) {
825
+					} catch (PDOException $e) {
826 826
 						return "error : ".$e->getMessage();
827 827
 					}
828 828
 					if ($sth->fetchColumn() > 0) {
829 829
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
830 830
 						try {
831 831
 							$sth = $Connection->db->prepare($query);
832
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
833
-						} catch(PDOException $e) {
832
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
833
+						} catch (PDOException $e) {
834 834
 							return "error : ".$e->getMessage();
835 835
 						}
836 836
 					} else {
837 837
 						if ($data['gps_code'] == $data['ident']) {
838 838
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
839 839
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
840
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
840
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
841 841
 						try {
842 842
 							$sth = $Connection->db->prepare($query);
843 843
 							$sth->execute($query_values);
844
-						} catch(PDOException $e) {
844
+						} catch (PDOException $e) {
845 845
 							return "error : ".$e->getMessage();
846 846
 						}
847 847
 						$i++;
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		
857 857
 		echo "Download data from another free database...\n";
858 858
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
859
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
860 860
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
861 861
 		update_db::unzip($out_file);
862 862
 		$header = NULL;
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 			//$Connection->db->beginTransaction();
869 869
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 870
 			{
871
-				if(!$header) $header = $row;
871
+				if (!$header) $header = $row;
872 872
 				else {
873 873
 					$data = $row;
874 874
 
875 875
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
876 876
 					try {
877 877
 						$sth = $Connection->db->prepare($query);
878
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
879
-					} catch(PDOException $e) {
878
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
879
+					} catch (PDOException $e) {
880 880
 						return "error : ".$e->getMessage();
881 881
 					}
882 882
 				}
@@ -890,15 +890,15 @@  discard block
 block discarded – undo
890 890
 		try {
891 891
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
892 892
 			$sth->execute();
893
-		} catch(PDOException $e) {
893
+		} catch (PDOException $e) {
894 894
 			return "error : ".$e->getMessage();
895 895
 		}
896 896
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
897 897
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
898 898
 			try {
899 899
 				$sth2 = $Connection->db->prepare($query2);
900
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
901
-			} catch(PDOException $e) {
900
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
901
+			} catch (PDOException $e) {
902 902
 				return "error : ".$e->getMessage();
903 903
 			}
904 904
 		}
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921 921
                         $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
922
+                } catch (PDOException $e) {
923 923
                         return "error : ".$e->getMessage();
924 924
                 }
925 925
 
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
937 937
 			{
938 938
 				$i++;
939
-				if($i > 12) {
939
+				if ($i > 12) {
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
                                                 //echo substr($operator, 0, 2)."\n";;
945 945
                                                 if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947
-							$operator = $airline_array[0]['icao'].substr($operator,2);
947
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
948 948
                                                 }
949 949
                                         }
950 950
 					
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953 953
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954 954
                                                 if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
955
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
956 956
                                             	}
957 957
                                         }
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
961
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
-					} catch(PDOException $e) {
961
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
+					} catch (PDOException $e) {
963 963
 						return "error : ".$e->getMessage();
964 964
 					}
965 965
 				}
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 			$Connection = new Connection();
980 980
 			$sth = $Connection->db->prepare($query);
981 981
                         $sth->execute(array(':source' => 'website_fam'));
982
-                } catch(PDOException $e) {
982
+                } catch (PDOException $e) {
983 983
                         return "error : ".$e->getMessage();
984 984
                 }
985 985
 
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
1000 1000
 					try {
1001 1001
 						$sth = $Connection->db->prepare($query);
1002
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
1003
-					} catch(PDOException $e) {
1002
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
1003
+					} catch (PDOException $e) {
1004 1004
 						return "error : ".$e->getMessage();
1005 1005
 					}
1006 1006
 				}
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 			$Connection = new Connection();
1024 1024
 			$sth = $Connection->db->prepare($query);
1025 1025
                         $sth->execute(array(':source' => 'website_faa'));
1026
-                } catch(PDOException $e) {
1026
+                } catch (PDOException $e) {
1027 1027
                         return "error : ".$e->getMessage();
1028 1028
                 }
1029 1029
 
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 			$Connection = new Connection();
1033 1033
 			$sth = $Connection->db->prepare($query);
1034 1034
                         $sth->execute(array(':source' => 'website_faa'));
1035
-                } catch(PDOException $e) {
1035
+                } catch (PDOException $e) {
1036 1036
                         return "error : ".$e->getMessage();
1037 1037
                 }
1038 1038
 
@@ -1049,8 +1049,8 @@  discard block
 block discarded – undo
1049 1049
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1050 1050
 					try {
1051 1051
 						$sths = $Connection->db->prepare($query_search);
1052
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1053
-					} catch(PDOException $e) {
1052
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1053
+					} catch (PDOException $e) {
1054 1054
 						return "error s : ".$e->getMessage();
1055 1055
 					}
1056 1056
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 							//}
1064 1064
 						try {
1065 1065
 							$sthi = $Connection->db->prepare($queryi);
1066
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1067
-						} catch(PDOException $e) {
1066
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1067
+						} catch (PDOException $e) {
1068 1068
 							return "error u : ".$e->getMessage();
1069 1069
 						}
1070 1070
 					} else {
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 						try {
1073 1073
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1074 1074
 							$sthsm->execute(array(':mfr' => $data[2]));
1075
-						} catch(PDOException $e) {
1075
+						} catch (PDOException $e) {
1076 1076
 							return "error mfr : ".$e->getMessage();
1077 1077
 						}
1078 1078
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1083 1083
 							try {
1084 1084
 								$sthf = $Connection->db->prepare($queryf);
1085
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1086
-							} catch(PDOException $e) {
1085
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1086
+							} catch (PDOException $e) {
1087 1087
 								return "error f : ".$e->getMessage();
1088 1088
 							}
1089 1089
 						}
@@ -1093,13 +1093,13 @@  discard block
 block discarded – undo
1093 1093
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1094 1094
 						try {
1095 1095
 							$sth = $Connection->db->prepare($query);
1096
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1097
-						} catch(PDOException $e) {
1096
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1097
+						} catch (PDOException $e) {
1098 1098
 							return "error i : ".$e->getMessage();
1099 1099
 						}
1100 1100
 					}
1101 1101
 				}
1102
-				if ($i % 90 == 0) {
1102
+				if ($i%90 == 0) {
1103 1103
 					if ($globalTransaction) $Connection->db->commit();
1104 1104
 					if ($globalTransaction) $Connection->db->beginTransaction();
1105 1105
 				}
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 			$Connection = new Connection();
1119 1119
 			$sth = $Connection->db->prepare($query);
1120 1120
                         $sth->execute(array(':source' => 'website_fam'));
1121
-                } catch(PDOException $e) {
1121
+                } catch (PDOException $e) {
1122 1122
                         return "error : ".$e->getMessage();
1123 1123
                 }
1124 1124
 
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1140
 					try {
1141 1141
 						$sth = $Connection->db->prepare($query);
1142
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1143
-					} catch(PDOException $e) {
1142
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1143
+					} catch (PDOException $e) {
1144 1144
 						return "error : ".$e->getMessage();
1145 1145
 					}
1146 1146
 				}
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 			$Connection = new Connection();
1160 1160
 			$sth = $Connection->db->prepare($query);
1161 1161
                         $sth->execute(array(':source' => 'website_fam'));
1162
-                } catch(PDOException $e) {
1162
+                } catch (PDOException $e) {
1163 1163
                         return "error : ".$e->getMessage();
1164 1164
                 }
1165 1165
 
@@ -1175,8 +1175,8 @@  discard block
 block discarded – undo
1175 1175
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1176 1176
 					try {
1177 1177
 						$sth = $Connection->db->prepare($query);
1178
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1179
-					} catch(PDOException $e) {
1178
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1179
+					} catch (PDOException $e) {
1180 1180
 						print_r($data);
1181 1181
 						return "error : ".$e->getMessage();
1182 1182
 					}
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 			$Connection = new Connection();
1197 1197
 			$sth = $Connection->db->prepare($query);
1198 1198
 			$sth->execute(array(':source' => 'website_fam'));
1199
-		} catch(PDOException $e) {
1199
+		} catch (PDOException $e) {
1200 1200
 			return "error : ".$e->getMessage();
1201 1201
 		}
1202 1202
 		$delimiter = "\t";
@@ -1211,9 +1211,9 @@  discard block
 block discarded – undo
1211 1211
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1212 1212
 					try {
1213 1213
 						$sth = $Connection->db->prepare($query);
1214
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1215
-					} catch(PDOException $e) {
1216
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1214
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1215
+					} catch (PDOException $e) {
1216
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1217 1217
 					}
1218 1218
 				}
1219 1219
 				$i++;
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 			$Connection = new Connection();
1232 1232
 			$sth = $Connection->db->prepare($query);
1233 1233
                         $sth->execute();
1234
-                } catch(PDOException $e) {
1234
+                } catch (PDOException $e) {
1235 1235
                         return "error : ".$e->getMessage();
1236 1236
                 }
1237 1237
 
@@ -1252,8 +1252,8 @@  discard block
 block discarded – undo
1252 1252
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1253 1253
 					try {
1254 1254
 						$sth = $Connection->db->prepare($query);
1255
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1256
-					} catch(PDOException $e) {
1255
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1256
+					} catch (PDOException $e) {
1257 1257
 						return "error : ".$e->getMessage();
1258 1258
 					}
1259 1259
 				}
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 			$Connection = new Connection();
1273 1273
 			$sth = $Connection->db->prepare($query);
1274 1274
 			$sth->execute();
1275
-		} catch(PDOException $e) {
1275
+		} catch (PDOException $e) {
1276 1276
 			return "error : ".$e->getMessage();
1277 1277
 		}
1278 1278
 
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 					try {
1289 1289
 						$sth = $Connection->db->prepare($query);
1290 1290
 						$sth->execute(array(':icao' => $icao));
1291
-					} catch(PDOException $e) {
1291
+					} catch (PDOException $e) {
1292 1292
 						return "error : ".$e->getMessage();
1293 1293
 					}
1294 1294
 				}
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 		return '';
1300 1300
         }
1301 1301
 
1302
-	public static function tle($filename,$tletype) {
1302
+	public static function tle($filename, $tletype) {
1303 1303
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1304 1304
 		global $tmp_dir, $globalTransaction;
1305 1305
 		//$Spotter = new Spotter();
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 			$Connection = new Connection();
1310 1310
 			$sth = $Connection->db->prepare($query);
1311 1311
                         $sth->execute(array(':source' => $filename));
1312
-                } catch(PDOException $e) {
1312
+                } catch (PDOException $e) {
1313 1313
                         return "error : ".$e->getMessage();
1314 1314
                 }
1315 1315
 		
@@ -1334,8 +1334,8 @@  discard block
 block discarded – undo
1334 1334
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1335 1335
 					try {
1336 1336
 						$sth = $Connection->db->prepare($query);
1337
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1338
-					} catch(PDOException $e) {
1337
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1338
+					} catch (PDOException $e) {
1339 1339
 						return "error : ".$e->getMessage();
1340 1340
 					}
1341 1341
 
@@ -1355,28 +1355,28 @@  discard block
 block discarded – undo
1355 1355
         */
1356 1356
         private static function table2array($data) {
1357 1357
                 $html = str_get_html($data);
1358
-                $tabledata=array();
1359
-                foreach($html->find('tr') as $element)
1358
+                $tabledata = array();
1359
+                foreach ($html->find('tr') as $element)
1360 1360
                 {
1361 1361
                         $td = array();
1362
-                        foreach( $element->find('th') as $row)
1362
+                        foreach ($element->find('th') as $row)
1363 1363
                         {
1364 1364
                                 $td [] = trim($row->plaintext);
1365 1365
                         }
1366
-                        $td=array_filter($td);
1366
+                        $td = array_filter($td);
1367 1367
                         $tabledata[] = $td;
1368 1368
 
1369 1369
                         $td = array();
1370 1370
                         $tdi = array();
1371
-                        foreach( $element->find('td') as $row)
1371
+                        foreach ($element->find('td') as $row)
1372 1372
                         {
1373 1373
                                 $td [] = trim($row->plaintext);
1374 1374
                                 $tdi [] = trim($row->innertext);
1375 1375
                         }
1376
-                        $td=array_filter($td);
1377
-                        $tdi=array_filter($tdi);
1376
+                        $td = array_filter($td);
1377
+                        $tdi = array_filter($tdi);
1378 1378
                     //    $tabledata[]=array_merge($td,$tdi);
1379
-                        $tabledata[]=$td;
1379
+                        $tabledata[] = $td;
1380 1380
                 }
1381 1381
                 return(array_filter($tabledata));
1382 1382
         }
@@ -1449,13 +1449,13 @@  discard block
 block discarded – undo
1449 1449
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1450 1450
 			{
1451 1451
 				$i++;
1452
-				if($i > 3 && count($row) > 2) {
1452
+				if ($i > 3 && count($row) > 2) {
1453 1453
 					$data = array_values(array_filter($row));
1454 1454
 					$cntdata = count($data);
1455 1455
 					if ($cntdata > 10) {
1456 1456
 						$value = $data[9];
1457 1457
 						
1458
-						for ($i =10;$i < $cntdata;$i++) {
1458
+						for ($i = 10; $i < $cntdata; $i++) {
1459 1459
 							$value .= ' '.$data[$i];
1460 1460
 						}
1461 1461
 						$data[9] = $value;
@@ -1465,8 +1465,8 @@  discard block
 block discarded – undo
1465 1465
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1466 1466
 						try {
1467 1467
 							$sth = $Connection->db->prepare($query);
1468
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1469
-						} catch(PDOException $e) {
1468
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1469
+						} catch (PDOException $e) {
1470 1470
 							return "error : ".$e->getMessage();
1471 1471
 						}
1472 1472
 					}
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 			$Connection = new Connection();
1488 1488
 			$sth = $Connection->db->prepare($query);
1489 1489
                         $sth->execute();
1490
-                } catch(PDOException $e) {
1490
+                } catch (PDOException $e) {
1491 1491
                         return "error : ".$e->getMessage();
1492 1492
                 }
1493 1493
 
@@ -1499,12 +1499,12 @@  discard block
 block discarded – undo
1499 1499
 			if ($globalTransaction) $Connection->db->beginTransaction();
1500 1500
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1501 1501
 			{
1502
-				if(count($row) > 1) {
1502
+				if (count($row) > 1) {
1503 1503
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1504 1504
 					try {
1505 1505
 						$sth = $Connection->db->prepare($query);
1506
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1507
-					} catch(PDOException $e) {
1506
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1507
+					} catch (PDOException $e) {
1508 1508
 						return "error : ".$e->getMessage();
1509 1509
 					}
1510 1510
 				}
@@ -1524,21 +1524,21 @@  discard block
 block discarded – undo
1524 1524
 			try {
1525 1525
 				$sth = $Connection->db->prepare($query);
1526 1526
                     		$sth->execute();
1527
-	                } catch(PDOException $e) {
1527
+	                } catch (PDOException $e) {
1528 1528
 				return "error : ".$e->getMessage();
1529 1529
 	                }
1530 1530
 	        }
1531 1531
 
1532 1532
 
1533
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1533
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1534 1534
 		else {
1535
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1535
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1536 1536
 			$query = "CREATE EXTENSION postgis";
1537
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1537
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1538 1538
 			try {
1539 1539
 				$sth = $Connection->db->prepare($query);
1540 1540
 				$sth->execute();
1541
-			} catch(PDOException $e) {
1541
+			} catch (PDOException $e) {
1542 1542
 				return "error : ".$e->getMessage();
1543 1543
 			}
1544 1544
 		}
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
 		include_once('class.create_db.php');
1552 1552
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1553 1553
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1554
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1554
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1555 1555
 		$error = '';
1556 1556
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1557 1557
 			if ($globalDebug) echo "Gunzip...";
@@ -1583,14 +1583,14 @@  discard block
 block discarded – undo
1583 1583
 			try {
1584 1584
 				$sth = $Connection->db->prepare($query);
1585 1585
             	        	$sth->execute();
1586
-	                } catch(PDOException $e) {
1586
+	                } catch (PDOException $e) {
1587 1587
     	                	echo "error : ".$e->getMessage();
1588 1588
 	                }
1589 1589
 		}
1590 1590
 		if ($globalDBdriver == 'mysql') {
1591
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1591
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1592 1592
 		} else {
1593
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1593
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1594 1594
 		}
1595 1595
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1596 1596
 		return $error;
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1604 1604
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1605 1605
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1606
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1606
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1607 1607
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1608 1608
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1609 1609
 		return $error;
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1624 1624
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1625 1625
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1626
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1626
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1627 1627
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1628 1628
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1629 1629
 		if ($error != '') {
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 		global $tmp_dir, $globalDebug;
1637 1637
 		$error = '';
1638 1638
 		if ($globalDebug) echo "Routes : Download...";
1639
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1639
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1640 1640
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1641 1641
 			if ($globalDebug) echo "Gunzip...";
1642 1642
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
 		global $tmp_dir, $globalDebug;
1653 1653
 		$error = '';
1654 1654
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1655
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1655
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1656 1656
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1657 1657
 			if ($globalDebug) echo "Gunzip...";
1658 1658
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1668,7 +1668,7 @@  discard block
 block discarded – undo
1668 1668
 		global $tmp_dir, $globalDebug;
1669 1669
 		$error = '';
1670 1670
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1671
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1671
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1672 1672
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1673 1673
 			if ($globalDebug) echo "Gunzip...";
1674 1674
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 */
1697 1697
 		if ($globalDebug) echo "Modes : Download...";
1698 1698
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1699
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1699
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1700 1700
 
1701 1701
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1702 1702
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
 	public static function update_ModeS_faa() {
1717 1717
 		global $tmp_dir, $globalDebug;
1718 1718
 		if ($globalDebug) echo "Modes FAA: Download...";
1719
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1719
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1720 1720
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1721 1721
 			if ($globalDebug) echo "Unzip...";
1722 1722
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 	public static function update_ModeS_flarm() {
1733 1733
 		global $tmp_dir, $globalDebug;
1734 1734
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1735
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1735
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1736 1736
 		if (file_exists($tmp_dir.'data.fln')) {
1737 1737
 			if ($globalDebug) echo "Add to DB...";
1738 1738
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
 	public static function update_ModeS_ogn() {
1747 1747
 		global $tmp_dir, $globalDebug;
1748 1748
 		if ($globalDebug) echo "Modes OGN: Download...";
1749
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1749
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1750 1750
 		if (file_exists($tmp_dir.'ogn.csv')) {
1751 1751
 			if ($globalDebug) echo "Add to DB...";
1752 1752
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1761,201 +1761,201 @@  discard block
 block discarded – undo
1761 1761
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1762 1762
 		
1763 1763
 		if ($globalDebug) echo "Owner France: Download...";
1764
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1764
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1765 1765
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1766 1766
 			if ($globalDebug) echo "Add to DB...";
1767
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1767
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1768 1768
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1769 1769
 		if ($error != '') {
1770 1770
 			return $error;
1771 1771
 		} elseif ($globalDebug) echo "Done\n";
1772 1772
 		
1773 1773
 		if ($globalDebug) echo "Owner Ireland: Download...";
1774
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1774
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1775 1775
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1776 1776
 			if ($globalDebug) echo "Add to DB...";
1777
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1777
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1778 1778
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1779 1779
 		if ($error != '') {
1780 1780
 			return $error;
1781 1781
 		} elseif ($globalDebug) echo "Done\n";
1782 1782
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1783
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1783
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1784 1784
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1785 1785
 			if ($globalDebug) echo "Add to DB...";
1786
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1786
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1787 1787
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1788 1788
 		if ($error != '') {
1789 1789
 			return $error;
1790 1790
 		} elseif ($globalDebug) echo "Done\n";
1791 1791
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1792
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1792
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1793 1793
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1794 1794
 			if ($globalDebug) echo "Add to DB...";
1795
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1795
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1796 1796
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1797 1797
 		if ($error != '') {
1798 1798
 			return $error;
1799 1799
 		} elseif ($globalDebug) echo "Done\n";
1800 1800
 		if ($globalDebug) echo "Owner Australia: Download...";
1801
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1801
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1802 1802
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1803 1803
 			if ($globalDebug) echo "Add to DB...";
1804
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1804
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1805 1805
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1806 1806
 		if ($error != '') {
1807 1807
 			return $error;
1808 1808
 		} elseif ($globalDebug) echo "Done\n";
1809 1809
 		if ($globalDebug) echo "Owner Austria: Download...";
1810
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1810
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1811 1811
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1812 1812
 			if ($globalDebug) echo "Add to DB...";
1813
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1813
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1814 1814
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1815 1815
 		if ($error != '') {
1816 1816
 			return $error;
1817 1817
 		} elseif ($globalDebug) echo "Done\n";
1818 1818
 		if ($globalDebug) echo "Owner Chile: Download...";
1819
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1819
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1820 1820
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1821 1821
 			if ($globalDebug) echo "Add to DB...";
1822
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1822
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1823 1823
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1824 1824
 		if ($error != '') {
1825 1825
 			return $error;
1826 1826
 		} elseif ($globalDebug) echo "Done\n";
1827 1827
 		if ($globalDebug) echo "Owner Colombia: Download...";
1828
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1828
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1829 1829
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1830 1830
 			if ($globalDebug) echo "Add to DB...";
1831
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1831
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1832 1832
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1833 1833
 		if ($error != '') {
1834 1834
 			return $error;
1835 1835
 		} elseif ($globalDebug) echo "Done\n";
1836 1836
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1837
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1837
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1838 1838
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1839 1839
 			if ($globalDebug) echo "Add to DB...";
1840
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1840
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1841 1841
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1842 1842
 		if ($error != '') {
1843 1843
 			return $error;
1844 1844
 		} elseif ($globalDebug) echo "Done\n";
1845 1845
 		if ($globalDebug) echo "Owner Brazil: Download...";
1846
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1846
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1847 1847
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1848 1848
 			if ($globalDebug) echo "Add to DB...";
1849
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1849
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1850 1850
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1851 1851
 		if ($error != '') {
1852 1852
 			return $error;
1853 1853
 		} elseif ($globalDebug) echo "Done\n";
1854 1854
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1855
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1855
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1856 1856
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1857 1857
 			if ($globalDebug) echo "Add to DB...";
1858
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1858
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1859 1859
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1860 1860
 		if ($error != '') {
1861 1861
 			return $error;
1862 1862
 		} elseif ($globalDebug) echo "Done\n";
1863 1863
 		if ($globalDebug) echo "Owner Croatia: Download...";
1864
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1864
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1865 1865
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1866 1866
 			if ($globalDebug) echo "Add to DB...";
1867
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1867
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1868 1868
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1869 1869
 		if ($error != '') {
1870 1870
 			return $error;
1871 1871
 		} elseif ($globalDebug) echo "Done\n";
1872 1872
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1873
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1873
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1874 1874
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1875 1875
 			if ($globalDebug) echo "Add to DB...";
1876
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1876
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1877 1877
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1878 1878
 		if ($error != '') {
1879 1879
 			return $error;
1880 1880
 		} elseif ($globalDebug) echo "Done\n";
1881 1881
 		if ($globalDebug) echo "Owner Maldives: Download...";
1882
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1882
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1883 1883
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1884 1884
 			if ($globalDebug) echo "Add to DB...";
1885
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1885
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1886 1886
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1887 1887
 		if ($error != '') {
1888 1888
 			return $error;
1889 1889
 		} elseif ($globalDebug) echo "Done\n";
1890 1890
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1891
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1891
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1892 1892
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1893 1893
 			if ($globalDebug) echo "Add to DB...";
1894
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1894
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1895 1895
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1896 1896
 		if ($error != '') {
1897 1897
 			return $error;
1898 1898
 		} elseif ($globalDebug) echo "Done\n";
1899 1899
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1900
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1900
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1901 1901
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1902 1902
 			if ($globalDebug) echo "Add to DB...";
1903
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1903
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1904 1904
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1905 1905
 		if ($error != '') {
1906 1906
 			return $error;
1907 1907
 		} elseif ($globalDebug) echo "Done\n";
1908 1908
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1909
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1909
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1910 1910
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1911 1911
 			if ($globalDebug) echo "Add to DB...";
1912
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1912
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1913 1913
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1914 1914
 		if ($error != '') {
1915 1915
 			return $error;
1916 1916
 		} elseif ($globalDebug) echo "Done\n";
1917 1917
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1918
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1918
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1919 1919
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1920 1920
 			if ($globalDebug) echo "Add to DB...";
1921
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1921
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1922 1922
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1923 1923
 		if ($error != '') {
1924 1924
 			return $error;
1925 1925
 		} elseif ($globalDebug) echo "Done\n";
1926 1926
 		if ($globalDebug) echo "Owner Iceland: Download...";
1927
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1927
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1928 1928
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1929 1929
 			if ($globalDebug) echo "Add to DB...";
1930
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1930
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1931 1931
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1932 1932
 		if ($error != '') {
1933 1933
 			return $error;
1934 1934
 		} elseif ($globalDebug) echo "Done\n";
1935 1935
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1936
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1936
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1937 1937
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1938 1938
 			if ($globalDebug) echo "Add to DB...";
1939
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1939
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1940 1940
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1941 1941
 		if ($error != '') {
1942 1942
 			return $error;
1943 1943
 		} elseif ($globalDebug) echo "Done\n";
1944 1944
 		if ($globalMasterSource) {
1945 1945
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1946
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1946
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1947 1947
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1948 1948
 				if ($globalDebug) echo "Add to DB...";
1949
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1949
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1950 1950
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1951 1951
 			if ($error != '') {
1952 1952
 				return $error;
1953 1953
 			} elseif ($globalDebug) echo "Done\n";
1954 1954
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1955
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1955
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1956 1956
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1957 1957
 				if ($globalDebug) echo "Add to DB...";
1958
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1958
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1959 1959
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1960 1960
 			if ($error != '') {
1961 1961
 				return $error;
@@ -1968,7 +1968,7 @@  discard block
 block discarded – undo
1968 1968
 		global $tmp_dir, $globalDebug;
1969 1969
 		$error = '';
1970 1970
 		if ($globalDebug) echo "Translation : Download...";
1971
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1971
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1972 1972
 		if (file_exists($tmp_dir.'translation.zip')) {
1973 1973
 			if ($globalDebug) echo "Unzip...";
1974 1974
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
 	public static function update_translation_fam() {
1985 1985
 		global $tmp_dir, $globalDebug;
1986 1986
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1987
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1987
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1988 1988
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1989 1989
 			if ($globalDebug) echo "Gunzip...";
1990 1990
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1999,7 +1999,7 @@  discard block
 block discarded – undo
1999 1999
 	public static function update_ModeS_fam() {
2000 2000
 		global $tmp_dir, $globalDebug;
2001 2001
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2002
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2002
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2003 2003
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2004 2004
 			if ($globalDebug) echo "Gunzip...";
2005 2005
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -2015,9 +2015,9 @@  discard block
 block discarded – undo
2015 2015
 		global $tmp_dir, $globalDebug, $globalOwner;
2016 2016
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2017 2017
 		if ($globalOwner === TRUE) {
2018
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2018
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2019 2019
 		} else {
2020
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2020
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2021 2021
 		}
2022 2022
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2023 2023
 			if ($globalDebug) echo "Gunzip...";
@@ -2033,7 +2033,7 @@  discard block
 block discarded – undo
2033 2033
 	public static function update_routes_fam() {
2034 2034
 		global $tmp_dir, $globalDebug;
2035 2035
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2036
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2036
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2037 2037
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2038 2038
 			if ($globalDebug) echo "Gunzip...";
2039 2039
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2047,13 +2047,13 @@  discard block
 block discarded – undo
2047 2047
 	}
2048 2048
 	public static function update_marine_identity_fam() {
2049 2049
 		global $tmp_dir, $globalDebug;
2050
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2050
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2051 2051
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2052
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2052
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2053 2053
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2054 2054
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2055 2055
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2056
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2056
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2057 2057
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2058 2058
 					if ($globalDebug) echo "Gunzip...";
2059 2059
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2073,7 +2073,7 @@  discard block
 block discarded – undo
2073 2073
 	public static function update_banned_fam() {
2074 2074
 		global $tmp_dir, $globalDebug;
2075 2075
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2076
-		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2076
+		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2077 2077
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2078 2078
 			//if ($globalDebug) echo "Gunzip...";
2079 2079
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2092,18 +2092,18 @@  discard block
 block discarded – undo
2092 2092
 		$error = '';
2093 2093
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2094 2094
 		if ($globalDBdriver == 'mysql') {
2095
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2095
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2096 2096
 		} else {
2097
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2097
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2098 2098
 		}
2099 2099
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2100
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2100
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2101 2101
 			$airspace_md5 = $airspace_md5_file[0];
2102 2102
 			if (!update_db::check_airspace_version($airspace_md5)) {
2103 2103
 				if ($globalDBdriver == 'mysql') {
2104
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2104
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2105 2105
 				} else {
2106
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2106
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2107 2107
 				}
2108 2108
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2109 2109
 					if ($globalDebug) echo "Gunzip...";
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
 						try {
2116 2116
 							$sth = $Connection->db->prepare($query);
2117 2117
     	    	    					$sth->execute();
2118
-			            		} catch(PDOException $e) {
2118
+			            		} catch (PDOException $e) {
2119 2119
 							return "error : ".$e->getMessage();
2120 2120
 		            			}
2121 2121
 		    			}
@@ -2134,15 +2134,15 @@  discard block
 block discarded – undo
2134 2134
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2135 2135
 		$error = '';
2136 2136
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2137
-		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2137
+		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2138 2138
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2139
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2139
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2140 2140
 			$geoid_md5 = $geoid_md5_file[0];
2141 2141
 			if (!update_db::check_geoid_version($geoid_md5)) {
2142
-				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2142
+				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2143 2143
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2144 2144
 					if ($globalDebug) echo "Gunzip...";
2145
-					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2145
+					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2146 2146
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2147 2147
 						update_db::insert_geoid_version($geoid_md5);
2148 2148
 					}
@@ -2158,15 +2158,15 @@  discard block
 block discarded – undo
2158 2158
 	public static function update_tle() {
2159 2159
 		global $tmp_dir, $globalDebug;
2160 2160
 		if ($globalDebug) echo "Download TLE : Download...";
2161
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2162
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2163
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2161
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2162
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2163
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2164 2164
 		foreach ($alltle as $filename) {
2165 2165
 			if ($globalDebug) echo "downloading ".$filename.'...';
2166
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2166
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2167 2167
 			if (file_exists($tmp_dir.$filename)) {
2168 2168
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2169
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2169
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2170 2170
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2171 2171
 			if ($error != '') {
2172 2172
 				echo $error."\n";
@@ -2179,32 +2179,32 @@  discard block
 block discarded – undo
2179 2179
 		global $tmp_dir, $globalDebug;
2180 2180
 		$error = '';
2181 2181
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2182
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2182
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2183 2183
 		if (file_exists($tmp_dir.'models.md5sum')) {
2184 2184
 			if ($globalDebug) echo "Check files...\n";
2185 2185
 			$newmodelsdb = array();
2186
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2187
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2186
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2187
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2188 2188
 					$model = trim($row[2]);
2189 2189
 					$newmodelsdb[$model] = trim($row[0]);
2190 2190
 				}
2191 2191
 			}
2192 2192
 			$modelsdb = array();
2193 2193
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2194
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2195
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2194
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2195
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2196 2196
 						$model = trim($row[2]);
2197 2197
 						$modelsdb[$model] = trim($row[0]);
2198 2198
 					}
2199 2199
 				}
2200 2200
 			}
2201
-			$diff = array_diff($newmodelsdb,$modelsdb);
2201
+			$diff = array_diff($newmodelsdb, $modelsdb);
2202 2202
 			foreach ($diff as $key => $value) {
2203 2203
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2204
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2204
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2205 2205
 				
2206 2206
 			}
2207
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2207
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2208 2208
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2209 2209
 		if ($error != '') {
2210 2210
 			return $error;
@@ -2216,32 +2216,32 @@  discard block
 block discarded – undo
2216 2216
 		global $tmp_dir, $globalDebug;
2217 2217
 		$error = '';
2218 2218
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2219
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2219
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2220 2220
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2221 2221
 			if ($globalDebug) echo "Check files...\n";
2222 2222
 			$newmodelsdb = array();
2223
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2224
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2223
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2224
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2225 2225
 					$model = trim($row[2]);
2226 2226
 					$newmodelsdb[$model] = trim($row[0]);
2227 2227
 				}
2228 2228
 			}
2229 2229
 			$modelsdb = array();
2230 2230
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2231
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2232
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2231
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2232
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2233 2233
 						$model = trim($row[2]);
2234 2234
 						$modelsdb[$model] = trim($row[0]);
2235 2235
 					}
2236 2236
 				}
2237 2237
 			}
2238
-			$diff = array_diff($newmodelsdb,$modelsdb);
2238
+			$diff = array_diff($newmodelsdb, $modelsdb);
2239 2239
 			foreach ($diff as $key => $value) {
2240 2240
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2241
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2241
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2242 2242
 				
2243 2243
 			}
2244
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2244
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2245 2245
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2246 2246
 		if ($error != '') {
2247 2247
 			return $error;
@@ -2253,32 +2253,32 @@  discard block
 block discarded – undo
2253 2253
 		global $tmp_dir, $globalDebug;
2254 2254
 		$error = '';
2255 2255
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2256
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2256
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2257 2257
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2258 2258
 			if ($globalDebug) echo "Check files...\n";
2259 2259
 			$newmodelsdb = array();
2260
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2261
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2260
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2261
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2262 2262
 					$model = trim($row[2]);
2263 2263
 					$newmodelsdb[$model] = trim($row[0]);
2264 2264
 				}
2265 2265
 			}
2266 2266
 			$modelsdb = array();
2267 2267
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2268
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2269
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2268
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2269
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2270 2270
 						$model = trim($row[2]);
2271 2271
 						$modelsdb[$model] = trim($row[0]);
2272 2272
 					}
2273 2273
 				}
2274 2274
 			}
2275
-			$diff = array_diff($newmodelsdb,$modelsdb);
2275
+			$diff = array_diff($newmodelsdb, $modelsdb);
2276 2276
 			foreach ($diff as $key => $value) {
2277 2277
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2278
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2278
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2279 2279
 				
2280 2280
 			}
2281
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2281
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2282 2282
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2283 2283
 		if ($error != '') {
2284 2284
 			return $error;
@@ -2301,8 +2301,8 @@  discard block
 block discarded – undo
2301 2301
 		*/
2302 2302
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2303 2303
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2304
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2305
-		    $result = fread($fh,100000000);
2304
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2305
+		    $result = fread($fh, 100000000);
2306 2306
 		    //echo $result;
2307 2307
 		    //var_dump(str_get_html($result));
2308 2308
 		    //print_r(self::table2array($result));
@@ -2320,23 +2320,23 @@  discard block
 block discarded – undo
2320 2320
 			$Connection = new Connection();
2321 2321
 			$sth = $Connection->db->prepare($query);
2322 2322
                         $sth->execute();
2323
-                } catch(PDOException $e) {
2323
+                } catch (PDOException $e) {
2324 2324
                         return "error : ".$e->getMessage();
2325 2325
                 }
2326 2326
 
2327 2327
 		$error = '';
2328 2328
 		if ($globalDebug) echo "Notam : Download...";
2329
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2329
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2330 2330
 		if (file_exists($tmp_dir.'notam.rss')) {
2331
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2331
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2332 2332
 			foreach ($notams['channel']['item'] as $notam) {
2333
-				$title = explode(':',$notam['title']);
2333
+				$title = explode(':', $notam['title']);
2334 2334
 				$data['ref'] = trim($title[0]);
2335 2335
 				unset($title[0]);
2336
-				$data['title'] = trim(implode(':',$title));
2337
-				$description = strip_tags($notam['description'],'<pre>');
2338
-				preg_match(':^(.*?)<pre>:',$description,$match);
2339
-				$q = explode('/',$match[1]);
2336
+				$data['title'] = trim(implode(':', $title));
2337
+				$description = strip_tags($notam['description'], '<pre>');
2338
+				preg_match(':^(.*?)<pre>:', $description, $match);
2339
+				$q = explode('/', $match[1]);
2340 2340
 				$data['fir'] = $q[0];
2341 2341
 				$data['code'] = $q[1];
2342 2342
 				$ifrvfr = $q[2];
@@ -2352,30 +2352,30 @@  discard block
 block discarded – undo
2352 2352
 				$data['lower_limit'] = $q[5];
2353 2353
 				$data['upper_limit'] = $q[6];
2354 2354
 				$latlonrad = $q[7];
2355
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2356
-				$latitude = $Common->convertDec($las,'latitude');
2357
-				$longitude = $Common->convertDec($lns,'longitude');
2355
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2356
+				$latitude = $Common->convertDec($las, 'latitude');
2357
+				$longitude = $Common->convertDec($lns, 'longitude');
2358 2358
 				if ($lac == 'S') $latitude = '-'.$latitude;
2359 2359
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2360 2360
 				$data['center_latitude'] = $latitude;
2361 2361
 				$data['center_longitude'] = $longitude;
2362 2362
 				$data['radius'] = intval($radius);
2363 2363
 				
2364
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2364
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2365 2365
 				$data['text'] = $match[1];
2366
-				preg_match(':</pre>(.*?)$:',$description,$match);
2366
+				preg_match(':</pre>(.*?)$:', $description, $match);
2367 2367
 				$fromto = $match[1];
2368
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2368
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2369 2369
 				$fromall = trim($match[1]);
2370
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2370
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2371 2371
 				$from = trim($match[1]);
2372
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2373
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2372
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2373
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2374 2374
 				$toall = trim($match[1]);
2375
-				if (!preg_match(':Permanent:',$toall)) {
2376
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2375
+				if (!preg_match(':Permanent:', $toall)) {
2376
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2377 2377
 					$to = trim($match[1]);
2378
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2378
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2379 2379
 					$data['permanent'] = 0;
2380 2380
 				} else {
2381 2381
 				    $data['date_end'] = NULL;
@@ -2383,7 +2383,7 @@  discard block
 block discarded – undo
2383 2383
 				}
2384 2384
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2385 2385
 				$NOTAM = new NOTAM();
2386
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2386
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
2387 2387
 				unset($data);
2388 2388
 			} 
2389 2389
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2406,16 +2406,16 @@  discard block
 block discarded – undo
2406 2406
 				$Connection = new Connection();
2407 2407
 				$sth = $Connection->db->prepare($query);
2408 2408
 				$sth->execute();
2409
-			} catch(PDOException $e) {
2409
+			} catch (PDOException $e) {
2410 2410
 				return "error : ".$e->getMessage();
2411 2411
 			}
2412 2412
 		}
2413 2413
 		$Common = new Common();
2414 2414
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2415
-		$airspace_json = json_decode($airspace_lst,true);
2415
+		$airspace_json = json_decode($airspace_lst, true);
2416 2416
 		foreach ($airspace_json['records'] as $airspace) {
2417 2417
 			if ($globalDebug) echo $airspace['name']."...\n";
2418
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2418
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2419 2419
 			if (file_exists($tmp_dir.$airspace['name'])) {
2420 2420
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2421 2421
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2437,7 +2437,7 @@  discard block
 block discarded – undo
2437 2437
 				$Connection = new Connection();
2438 2438
 				$sth = $Connection->db->prepare($query);
2439 2439
 				$sth->execute(array(':new' => $new, ':old' => $old));
2440
-			} catch(PDOException $e) {
2440
+			} catch (PDOException $e) {
2441 2441
 				return "error : ".$e->getMessage();
2442 2442
 			}
2443 2443
 		}
@@ -2454,7 +2454,7 @@  discard block
 block discarded – undo
2454 2454
 			$Connection = new Connection();
2455 2455
 			$sth = $Connection->db->prepare($query);
2456 2456
                         $sth->execute();
2457
-                } catch(PDOException $e) {
2457
+                } catch (PDOException $e) {
2458 2458
                         return "error : ".$e->getMessage();
2459 2459
                 }
2460 2460
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2469,7 +2469,7 @@  discard block
 block discarded – undo
2469 2469
 			$Connection = new Connection();
2470 2470
 			$sth = $Connection->db->prepare($query);
2471 2471
                         $sth->execute();
2472
-                } catch(PDOException $e) {
2472
+                } catch (PDOException $e) {
2473 2473
                         return "error : ".$e->getMessage();
2474 2474
                 }
2475 2475
 	}
@@ -2480,7 +2480,7 @@  discard block
 block discarded – undo
2480 2480
 			$Connection = new Connection();
2481 2481
 			$sth = $Connection->db->prepare($query);
2482 2482
                         $sth->execute(array(':version' => $version));
2483
-                } catch(PDOException $e) {
2483
+                } catch (PDOException $e) {
2484 2484
                         return "error : ".$e->getMessage();
2485 2485
                 }
2486 2486
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2494,7 +2494,7 @@  discard block
 block discarded – undo
2494 2494
 			$Connection = new Connection();
2495 2495
 			$sth = $Connection->db->prepare($query);
2496 2496
                         $sth->execute(array(':version' => $version));
2497
-                } catch(PDOException $e) {
2497
+                } catch (PDOException $e) {
2498 2498
                         return "error : ".$e->getMessage();
2499 2499
                 }
2500 2500
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2508,7 +2508,7 @@  discard block
 block discarded – undo
2508 2508
 			$Connection = new Connection();
2509 2509
 			$sth = $Connection->db->prepare($query);
2510 2510
                         $sth->execute(array(':version' => $version));
2511
-                } catch(PDOException $e) {
2511
+                } catch (PDOException $e) {
2512 2512
                         return "error : ".$e->getMessage();
2513 2513
                 }
2514 2514
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2524,7 +2524,7 @@  discard block
 block discarded – undo
2524 2524
 			$Connection = new Connection();
2525 2525
 			$sth = $Connection->db->prepare($query);
2526 2526
 			$sth->execute(array(':version' => $version));
2527
-		} catch(PDOException $e) {
2527
+		} catch (PDOException $e) {
2528 2528
 			return "error : ".$e->getMessage();
2529 2529
 		}
2530 2530
 	}
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
 			$Connection = new Connection();
2537 2537
 			$sth = $Connection->db->prepare($query);
2538 2538
                         $sth->execute(array(':version' => $version));
2539
-                } catch(PDOException $e) {
2539
+                } catch (PDOException $e) {
2540 2540
                         return "error : ".$e->getMessage();
2541 2541
                 }
2542 2542
 	}
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
 			$Connection = new Connection();
2549 2549
 			$sth = $Connection->db->prepare($query);
2550 2550
                         $sth->execute(array(':version' => $version));
2551
-                } catch(PDOException $e) {
2551
+                } catch (PDOException $e) {
2552 2552
                         return "error : ".$e->getMessage();
2553 2553
                 }
2554 2554
 	}
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 			$Connection = new Connection();
2565 2565
 			$sth = $Connection->db->prepare($query);
2566 2566
                         $sth->execute();
2567
-                } catch(PDOException $e) {
2567
+                } catch (PDOException $e) {
2568 2568
                         return "error : ".$e->getMessage();
2569 2569
                 }
2570 2570
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
 			$Connection = new Connection();
2580 2580
 			$sth = $Connection->db->prepare($query);
2581 2581
                         $sth->execute();
2582
-                } catch(PDOException $e) {
2582
+                } catch (PDOException $e) {
2583 2583
                         return "error : ".$e->getMessage();
2584 2584
                 }
2585 2585
 	}
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
 			$Connection = new Connection();
2596 2596
 			$sth = $Connection->db->prepare($query);
2597 2597
                         $sth->execute();
2598
-                } catch(PDOException $e) {
2598
+                } catch (PDOException $e) {
2599 2599
                         return "error : ".$e->getMessage();
2600 2600
                 }
2601 2601
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2610,7 +2610,7 @@  discard block
 block discarded – undo
2610 2610
 			$Connection = new Connection();
2611 2611
 			$sth = $Connection->db->prepare($query);
2612 2612
                         $sth->execute();
2613
-                } catch(PDOException $e) {
2613
+                } catch (PDOException $e) {
2614 2614
                         return "error : ".$e->getMessage();
2615 2615
                 }
2616 2616
 	}
@@ -2626,7 +2626,7 @@  discard block
 block discarded – undo
2626 2626
 			$Connection = new Connection();
2627 2627
 			$sth = $Connection->db->prepare($query);
2628 2628
                         $sth->execute();
2629
-                } catch(PDOException $e) {
2629
+                } catch (PDOException $e) {
2630 2630
                         return "error : ".$e->getMessage();
2631 2631
                 }
2632 2632
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
 			$Connection = new Connection();
2642 2642
 			$sth = $Connection->db->prepare($query);
2643 2643
                         $sth->execute();
2644
-                } catch(PDOException $e) {
2644
+                } catch (PDOException $e) {
2645 2645
                         return "error : ".$e->getMessage();
2646 2646
                 }
2647 2647
 	}
@@ -2657,7 +2657,7 @@  discard block
 block discarded – undo
2657 2657
 			$Connection = new Connection();
2658 2658
 			$sth = $Connection->db->prepare($query);
2659 2659
                         $sth->execute();
2660
-                } catch(PDOException $e) {
2660
+                } catch (PDOException $e) {
2661 2661
                         return "error : ".$e->getMessage();
2662 2662
                 }
2663 2663
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2672,7 +2672,7 @@  discard block
 block discarded – undo
2672 2672
 			$Connection = new Connection();
2673 2673
 			$sth = $Connection->db->prepare($query);
2674 2674
                         $sth->execute();
2675
-                } catch(PDOException $e) {
2675
+                } catch (PDOException $e) {
2676 2676
                         return "error : ".$e->getMessage();
2677 2677
                 }
2678 2678
 	}
@@ -2687,7 +2687,7 @@  discard block
 block discarded – undo
2687 2687
 			$Connection = new Connection();
2688 2688
 			$sth = $Connection->db->prepare($query);
2689 2689
                         $sth->execute();
2690
-                } catch(PDOException $e) {
2690
+                } catch (PDOException $e) {
2691 2691
                         return "error : ".$e->getMessage();
2692 2692
                 }
2693 2693
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2702,7 +2702,7 @@  discard block
 block discarded – undo
2702 2702
 			$Connection = new Connection();
2703 2703
 			$sth = $Connection->db->prepare($query);
2704 2704
                         $sth->execute();
2705
-                } catch(PDOException $e) {
2705
+                } catch (PDOException $e) {
2706 2706
                         return "error : ".$e->getMessage();
2707 2707
                 }
2708 2708
 	}
@@ -2717,7 +2717,7 @@  discard block
 block discarded – undo
2717 2717
 			$Connection = new Connection();
2718 2718
 			$sth = $Connection->db->prepare($query);
2719 2719
                         $sth->execute();
2720
-                } catch(PDOException $e) {
2720
+                } catch (PDOException $e) {
2721 2721
                         return "error : ".$e->getMessage();
2722 2722
                 }
2723 2723
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2732,7 +2732,7 @@  discard block
 block discarded – undo
2732 2732
 			$Connection = new Connection();
2733 2733
 			$sth = $Connection->db->prepare($query);
2734 2734
                         $sth->execute();
2735
-                } catch(PDOException $e) {
2735
+                } catch (PDOException $e) {
2736 2736
                         return "error : ".$e->getMessage();
2737 2737
                 }
2738 2738
 	}
@@ -2747,7 +2747,7 @@  discard block
 block discarded – undo
2747 2747
 			$Connection = new Connection();
2748 2748
 			$sth = $Connection->db->prepare($query);
2749 2749
                         $sth->execute();
2750
-                } catch(PDOException $e) {
2750
+                } catch (PDOException $e) {
2751 2751
                         return "error : ".$e->getMessage();
2752 2752
                 }
2753 2753
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2762,7 +2762,7 @@  discard block
 block discarded – undo
2762 2762
 			$Connection = new Connection();
2763 2763
 			$sth = $Connection->db->prepare($query);
2764 2764
                         $sth->execute();
2765
-                } catch(PDOException $e) {
2765
+                } catch (PDOException $e) {
2766 2766
                         return "error : ".$e->getMessage();
2767 2767
                 }
2768 2768
 	}
@@ -2777,7 +2777,7 @@  discard block
 block discarded – undo
2777 2777
 			$Connection = new Connection();
2778 2778
 			$sth = $Connection->db->prepare($query);
2779 2779
                         $sth->execute();
2780
-                } catch(PDOException $e) {
2780
+                } catch (PDOException $e) {
2781 2781
                         return "error : ".$e->getMessage();
2782 2782
                 }
2783 2783
 	}
@@ -2792,7 +2792,7 @@  discard block
 block discarded – undo
2792 2792
 			$Connection = new Connection();
2793 2793
 			$sth = $Connection->db->prepare($query);
2794 2794
                         $sth->execute();
2795
-                } catch(PDOException $e) {
2795
+                } catch (PDOException $e) {
2796 2796
                         return "error : ".$e->getMessage();
2797 2797
                 }
2798 2798
 	}
Please login to merge, or discard this patch.
require/class.ACARS.php 1 patch
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	* @return String the icao
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25
-		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
25
+		if (substr($ident, 0, 2) == 'AF') {
26
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
28 28
 		} else {
29 29
 			$Spotter = new Spotter($this->db);
30
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
30
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
31 31
 			if (isset($identicao[0])) {
32
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
32
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
33 33
 			} else $icao = $ident;
34 34
 		}
35 35
 		return $icao;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 			$sth = $this->db->prepare($query);
55 55
 			$sth->execute();
56
-		} catch(PDOException $e) {
56
+		} catch (PDOException $e) {
57 57
 			return "error";
58 58
 		}
59 59
 		return "success";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute();
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error";
82 82
 		}
83 83
 		return "success";
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 		$ident = '';
103 103
 		$message = '';
104 104
 		$result = array();
105
-		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
105
+		$n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
106
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
107
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
108
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
109 109
 		if ($n != 0) {
110
-			$registration = str_replace('.','',$registration);
111
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
110
+			$registration = str_replace('.', '', $registration);
111
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
112 112
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113 113
 		} else $message = $data;
114 114
 		$decode = array();
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 				$temp = '';
129 129
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
130 130
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131
-					$latitude = $la / 10000.0;
132
-					$longitude = $ln / 10000.0;
131
+					$latitude = $la/10000.0;
132
+					$longitude = $ln/10000.0;
133 133
 					if ($lac == 'S') $latitude = '-'.$latitude;
134 134
 					if ($lnc == 'W') $longitude = '-'.$longitude;
135 135
 					// Temp not always available
136 136
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
137
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
138
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
139 139
 
140 140
 					//$icao = $Translation->checkTranslation($ident);
141 141
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -147,19 +147,19 @@  discard block
 block discarded – undo
147 147
 				$dhour = '';
148 148
 				$darr = '';
149 149
 				$ahour = '';
150
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
150
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
151 151
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
152
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
153
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
154
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
155 155
 					//$icao = ACARS->ident2icao($ident);
156 156
 					//$icao = $Translation->checkTranslation($ident);
157 157
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 158
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 159
 					$found = true;
160 160
 				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
161
+				elseif ($n == 2 || $n == 4) {
162
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
163 163
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
164 164
 					//$icao = ACARS->ident2icao($ident);
165 165
 					//$icao = $Translation->checkTranslation($ident);
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 				$ahour = '';
218 218
 				$aair = '';
219 219
 				$apiste = '';
220
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
220
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
221 221
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
222
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
224
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
225 225
 					$icao = trim($aident);
226 226
 
227 227
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
247 247
 					$las = $las.'.'.$lass;
248 248
 					$lns = $lns.'.'.$lns;
249
-					$latitude = $las / 1000.0;
250
-					$longitude = $lns / 1000.0;
249
+					$latitude = $las/1000.0;
250
+					$longitude = $lns/1000.0;
251 251
 					if ($lac == 'S') $latitude = '-'.$latitude;
252 252
 					if ($lnc == 'W') $longitude = '-'.$longitude;
253 253
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -342,17 +342,17 @@  discard block
 block discarded – undo
342 342
 				$alt = '';
343 343
 				$fuel = '';
344 344
 				$speed = '';
345
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
345
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
346 346
 				if ($n == 9) {
347 347
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
348 348
 					$icao = trim($aident);
349 349
 					$decode['icao'] = $icao;
350
-					$latitude = $las / 100.0;
351
-					$longitude = $lns / 100.0;
350
+					$latitude = $las/100.0;
351
+					$longitude = $lns/100.0;
352 352
 					if ($lac == 'S') $latitude = '-'.$latitude;
353 353
 					if ($lnc == 'W') $longitude = '-'.$longitude;
354 354
 
355
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
355
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
356 356
 					$found = true;
357 357
 				}
358 358
 			}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 					if ($lac == 'S') $latitude = '-'.$latitude;
372 372
 					if ($lnc == 'W') $longitude = '-'.$longitude;
373 373
 
374
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
374
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
375 375
 					$found = true;
376 376
 				}
377 377
 			}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				$dair = '';
405 405
 				$darr = '';
406 406
 				$aident = '';
407
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
407
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 408
 				if ($n == 8) {
409 409
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
410 410
 					$icao = trim($aident);
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 				*/
437 437
 				$dair = '';
438 438
 				$darr = '';
439
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
439
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
440 440
 				if ($n == 3) {
441 441
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
442 442
 					//$icao = $Translation->checkTranslation($ident);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 				*/
452 452
 				$dair = '';
453 453
 				$darr = '';
454
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
454
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
455 455
 				if ($n == 3) {
456 456
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457 457
 					//$icao = $Translation->checkTranslation($ident);
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 				}
462 462
 			}
463 463
 			if (!$found) {
464
-				$n = sscanf($message,'MET01%4c',$airport);
464
+				$n = sscanf($message, 'MET01%4c', $airport);
465 465
 				if ($n == 1) {
466 466
 					if ($globalDebug) echo 'airport name : '.$airport;
467 467
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -469,241 +469,241 @@  discard block
 block discarded – undo
469 469
 				}
470 470
 			}
471 471
 			if ($label == 'H1') {
472
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
473
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
472
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
473
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
474 474
 				}
475
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
476
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
475
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
476
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
477 477
 				}
478
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
479
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
478
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
479
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
480 480
 				}
481
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
482
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
481
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
482
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
483 483
 				}
484
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
485
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
484
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
485
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
486 486
 				}
487
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
488
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
487
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
488
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
489 489
 				}
490
-				elseif (preg_match(':^#M1AAEP:',$message)) {
491
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
490
+				elseif (preg_match(':^#M1AAEP:', $message)) {
491
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
492 492
 				}
493
-				elseif (preg_match(':^#M2APWD:',$message)) {
494
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
493
+				elseif (preg_match(':^#M2APWD:', $message)) {
494
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
495 495
 				}
496
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
497
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
496
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
497
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
498 498
 				}
499
-				elseif (preg_match(':^#CF:',$message)) {
500
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
499
+				elseif (preg_match(':^#CF:', $message)) {
500
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
501 501
 				}
502
-				elseif (preg_match(':^#DF:',$message)) {
503
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
502
+				elseif (preg_match(':^#DF:', $message)) {
503
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
504 504
 				}
505
-				elseif (preg_match(':^#EC:',$message)) {
506
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
505
+				elseif (preg_match(':^#EC:', $message)) {
506
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
507 507
 				}
508
-				elseif (preg_match(':^#EI:',$message)) {
509
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
508
+				elseif (preg_match(':^#EI:', $message)) {
509
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
510 510
 				}
511
-				elseif (preg_match(':^#H1:',$message)) {
512
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
511
+				elseif (preg_match(':^#H1:', $message)) {
512
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
513 513
 				}
514
-				elseif (preg_match(':^#H2:',$message)) {
515
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
514
+				elseif (preg_match(':^#H2:', $message)) {
515
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
516 516
 				}
517
-				elseif (preg_match(':^#HD:',$message)) {
518
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
517
+				elseif (preg_match(':^#HD:', $message)) {
518
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
519 519
 				}
520
-				elseif (preg_match(':^#M1:',$message)) {
521
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
520
+				elseif (preg_match(':^#M1:', $message)) {
521
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
522 522
 				}
523
-				elseif (preg_match(':^#M2:',$message)) {
524
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
523
+				elseif (preg_match(':^#M2:', $message)) {
524
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
525 525
 				}
526
-				elseif (preg_match(':^#M3:',$message)) {
527
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
526
+				elseif (preg_match(':^#M3:', $message)) {
527
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
528 528
 				}
529
-				elseif (preg_match(':^#MD:',$message)) {
530
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
529
+				elseif (preg_match(':^#MD:', $message)) {
530
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
531 531
 				}
532
-				elseif (preg_match(':^#PS:',$message)) {
533
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
532
+				elseif (preg_match(':^#PS:', $message)) {
533
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
534 534
 				}
535
-				elseif (preg_match(':^#S1:',$message)) {
536
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
535
+				elseif (preg_match(':^#S1:', $message)) {
536
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
537 537
 				}
538
-				elseif (preg_match(':^#S2:',$message)) {
539
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
538
+				elseif (preg_match(':^#S2:', $message)) {
539
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
540 540
 				}
541
-				elseif (preg_match(':^#SD:',$message)) {
542
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
541
+				elseif (preg_match(':^#SD:', $message)) {
542
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
543 543
 				}
544
-				elseif (preg_match(':^#T[0-8]:',$message)) {
545
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
544
+				elseif (preg_match(':^#T[0-8]:', $message)) {
545
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
546 546
 				}
547
-				elseif (preg_match(':^#WO:',$message)) {
548
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
547
+				elseif (preg_match(':^#WO:', $message)) {
548
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
549 549
 				}
550
-				elseif (preg_match(':^#A1:',$message)) {
551
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
550
+				elseif (preg_match(':^#A1:', $message)) {
551
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
552 552
 				}
553
-				elseif (preg_match(':^#A3:',$message)) {
554
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
553
+				elseif (preg_match(':^#A3:', $message)) {
554
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
555 555
 				}
556
-				elseif (preg_match(':^#A4:',$message)) {
557
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
556
+				elseif (preg_match(':^#A4:', $message)) {
557
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
558 558
 				}
559
-				elseif (preg_match(':^#A6:',$message)) {
560
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
559
+				elseif (preg_match(':^#A6:', $message)) {
560
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
561 561
 				}
562
-				elseif (preg_match(':^#A8:',$message)) {
563
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
562
+				elseif (preg_match(':^#A8:', $message)) {
563
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
564 564
 				}
565
-				elseif (preg_match(':^#A9:',$message)) {
566
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
565
+				elseif (preg_match(':^#A9:', $message)) {
566
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
567 567
 				}
568
-				elseif (preg_match(':^#A0:',$message)) {
569
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
568
+				elseif (preg_match(':^#A0:', $message)) {
569
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
570 570
 				}
571
-				elseif (preg_match(':^#AA:',$message)) {
572
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
571
+				elseif (preg_match(':^#AA:', $message)) {
572
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
573 573
 				}
574
-				elseif (preg_match(':^#AB:',$message)) {
575
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
574
+				elseif (preg_match(':^#AB:', $message)) {
575
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
576 576
 				}
577
-				elseif (preg_match(':^#AC:',$message)) {
578
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
577
+				elseif (preg_match(':^#AC:', $message)) {
578
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
579 579
 				}
580
-				elseif (preg_match(':^#AD:',$message)) {
581
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
580
+				elseif (preg_match(':^#AD:', $message)) {
581
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
582 582
 				}
583
-				elseif (preg_match(':^#AF:',$message)) {
584
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
583
+				elseif (preg_match(':^#AF:', $message)) {
584
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
585 585
 				}
586
-				elseif (preg_match(':^#B1:',$message)) {
587
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
586
+				elseif (preg_match(':^#B1:', $message)) {
587
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
588 588
 				}
589
-				elseif (preg_match(':^#B2:',$message)) {
590
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
589
+				elseif (preg_match(':^#B2:', $message)) {
590
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
591 591
 				}
592
-				elseif (preg_match(':^#B3:',$message)) {
593
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
592
+				elseif (preg_match(':^#B3:', $message)) {
593
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
594 594
 				}
595
-				elseif (preg_match(':^#B4:',$message)) {
596
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
595
+				elseif (preg_match(':^#B4:', $message)) {
596
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
597 597
 				}
598
-				elseif (preg_match(':^#B6:',$message)) {
599
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
598
+				elseif (preg_match(':^#B6:', $message)) {
599
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
600 600
 				}
601
-				elseif (preg_match(':^#B8:',$message)) {
602
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
601
+				elseif (preg_match(':^#B8:', $message)) {
602
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
603 603
 				}
604
-				elseif (preg_match(':^#B9:',$message)) {
605
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
604
+				elseif (preg_match(':^#B9:', $message)) {
605
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
606 606
 				}
607
-				elseif (preg_match(':^#B0:',$message)) {
608
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
607
+				elseif (preg_match(':^#B0:', $message)) {
608
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
609 609
 				}
610
-				elseif (preg_match(':^#BA:',$message)) {
611
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
610
+				elseif (preg_match(':^#BA:', $message)) {
611
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
612 612
 				}
613
-				elseif (preg_match(':^#BB:',$message)) {
614
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
613
+				elseif (preg_match(':^#BB:', $message)) {
614
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
615 615
 				}
616
-				elseif (preg_match(':^#BC:',$message)) {
617
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
616
+				elseif (preg_match(':^#BC:', $message)) {
617
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
618 618
 				}
619
-				elseif (preg_match(':^#BD:',$message)) {
620
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
619
+				elseif (preg_match(':^#BD:', $message)) {
620
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
621 621
 				}
622
-				elseif (preg_match(':^#BE:',$message)) {
623
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
622
+				elseif (preg_match(':^#BE:', $message)) {
623
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
624 624
 				}
625
-				elseif (preg_match(':^#BF:',$message)) {
626
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
625
+				elseif (preg_match(':^#BF:', $message)) {
626
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
627 627
 				}
628
-				elseif (preg_match(':^#H3:',$message)) {
629
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
628
+				elseif (preg_match(':^#H3:', $message)) {
629
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
630 630
 				}
631 631
 			}
632 632
 			if ($label == '10') {
633
-				if (preg_match(':^DTO01:',$message)) {
634
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
633
+				if (preg_match(':^DTO01:', $message)) {
634
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
635 635
 				}
636
-				elseif (preg_match(':^AIS01:',$message)) {
637
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
636
+				elseif (preg_match(':^AIS01:', $message)) {
637
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
638 638
 				}
639
-				elseif (preg_match(':^FTX01:',$message)) {
640
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
639
+				elseif (preg_match(':^FTX01:', $message)) {
640
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
641 641
 				}
642
-				elseif (preg_match(':^FPL01:',$message)) {
643
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
642
+				elseif (preg_match(':^FPL01:', $message)) {
643
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
644 644
 				}
645
-				elseif (preg_match(':^WAB01:',$message)) {
646
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
645
+				elseif (preg_match(':^WAB01:', $message)) {
646
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
647 647
 				}
648
-				elseif (preg_match(':^MET01:',$message)) {
649
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
648
+				elseif (preg_match(':^MET01:', $message)) {
649
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
650 650
 				}
651
-				elseif (preg_match(':^WAB02:',$message)) {
652
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
651
+				elseif (preg_match(':^WAB02:', $message)) {
652
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
653 653
 				}
654 654
 			}
655 655
 			if ($label == '15') {
656
-				if (preg_match(':^FST01:',$message)) {
657
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
656
+				if (preg_match(':^FST01:', $message)) {
657
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
658 658
 				}
659 659
 			}
660 660
 			if (!$found && $label == 'SA') {
661
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
661
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
662 662
 				if ($n == 4) {
663 663
 					$vsta = array('Version' => $version);
664 664
 					if ($state == 'E') {
665
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
665
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
666 666
 					}
667 667
 					elseif ($state == 'L') {
668
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
668
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
669 669
 					}
670 670
 					else {
671
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
671
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
672 672
 					}
673 673
 					if ($type == 'V') {
674
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
674
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
675 675
 					}
676 676
 					elseif ($type == 'S') {
677
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
677
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
678 678
 					}
679 679
 					elseif ($type == 'H') {
680
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
680
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
681 681
 					}
682 682
 					elseif ($type == 'G') {
683
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
683
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
684 684
 					}
685 685
 					elseif ($type == 'C') {
686
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
686
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
687 687
 					}
688 688
 					elseif ($type == '2') {
689
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
689
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
690 690
 					}
691 691
 					elseif ($type == 'X') {
692
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
692
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
693 693
 					}
694 694
 					elseif ($type == 'I') {
695
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
695
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
696 696
 					}
697 697
 					else {
698
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
698
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
699 699
 					}
700
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
701
-					$decode = array_merge($vsta,$decode);
700
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
701
+					$decode = array_merge($vsta, $decode);
702 702
 				}
703 703
 			}
704 704
 
705 705
 			$title = $this->getTitlefromLabel($label);
706
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
706
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
707 707
 			/*
708 708
 			// Business jets always use GS0001
709 709
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -731,13 +731,13 @@  discard block
 block discarded – undo
731 731
 		$Translation = new Translation($this->db);
732 732
 		$message = $this->parse($data);
733 733
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
734
-			$ident = (string)$message['ident'];
734
+			$ident = (string) $message['ident'];
735 735
 			$label = $message['label'];
736 736
 			$block_id = $message['block_id'];
737 737
 			$msg_no = $message['msg_no'];
738 738
 			$msg = $message['message'];
739 739
 			$decode = $message['decode'];
740
-			$registration = (string)$message['registration'];
740
+			$registration = (string) $message['registration'];
741 741
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
742 742
 			else $latitude = '';
743 743
 			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
@@ -751,20 +751,20 @@  discard block
 block discarded – undo
751 751
 				$Image->addSpotterImage($registration);
752 752
 			}
753 753
 			// Business jets always use GS0001
754
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
754
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
755 755
 			if ($globalDebug && isset($info) && $info != '') echo $info;
756 756
 			if (count($decode) > 0) $decode_json = json_encode($decode);
757 757
 			else $decode_json = '';
758 758
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
759
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
759
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
760 760
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
761
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
761
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
762 762
 			}
763
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
764
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
765
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
763
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
764
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
765
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
766 766
 			if ($globalDebug && count($decode) > 0) {
767
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
767
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
768 768
 			}
769 769
 		}
770 770
 	}
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	* @param String $msg_no Number of the ACARS message
780 780
 	* @param String $message ACARS message
781 781
 	*/
782
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
782
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
783 783
 		global $globalDebug;
784 784
 		date_default_timezone_set('UTC');
785 785
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -787,21 +787,21 @@  discard block
 block discarded – undo
787 787
 			$this->db = $Connection->db;
788 788
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
789 789
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
790
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
790
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
791 791
 			try {
792 792
 				$stht = $this->db->prepare($query_test);
793 793
 				$stht->execute($query_test_values);
794
-			} catch(PDOException $e) {
794
+			} catch (PDOException $e) {
795 795
 				return "error : ".$e->getMessage();
796 796
 			}
797 797
 			if ($stht->fetchColumn() == 0) {
798 798
 				if ($globalDebug) echo "Add Live ACARS data...";
799 799
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
800
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
800
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
801 801
 				try {
802 802
 					$sth = $this->db->prepare($query);
803 803
 					$sth->execute($query_values);
804
-				} catch(PDOException $e) {
804
+				} catch (PDOException $e) {
805 805
 					return "error : ".$e->getMessage();
806 806
 				}
807 807
 			} else {
@@ -823,10 +823,10 @@  discard block
 block discarded – undo
823 823
 	* @param String $msg_no Number of the ACARS message
824 824
 	* @param String $message ACARS message
825 825
 	*/
826
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
826
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
827 827
 		global $globalDebug;
828 828
 		date_default_timezone_set('UTC');
829
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
829
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
830 830
 			/*
831 831
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
832 832
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -841,11 +841,11 @@  discard block
 block discarded – undo
841 841
 			*/
842 842
 			if ($globalDebug) echo "Add Live ACARS data...";
843 843
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
844
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
844
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
845 845
 			try {
846 846
 				$sth = $this->db->prepare($query);
847 847
 				$sth->execute($query_values);
848
-			} catch(PDOException $e) {
848
+			} catch (PDOException $e) {
849 849
 				return "error : ".$e->getMessage();
850 850
 			}
851 851
 			if ($globalDebug) echo "Done\n";
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 		try {
867 867
 			$sth = $this->db->prepare($query);
868 868
 			$sth->execute($query_values);
869
-		} catch(PDOException $e) {
869
+		} catch (PDOException $e) {
870 870
 			echo "error : ".$e->getMessage();
871 871
 			die;
872 872
 		}
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 		try {
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_values);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			echo "error : ".$e->getMessage();
891 891
 			die;
892 892
 		}
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 		try {
908 908
 			$sth = $this->db->prepare($query);
909 909
 			$sth->execute($query_values);
910
-		} catch(PDOException $e) {
910
+		} catch (PDOException $e) {
911 911
 			echo "error : ".$e->getMessage();
912 912
 			die;
913 913
 		}
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	*
922 922
 	* @return Array Return ACARS data in array
923 923
 	*/
924
-	public function getLatestAcarsData($limit = '',$label = '') {
924
+	public function getLatestAcarsData($limit = '', $label = '') {
925 925
 		global $globalURL, $globalDBdriver;
926 926
 		$Image = new Image($this->db);
927 927
 		$Spotter = new Spotter($this->db);
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 		if ($limit != "")
933 933
 		{
934 934
 			$limit_array = explode(",", $limit);
935
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
936
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
935
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
936
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
937 937
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
938 938
 			{
939 939
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -949,46 +949,46 @@  discard block
 block discarded – undo
949 949
 		try {
950 950
 			$sth = $this->db->prepare($query);
951 951
 			$sth->execute($query_values);
952
-		} catch(PDOException $e) {
952
+		} catch (PDOException $e) {
953 953
 			return "error : ".$e->getMessage();
954 954
 		}
955 955
 		$i = 0;
956 956
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
957 957
 			$data = array();
958 958
 			if ($row['registration'] != '') {
959
-				$row['registration'] = str_replace('.','',$row['registration']);
959
+				$row['registration'] = str_replace('.', '', $row['registration']);
960 960
 				$image_array = $Image->getSpotterImage($row['registration']);
961
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
962
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
963
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
961
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
962
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
963
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
964 964
 			if ($row['registration'] == '') $row['registration'] = 'NA';
965 965
 			if ($row['ident'] == '') $row['ident'] = 'NA';
966
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
966
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
967 967
 			if (isset($identicao[0])) {
968
-				if (substr($row['ident'],0,2) == 'AF') {
969
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
970
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
971
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
972
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
968
+				if (substr($row['ident'], 0, 2) == 'AF') {
969
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
970
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
971
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
972
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
973 973
 			} else $icao = $row['ident'];
974
-			$icao = $Translation->checkTranslation($icao,false);
975
-			$decode = json_decode($row['decode'],true);
974
+			$icao = $Translation->checkTranslation($icao, false);
975
+			$decode = json_decode($row['decode'], true);
976 976
 			$found = false;
977
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
977
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
978 978
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
979 979
 				if (isset($airport_info[0]['icao'])) {
980 980
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
981 981
 					$found = true;
982 982
 				}
983 983
 			}
984
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
984
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
985 985
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
986 986
 				if (isset($airport_info[0]['icao'])) {
987 987
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
988 988
 					$found = true;
989 989
 				}
990 990
 			}
991
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
991
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
992 992
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
993 993
 				if (isset($airport_info[0]['icao'])) {
994 994
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 				}
997 997
 			}
998 998
 			if ($found) $row['decode'] = json_encode($decode);
999
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
999
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1000 1000
 			$result[] = $data;
1001 1001
 			$i++;
1002 1002
 		}
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 	*
1013 1013
 	* @return Array Return ACARS data in array
1014 1014
 	*/
1015
-	public function getArchiveAcarsData($limit = '',$label = '') {
1015
+	public function getArchiveAcarsData($limit = '', $label = '') {
1016 1016
 		global $globalURL, $globalDBdriver;
1017 1017
 		$Image = new Image($this->db);
1018 1018
 		$Spotter = new Spotter($this->db);
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 		if ($limit != "")
1023 1023
 		{
1024 1024
 			$limit_array = explode(",", $limit);
1025
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1026
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1025
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1026
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1027 1027
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1028 1028
 			{
1029 1029
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1044,43 +1044,43 @@  discard block
 block discarded – undo
1044 1044
 		try {
1045 1045
 			$sth = $this->db->prepare($query);
1046 1046
 			$sth->execute($query_values);
1047
-		} catch(PDOException $e) {
1047
+		} catch (PDOException $e) {
1048 1048
 			return "error : ".$e->getMessage();
1049 1049
 		}
1050
-		$i=0;
1050
+		$i = 0;
1051 1051
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1052 1052
 			$data = array();
1053 1053
 			if ($row['registration'] != '') {
1054
-				$row['registration'] = str_replace('.','',$row['registration']);
1054
+				$row['registration'] = str_replace('.', '', $row['registration']);
1055 1055
 				$image_array = $Image->getSpotterImage($row['registration']);
1056
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1057
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1058
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1056
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1057
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1058
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1059 1059
 			$icao = '';
1060 1060
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1061 1061
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1062
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1062
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1063 1063
 			if (isset($identicao[0])) {
1064
-				if (substr($row['ident'],0,2) == 'AF') {
1065
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1066
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1067
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1068
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1064
+				if (substr($row['ident'], 0, 2) == 'AF') {
1065
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1066
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1067
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1068
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1069 1069
 			} else $icao = $row['ident'];
1070 1070
 			$icao = $Translation->checkTranslation($icao);
1071
-			$decode = json_decode($row['decode'],true);
1071
+			$decode = json_decode($row['decode'], true);
1072 1072
 			$found = false;
1073
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1073
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1074 1074
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1075 1075
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1076 1076
 				$found = true;
1077 1077
 			}
1078
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1078
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1079 1079
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1080 1080
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1081 1081
 				$found = true;
1082 1082
 			}
1083
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1083
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1084 1084
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1085 1085
 				if (isset($airport_info[0]['icao'])) {
1086 1086
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 				}
1089 1089
 			}
1090 1090
 			if ($found) $row['decode'] = json_encode($decode);
1091
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1091
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1092 1092
 			$result[] = $data;
1093 1093
 			$i++;
1094 1094
 		}
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 	* @param String $icao
1107 1107
 	* @param String $ICAOTypeCode
1108 1108
 	*/
1109
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1109
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1110 1110
 		global $globalDebug, $globalDBdriver;
1111 1111
 		$ident = trim($ident);
1112 1112
 		$Translation = new Translation($this->db);
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 			if ($globalDebug) echo "Ident or registration null, exit\n";
1120 1120
 			return '';
1121 1121
 		}
1122
-		$registration = str_replace('.','',$registration);
1122
+		$registration = str_replace('.', '', $registration);
1123 1123
 		$ident = $Translation->ident2icao($ident);
1124 1124
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1125 1125
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 		try {
1129 1129
 			$sthsi = $this->db->prepare($querysi);
1130 1130
 			$sthsi->execute($querysi_values);
1131
-		} catch(PDOException $e) {
1131
+		} catch (PDOException $e) {
1132 1132
 			if ($globalDebug) echo $e->getMessage();
1133 1133
 			return "error : ".$e->getMessage();
1134 1134
 		}
@@ -1138,8 +1138,8 @@  discard block
 block discarded – undo
1138 1138
 			$Translation = new Translation($this->db);
1139 1139
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1140 1140
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1141
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1142
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1141
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1142
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1143 1143
 		} else {
1144 1144
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1145 1145
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 				try {
1148 1148
 					$sth = $this->db->prepare($query);
1149 1149
 					$sth->execute($query_values);
1150
-				} catch(PDOException $e) {
1150
+				} catch (PDOException $e) {
1151 1151
 					if ($globalDebug) echo $e->getMessage();
1152 1152
 					return "error : ".$e->getMessage();
1153 1153
 				}
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 				$sth->closeCursor();
1156 1156
 				if (isset($result['modes'])) $hex = $result['modes'];
1157 1157
 				else $hex = '';
1158
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1158
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1159 1159
 				$this->SI->add($SI_data);
1160 1160
 			}
1161 1161
 		}
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 		try {
1166 1166
 			$sth = $this->db->prepare($query);
1167 1167
 			$sth->execute($query_values);
1168
-		} catch(PDOException $e) {
1168
+		} catch (PDOException $e) {
1169 1169
 			if ($globalDebug) echo $e->getMessage();
1170 1170
 			return "error : ".$e->getMessage();
1171 1171
 		}
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1176 1176
 			else $ModeS = '';
1177 1177
 			if ($ModeS == '') {
1178
-				$id = explode('-',$result['flightaware_id']);
1178
+				$id = explode('-', $result['flightaware_id']);
1179 1179
 				$ModeS = $id[0];
1180 1180
 			}
1181 1181
 			if ($ModeS != '') {
@@ -1185,20 +1185,20 @@  discard block
 block discarded – undo
1185 1185
 				try {
1186 1186
 					$sthc = $this->db->prepare($queryc);
1187 1187
 					$sthc->execute($queryc_values);
1188
-				} catch(PDOException $e) {
1188
+				} catch (PDOException $e) {
1189 1189
 					if ($globalDebug) echo $e->getMessage();
1190 1190
 					return "error : ".$e->getMessage();
1191 1191
 				}
1192 1192
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1193 1193
 				$sthc->closeCursor();
1194
-				if (count($row) ==  0) {
1194
+				if (count($row) == 0) {
1195 1195
 					if ($globalDebug) echo " Add to ModeS table - ";
1196 1196
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1197
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1197
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1198 1198
 					try {
1199 1199
 						$sthi = $this->db->prepare($queryi);
1200 1200
 						$sthi->execute($queryi_values);
1201
-					} catch(PDOException $e) {
1201
+					} catch (PDOException $e) {
1202 1202
 						if ($globalDebug) echo $e->getMessage();
1203 1203
 						return "error : ".$e->getMessage();
1204 1204
 					}
@@ -1206,15 +1206,15 @@  discard block
 block discarded – undo
1206 1206
 					if ($globalDebug) echo " Update ModeS table - ";
1207 1207
 					if ($ICAOTypeCode != '') {
1208 1208
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1209
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1209
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1210 1210
 					} else {
1211 1211
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1212
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1212
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1213 1213
 					}
1214 1214
 					try {
1215 1215
 						$sthi = $this->db->prepare($queryi);
1216 1216
 						$sthi->execute($queryi_values);
1217
-					} catch(PDOException $e) {
1217
+					} catch (PDOException $e) {
1218 1218
 						if ($globalDebug) echo $e->getMessage();
1219 1219
 						return "error : ".$e->getMessage();
1220 1220
 					}
@@ -1251,12 +1251,12 @@  discard block
 block discarded – undo
1251 1251
 					elseif ($globalDBdriver == 'pgsql') {
1252 1252
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1253 1253
 					}
1254
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1254
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1255 1255
 				}
1256 1256
 				try {
1257 1257
 					$sthi = $this->db->prepare($queryi);
1258 1258
 					$sthi->execute($queryi_values);
1259
-				} catch(PDOException $e) {
1259
+				} catch (PDOException $e) {
1260 1260
 					if ($globalDebug) echo $e->getMessage();
1261 1261
 					return "error : ".$e->getMessage();
1262 1262
 				}
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21
-				foreach($globalStatsFilters[$globalFilterName] as $source) {
21
+				foreach ($globalStatsFilters[$globalFilterName] as $source) {
22 22
 					if (isset($source['source'])) $filter['source'][] = $source['source'];
23 23
 				}
24 24
 			} else {
25 25
 				$filter = $globalStatsFilters[$globalFilterName];
26 26
 			}
27 27
 		}
28
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
28
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
29 29
 		$filter_query_join = '';
30 30
 		$filter_query_where = '';
31 31
 		if (isset($filter['source']) && !empty($filter['source'])) {
32
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
32
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
33 33
 		}
34 34
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
35 35
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		try {
45 45
 			$sth = $this->db->prepare($query);
46 46
 			$sth->execute($query_values);
47
-		} catch(PDOException $e) {
47
+		} catch (PDOException $e) {
48 48
 			return "error : ".$e->getMessage();
49 49
 		}
50 50
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	public function getById($id) {
55
-		$filter_query = $this->getFilter(array(),true);
55
+		$filter_query = $this->getFilter(array(), true);
56 56
 		$query = "SELECT * FROM atc".$filter_query." atc_id = :id";
57 57
 		$query_values = array(':id' => $id);
58 58
 		try {
59 59
 			$sth = $this->db->prepare($query);
60 60
 			$sth->execute($query_values);
61
-		} catch(PDOException $e) {
61
+		} catch (PDOException $e) {
62 62
 			return "error : ".$e->getMessage();
63 63
 		}
64 64
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
65 65
 		return $all;
66 66
 	}
67 67
 
68
-	public function getByIdent($ident,$format_source = '') {
69
-		$filter_query = $this->getFilter(array(),true);
68
+	public function getByIdent($ident, $format_source = '') {
69
+		$filter_query = $this->getFilter(array(), true);
70 70
 		if ($format_source == '') {
71 71
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident";
72 72
 			$query_values = array(':ident' => $ident);
73 73
 		} else {
74 74
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source";
75
-			$query_values = array(':ident' => $ident,':format_source' => $format_source);
75
+			$query_values = array(':ident' => $ident, ':format_source' => $format_source);
76 76
 		}
77 77
 		try {
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute($query_values);
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error : ".$e->getMessage();
82 82
 		}
83 83
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
84 84
 		return $all;
85 85
 	}
86 86
 
87
-	public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
88
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
89
-		$info = str_replace('^','<br />',$info);
90
-		$info = str_replace('&amp;sect;','',$info);
91
-		$info = str_replace('"','',$info);
87
+	public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
88
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
89
+		$info = str_replace('^', '<br />', $info);
90
+		$info = str_replace('&amp;sect;', '', $info);
91
+		$info = str_replace('"', '', $info);
92 92
 		if ($type == '') $type = NULL;
93 93
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
94
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
94
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
95 95
 		try {
96 96
 			$sth = $this->db->prepare($query);
97 97
 			$sth->execute($query_values);
98
-		} catch(PDOException $e) {
98
+		} catch (PDOException $e) {
99 99
 			return "error : ".$e->getMessage();
100 100
 		}
101 101
 	}
102 102
 
103
-	public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
104
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
105
-		$info = str_replace('^','<br />',$info);
106
-		$info = str_replace('&amp;sect;','',$info);
107
-		$info = str_replace('"','',$info);
103
+	public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
104
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
105
+		$info = str_replace('^', '<br />', $info);
106
+		$info = str_replace('&amp;sect;', '', $info);
107
+		$info = str_replace('"', '', $info);
108 108
 		if ($type == '') $type = NULL;
109 109
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
110
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
110
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
111 111
 		try {
112 112
 			$sth = $this->db->prepare($query);
113 113
 			$sth->execute($query_values);
114
-		} catch(PDOException $e) {
114
+		} catch (PDOException $e) {
115 115
 			return "error : ".$e->getMessage();
116 116
 		}
117 117
 	}
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
 		try {
123 123
 			$sth = $this->db->prepare($query);
124 124
 			$sth->execute($query_values);
125
-		} catch(PDOException $e) {
125
+		} catch (PDOException $e) {
126 126
 			return "error : ".$e->getMessage();
127 127
 		}
128 128
 	}
129 129
 
130
-	public function deleteByIdent($ident,$format_source) {
130
+	public function deleteByIdent($ident, $format_source) {
131 131
 		$query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
132
-		$query_values = array(':ident' => $ident,':format_source' => $format_source);
132
+		$query_values = array(':ident' => $ident, ':format_source' => $format_source);
133 133
 		try {
134 134
 			$sth = $this->db->prepare($query);
135 135
 			$sth->execute($query_values);
136
-		} catch(PDOException $e) {
136
+		} catch (PDOException $e) {
137 137
 			return "error : ".$e->getMessage();
138 138
 		}
139 139
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		try {
145 145
 			$sth = $this->db->prepare($query);
146 146
 			$sth->execute($query_values);
147
-		} catch(PDOException $e) {
147
+		} catch (PDOException $e) {
148 148
 			return "error : ".$e->getMessage();
149 149
 		}
150 150
 	}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		try {
160 160
 			$sth = $this->db->prepare($query);
161 161
 			$sth->execute();
162
-		} catch(PDOException $e) {
162
+		} catch (PDOException $e) {
163 163
 			return "error";
164 164
 		}
165 165
 		return "success";
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
37
+		    foreach ($sourcestat as $srcst) {
38 38
 		    	$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40 40
 			    $source = $srcst['source_name'];
41 41
 			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
43 43
 	    		}
44 44
 		    }
45 45
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	if (isset($globalGeoid) && $globalGeoid) {
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54
-		} catch(Exception $e) {
54
+		} catch (Exception $e) {
55 55
 			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php \n";
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59 59
     }
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+    public function get_Schedule($id, $ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85 85
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
86
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
87
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
88 88
 		    // Should also check if route schedule = route from DB
89 89
 		    if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			    }
105 105
 			}
106 106
 		    }
107
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
107
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
108 108
 		}
109 109
 	    } else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
        if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114 114
     		$sch = $Schedule->getSchedule($operator);
115
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
115
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
116 116
        }
117 117
 	$Spotter->db = null;
118 118
 	$Schedule->db = null;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 140
     		    $Spotter = new Spotter($this->db);
141 141
         	    $real_arrival = $this->arrival($key);
142
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
142
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
143 143
         	}
144 144
 	    }
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $airport_time = '';
154 154
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
155 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
156
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
157 157
     	    if (isset($closestAirports[0])) {
158 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 159
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         		    break;
169 169
         		}
170 170
         	    }
171
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
171
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
172 172
         		$airport_icao = $closestAirports[0]['icao'];
173 173
         		$airport_time = $this->all_flights[$key]['datetime'];
174 174
         	} else {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         } else {
182 182
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183 183
         }
184
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
184
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
185 185
     }
186 186
 
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
193 193
 	foreach ($this->all_flights as $key => $flight) {
194 194
 	    if (isset($flight['lastupdate'])) {
195
-		if ($flight['lastupdate'] < (time()-5900)) {
195
+		if ($flight['lastupdate'] < (time() - 5900)) {
196 196
 		    $this->delKey($key);
197 197
 		}
198 198
 	    }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$real_arrival = $this->arrival($key);
209 209
 			$Spotter = new Spotter($this->db);
210 210
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
211
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
212 212
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
213 213
 			}
214 214
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	$send = false;
242 242
 	
243 243
 	// SBS format is CSV format
244
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
244
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 245
 	    //print_r($line);
246 246
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247 247
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
 		if (!isset($this->all_flights[$id])) {
278 278
 		    if ($globalDebug) echo 'New flight...'."\n";
279 279
 		    $this->all_flights[$id] = array();
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
281
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
282
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
283 283
 		    if (!isset($line['id'])) {
284 284
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
286 286
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
287
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
287
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
288 288
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
289
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
290 290
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
291 291
 		}
292 292
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
293
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
294 294
 		}
295 295
 		
296 296
 		//print_r($this->all_flights);
297 297
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
298
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
298
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
299 299
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
300 300
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301 301
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -304,27 +304,27 @@  discard block
 block discarded – undo
304 304
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305 305
 			    $Spotter = new Spotter($this->db);
306 306
 			    if (isset($this->all_flights[$id]['source_type'])) {
307
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
307
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
308 308
 			    } else {
309 309
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 310
 			    }
311 311
 			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
312
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
313
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
314 314
 			}
315 315
 		    }
316 316
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
317 317
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
318 318
 		}
319 319
 	        if (isset($line['id']) && !isset($line['hex'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
320
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
321 321
 	        }
322 322
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 323
 			$icao = $line['aircraft_icao'];
324 324
 			$Spotter = new Spotter($this->db);
325 325
 			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
326 326
 			$Spotter->db = null;
327
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
327
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
328 328
 		}
329 329
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
330 330
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 				$Spotter = new Spotter($this->db);
333 333
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
334 334
 				$Spotter->db = null;
335
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
335
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
336 336
 			}
337 337
 		}
338 338
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
341 341
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
342 342
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
343
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
343
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
344 344
 		}
345 345
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
346
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
346
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
347 347
 		}
348 348
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
349
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
349
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
350 350
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
351
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
351
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
352 352
 		    } else {
353 353
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
354 354
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -359,31 +359,31 @@  discard block
 block discarded – undo
359 359
 				*/
360 360
 				return '';
361 361
 		    }
362
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
362
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
363 363
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
364 364
 			return '';
365
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
365
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
366 366
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
367 367
 			return '';
368 368
 		} elseif (!isset($line['datetime'])) {
369 369
 			date_default_timezone_set('UTC');
370
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
370
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
371 371
 		} else {
372 372
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
373 373
 			return '';
374 374
 		}
375 375
 
376 376
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
377
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
377
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
378 378
 		}
379 379
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
380
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
380
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
381 381
 		}
382 382
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
383
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
383
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
384 384
 		}
385 385
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
386
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
386
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
387 387
 		}
388 388
  
389 389
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
392 392
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
393 393
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
394
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
395
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
396
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
397
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
398
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
394
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
395
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
396
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
397
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
398
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
399 399
 			} else {
400
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
400
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
401 401
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
402 402
 				$timeelapsed = microtime(true);
403 403
             			$Spotter = new Spotter($this->db);
@@ -407,13 +407,13 @@  discard block
 block discarded – undo
407 407
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
408 408
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
409 409
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
410
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
410
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
411 411
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
412 412
 				$Spotter->db = null;
413
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
413
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
414 414
 			    }
415 415
 			}
416
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
416
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
417 417
 		    
418 418
 /*
419 419
 		    if (!isset($line['id'])) {
@@ -423,25 +423,25 @@  discard block
 block discarded – undo
423 423
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
424 424
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
425 425
   */
426
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
427 427
 
428 428
 		    //$putinarchive = true;
429 429
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
430
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
430
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
431 431
 		    }
432 432
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
433
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
433
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
434 434
 		    }
435 435
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
436
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
436
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
437 437
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
438 438
 			$timeelapsed = microtime(true);
439 439
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
440 440
 				$Spotter = new Spotter($this->db);
441 441
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
442 442
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
443
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
444
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
443
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
444
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
445 445
                         }
446 446
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
447 447
 			$timeelapsed = microtime(true);
@@ -455,35 +455,35 @@  discard block
 block discarded – undo
455 455
 				$Translation->db = null;
456 456
 			    }
457 457
 			    $Spotter->db = null;
458
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
458
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
459 459
                     	}
460 460
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
461 461
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
462 462
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
463 463
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
464
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
464
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
465 465
 		    	    }
466 466
 			}
467 467
 			if (!isset($globalFork)) $globalFork = TRUE;
468 468
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
469
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
469
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
470 470
 			}
471 471
 		    }
472 472
 		}
473 473
 
474 474
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
475 475
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
476
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
477
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
476
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
477
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
478 478
 		    //$dataFound = true;
479 479
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
480
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
480
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
481 481
 		    if ($distance > 1000 && $distance < 10000) {
482 482
 		    // use datetime
483 483
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
484 484
 			$speed = $speed*3.6;
485 485
 			if ($speed < 1000) {
486
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
486
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
487 487
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
488 488
 	  		} else {
489 489
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -498,9 +498,9 @@  discard block
 block discarded – undo
498 498
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
499 499
 	    	    	return false;
500 500
 	    	    }
501
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
501
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
502 502
 	    	    else unset($timediff);
503
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
503
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
504 504
 	    	    else unset($timediff_archive);
505 505
 	    	    if ($this->tmd > 5
506 506
 	    	        || (isset($line['format_source']) 
@@ -524,14 +524,14 @@  discard block
 block discarded – undo
524 524
 	    	    	|| ($timediff > 30 
525 525
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
526 526
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
527
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
527
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
528 528
 	    	    	    )
529 529
 	    	    	) {
530 530
 
531 531
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
532 532
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
533 533
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
534
-				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
534
+				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
535 535
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
536 536
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
537 537
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
 				    $timeelapsed = microtime(true);
542 542
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
543 543
 					$Spotter = new Spotter($this->db);
544
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
544
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
545 545
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
546 546
 					else $this->all_flights[$id]['over_country'] = '';
547 547
 					$Spotter->db = null;
548
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
548
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
549 549
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
550 550
 				    }
551 551
 				}
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
 					$this->all_flights[$id]['time_last_coord'] = time();
572 572
 				}
573 573
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
574
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
574
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) {
575 575
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
576 576
 				    $dataFound = true;
577 577
 				    $this->all_flights[$id]['time_last_coord'] = time();
578 578
 				}
579 579
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
580
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
580
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
581 581
 				/*
582 582
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
583 583
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -599,13 +599,13 @@  discard block
 block discarded – undo
599 599
 					$this->all_flights[$id]['time_last_coord'] = time();
600 600
 				}
601 601
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
602
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
602
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) {
603 603
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
604 604
 				    $dataFound = true;
605 605
 				    $this->all_flights[$id]['time_last_coord'] = time();
606 606
 				}
607 607
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
608
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
608
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
609 609
 				/*
610 610
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
611 611
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -623,46 +623,46 @@  discard block
 block discarded – undo
623 623
 		    } else if ($globalDebug && $timediff > 30) {
624 624
 			$this->tmd = $this->tmd + 1;
625 625
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
626
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
627
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
626
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
627
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
628 628
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
629 629
 		    }
630 630
 		}
631 631
 		if (isset($line['last_update']) && $line['last_update'] != '') {
632 632
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
633
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
633
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
634 634
 		}
635 635
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
636
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
637 637
 		    //$dataFound = true;
638 638
 		}
639 639
 		if (isset($line['format_source']) && $line['format_source'] != '') {
640
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
640
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
641 641
 		}
642 642
 		if (isset($line['source_name']) && $line['source_name'] != '') {
643
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
643
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
644 644
 		}
645 645
 		if (isset($line['emergency']) && $line['emergency'] != '') {
646
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
646
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
647 647
 		    //$dataFound = true;
648 648
 		}
649 649
 		if (isset($line['ground']) && $line['ground'] != '') {
650 650
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
651 651
 			// Here we force archive of flight because after ground it's a new one (or should be)
652
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
653
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
654
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
655
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
656
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
652
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
653
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
654
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
655
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
656
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
657 657
 		    }
658 658
 		    if ($line['ground'] != 1) $line['ground'] = 0;
659
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
659
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
660 660
 		    //$dataFound = true;
661 661
 		}
662 662
 		if (isset($line['squawk']) && $line['squawk'] != '') {
663 663
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
664 664
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
665
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
665
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
666 666
 			    $highlight = '';
667 667
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
668 668
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -671,66 +671,66 @@  discard block
 block discarded – undo
671 671
 				$timeelapsed = microtime(true);
672 672
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
673 673
 				    $Spotter = new Spotter($this->db);
674
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
674
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
675 675
 				    $Spotter->db = null;
676
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
676
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
677 677
 				}
678 678
 				//$putinarchive = true;
679 679
 				//$highlight = '';
680 680
 			    }
681 681
 			    
682
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
682
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
683 683
 		    //$dataFound = true;
684 684
 		}
685 685
 
686 686
 		if (isset($line['altitude']) && $line['altitude'] != '') {
687 687
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
688 688
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
689
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
689
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
690 690
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
691 691
 					$line['altitude'] = $line['altitude'] - $geoid;
692 692
 				}
693 693
 			}
694 694
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
695
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
696
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
697
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
695
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
696
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
697
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
698 698
 			//$dataFound = true;
699 699
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
700 700
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
701 701
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
702 702
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
703
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
704
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
705
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
706
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
707
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
703
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
704
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
705
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
706
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
707
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
708 708
 			}
709 709
 		    }
710
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
710
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
711 711
 		}
712 712
 
713 713
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
714
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
714
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
715 715
 		}
716 716
 		
717 717
 		if (isset($line['heading']) && $line['heading'] != '') {
718
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
719
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
720
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
718
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
719
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
720
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
721 721
 		    //$dataFound = true;
722 722
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
723
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
724
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
725
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
723
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
724
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
725
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726 726
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
727 727
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
728 728
   		    // If not enough messages and ACARS set heading to 0
729
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
729
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
730 730
   		}
731
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
732
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
733
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
731
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
732
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
733
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
734 734
 
735 735
 //		print_r($this->all_flights[$id]);
736 736
 		//gets the callsign from the last hour
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
742 742
 		    $this->all_flights[$id]['lastupdate'] = time();
743 743
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
744
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
744
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
745 745
 			    //print_r($this->all_flights);
746 746
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
747 747
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -752,61 +752,61 @@  discard block
 block discarded – undo
752 752
 				    $SpotterLive = new SpotterLive($this->db);
753 753
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
754 754
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
755
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
755
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
756 756
 				    } elseif (isset($line['id'])) {
757 757
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
758
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
758
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
759 759
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
760 760
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
761
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
761
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
762 762
 				    } else $recent_ident = '';
763
-				    $SpotterLive->db=null;
763
+				    $SpotterLive->db = null;
764 764
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
765 765
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
766 766
 				} else $recent_ident = '';
767 767
 			    } else {
768 768
 				$recent_ident = '';
769
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
769
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
770 770
 			    }
771 771
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
772
-			    if($recent_ident == "")
772
+			    if ($recent_ident == "")
773 773
 			    {
774 774
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
775 775
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
776 776
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
777 777
 				//adds the spotter data for the archive
778 778
 				$ignoreImport = false;
779
-				foreach($globalAirportIgnore as $airportIgnore) {
779
+				foreach ($globalAirportIgnore as $airportIgnore) {
780 780
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
781 781
 					$ignoreImport = true;
782 782
 				    }
783 783
 				}
784 784
 				if (count($globalAirportAccept) > 0) {
785 785
 				    $ignoreImport = true;
786
-				    foreach($globalAirportIgnore as $airportIgnore) {
786
+				    foreach ($globalAirportIgnore as $airportIgnore) {
787 787
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
788 788
 					    $ignoreImport = false;
789 789
 					}
790 790
 				    }
791 791
 				}
792 792
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
793
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
794
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
793
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
794
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
795 795
 					    $ignoreImport = true;
796 796
 					}
797 797
 				    }
798 798
 				}
799 799
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
800 800
 				    $ignoreImport = true;
801
-				    foreach($globalAirlineAccept as $airlineAccept) {
802
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
801
+				    foreach ($globalAirlineAccept as $airlineAccept) {
802
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
803 803
 					    $ignoreImport = false;
804 804
 					}
805 805
 				    }
806 806
 				}
807 807
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
808 808
 				    $ignoreImport = true;
809
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
809
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
810 810
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
811 811
 					    $ignoreImport = false;
812 812
 					}
@@ -818,32 +818,32 @@  discard block
 block discarded – undo
818 818
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
819 819
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
820 820
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
821
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
821
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
822 822
 				    $timeelapsed = microtime(true);
823 823
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
824 824
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
825 825
 					    $Spotter = new Spotter($this->db);
826
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
826
+					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']);
827 827
 					    $Spotter->db = null;
828 828
 					    if ($globalDebug && isset($result)) echo $result."\n";
829 829
 					}
830 830
 				    }
831
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
831
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
832 832
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
833 833
 
834 834
 				    // Add source stat in DB
835 835
 				    $Stats = new Stats($this->db);
836 836
 				    if (!empty($this->stats)) {
837 837
 					if ($globalDebug) echo 'Add source stats : ';
838
-				        foreach($this->stats as $date => $data) {
839
-					    foreach($data as $source => $sourced) {
838
+				        foreach ($this->stats as $date => $data) {
839
+					    foreach ($data as $source => $sourced) {
840 840
 					        //print_r($sourced);
841
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
842
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
841
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
842
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
843 843
 				    		if (isset($sourced['msg'])) {
844 844
 				    		    if (time() - $sourced['msg']['date'] > 10) {
845 845
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
846
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
846
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
847 847
 			    			        unset($this->stats[$date][$source]['msg']);
848 848
 			    			    }
849 849
 			    			}
@@ -881,14 +881,14 @@  discard block
 block discarded – undo
881 881
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
882 882
 					    $SpotterLive = new SpotterLive($this->db);
883 883
 					    $SpotterLive->deleteLiveSpotterData();
884
-					    $SpotterLive->db=null;
884
+					    $SpotterLive->db = null;
885 885
 					}
886 886
 				    }
887 887
 				    if ($globalDebug) echo " Done\n";
888 888
 				    $this->last_delete = time();
889 889
 				}
890 890
 			    } else {
891
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
891
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
892 892
 				    $this->all_flights[$id]['id'] = $recent_ident;
893 893
 				    $this->all_flights[$id]['addedSpotter'] = 1;
894 894
 				}
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
897 897
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
898 898
 					    $Spotter = new Spotter($this->db);
899
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
899
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
900 900
 					    $Spotter->db = null;
901 901
 					}
902 902
 				    }
@@ -922,37 +922,37 @@  discard block
 block discarded – undo
922 922
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
923 923
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
924 924
 
925
-		    foreach($globalAirportIgnore as $airportIgnore) {
925
+		    foreach ($globalAirportIgnore as $airportIgnore) {
926 926
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
927 927
 			    $ignoreImport = true;
928 928
 			}
929 929
 		    }
930 930
 		    if (count($globalAirportAccept) > 0) {
931 931
 		        $ignoreImport = true;
932
-		        foreach($globalAirportIgnore as $airportIgnore) {
932
+		        foreach ($globalAirportIgnore as $airportIgnore) {
933 933
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
934 934
 				$ignoreImport = false;
935 935
 			    }
936 936
 			}
937 937
 		    }
938 938
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
939
-			foreach($globalAirlineIgnore as $airlineIgnore) {
940
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
939
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
940
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
941 941
 				$ignoreImport = true;
942 942
 			    }
943 943
 			}
944 944
 		    }
945 945
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
946 946
 			$ignoreImport = true;
947
-			foreach($globalAirlineAccept as $airlineAccept) {
948
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
947
+			foreach ($globalAirlineAccept as $airlineAccept) {
948
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
949 949
 				$ignoreImport = false;
950 950
 			    }
951 951
 			}
952 952
 		    }
953 953
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
954 954
 			$ignoreImport = true;
955
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
955
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
956 956
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
957 957
 			        $ignoreImport = false;
958 958
 			    }
@@ -960,23 +960,23 @@  discard block
 block discarded – undo
960 960
 		    }
961 961
 
962 962
 		    if (!$ignoreImport) {
963
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
964
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
963
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
964
+				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
965 965
 				$timeelapsed = microtime(true);
966 966
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
967 967
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
968 968
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
969 969
 					$SpotterLive = new SpotterLive($this->db);
970
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
970
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
971 971
 					$SpotterLive->db = null;
972 972
 					if ($globalDebug) echo $result."\n";
973 973
 				    }
974 974
 				}
975 975
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
976
-					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
976
+					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
977 977
 				}
978 978
 				$this->all_flights[$id]['putinarchive'] = false;
979
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
979
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
980 980
 
981 981
 				// Put statistics in $this->stats variable
982 982
 				//if ($line['format_source'] != 'aprs') {
@@ -995,19 +995,19 @@  discard block
 block discarded – undo
995 995
 							$latitude = $globalCenterLatitude;
996 996
 							$longitude = $globalCenterLongitude;
997 997
 						}
998
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
998
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
999 999
 					} else {
1000 1000
 						$latitude = $this->source_location[$source]['latitude'];
1001 1001
 						$longitude = $this->source_location[$source]['longitude'];
1002 1002
 					}
1003
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1003
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1004 1004
 					//$stats_heading = $stats_heading%22.5;
1005 1005
 					$stats_heading = round($stats_heading/22.5);
1006
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1006
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1007 1007
 					$current_date = date('Y-m-d');
1008 1008
 					if ($stats_heading == 16) $stats_heading = 0;
1009 1009
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1010
-						for ($i=0;$i<=15;$i++) {
1010
+						for ($i = 0; $i <= 15; $i++) {
1011 1011
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1012 1012
 						}
1013 1013
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1022,9 +1022,9 @@  discard block
 block discarded – undo
1022 1022
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1023 1023
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1024 1024
 						    end($this->stats[$current_date][$source]['hist']);
1025
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1025
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1026 1026
 						} else $mini = 0;
1027
-						for ($i=$mini;$i<=$distance;$i+=10) {
1027
+						for ($i = $mini; $i <= $distance; $i += 10) {
1028 1028
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1029 1029
 						}
1030 1030
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 				$this->all_flights[$id]['lastupdate'] = time();
1038 1038
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1039 1039
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1040
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1040
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
1041 1041
 			//$this->del();
1042 1042
 			
1043 1043
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			$Connection = new Connection();
55 55
 			$sth = $Connection->db->prepare($query);
56 56
 			$sth->execute();
57
-		} catch(PDOException $e) {
57
+		} catch (PDOException $e) {
58 58
 			return "error : ".$e->getMessage();
59 59
 		}
60 60
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			$Connection = new Connection();
71 71
 			$sth = $Connection->db->prepare($query);
72 72
 			$sth->execute();
73
-		} catch(PDOException $e) {
73
+		} catch (PDOException $e) {
74 74
 			return "error : ".$e->getMessage();
75 75
 		}
76 76
 	}
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	public function parse($data) {
79 79
 		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
80 80
 		$codes = implode('|', array_keys($this->texts));
81
-		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
81
+		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
82 82
 		//$pieces = explode(' ',$data);
83
-		$pieces = preg_split('/\s/',$data);
83
+		$pieces = preg_split('/\s/', $data);
84 84
 		$pos = 0;
85 85
 		if ($pieces[0] == 'METAR') $pos++;
86 86
 		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
 		$result = array();
89 89
 		$result['location'] = $pieces[$pos];
90 90
 		$pos++;
91
-		$result['dayofmonth'] = substr($pieces[$pos],0,2);
92
-		$result['time'] = substr($pieces[$pos],2,4);
91
+		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
92
+		$result['time'] = substr($pieces[$pos], 2, 4);
93 93
 		$c = count($pieces);
94
-		for($pos++; $pos < $c; $pos++) {
94
+		for ($pos++; $pos < $c; $pos++) {
95 95
 			$piece = $pieces[$pos];
96 96
 			if ($piece == 'RMK') break;
97 97
 			if ($piece == 'AUTO') $result['auto'] = true;
98 98
 			if ($piece == 'COR') $result['correction'] = true;
99 99
 			// Wind Speed
100 100
 			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
101
-				$result['wind']['direction'] = (float)$matches[1];
101
+				$result['wind']['direction'] = (float) $matches[1];
102 102
 				$result['wind']['unit'] = $matches[4];
103
-				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
104
-				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
105
-				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
106
-				$result['wind']['gust'] = (float)$matches[3];
103
+				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
104
+				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
105
+				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
106
+				$result['wind']['gust'] = (float) $matches[3];
107 107
 				$result['wind']['unit'] = $matches[4];
108
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
109
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
108
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
109
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
110 110
 			}
111 111
 
112 112
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 
128 128
 			// Temperature
129 129
 			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
130
-				$temp = (float)$matches[1];
130
+				$temp = (float) $matches[1];
131 131
 				if ($matches[1]{0} == 'M') {
132
-					$temp = ((float)substr($matches[1], 1)) * -1;
132
+					$temp = ((float) substr($matches[1], 1))*-1;
133 133
 				}
134 134
 				$result['temperature'] = $temp;
135
-				$dew = (float)$matches[2];
135
+				$dew = (float) $matches[2];
136 136
 				if ($matches[2]{0} == 'M') {
137
-					$dew = ((float)substr($matches[2], 1)) * -1;
137
+					$dew = ((float) substr($matches[2], 1))*-1;
138 138
 				}
139 139
 				$result['dew'] = $dew;
140 140
 			}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 					$result['QNH'] = $matches[2];
147 147
 				} else {
148 148
 					// inHg
149
-					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
149
+					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
150 150
 				}
151 151
 				/*
152 152
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
     			// Visibility
168 168
 			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
169 169
 				if (isset($matches[3]) && strlen($matches[3]) > 0) {
170
-					$result['visibility'] = (float)$matches[3] * 1609.34;
170
+					$result['visibility'] = (float) $matches[3]*1609.34;
171 171
 				} else {
172 172
 					if ($matches[1] == '9999') {
173 173
 						$result['visibility'] = '> 10000';
174 174
 					} else {
175
-						$result['visibility'] = (float)$matches[1];
175
+						$result['visibility'] = (float) $matches[1];
176 176
 					}
177 177
 				}
178 178
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
195 195
 				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
196 196
 				$cloud['type_code'] = $type;
197
-				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
197
+				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
198 198
 				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
199 199
 				$result['cloud'][] = $cloud;
200 200
 			}
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 				$rvr['runway'] = $matches[1];
205 205
 				$rvr['assessment'] = $matches[2];
206 206
 				$rvr['rvr'] = $matches[3];
207
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
208
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
207
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
208
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
209 209
 				$result['RVR'] = $rvr;
210 210
 			}
211 211
 			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 				$result['RVR']['friction'] = $matches[5];
219 219
 			}
220 220
 			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
221
-				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
222
-				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
221
+				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
222
+				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
223 223
 				if (isset($matches[3])) {
224 224
 					$range = Array(
225
-					    'from' => (float)$matches[2],
226
-					    'to'   => (float)$matches[4],
225
+					    'from' => (float) $matches[2],
226
+					    'to'   => (float) $matches[4],
227 227
 					    'unit' => $matches[5] ? 'FT' : 'M'
228 228
 					);
229 229
 				}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		try {
272 272
 			$sth = $this->db->prepare($query);
273 273
 			$sth->execute($query_values);
274
-		} catch(PDOException $e) {
274
+		} catch (PDOException $e) {
275 275
 			return "error : ".$e->getMessage();
276 276
 		}
277 277
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
 		return $all;
282 282
 	}
283 283
 
284
-	public function addMETAR($location,$metar,$date) {
284
+	public function addMETAR($location, $metar, $date) {
285 285
 		global $globalDBdriver;
286
-		$date = date('Y-m-d H:i:s',strtotime($date));
286
+		$date = date('Y-m-d H:i:s', strtotime($date));
287 287
 		if ($globalDBdriver == 'mysql') {
288 288
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
289 289
 		} else {
290 290
 			$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);";
291 291
 		}
292
-		$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
292
+		$query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
293 293
 		try {
294 294
 			$sth = $this->db->prepare($query);
295 295
 			$sth->execute($query_values);
296
-		} catch(PDOException $e) {
296
+		} catch (PDOException $e) {
297 297
 			return "error : ".$e->getMessage();
298 298
 		}
299 299
 	}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		try {
305 305
 			$sth = $this->db->prepare($query);
306 306
 			$sth->execute($query_values);
307
-		} catch(PDOException $e) {
307
+		} catch (PDOException $e) {
308 308
 			return "error : ".$e->getMessage();
309 309
 		}
310 310
 	}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		try {
315 315
 			$sth = $this->db->prepare($query);
316 316
 			$sth->execute();
317
-		} catch(PDOException $e) {
317
+		} catch (PDOException $e) {
318 318
 			return "error : ".$e->getMessage();
319 319
 		}
320 320
 	}
@@ -325,27 +325,27 @@  discard block
 block discarded – undo
325 325
 		date_default_timezone_set("UTC");
326 326
 		$Common = new Common();
327 327
 		if (isset($globalIVAO) && $globalIVAO) {
328
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
329
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
328
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
329
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
330 330
 		} else {
331
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
332
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
331
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
332
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
333 333
 		}
334 334
 		if ($handle) {
335 335
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
336 336
 			$date = '';
337 337
 			if ($globalTransaction) $this->db->beginTransaction();
338
-			while(($line = fgets($handle,4096)) !== false) {
339
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
338
+			while (($line = fgets($handle, 4096)) !== false) {
339
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
340 340
 					$date = $line;
341 341
 				} elseif ($line != '') {
342 342
 					if ($date == '') $date = date('Y/m/d H:m');
343 343
 					$pos = 0;
344
-					$pieces = preg_split('/\s/',$line);
344
+					$pieces = preg_split('/\s/', $line);
345 345
 					if ($pieces[0] == 'METAR') $pos++;
346 346
 					if (strlen($pieces[$pos]) != 4) $pos++;
347 347
 					$location = $pieces[$pos];
348
-					echo $this->addMETAR($location,$line,$date);
348
+					echo $this->addMETAR($location, $line, $date);
349 349
 				}
350 350
 			}
351 351
 			fclose($handle);
@@ -359,22 +359,22 @@  discard block
 block discarded – undo
359 359
 		if ($globalMETARurl == '') return array();
360 360
 		date_default_timezone_set("UTC");
361 361
 		$Common = new Common();
362
-		$url = str_replace('{icao}',$icao,$globalMETARurl);
362
+		$url = str_replace('{icao}', $icao, $globalMETARurl);
363 363
 		$cycle = $Common->getData($url);
364 364
 		$date = '';
365
-		foreach(explode("\n",$cycle) as $line) {
366
-			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
365
+		foreach (explode("\n", $cycle) as $line) {
366
+			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
367 367
 				$date = $line;
368 368
 			} 
369 369
 			if ($line != '') {
370 370
 				if ($date == '') $date = date('Y/m/d H:m');
371 371
 				$pos = 0;
372
-				$pieces = preg_split('/\s/',$line);
372
+				$pieces = preg_split('/\s/', $line);
373 373
 				if ($pieces[0] == 'METAR') $pos++;
374 374
 				if (strlen($pieces[$pos]) != 4) $pos++;
375 375
 				$location = $pieces[$pos];
376 376
 				if (strlen($location == 4)) {
377
-					$this->addMETAR($location,$line,$date);
377
+					$this->addMETAR($location, $line, $date);
378 378
 					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
379 379
 				} else return array();
380 380
 			}
Please login to merge, or discard this patch.