Completed
Push — master ( eb2be6...314f84 )
by Yannick
33:50
created
install/class.update_db.php 1 patch
Spacing   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		$ch = curl_init();
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
19
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
19
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
20 20
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
21 21
 			}
22 22
 		}
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
 		fclose($fp);
35 35
 	}
36 36
 
37
-	public static function gunzip($in_file,$out_file_name = '') {
37
+	public static function gunzip($in_file, $out_file_name = '') {
38 38
 		//echo $in_file.' -> '.$out_file_name."\n";
39 39
 		$buffer_size = 4096; // read 4kb at a time
40 40
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
41 41
 		if ($in_file != '' && file_exists($in_file)) {
42 42
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
43
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
44
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
45 45
 			else {
46 46
 				echo 'gzopen not available';
47 47
 				die;
48 48
 			}
49 49
 			$out_file = fopen($out_file_name, 'wb'); 
50
-			while(!gzeof($file)) {
50
+			while (!gzeof($file)) {
51 51
 				fwrite($out_file, gzread($file, $buffer_size));
52 52
 			}  
53 53
 			fclose($out_file);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		try {
72 72
 			self::$db_sqlite = new PDO('sqlite:'.$database);
73 73
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
74
-		} catch(PDOException $e) {
74
+		} catch (PDOException $e) {
75 75
 			return "error : ".$e->getMessage();
76 76
 		}
77 77
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88 88
                         $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
89
+                } catch (PDOException $e) {
90 90
                         return "error : ".$e->getMessage();
91 91
                 }
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		try {
98 98
                         $sth = update_db::$db_sqlite->prepare($query);
99 99
                         $sth->execute();
100
-                } catch(PDOException $e) {
100
+                } catch (PDOException $e) {
101 101
                         return "error : ".$e->getMessage();
102 102
                 }
103 103
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109 109
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
112 112
 				$sth_dest->execute($query_dest_values);
113 113
             		}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115
-		} catch(PDOException $e) {
115
+		} catch (PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
@@ -128,26 +128,26 @@  discard block
 block discarded – undo
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130 130
                         $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
131
+                } catch (PDOException $e) {
132 132
                         return "error : ".$e->getMessage();
133 133
                 }
134 134
 
135 135
     		if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138
-		if ($fh = fopen($database_file,"r")) {
138
+		if ($fh = fopen($database_file, "r")) {
139 139
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
140 140
 			$Connection = new Connection();
141 141
 			$sth_dest = $Connection->db->prepare($query_dest);
142 142
 			if ($globalTransaction) $Connection->db->beginTransaction();
143 143
 			while (!feof($fh)) {
144
-				$line = fgetcsv($fh,9999,',');
144
+				$line = fgetcsv($fh, 9999, ',');
145 145
 				if ($line[0] != '') {
146 146
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
147 147
 						try {
148
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
148
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
149 149
 							$sth_dest->execute($query_dest_values);
150
-						} catch(PDOException $e) {
150
+						} catch (PDOException $e) {
151 151
 							if ($globalTransaction) $Connection->db->rollBack(); 
152 152
 							return "error : ".$e->getMessage();
153 153
 						}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171 171
                         $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
172
+                } catch (PDOException $e) {
173 173
                         return "error : ".$e->getMessage();
174 174
                 }
175 175
 
@@ -177,24 +177,24 @@  discard block
 block discarded – undo
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
180
-		if ($fh = fopen($database_file,"r")) {
180
+		if ($fh = fopen($database_file, "r")) {
181 181
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
182 182
 			$Connection = new Connection();
183 183
 			$sth_dest = $Connection->db->prepare($query_dest);
184 184
 			try {
185 185
 				if ($globalTransaction) $Connection->db->beginTransaction();
186 186
 				while (!feof($fh)) {
187
-					$line = fgetcsv($fh,9999,',');
187
+					$line = fgetcsv($fh, 9999, ',');
188 188
 					if ($line[0] != '') {
189
-						$datebe = explode('  -  ',$line[2]);
189
+						$datebe = explode('  -  ', $line[2]);
190 190
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
191
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
191
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
192 192
 							$sth_dest->execute($query_dest_values);
193 193
 						}
194 194
 					}
195 195
 				}
196 196
 				if ($globalTransaction) $Connection->db->commit();
197
-			} catch(PDOException $e) {
197
+			} catch (PDOException $e) {
198 198
 				if ($globalTransaction) $Connection->db->rollBack(); 
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211 211
                         $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
212
+                } catch (PDOException $e) {
213 213
                         return "error : ".$e->getMessage();
214 214
                 }
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219 219
                         $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		try {
227 227
                         $sth = update_db::$db_sqlite->prepare($query);
228 228
                         $sth->execute();
229
-                } catch(PDOException $e) {
229
+                } catch (PDOException $e) {
230 230
                         return "error : ".$e->getMessage();
231 231
                 }
232 232
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
246
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
247 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
249
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
250 250
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252 252
             		}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254
-		} catch(PDOException $e) {
254
+		} catch (PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
256 256
 		}
257 257
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263 263
                         $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
264
+                } catch (PDOException $e) {
265 265
                         return "error : ".$e->getMessage();
266 266
                 }
267 267
 		return '';
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278 278
                         $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
279
+                } catch (PDOException $e) {
280 280
                         return "error : ".$e->getMessage();
281 281
                 }
282 282
 		
283
-		if ($fh = fopen($database_file,"r")) {
283
+		if ($fh = fopen($database_file, "r")) {
284 284
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
285 285
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
286 286
 		
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291 291
             			while (!feof($fh)) {
292 292
             				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
293
+            				$line = $Common->hex2str(fgets($fh, 9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
295
+            				$values['ModeS'] = substr($line, 0, 6);
296
+            				$values['Registration'] = trim(substr($line, 69, 6));
297
+            				$aircraft_name = trim(substr($line, 48, 6));
298 298
             				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
299
+            				$aircraft_name_split = explode(' ', $aircraft_name);
300 300
             				$search_more = '';
301 301
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302 302
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	            				if (isset($result['icao']) && $result['icao'] != '') {
309 309
 	            				    $values['ICAOTypeCode'] = $result['icao'];
310 310
 	            				} 
311
-					} catch(PDOException $e) {
311
+					} catch (PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
314 314
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
315 315
 					// Add data to db
316 316
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 317
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
318
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
318
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
319 319
 						//print_r($query_dest_values);
320 320
 						$sth_dest->execute($query_dest_values);
321 321
 					}
322 322
 				}
323 323
 				if ($globalTransaction) $Connection->db->commit();
324
-			} catch(PDOException $e) {
324
+			} catch (PDOException $e) {
325 325
 				return "error : ".$e->getMessage();
326 326
 			}
327 327
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333 333
                         $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
334
+                } catch (PDOException $e) {
335 335
                         return "error : ".$e->getMessage();
336 336
                 }
337 337
 		return '';
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347 347
                         $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
348
+                } catch (PDOException $e) {
349 349
                         return "error : ".$e->getMessage();
350 350
                 }
351 351
 		
352
-		if ($fh = fopen($database_file,"r")) {
352
+		if ($fh = fopen($database_file, "r")) {
353 353
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
354 354
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
355 355
 		
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 			$sth_dest = $Connection->db->prepare($query_dest);
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360
-				$tmp = fgetcsv($fh,9999,',',"'");
360
+				$tmp = fgetcsv($fh, 9999, ',', "'");
361 361
             			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
362
+            				$line = fgetcsv($fh, 9999, ',', "'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
             				$values['ICAOTypeCode'] = '';
369 369
             				$aircraft_name = $line[2];
370 370
             				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
371
+            				$aircraft_name_split = explode(' ', $aircraft_name);
372 372
             				$search_more = '';
373 373
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374 374
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -377,20 +377,20 @@  discard block
 block discarded – undo
377 377
                                     		$sth_search->execute();
378 378
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379 379
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380
-					} catch(PDOException $e) {
380
+					} catch (PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
383 383
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
384 384
 					// Add data to db
385 385
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
386 386
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
387
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
387
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
388 388
 						//print_r($query_dest_values);
389 389
 						$sth_dest->execute($query_dest_values);
390 390
 					}
391 391
 				}
392 392
 				if ($globalTransaction) $Connection->db->commit();
393
-			} catch(PDOException $e) {
393
+			} catch (PDOException $e) {
394 394
 				return "error : ".$e->getMessage();
395 395
 			}
396 396
 		}
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402 402
                         $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
403
+                } catch (PDOException $e) {
404 404
                         return "error : ".$e->getMessage();
405 405
                 }
406 406
 		return '';
407 407
 	}
408 408
 
409
-	public static function retrieve_owner($database_file,$country = 'F') {
409
+	public static function retrieve_owner($database_file, $country = 'F') {
410 410
 		global $globalTransaction, $globalMasterSource;
411 411
 		//$query = 'TRUNCATE TABLE aircraft_modes';
412 412
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416 416
                         $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
417
+                } catch (PDOException $e) {
418 418
                         return "error : ".$e->getMessage();
419 419
                 }
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422
-		if ($fh = fopen($database_file,"r")) {
422
+		if ($fh = fopen($database_file, "r")) {
423 423
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425 425
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 			$sth_modes = $Connection->db->prepare($query_modes);
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432
-				$tmp = fgetcsv($fh,9999,',','"');
432
+				$tmp = fgetcsv($fh, 9999, ',', '"');
433 433
             			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
434
+            				$line = fgetcsv($fh, 9999, ',', '"');
435 435
             				$values = array();
436 436
             				//print_r($line);
437 437
             				if ($country == 'F') {
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             				    $values['base'] = $line[4];
440 440
             				    $values['owner'] = $line[5];
441 441
             				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
442
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
443 443
 					    $values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445 445
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             				    $values['base'] = $line[3];
448 448
             				    $values['owner'] = $line[2];
449 449
             				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
450
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
451 451
 					    $values['cancel'] = '';
452 452
 					    $values['modes'] = $line[7];
453 453
 					    $values['icao'] = $line[8];
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             				    $values['base'] = null;
468 468
             				    $values['owner'] = $line[5];
469 469
             				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
470
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
471 471
 					    $values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473 473
 					    // TODO : add modeS & reg to aircraft_modes
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
             				    $values['base'] = null;
476 476
             				    $values['owner'] = $line[12];
477 477
             				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
478
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
479 479
 
480 480
 					    $values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -495,28 +495,28 @@  discard block
 block discarded – undo
495 495
             				    $values['base'] = null;
496 496
             				    $values['owner'] = $line[8];
497 497
             				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
498
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
499 499
 					    $values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501 501
             				    $values['registration'] = $line[0];
502 502
             				    $values['base'] = null;
503 503
             				    $values['owner'] = $line[4];
504 504
             				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
505
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
506 506
 					    $values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508 508
             				    $values['registration'] = $line[0];
509 509
             				    $values['base'] = null;
510 510
             				    $values['owner'] = $line[4];
511 511
             				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
512
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
513 513
 					    $values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515 515
             				    $values['registration'] = $line[0];
516 516
             				    $values['base'] = null;
517 517
             				    $values['owner'] = $line[3];
518 518
             				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
519
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
520 520
 					    $values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522 522
             				    $values['registration'] = $line[0];
@@ -530,18 +530,18 @@  discard block
 block discarded – undo
530 530
             				    $values['registration'] = $line[0];
531 531
             				    $values['base'] = null;
532 532
             				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
533
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
534
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
535 535
 					    $values['modes'] = $line[4];
536 536
 					    $values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538 538
             				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
539
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
540 540
 					    $values['modes'] = $line[5];
541 541
 					    $values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543 543
             				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
544
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
545 545
 					    $values['modes'] = $line[4];
546 546
 					    $values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -552,17 +552,17 @@  discard block
 block discarded – undo
552 552
 					    $values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
555
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
556 556
 						$sth_dest->execute($query_dest_values);
557 557
 					}
558 558
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
559 559
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
560
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
560
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
561 561
 						$sth_modes->execute($query_modes_values);
562 562
 					}
563 563
 				}
564 564
 				if ($globalTransaction) $Connection->db->commit();
565
-			} catch(PDOException $e) {
565
+			} catch (PDOException $e) {
566 566
 				return "error : ".$e->getMessage();
567 567
 			}
568 568
 		}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		if ($globalTransaction) $Connection->db->beginTransaction();
701 701
   
702 702
 		$i = 0;
703
-		while($row = sparql_fetch_array($result))
703
+		while ($row = sparql_fetch_array($result))
704 704
 		{
705 705
 			if ($i >= 1) {
706 706
 			//print_r($row);
@@ -720,33 +720,33 @@  discard block
 block discarded – undo
720 720
 				$row['image'] = '';
721 721
 				$row['image_thumb'] = '';
722 722
 			} else {
723
-				$image = str_replace(' ','_',$row['image']);
723
+				$image = str_replace(' ', '_', $row['image']);
724 724
 				$digest = md5($image);
725
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
726
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
727
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
728
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
725
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
726
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
727
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
728
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
729 729
 			}
730 730
 			
731
-			$country = explode('-',$row['country']);
731
+			$country = explode('-', $row['country']);
732 732
 			$row['country'] = $country[0];
733 733
 			
734 734
 			$row['type'] = trim($row['type']);
735
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
735
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
736 736
 				$row['type'] = 'military';
737 737
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
738 738
 				$row['type'] = 'small_airport';
739 739
 			}
740 740
 			
741
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
742
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
741
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
742
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
743 743
 			//print_r($query_dest_values);
744 744
 			
745 745
 			if ($row['icao'] != '') {
746 746
 				try {
747 747
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
748 748
 					$sth->execute(array(':icao' => $row['icao']));
749
-				} catch(PDOException $e) {
749
+				} catch (PDOException $e) {
750 750
 					return "error : ".$e->getMessage();
751 751
 				}
752 752
 					if ($sth->fetchColumn() > 0) {
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
755 755
 						try {
756 756
 							$sth = $Connection->db->prepare($query);
757
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
758
-						} catch(PDOException $e) {
757
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
758
+						} catch (PDOException $e) {
759 759
 							return "error : ".$e->getMessage();
760 760
 						}
761 761
 						echo $row['icao'].' : '.$row['type']."\n";
762 762
 					} else {
763 763
 						try {
764 764
 							$sth_dest->execute($query_dest_values);
765
-						} catch(PDOException $e) {
765
+						} catch (PDOException $e) {
766 766
 							return "error : ".$e->getMessage();
767 767
 						}
768 768
 					}
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		echo "Download data from ourairports.com...\n";
814 814
 		$delimiter = ',';
815 815
 		$out_file = $tmp_dir.'airports.csv';
816
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
816
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
817 817
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
818 818
 		echo "Add data from ourairports.com...\n";
819 819
 
@@ -824,33 +824,33 @@  discard block
 block discarded – undo
824 824
 			//$Connection->db->beginTransaction();
825 825
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 826
 			{
827
-				if(!$header) $header = $row;
827
+				if (!$header) $header = $row;
828 828
 				else {
829 829
 					$data = array();
830 830
 					$data = array_combine($header, $row);
831 831
 					try {
832 832
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
833 833
 						$sth->execute(array(':icao' => $data['ident']));
834
-					} catch(PDOException $e) {
834
+					} catch (PDOException $e) {
835 835
 						return "error : ".$e->getMessage();
836 836
 					}
837 837
 					if ($sth->fetchColumn() > 0) {
838 838
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
839 839
 						try {
840 840
 							$sth = $Connection->db->prepare($query);
841
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
842
-						} catch(PDOException $e) {
841
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
842
+						} catch (PDOException $e) {
843 843
 							return "error : ".$e->getMessage();
844 844
 						}
845 845
 					} else {
846 846
 						if ($data['gps_code'] == $data['ident']) {
847 847
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
848 848
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
849
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
849
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
850 850
 						try {
851 851
 							$sth = $Connection->db->prepare($query);
852 852
 							$sth->execute($query_values);
853
-						} catch(PDOException $e) {
853
+						} catch (PDOException $e) {
854 854
 							return "error : ".$e->getMessage();
855 855
 						}
856 856
 						$i++;
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		
866 866
 		echo "Download data from another free database...\n";
867 867
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
868
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
869 869
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
870 870
 		update_db::unzip($out_file);
871 871
 		$header = NULL;
@@ -877,15 +877,15 @@  discard block
 block discarded – undo
877 877
 			//$Connection->db->beginTransaction();
878 878
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 879
 			{
880
-				if(!$header) $header = $row;
880
+				if (!$header) $header = $row;
881 881
 				else {
882 882
 					$data = $row;
883 883
 
884 884
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
885 885
 					try {
886 886
 						$sth = $Connection->db->prepare($query);
887
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
888
-					} catch(PDOException $e) {
887
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
888
+					} catch (PDOException $e) {
889 889
 						return "error : ".$e->getMessage();
890 890
 					}
891 891
 				}
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 		try {
900 900
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
901 901
 			$sth->execute();
902
-		} catch(PDOException $e) {
902
+		} catch (PDOException $e) {
903 903
 			return "error : ".$e->getMessage();
904 904
 		}
905 905
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
906 906
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
907 907
 			try {
908 908
 				$sth2 = $Connection->db->prepare($query2);
909
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
910
-			} catch(PDOException $e) {
909
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
910
+			} catch (PDOException $e) {
911 911
 				return "error : ".$e->getMessage();
912 912
 			}
913 913
 		}
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930 930
                         $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
931
+                } catch (PDOException $e) {
932 932
                         return "error : ".$e->getMessage();
933 933
                 }
934 934
 
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
946 946
 			{
947 947
 				$i++;
948
-				if($i > 12) {
948
+				if ($i > 12) {
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
                                                 //echo substr($operator, 0, 2)."\n";;
954 954
                                                 if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956
-							$operator = $airline_array[0]['icao'].substr($operator,2);
956
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
957 957
                                                 }
958 958
                                         }
959 959
 					
@@ -961,14 +961,14 @@  discard block
 block discarded – undo
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962 962
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963 963
                                                 if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
964
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
965 965
                                             	}
966 966
                                         }
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
970
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
-					} catch(PDOException $e) {
970
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
+					} catch (PDOException $e) {
972 972
 						return "error : ".$e->getMessage();
973 973
 					}
974 974
 				}
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 			$Connection = new Connection();
987 987
 			$sth = $Connection->db->prepare($query);
988 988
 			$sth->execute(array(':source' => 'website_fam'));
989
-		} catch(PDOException $e) {
989
+		} catch (PDOException $e) {
990 990
 			return "error : ".$e->getMessage();
991 991
 		}
992 992
 		//update_db::unzip($out_file);
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
1005 1005
 					try {
1006 1006
 						$sth = $Connection->db->prepare($query);
1007
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
-					} catch(PDOException $e) {
1007
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
+					} catch (PDOException $e) {
1009 1009
 						return "error : ".$e->getMessage();
1010 1010
 					}
1011 1011
 				}
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030 1030
                         $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1031
+                } catch (PDOException $e) {
1032 1032
                         return "error : ".$e->getMessage();
1033 1033
                 }
1034 1034
 
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039 1039
                         $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1040
+                } catch (PDOException $e) {
1041 1041
                         return "error : ".$e->getMessage();
1042 1042
                 }
1043 1043
 
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1055 1055
 					try {
1056 1056
 						$sths = $Connection->db->prepare($query_search);
1057
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1058
-					} catch(PDOException $e) {
1057
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1058
+					} catch (PDOException $e) {
1059 1059
 						return "error s : ".$e->getMessage();
1060 1060
 					}
1061 1061
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
 							//}
1069 1069
 						try {
1070 1070
 							$sthi = $Connection->db->prepare($queryi);
1071
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1072
-						} catch(PDOException $e) {
1071
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1072
+						} catch (PDOException $e) {
1073 1073
 							return "error u : ".$e->getMessage();
1074 1074
 						}
1075 1075
 					} else {
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 						try {
1078 1078
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1079 1079
 							$sthsm->execute(array(':mfr' => $data[2]));
1080
-						} catch(PDOException $e) {
1080
+						} catch (PDOException $e) {
1081 1081
 							return "error mfr : ".$e->getMessage();
1082 1082
 						}
1083 1083
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1088
 							try {
1089 1089
 								$sthf = $Connection->db->prepare($queryf);
1090
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1091
-							} catch(PDOException $e) {
1090
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1091
+							} catch (PDOException $e) {
1092 1092
 								return "error f : ".$e->getMessage();
1093 1093
 							}
1094 1094
 						}
@@ -1098,13 +1098,13 @@  discard block
 block discarded – undo
1098 1098
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1099
 						try {
1100 1100
 							$sth = $Connection->db->prepare($query);
1101
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1102
-						} catch(PDOException $e) {
1101
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1102
+						} catch (PDOException $e) {
1103 1103
 							return "error i : ".$e->getMessage();
1104 1104
 						}
1105 1105
 					}
1106 1106
 				}
1107
-				if ($i % 90 == 0) {
1107
+				if ($i%90 == 0) {
1108 1108
 					if ($globalTransaction) $Connection->db->commit();
1109 1109
 					if ($globalTransaction) $Connection->db->beginTransaction();
1110 1110
 				}
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			$Connection = new Connection();
1124 1124
 			$sth = $Connection->db->prepare($query);
1125 1125
 			$sth->execute(array(':source' => 'website_fam'));
1126
-		} catch(PDOException $e) {
1126
+		} catch (PDOException $e) {
1127 1127
 			return "error : ".$e->getMessage();
1128 1128
 		}
1129 1129
 		$delimiter = "\t";
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1140
 					try {
1141 1141
 						$sth = $Connection->db->prepare($query);
1142
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1143
-					} catch(PDOException $e) {
1142
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1143
+					} catch (PDOException $e) {
1144 1144
 						return "error : ".$e->getMessage();
1145 1145
 					}
1146 1146
 				}
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
 		try {
1173 1173
 			$sth = $Connection->db->prepare($query);
1174 1174
 			$sth->execute();
1175
-		} catch(PDOException $e) {
1175
+		} catch (PDOException $e) {
1176 1176
 			return "error : ".$e->getMessage();
1177 1177
 		}
1178 1178
 		$delimiter = "\t";
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1188
 					try {
1189 1189
 						$sth = $Connection->db->prepare($query);
1190
-						$sth->execute(array(':name' => $data[0],':alias' => $data[1],':iata' => $data[2],':icao' => $data[3], ':callsign' => $data[4],':country' => $data[5],':active' => $data[6],':type' => $data[7],':home' => $data[8],':wikipedia_link' => $data[9],':alliance' => $data[10],':ban_eu' => $data[11]));
1191
-					} catch(PDOException $e) {
1190
+						$sth->execute(array(':name' => $data[0], ':alias' => $data[1], ':iata' => $data[2], ':icao' => $data[3], ':callsign' => $data[4], ':country' => $data[5], ':active' => $data[6], ':type' => $data[7], ':home' => $data[8], ':wikipedia_link' => $data[9], ':alliance' => $data[10], ':ban_eu' => $data[11]));
1191
+					} catch (PDOException $e) {
1192 1192
 						return "error : ".$e->getMessage();
1193 1193
 					}
1194 1194
 				}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 			$Connection = new Connection();
1217 1217
 			$sth = $Connection->db->prepare($query);
1218 1218
                         $sth->execute(array(':source' => 'website_fam'));
1219
-                } catch(PDOException $e) {
1219
+                } catch (PDOException $e) {
1220 1220
                         return "error : ".$e->getMessage();
1221 1221
                 }
1222 1222
 
@@ -1232,8 +1232,8 @@  discard block
 block discarded – undo
1232 1232
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1233 1233
 					try {
1234 1234
 						$sth = $Connection->db->prepare($query);
1235
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1236
-					} catch(PDOException $e) {
1235
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1236
+					} catch (PDOException $e) {
1237 1237
 						//print_r($data);
1238 1238
 						return "error : ".$e->getMessage();
1239 1239
 					}
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 			$Connection = new Connection();
1254 1254
 			$sth = $Connection->db->prepare($query);
1255 1255
 			$sth->execute(array(':source' => 'website_fam'));
1256
-		} catch(PDOException $e) {
1256
+		} catch (PDOException $e) {
1257 1257
 			return "error : ".$e->getMessage();
1258 1258
 		}
1259 1259
 		$delimiter = "\t";
@@ -1269,13 +1269,13 @@  discard block
 block discarded – undo
1269 1269
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1270 1270
 					try {
1271 1271
 						$sth = $Connection->db->prepare($query);
1272
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1273
-					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1272
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1273
+					} catch (PDOException $e) {
1274
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1275 1275
 						die();
1276 1276
 					}
1277 1277
 				}
1278
-				if ($globalTransaction && $i % 2000 == 0) {
1278
+				if ($globalTransaction && $i%2000 == 0) {
1279 1279
 					$Connection->db->commit();
1280 1280
 					if ($globalDebug) echo '.';
1281 1281
 					$Connection->db->beginTransaction();
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 			$Connection = new Connection();
1296 1296
 			$sth = $Connection->db->prepare($query);
1297 1297
                         $sth->execute();
1298
-                } catch(PDOException $e) {
1298
+                } catch (PDOException $e) {
1299 1299
                         return "error : ".$e->getMessage();
1300 1300
                 }
1301 1301
 
@@ -1316,8 +1316,8 @@  discard block
 block discarded – undo
1316 1316
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1317 1317
 					try {
1318 1318
 						$sth = $Connection->db->prepare($query);
1319
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1320
-					} catch(PDOException $e) {
1319
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1320
+					} catch (PDOException $e) {
1321 1321
 						return "error : ".$e->getMessage();
1322 1322
 					}
1323 1323
 				}
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
 			$Connection = new Connection();
1337 1337
 			$sth = $Connection->db->prepare($query);
1338 1338
 			$sth->execute();
1339
-		} catch(PDOException $e) {
1339
+		} catch (PDOException $e) {
1340 1340
 			return "error : ".$e->getMessage();
1341 1341
 		}
1342 1342
 		$delimiter = "\t";
@@ -1353,8 +1353,8 @@  discard block
 block discarded – undo
1353 1353
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1354 1354
 					try {
1355 1355
 						$sth = $Connection->db->prepare($query);
1356
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1357
-					} catch(PDOException $e) {
1356
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1357
+					} catch (PDOException $e) {
1358 1358
 						return "error : ".$e->getMessage();
1359 1359
 					}
1360 1360
 				}
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 			$Connection = new Connection();
1374 1374
 			$sth = $Connection->db->prepare($query);
1375 1375
 			$sth->execute();
1376
-		} catch(PDOException $e) {
1376
+		} catch (PDOException $e) {
1377 1377
 			return "error : ".$e->getMessage();
1378 1378
 		}
1379 1379
 
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
 					try {
1390 1390
 						$sth = $Connection->db->prepare($query);
1391 1391
 						$sth->execute(array(':icao' => $icao));
1392
-					} catch(PDOException $e) {
1392
+					} catch (PDOException $e) {
1393 1393
 						return "error : ".$e->getMessage();
1394 1394
 					}
1395 1395
 				}
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		return '';
1401 1401
         }
1402 1402
 
1403
-	public static function tle($filename,$tletype) {
1403
+	public static function tle($filename, $tletype) {
1404 1404
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1405 1405
 		global $tmp_dir, $globalTransaction;
1406 1406
 		//$Spotter = new Spotter();
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 			$Connection = new Connection();
1411 1411
 			$sth = $Connection->db->prepare($query);
1412 1412
                         $sth->execute(array(':source' => $filename));
1413
-                } catch(PDOException $e) {
1413
+                } catch (PDOException $e) {
1414 1414
                         return "error : ".$e->getMessage();
1415 1415
                 }
1416 1416
 		
@@ -1435,8 +1435,8 @@  discard block
 block discarded – undo
1435 1435
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1436 1436
 					try {
1437 1437
 						$sth = $Connection->db->prepare($query);
1438
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1439
-					} catch(PDOException $e) {
1438
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1439
+					} catch (PDOException $e) {
1440 1440
 						return "error : ".$e->getMessage();
1441 1441
 					}
1442 1442
 
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 			$Connection = new Connection();
1457 1457
 			$sth = $Connection->db->prepare($query);
1458 1458
 			$sth->execute(array(':source' => $filename));
1459
-		} catch(PDOException $e) {
1459
+		} catch (PDOException $e) {
1460 1460
 			return "error : ".$e->getMessage();
1461 1461
 		}
1462 1462
 		
@@ -1466,13 +1466,13 @@  discard block
 block discarded – undo
1466 1466
 			$i = 0;
1467 1467
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1468 1468
 			//$Connection->db->beginTransaction();
1469
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1469
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1470 1470
 			{
1471 1471
 				if ($i > 0 && $data[0] != '') {
1472 1472
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1473
-					$period = str_replace(',','',$data[14]);
1474
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1475
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1473
+					$period = str_replace(',', '', $data[14]);
1474
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1475
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1476 1476
 					else $launch_date = NULL;
1477 1477
 					$data = array_map(function($value) {
1478 1478
 						return trim($value) === '' ? null : $value;
@@ -1482,8 +1482,8 @@  discard block
 block discarded – undo
1482 1482
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1483 1483
 					try {
1484 1484
 						$sth = $Connection->db->prepare($query);
1485
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',','',$data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',','',$data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+',','),'',$data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',','-1900',' (BOL)',' (EOL)'),'',$data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',',' (BOL)',' (EOL)'),'',$data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20],':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1486
-					} catch(PDOException $e) {
1485
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',', '', $data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',', '', $data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+', ','), '', $data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',', '-1900', ' (BOL)', ' (EOL)'), '', $data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',', ' (BOL)', ' (EOL)'), '', $data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20], ':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1486
+					} catch (PDOException $e) {
1487 1487
 						return "error : ".$e->getMessage();
1488 1488
 					}
1489 1489
 				}
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1524 1524
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1525 1525
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1526
-			'EST' => array('country' => 'Estonia','owner' => ''),
1526
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1527 1527
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1528 1528
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1529 1529
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1647,10 +1647,10 @@  discard block
 block discarded – undo
1647 1647
 			{
1648 1648
 				if ($data != '') {
1649 1649
 				$result = array();
1650
-				$result['cospar'] = trim(substr($data,0,11));
1651
-				$result['norad'] = trim(substr($data,13,6));
1652
-				$result['operational'] = trim(substr($data,21,1));
1653
-				$result['name'] = trim(substr($data,23,24));
1650
+				$result['cospar'] = trim(substr($data, 0, 11));
1651
+				$result['norad'] = trim(substr($data, 13, 6));
1652
+				$result['operational'] = trim(substr($data, 21, 1));
1653
+				$result['name'] = trim(substr($data, 23, 24));
1654 1654
 				/*
1655 1655
 				    * R/B(1) = Rocket body, first stage
1656 1656
 				    * R/B(2) = Rocket body, second stage
@@ -1662,29 +1662,29 @@  discard block
 block discarded – undo
1662 1662
 				    * An ampersand (&) indicates two or more objects are attached
1663 1663
 				*/
1664 1664
 				
1665
-				$owner_code = trim(substr($data,49,5));
1665
+				$owner_code = trim(substr($data, 49, 5));
1666 1666
 				
1667 1667
 				if (!isset($satcat_sources[$owner_code])) {
1668 1668
 					echo $data;
1669 1669
 					echo 'owner_code: '.$owner_code."\n";
1670 1670
 				}
1671
-				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1672
-					echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1671
+				if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1672
+					echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n";
1673 1673
 				}
1674 1674
 				
1675
-				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
1675
+				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1676 1676
 					$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1677 1677
 					$result['owner'] = $satcat_sources[$owner_code]['owner'];
1678
-					$result['launch_date'] = trim(substr($data,56,10));
1679
-					$launch_site_code = trim(substr($data,68,5));
1678
+					$result['launch_date'] = trim(substr($data, 56, 10));
1679
+					$launch_site_code = trim(substr($data, 68, 5));
1680 1680
 					$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1681
-					$result['lifetime'] = trim(substr($data,75,10));
1682
-					$result['period'] = trim(substr($data,87,7));
1683
-					$result['inclination'] = trim(substr($data,96,5));
1684
-					$result['apogee'] = trim(substr($data,103,6));
1685
-					$result['perigee'] = trim(substr($data,111,6));
1681
+					$result['lifetime'] = trim(substr($data, 75, 10));
1682
+					$result['period'] = trim(substr($data, 87, 7));
1683
+					$result['inclination'] = trim(substr($data, 96, 5));
1684
+					$result['apogee'] = trim(substr($data, 103, 6));
1685
+					$result['perigee'] = trim(substr($data, 111, 6));
1686 1686
 					//$result['radarcross'] = trim(substr($data,119,8));
1687
-					$result['status'] = trim(substr($data,129,3));
1687
+					$result['status'] = trim(substr($data, 129, 3));
1688 1688
 					//print_r($result);
1689 1689
 					$result = array_map(function($value) {
1690 1690
 						return trim($value) === '' ? null : $value;
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
 							$sth = $Connection->db->prepare($query);
1698 1698
 							$sth->execute(array(':cospar' => $result['cospar']));
1699 1699
 							$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1700
-						} catch(PDOException $e) {
1700
+						} catch (PDOException $e) {
1701 1701
 							return "error : ".$e->getMessage();
1702 1702
 						}
1703 1703
 						if (empty($exist)) {
@@ -1709,10 +1709,10 @@  discard block
 block discarded – undo
1709 1709
 								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710 1710
 								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711 1711
 								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1712
+								    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713 1713
 								    )
1714 1714
 								);
1715
-							} catch(PDOException $e) {
1715
+							} catch (PDOException $e) {
1716 1716
 								return "error : ".$e->getMessage();
1717 1717
 							}
1718 1718
 						} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1720,8 +1720,8 @@  discard block
 block discarded – undo
1720 1720
 							try {
1721 1721
 								$Connection = new Connection();
1722 1722
 								$sth = $Connection->db->prepare($query);
1723
-								$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1724
-							} catch(PDOException $e) {
1723
+								$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1724
+							} catch (PDOException $e) {
1725 1725
 								return "error : ".$e->getMessage();
1726 1726
 							}
1727 1727
 						}
@@ -1840,13 +1840,13 @@  discard block
 block discarded – undo
1840 1840
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1841 1841
 			{
1842 1842
 				$i++;
1843
-				if($i > 3 && count($row) > 2) {
1843
+				if ($i > 3 && count($row) > 2) {
1844 1844
 					$data = array_values(array_filter($row));
1845 1845
 					$cntdata = count($data);
1846 1846
 					if ($cntdata > 10) {
1847 1847
 						$value = $data[9];
1848 1848
 						
1849
-						for ($i =10;$i < $cntdata;$i++) {
1849
+						for ($i = 10; $i < $cntdata; $i++) {
1850 1850
 							$value .= ' '.$data[$i];
1851 1851
 						}
1852 1852
 						$data[9] = $value;
@@ -1856,8 +1856,8 @@  discard block
 block discarded – undo
1856 1856
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1857 1857
 						try {
1858 1858
 							$sth = $Connection->db->prepare($query);
1859
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1860
-						} catch(PDOException $e) {
1859
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1860
+						} catch (PDOException $e) {
1861 1861
 							return "error : ".$e->getMessage();
1862 1862
 						}
1863 1863
 					}
@@ -1874,16 +1874,16 @@  discard block
 block discarded – undo
1874 1874
 		require_once(dirname(__FILE__).'/../require/class.Source.php');
1875 1875
 		$delimiter = ',';
1876 1876
 		$Common = new Common();
1877
-		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv');
1877
+		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv');
1878 1878
 		$Connection = new Connection();
1879 1879
 		$Source = new Source();
1880 1880
 		$Source->deleteLocationByType('fires');
1881 1881
 		$i = 0;
1882
-		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1883
-			while (($row = fgetcsv($handle,1000)) !== false) {
1882
+		if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) {
1883
+			while (($row = fgetcsv($handle, 1000)) !== false) {
1884 1884
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1885
-					$description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]);
1886
-					$Source->addLocation('',$row[0],$row[1],null,'','','fires','fire.png','fires',0,0,$row[5].' '.substr($row[6],0,2).':'.substr($row[6],2,2),json_encode($description));
1885
+					$description = array('bright_t14' => $row[2], 'scan' => $row[3], 'track' => $row[4], 'sat' => $row[7], 'confidence' => $row[8], 'version' => $row[9], 'bright_t15' => $row[10], 'frp' => $row[11], 'daynight' => $row[12]);
1886
+					$Source->addLocation('', $row[0], $row[1], null, '', '', 'fires', 'fire.png', 'fires', 0, 0, $row[5].' '.substr($row[6], 0, 2).':'.substr($row[6], 2, 2), json_encode($description));
1887 1887
 				}
1888 1888
 				$i++;
1889 1889
 			}
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
 			$Connection = new Connection();
1900 1900
 			$sth = $Connection->db->prepare($query);
1901 1901
 			$sth->execute();
1902
-		} catch(PDOException $e) {
1902
+		} catch (PDOException $e) {
1903 1903
 			return "error : ".$e->getMessage();
1904 1904
 		}
1905 1905
 		$header = NULL;
@@ -1910,12 +1910,12 @@  discard block
 block discarded – undo
1910 1910
 			if ($globalTransaction) $Connection->db->beginTransaction();
1911 1911
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1912 1912
 			{
1913
-				if(count($row) > 1) {
1913
+				if (count($row) > 1) {
1914 1914
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1915 1915
 					try {
1916 1916
 						$sth = $Connection->db->prepare($query);
1917
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1918
-					} catch(PDOException $e) {
1917
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1918
+					} catch (PDOException $e) {
1919 1919
 						return "error : ".$e->getMessage();
1920 1920
 					}
1921 1921
 				}
@@ -1935,21 +1935,21 @@  discard block
 block discarded – undo
1935 1935
 			try {
1936 1936
 				$sth = $Connection->db->prepare($query);
1937 1937
                     		$sth->execute();
1938
-	                } catch(PDOException $e) {
1938
+	                } catch (PDOException $e) {
1939 1939
 				return "error : ".$e->getMessage();
1940 1940
 	                }
1941 1941
 	        }
1942 1942
 
1943 1943
 
1944
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1944
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1945 1945
 		else {
1946
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1946
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1947 1947
 			$query = "CREATE EXTENSION postgis";
1948
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1948
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1949 1949
 			try {
1950 1950
 				$sth = $Connection->db->prepare($query);
1951 1951
 				$sth->execute();
1952
-			} catch(PDOException $e) {
1952
+			} catch (PDOException $e) {
1953 1953
 				return "error : ".$e->getMessage();
1954 1954
 			}
1955 1955
 		}
@@ -1962,13 +1962,13 @@  discard block
 block discarded – undo
1962 1962
 		include_once('class.create_db.php');
1963 1963
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1964 1964
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1965
-		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1965
+		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5');
1966 1966
 		$error = '';
1967 1967
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
1968
-			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1968
+			$notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1969 1969
 			$notam_md5 = $notam_md5_file[0];
1970 1970
 			if (!update_db::check_notam_version($notam_md5)) {
1971
-				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1971
+				update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1972 1972
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
1973 1973
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1974 1974
 						if ($globalDebug) echo "Gunzip...";
@@ -2004,14 +2004,14 @@  discard block
 block discarded – undo
2004 2004
 			try {
2005 2005
 				$sth = $Connection->db->prepare($query);
2006 2006
             	        	$sth->execute();
2007
-	                } catch(PDOException $e) {
2007
+	                } catch (PDOException $e) {
2008 2008
     	                	echo "error : ".$e->getMessage();
2009 2009
 	                }
2010 2010
 		}
2011 2011
 		if ($globalDBdriver == 'mysql') {
2012
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
2012
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
2013 2013
 		} else {
2014
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
2014
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
2015 2015
 		}
2016 2016
 		$error = create_db::import_file($tmp_dir.'countries.sql');
2017 2017
 		return $error;
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
 //		update_db::unzip($tmp_dir.'AptNav.zip');
2025 2025
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
2026 2026
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
2027
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
2027
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
2028 2028
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
2029 2029
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
2030 2030
 		return $error;
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2046 2046
 				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2047 2047
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2048
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2048
+					if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2049 2049
 				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2050 2050
 			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2051 2051
 		} else $error = "ZIP module not loaded but required for IVAO.";
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
 		global $tmp_dir, $globalDebug;
2060 2060
 		$error = '';
2061 2061
 		if ($globalDebug) echo "Routes : Download...";
2062
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2062
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
2063 2063
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2064 2064
 			if ($globalDebug) echo "Gunzip...";
2065 2065
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -2075,7 +2075,7 @@  discard block
 block discarded – undo
2075 2075
 		global $tmp_dir, $globalDebug;
2076 2076
 		$error = '';
2077 2077
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
2078
-		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2078
+		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
2079 2079
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2080 2080
 			if ($globalDebug) echo "Gunzip...";
2081 2081
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
 		global $tmp_dir, $globalDebug;
2092 2092
 		$error = '';
2093 2093
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
2094
-		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2094
+		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
2095 2095
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2096 2096
 			if ($globalDebug) echo "Gunzip...";
2097 2097
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
 */
2120 2120
 		if ($globalDebug) echo "Modes : Download...";
2121 2121
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2122
-		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2122
+		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2123 2123
 
2124 2124
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2125 2125
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
 	public static function update_ModeS_faa() {
2140 2140
 		global $tmp_dir, $globalDebug;
2141 2141
 		if ($globalDebug) echo "Modes FAA: Download...";
2142
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2142
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2143 2143
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2144 2144
 			if ($globalDebug) echo "Unzip...";
2145 2145
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
 	public static function update_ModeS_flarm() {
2156 2156
 		global $tmp_dir, $globalDebug;
2157 2157
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2158
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2158
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2159 2159
 		if (file_exists($tmp_dir.'data.fln')) {
2160 2160
 			if ($globalDebug) echo "Add to DB...";
2161 2161
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2169,7 +2169,7 @@  discard block
 block discarded – undo
2169 2169
 	public static function update_ModeS_ogn() {
2170 2170
 		global $tmp_dir, $globalDebug;
2171 2171
 		if ($globalDebug) echo "Modes OGN: Download...";
2172
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2172
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2173 2173
 		if (file_exists($tmp_dir.'ogn.csv')) {
2174 2174
 			if ($globalDebug) echo "Add to DB...";
2175 2175
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2184,201 +2184,201 @@  discard block
 block discarded – undo
2184 2184
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2185 2185
 		
2186 2186
 		if ($globalDebug) echo "Owner France: Download...";
2187
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2187
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2188 2188
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2189 2189
 			if ($globalDebug) echo "Add to DB...";
2190
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2190
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2191 2191
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2192 2192
 		if ($error != '') {
2193 2193
 			return $error;
2194 2194
 		} elseif ($globalDebug) echo "Done\n";
2195 2195
 		
2196 2196
 		if ($globalDebug) echo "Owner Ireland: Download...";
2197
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2197
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2198 2198
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2199 2199
 			if ($globalDebug) echo "Add to DB...";
2200
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2200
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2201 2201
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2202 2202
 		if ($error != '') {
2203 2203
 			return $error;
2204 2204
 		} elseif ($globalDebug) echo "Done\n";
2205 2205
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2206
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2206
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2207 2207
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2208 2208
 			if ($globalDebug) echo "Add to DB...";
2209
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2209
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2210 2210
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2211 2211
 		if ($error != '') {
2212 2212
 			return $error;
2213 2213
 		} elseif ($globalDebug) echo "Done\n";
2214 2214
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2215
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2215
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2216 2216
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2217 2217
 			if ($globalDebug) echo "Add to DB...";
2218
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2218
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2219 2219
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2220 2220
 		if ($error != '') {
2221 2221
 			return $error;
2222 2222
 		} elseif ($globalDebug) echo "Done\n";
2223 2223
 		if ($globalDebug) echo "Owner Australia: Download...";
2224
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2224
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2225 2225
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2226 2226
 			if ($globalDebug) echo "Add to DB...";
2227
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2227
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2228 2228
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2229 2229
 		if ($error != '') {
2230 2230
 			return $error;
2231 2231
 		} elseif ($globalDebug) echo "Done\n";
2232 2232
 		if ($globalDebug) echo "Owner Austria: Download...";
2233
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2233
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2234 2234
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2235 2235
 			if ($globalDebug) echo "Add to DB...";
2236
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2236
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2237 2237
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2238 2238
 		if ($error != '') {
2239 2239
 			return $error;
2240 2240
 		} elseif ($globalDebug) echo "Done\n";
2241 2241
 		if ($globalDebug) echo "Owner Chile: Download...";
2242
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2242
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2243 2243
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2244 2244
 			if ($globalDebug) echo "Add to DB...";
2245
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2245
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2246 2246
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2247 2247
 		if ($error != '') {
2248 2248
 			return $error;
2249 2249
 		} elseif ($globalDebug) echo "Done\n";
2250 2250
 		if ($globalDebug) echo "Owner Colombia: Download...";
2251
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2251
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2252 2252
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2253 2253
 			if ($globalDebug) echo "Add to DB...";
2254
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2254
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2255 2255
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2256 2256
 		if ($error != '') {
2257 2257
 			return $error;
2258 2258
 		} elseif ($globalDebug) echo "Done\n";
2259 2259
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2260
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2260
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2261 2261
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2262 2262
 			if ($globalDebug) echo "Add to DB...";
2263
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2263
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2264 2264
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2265 2265
 		if ($error != '') {
2266 2266
 			return $error;
2267 2267
 		} elseif ($globalDebug) echo "Done\n";
2268 2268
 		if ($globalDebug) echo "Owner Brazil: Download...";
2269
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2269
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2270 2270
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2271 2271
 			if ($globalDebug) echo "Add to DB...";
2272
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2272
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2273 2273
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2274 2274
 		if ($error != '') {
2275 2275
 			return $error;
2276 2276
 		} elseif ($globalDebug) echo "Done\n";
2277 2277
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2278
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2278
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2279 2279
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2280 2280
 			if ($globalDebug) echo "Add to DB...";
2281
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2281
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2282 2282
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2283 2283
 		if ($error != '') {
2284 2284
 			return $error;
2285 2285
 		} elseif ($globalDebug) echo "Done\n";
2286 2286
 		if ($globalDebug) echo "Owner Croatia: Download...";
2287
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2287
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2288 2288
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2289 2289
 			if ($globalDebug) echo "Add to DB...";
2290
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2290
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2291 2291
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2292 2292
 		if ($error != '') {
2293 2293
 			return $error;
2294 2294
 		} elseif ($globalDebug) echo "Done\n";
2295 2295
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2296
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2296
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2297 2297
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2298 2298
 			if ($globalDebug) echo "Add to DB...";
2299
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2299
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2300 2300
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2301 2301
 		if ($error != '') {
2302 2302
 			return $error;
2303 2303
 		} elseif ($globalDebug) echo "Done\n";
2304 2304
 		if ($globalDebug) echo "Owner Maldives: Download...";
2305
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2305
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2306 2306
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2307 2307
 			if ($globalDebug) echo "Add to DB...";
2308
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2308
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2309 2309
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2310 2310
 		if ($error != '') {
2311 2311
 			return $error;
2312 2312
 		} elseif ($globalDebug) echo "Done\n";
2313 2313
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2314
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2314
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2315 2315
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2316 2316
 			if ($globalDebug) echo "Add to DB...";
2317
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2317
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2318 2318
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2319 2319
 		if ($error != '') {
2320 2320
 			return $error;
2321 2321
 		} elseif ($globalDebug) echo "Done\n";
2322 2322
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2323
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2323
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2324 2324
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2325 2325
 			if ($globalDebug) echo "Add to DB...";
2326
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2326
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2327 2327
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2328 2328
 		if ($error != '') {
2329 2329
 			return $error;
2330 2330
 		} elseif ($globalDebug) echo "Done\n";
2331 2331
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2332
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2332
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2333 2333
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2334 2334
 			if ($globalDebug) echo "Add to DB...";
2335
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2335
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2336 2336
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2337 2337
 		if ($error != '') {
2338 2338
 			return $error;
2339 2339
 		} elseif ($globalDebug) echo "Done\n";
2340 2340
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2341
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2341
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2342 2342
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2343 2343
 			if ($globalDebug) echo "Add to DB...";
2344
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2344
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2345 2345
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2346 2346
 		if ($error != '') {
2347 2347
 			return $error;
2348 2348
 		} elseif ($globalDebug) echo "Done\n";
2349 2349
 		if ($globalDebug) echo "Owner Iceland: Download...";
2350
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2350
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2351 2351
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2352 2352
 			if ($globalDebug) echo "Add to DB...";
2353
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2353
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2354 2354
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2355 2355
 		if ($error != '') {
2356 2356
 			return $error;
2357 2357
 		} elseif ($globalDebug) echo "Done\n";
2358 2358
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2359
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2359
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2360 2360
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2361 2361
 			if ($globalDebug) echo "Add to DB...";
2362
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2362
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2363 2363
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2364 2364
 		if ($error != '') {
2365 2365
 			return $error;
2366 2366
 		} elseif ($globalDebug) echo "Done\n";
2367 2367
 		if ($globalMasterSource) {
2368 2368
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2369
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2369
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2370 2370
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2371 2371
 				if ($globalDebug) echo "Add to DB...";
2372
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2372
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2373 2373
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2374 2374
 			if ($error != '') {
2375 2375
 				return $error;
2376 2376
 			} elseif ($globalDebug) echo "Done\n";
2377 2377
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2378
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2378
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2379 2379
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2380 2380
 				if ($globalDebug) echo "Add to DB...";
2381
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2381
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2382 2382
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2383 2383
 			if ($error != '') {
2384 2384
 				return $error;
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
 		global $tmp_dir, $globalDebug;
2392 2392
 		$error = '';
2393 2393
 		if ($globalDebug) echo "Translation : Download...";
2394
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2394
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2395 2395
 		if (file_exists($tmp_dir.'translation.zip')) {
2396 2396
 			if ($globalDebug) echo "Unzip...";
2397 2397
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2408,10 +2408,10 @@  discard block
 block discarded – undo
2408 2408
 		global $tmp_dir, $globalDebug;
2409 2409
 		$error = '';
2410 2410
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2411
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2412
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2411
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2412
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5');
2413 2413
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2414
-			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2414
+			$translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2415 2415
 			$translation_md5 = $translation_md5_file[0];
2416 2416
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2417 2417
 				if ($globalDebug) echo "Gunzip...";
@@ -2429,10 +2429,10 @@  discard block
 block discarded – undo
2429 2429
 		global $tmp_dir, $globalDebug;
2430 2430
 		$error = '';
2431 2431
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2432
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2433
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2432
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2433
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5');
2434 2434
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2435
-			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2435
+			$modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2436 2436
 			$modes_md5 = $modes_md5_file[0];
2437 2437
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2438 2438
 				if ($globalDebug) echo "Gunzip...";
@@ -2451,12 +2451,12 @@  discard block
 block discarded – undo
2451 2451
 		global $tmp_dir, $globalDebug;
2452 2452
 		$error = '';
2453 2453
 		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2454
-		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2454
+		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5');
2455 2455
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2456
-			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2456
+			$airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2457 2457
 			$airlines_md5 = $airlines_md5_file[0];
2458 2458
 			if (!update_db::check_airlines_version($airlines_md5)) {
2459
-				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2459
+				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz');
2460 2460
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2461 2461
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2462 2462
 						if ($globalDebug) echo "Gunzip...";
@@ -2481,14 +2481,14 @@  discard block
 block discarded – undo
2481 2481
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2482 2482
 		$error = '';
2483 2483
 		if ($globalOwner === TRUE) {
2484
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2485
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2484
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2485
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2486 2486
 		} else {
2487
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2488
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2487
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2488
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2489 2489
 		}
2490 2490
 		if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) {
2491
-			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2491
+			$owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2492 2492
 			$owners_md5 = $owners_md5_file[0];
2493 2493
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2494 2494
 				if ($globalDebug) echo "Gunzip...";
@@ -2505,10 +2505,10 @@  discard block
 block discarded – undo
2505 2505
 	public static function update_routes_fam() {
2506 2506
 		global $tmp_dir, $globalDebug;
2507 2507
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2508
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2509
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2508
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2509
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5');
2510 2510
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2511
-			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2511
+			$routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2512 2512
 			$routes_md5 = $routes_md5_file[0];
2513 2513
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2514 2514
 				if ($globalDebug) echo "Gunzip...";
@@ -2524,13 +2524,13 @@  discard block
 block discarded – undo
2524 2524
 	}
2525 2525
 	public static function update_marine_identity_fam() {
2526 2526
 		global $tmp_dir, $globalDebug;
2527
-		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2527
+		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2528 2528
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2529
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2529
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2530 2530
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2531 2531
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2532 2532
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2533
-				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2533
+				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2534 2534
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2535 2535
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2536 2536
 						if ($globalDebug) echo "Gunzip...";
@@ -2552,13 +2552,13 @@  discard block
 block discarded – undo
2552 2552
 
2553 2553
 	public static function update_satellite_fam() {
2554 2554
 		global $tmp_dir, $globalDebug;
2555
-		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2555
+		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2556 2556
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2557
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2557
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2558 2558
 			$satellite_md5 = $satellite_md5_file[0];
2559 2559
 			if (!update_db::check_satellite_version($satellite_md5)) {
2560 2560
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2561
-				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2561
+				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2562 2562
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2563 2563
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2564 2564
 						if ($globalDebug) echo "Gunzip...";
@@ -2580,7 +2580,7 @@  discard block
 block discarded – undo
2580 2580
 	public static function update_banned_fam() {
2581 2581
 		global $tmp_dir, $globalDebug;
2582 2582
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2583
-		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2583
+		update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2584 2584
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2585 2585
 			//if ($globalDebug) echo "Gunzip...";
2586 2586
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2599,18 +2599,18 @@  discard block
 block discarded – undo
2599 2599
 		$error = '';
2600 2600
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2601 2601
 		if ($globalDBdriver == 'mysql') {
2602
-			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2602
+			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2603 2603
 		} else {
2604
-			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2604
+			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2605 2605
 		}
2606 2606
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2607
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2607
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2608 2608
 			$airspace_md5 = $airspace_md5_file[0];
2609 2609
 			if (!update_db::check_airspace_version($airspace_md5)) {
2610 2610
 				if ($globalDBdriver == 'mysql') {
2611
-					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2611
+					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2612 2612
 				} else {
2613
-					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2613
+					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2614 2614
 				}
2615 2615
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2616 2616
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
@@ -2623,7 +2623,7 @@  discard block
 block discarded – undo
2623 2623
 							try {
2624 2624
 								$sth = $Connection->db->prepare($query);
2625 2625
 								$sth->execute();
2626
-							} catch(PDOException $e) {
2626
+							} catch (PDOException $e) {
2627 2627
 								return "error : ".$e->getMessage();
2628 2628
 							}
2629 2629
 						}
@@ -2643,16 +2643,16 @@  discard block
 block discarded – undo
2643 2643
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2644 2644
 		$error = '';
2645 2645
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2646
-		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2646
+		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2647 2647
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2648
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2648
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2649 2649
 			$geoid_md5 = $geoid_md5_file[0];
2650 2650
 			if (!update_db::check_geoid_version($geoid_md5)) {
2651
-				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2651
+				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2652 2652
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2653 2653
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2654 2654
 						if ($globalDebug) echo "Gunzip...";
2655
-						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2655
+						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2656 2656
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2657 2657
 							update_db::insert_geoid_version($geoid_md5);
2658 2658
 						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
@@ -2669,15 +2669,15 @@  discard block
 block discarded – undo
2669 2669
 	public static function update_tle() {
2670 2670
 		global $tmp_dir, $globalDebug;
2671 2671
 		if ($globalDebug) echo "Download TLE : Download...";
2672
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2673
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2674
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2672
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2673
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2674
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt', 'visual.txt', 'sarsat.txt', 'argos.txt', 'ses.txt', 'iridium-NEXT.txt', 'beidou.txt');
2675 2675
 		foreach ($alltle as $filename) {
2676 2676
 			if ($globalDebug) echo "downloading ".$filename.'...';
2677
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2677
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2678 2678
 			if (file_exists($tmp_dir.$filename)) {
2679 2679
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2680
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2680
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2681 2681
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2682 2682
 			if ($error != '') {
2683 2683
 				echo $error."\n";
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
 	public static function update_ucsdb() {
2690 2690
 		global $tmp_dir, $globalDebug;
2691 2691
 		if ($globalDebug) echo "Download UCS DB : Download...";
2692
-		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2692
+		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt', $tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2693 2693
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2694 2694
 			if ($globalDebug) echo "Add to DB...";
2695 2695
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
@@ -2703,7 +2703,7 @@  discard block
 block discarded – undo
2703 2703
 	public static function update_celestrak() {
2704 2704
 		global $tmp_dir, $globalDebug;
2705 2705
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2706
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2706
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2707 2707
 		if (file_exists($tmp_dir.'satcat.txt')) {
2708 2708
 			if ($globalDebug) echo "Add to DB...";
2709 2709
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2718,63 +2718,63 @@  discard block
 block discarded – undo
2718 2718
 		global $tmp_dir, $globalDebug;
2719 2719
 		$error = '';
2720 2720
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2721
-		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2721
+		update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2722 2722
 		if (file_exists($tmp_dir.'models.md5sum')) {
2723 2723
 			if ($globalDebug) echo "Check files...\n";
2724 2724
 			$newmodelsdb = array();
2725
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2726
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2725
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2726
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2727 2727
 					$model = trim($row[2]);
2728 2728
 					$newmodelsdb[$model] = trim($row[0]);
2729 2729
 				}
2730 2730
 			}
2731 2731
 			$modelsdb = array();
2732 2732
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2733
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2734
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2733
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2734
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2735 2735
 						$model = trim($row[2]);
2736 2736
 						$modelsdb[$model] = trim($row[0]);
2737 2737
 					}
2738 2738
 				}
2739 2739
 			}
2740
-			$diff = array_diff($newmodelsdb,$modelsdb);
2740
+			$diff = array_diff($newmodelsdb, $modelsdb);
2741 2741
 			foreach ($diff as $key => $value) {
2742 2742
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2743
-				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2743
+				update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2744 2744
 				
2745 2745
 			}
2746
-			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2746
+			update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2747 2747
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2748 2748
 		if ($error != '') {
2749 2749
 			return $error;
2750 2750
 		} elseif ($globalDebug) echo "Done\n";
2751 2751
 		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
2752
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2752
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum');
2753 2753
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2754 2754
 			if ($globalDebug) echo "Check files...\n";
2755 2755
 			$newmodelsdb = array();
2756
-			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2757
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2756
+			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) {
2757
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2758 2758
 					$model = trim($row[2]);
2759 2759
 					$newmodelsdb[$model] = trim($row[0]);
2760 2760
 				}
2761 2761
 			}
2762 2762
 			$modelsdb = array();
2763 2763
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) {
2764
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) {
2765
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2764
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) {
2765
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2766 2766
 						$model = trim($row[2]);
2767 2767
 						$modelsdb[$model] = trim($row[0]);
2768 2768
 					}
2769 2769
 				}
2770 2770
 			}
2771
-			$diff = array_diff($newmodelsdb,$modelsdb);
2771
+			$diff = array_diff($newmodelsdb, $modelsdb);
2772 2772
 			foreach ($diff as $key => $value) {
2773 2773
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2774
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2774
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key);
2775 2775
 				
2776 2776
 			}
2777
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2777
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum');
2778 2778
 		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
2779 2779
 		if ($error != '') {
2780 2780
 			return $error;
@@ -2786,32 +2786,32 @@  discard block
 block discarded – undo
2786 2786
 		global $tmp_dir, $globalDebug;
2787 2787
 		$error = '';
2788 2788
 		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
2789
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2789
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum');
2790 2790
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2791 2791
 			if ($globalDebug) echo "Check files...\n";
2792 2792
 			$newmodelsdb = array();
2793
-			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2794
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2793
+			if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) {
2794
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2795 2795
 					$model = trim($row[2]);
2796 2796
 					$newmodelsdb[$model] = trim($row[0]);
2797 2797
 				}
2798 2798
 			}
2799 2799
 			$modelsdb = array();
2800 2800
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) {
2801
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) {
2802
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2801
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) {
2802
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2803 2803
 						$model = trim($row[2]);
2804 2804
 						$modelsdb[$model] = trim($row[0]);
2805 2805
 					}
2806 2806
 				}
2807 2807
 			}
2808
-			$diff = array_diff($newmodelsdb,$modelsdb);
2808
+			$diff = array_diff($newmodelsdb, $modelsdb);
2809 2809
 			foreach ($diff as $key => $value) {
2810 2810
 				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
2811
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2811
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2812 2812
 				
2813 2813
 			}
2814
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2814
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2815 2815
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2816 2816
 		if ($error != '') {
2817 2817
 			return $error;
@@ -2823,32 +2823,32 @@  discard block
 block discarded – undo
2823 2823
 		global $tmp_dir, $globalDebug;
2824 2824
 		$error = '';
2825 2825
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2826
-		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2826
+		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2827 2827
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2828 2828
 			if ($globalDebug) echo "Check files...\n";
2829 2829
 			$newmodelsdb = array();
2830
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2831
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2830
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2831
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2832 2832
 					$model = trim($row[2]);
2833 2833
 					$newmodelsdb[$model] = trim($row[0]);
2834 2834
 				}
2835 2835
 			}
2836 2836
 			$modelsdb = array();
2837 2837
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2838
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2839
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2838
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2839
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2840 2840
 						$model = trim($row[2]);
2841 2841
 						$modelsdb[$model] = trim($row[0]);
2842 2842
 					}
2843 2843
 				}
2844 2844
 			}
2845
-			$diff = array_diff($newmodelsdb,$modelsdb);
2845
+			$diff = array_diff($newmodelsdb, $modelsdb);
2846 2846
 			foreach ($diff as $key => $value) {
2847 2847
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2848
-				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2848
+				update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2849 2849
 				
2850 2850
 			}
2851
-			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2851
+			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2852 2852
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2853 2853
 		if ($error != '') {
2854 2854
 			return $error;
@@ -2860,32 +2860,32 @@  discard block
 block discarded – undo
2860 2860
 		global $tmp_dir, $globalDebug;
2861 2861
 		$error = '';
2862 2862
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2863
-		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2863
+		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2864 2864
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2865 2865
 			if ($globalDebug) echo "Check files...\n";
2866 2866
 			$newmodelsdb = array();
2867
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2868
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2867
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2868
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2869 2869
 					$model = trim($row[2]);
2870 2870
 					$newmodelsdb[$model] = trim($row[0]);
2871 2871
 				}
2872 2872
 			}
2873 2873
 			$modelsdb = array();
2874 2874
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2875
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2876
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2875
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2876
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2877 2877
 						$model = trim($row[2]);
2878 2878
 						$modelsdb[$model] = trim($row[0]);
2879 2879
 					}
2880 2880
 				}
2881 2881
 			}
2882
-			$diff = array_diff($newmodelsdb,$modelsdb);
2882
+			$diff = array_diff($newmodelsdb, $modelsdb);
2883 2883
 			foreach ($diff as $key => $value) {
2884 2884
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2885
-				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2885
+				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2886 2886
 				
2887 2887
 			}
2888
-			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2888
+			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2889 2889
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2890 2890
 		if ($error != '') {
2891 2891
 			return $error;
@@ -2897,8 +2897,8 @@  discard block
 block discarded – undo
2897 2897
 		global $tmp_dir, $globalDebug;
2898 2898
 		date_default_timezone_set('UTC');
2899 2899
 		$Common = new Common();
2900
-		$data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes','post',array('X-Requested-With: XMLHttpRequest','Accept: application/json, text/javascript, */*; q=0.01','Host: www4.icao.int','Origin: https://www.icao.int','Content-Length: 0'),'','','https://www.icao.int/publications/DOC8643/Pages/Search.aspx',60);
2901
-		$all = json_decode($data,true);
2900
+		$data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes', 'post', array('X-Requested-With: XMLHttpRequest', 'Accept: application/json, text/javascript, */*; q=0.01', 'Host: www4.icao.int', 'Origin: https://www.icao.int', 'Content-Length: 0'), '', '', 'https://www.icao.int/publications/DOC8643/Pages/Search.aspx', 60);
2901
+		$all = json_decode($data, true);
2902 2902
 		$Connection = new Connection();
2903 2903
 		$querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao";
2904 2904
 		$sth = $Connection->db->prepare($querychk);
@@ -2910,8 +2910,8 @@  discard block
 block discarded – undo
2910 2910
 		foreach ($all as $model) {
2911 2911
 			$icao = $model['Designator'];
2912 2912
 			if (!isset($allicao[$icao])) {
2913
-				$aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png';
2914
-				$allicao[$icao] = array(':icao' => $icao,':type' => $model['ModelFullName'],':manufacturer' => $model['ManufacturerCode'],':aircraft_shadow' => $aircraft_shadow,':aircraft_description' => $model['AircraftDescription'],':engine_type' => $model['EngineType'],':engine_count' => $model['EngineCount'],':wake_category' => $model['WTC']);
2913
+				$aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png';
2914
+				$allicao[$icao] = array(':icao' => $icao, ':type' => $model['ModelFullName'], ':manufacturer' => $model['ManufacturerCode'], ':aircraft_shadow' => $aircraft_shadow, ':aircraft_description' => $model['AircraftDescription'], ':engine_type' => $model['EngineType'], ':engine_count' => $model['EngineCount'], ':wake_category' => $model['WTC']);
2915 2915
 			} else {
2916 2916
 				$allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName'];
2917 2917
 			}
@@ -2923,9 +2923,9 @@  discard block
 block discarded – undo
2923 2923
 				if ($exist[0]['nb'] == 0) {
2924 2924
 					$sthins->execute($airdata);
2925 2925
 				} else {
2926
-					$sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao));
2926
+					$sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao));
2927 2927
 				}
2928
-			} catch(PDOException $e) {
2928
+			} catch (PDOException $e) {
2929 2929
 				return "error : ".$e->getMessage();
2930 2930
 			}
2931 2931
 		}
@@ -2957,23 +2957,23 @@  discard block
 block discarded – undo
2957 2957
 			$Connection = new Connection();
2958 2958
 			$sth = $Connection->db->prepare($query);
2959 2959
                         $sth->execute();
2960
-                } catch(PDOException $e) {
2960
+                } catch (PDOException $e) {
2961 2961
                         return "error : ".$e->getMessage();
2962 2962
                 }
2963 2963
 
2964 2964
 		$error = '';
2965 2965
 		if ($globalDebug) echo "Notam : Download...";
2966
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2966
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2967 2967
 		if (file_exists($tmp_dir.'notam.rss')) {
2968
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2968
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2969 2969
 			foreach ($notams['channel']['item'] as $notam) {
2970
-				$title = explode(':',$notam['title']);
2970
+				$title = explode(':', $notam['title']);
2971 2971
 				$data['ref'] = trim($title[0]);
2972 2972
 				unset($title[0]);
2973
-				$data['title'] = trim(implode(':',$title));
2974
-				$description = strip_tags($notam['description'],'<pre>');
2975
-				preg_match(':^(.*?)<pre>:',$description,$match);
2976
-				$q = explode('/',$match[1]);
2973
+				$data['title'] = trim(implode(':', $title));
2974
+				$description = strip_tags($notam['description'], '<pre>');
2975
+				preg_match(':^(.*?)<pre>:', $description, $match);
2976
+				$q = explode('/', $match[1]);
2977 2977
 				$data['fir'] = $q[0];
2978 2978
 				$data['code'] = $q[1];
2979 2979
 				$ifrvfr = $q[2];
@@ -2989,30 +2989,30 @@  discard block
 block discarded – undo
2989 2989
 				$data['lower_limit'] = $q[5];
2990 2990
 				$data['upper_limit'] = $q[6];
2991 2991
 				$latlonrad = $q[7];
2992
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2993
-				$latitude = $Common->convertDec($las,'latitude');
2994
-				$longitude = $Common->convertDec($lns,'longitude');
2992
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2993
+				$latitude = $Common->convertDec($las, 'latitude');
2994
+				$longitude = $Common->convertDec($lns, 'longitude');
2995 2995
 				if ($lac == 'S') $latitude = '-'.$latitude;
2996 2996
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2997 2997
 				$data['center_latitude'] = $latitude;
2998 2998
 				$data['center_longitude'] = $longitude;
2999 2999
 				$data['radius'] = intval($radius);
3000 3000
 				
3001
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
3001
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
3002 3002
 				$data['text'] = $match[1];
3003
-				preg_match(':</pre>(.*?)$:',$description,$match);
3003
+				preg_match(':</pre>(.*?)$:', $description, $match);
3004 3004
 				$fromto = $match[1];
3005
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
3005
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
3006 3006
 				$fromall = trim($match[1]);
3007
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
3007
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
3008 3008
 				$from = trim($match[1]);
3009
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
3010
-				preg_match('#TO:(.*?)$#',$fromto,$match);
3009
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
3010
+				preg_match('#TO:(.*?)$#', $fromto, $match);
3011 3011
 				$toall = trim($match[1]);
3012
-				if (!preg_match(':Permanent:',$toall)) {
3013
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
3012
+				if (!preg_match(':Permanent:', $toall)) {
3013
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
3014 3014
 					$to = trim($match[1]);
3015
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3015
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
3016 3016
 					$data['permanent'] = 0;
3017 3017
 				} else {
3018 3018
 				    $data['date_end'] = NULL;
@@ -3020,7 +3020,7 @@  discard block
 block discarded – undo
3020 3020
 				}
3021 3021
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3022 3022
 				$NOTAM = new NOTAM();
3023
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
3023
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
3024 3024
 				unset($data);
3025 3025
 			} 
3026 3026
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -3043,16 +3043,16 @@  discard block
 block discarded – undo
3043 3043
 				$Connection = new Connection();
3044 3044
 				$sth = $Connection->db->prepare($query);
3045 3045
 				$sth->execute();
3046
-			} catch(PDOException $e) {
3046
+			} catch (PDOException $e) {
3047 3047
 				return "error : ".$e->getMessage();
3048 3048
 			}
3049 3049
 		}
3050 3050
 		$Common = new Common();
3051 3051
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3052
-		$airspace_json = json_decode($airspace_lst,true);
3052
+		$airspace_json = json_decode($airspace_lst, true);
3053 3053
 		foreach ($airspace_json['records'] as $airspace) {
3054 3054
 			if ($globalDebug) echo $airspace['name']."...\n";
3055
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3055
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
3056 3056
 			if (file_exists($tmp_dir.$airspace['name'])) {
3057 3057
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
3058 3058
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -3074,7 +3074,7 @@  discard block
 block discarded – undo
3074 3074
 				$Connection = new Connection();
3075 3075
 				$sth = $Connection->db->prepare($query);
3076 3076
 				$sth->execute(array(':new' => $new, ':old' => $old));
3077
-			} catch(PDOException $e) {
3077
+			} catch (PDOException $e) {
3078 3078
 				return "error : ".$e->getMessage();
3079 3079
 			}
3080 3080
 		}
@@ -3091,7 +3091,7 @@  discard block
 block discarded – undo
3091 3091
 			$Connection = new Connection();
3092 3092
 			$sth = $Connection->db->prepare($query);
3093 3093
                         $sth->execute();
3094
-                } catch(PDOException $e) {
3094
+                } catch (PDOException $e) {
3095 3095
                         return "error : ".$e->getMessage();
3096 3096
                 }
3097 3097
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3106,7 +3106,7 @@  discard block
 block discarded – undo
3106 3106
 			$Connection = new Connection();
3107 3107
 			$sth = $Connection->db->prepare($query);
3108 3108
                         $sth->execute();
3109
-                } catch(PDOException $e) {
3109
+                } catch (PDOException $e) {
3110 3110
                         return "error : ".$e->getMessage();
3111 3111
                 }
3112 3112
 	}
@@ -3117,7 +3117,7 @@  discard block
 block discarded – undo
3117 3117
 			$Connection = new Connection();
3118 3118
 			$sth = $Connection->db->prepare($query);
3119 3119
                         $sth->execute(array(':version' => $version));
3120
-                } catch(PDOException $e) {
3120
+                } catch (PDOException $e) {
3121 3121
                         return "error : ".$e->getMessage();
3122 3122
                 }
3123 3123
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3131,7 +3131,7 @@  discard block
 block discarded – undo
3131 3131
 			$Connection = new Connection();
3132 3132
 			$sth = $Connection->db->prepare($query);
3133 3133
                         $sth->execute(array(':version' => $version));
3134
-                } catch(PDOException $e) {
3134
+                } catch (PDOException $e) {
3135 3135
                         return "error : ".$e->getMessage();
3136 3136
                 }
3137 3137
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3145,7 +3145,7 @@  discard block
 block discarded – undo
3145 3145
 			$Connection = new Connection();
3146 3146
 			$sth = $Connection->db->prepare($query);
3147 3147
 			$sth->execute(array(':version' => $version));
3148
-		} catch(PDOException $e) {
3148
+		} catch (PDOException $e) {
3149 3149
 			return "error : ".$e->getMessage();
3150 3150
 		}
3151 3151
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3159,7 +3159,7 @@  discard block
 block discarded – undo
3159 3159
 			$Connection = new Connection();
3160 3160
 			$sth = $Connection->db->prepare($query);
3161 3161
 			$sth->execute(array(':version' => $version));
3162
-		} catch(PDOException $e) {
3162
+		} catch (PDOException $e) {
3163 3163
 			return "error : ".$e->getMessage();
3164 3164
 		}
3165 3165
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
 			$Connection = new Connection();
3174 3174
 			$sth = $Connection->db->prepare($query);
3175 3175
 			$sth->execute(array(':version' => $version));
3176
-		} catch(PDOException $e) {
3176
+		} catch (PDOException $e) {
3177 3177
 			return "error : ".$e->getMessage();
3178 3178
 		}
3179 3179
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
 			$Connection = new Connection();
3188 3188
 			$sth = $Connection->db->prepare($query);
3189 3189
 			$sth->execute(array(':version' => $version));
3190
-		} catch(PDOException $e) {
3190
+		} catch (PDOException $e) {
3191 3191
 			return "error : ".$e->getMessage();
3192 3192
 		}
3193 3193
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3202,7 +3202,7 @@  discard block
 block discarded – undo
3202 3202
 			$Connection = new Connection();
3203 3203
 			$sth = $Connection->db->prepare($query);
3204 3204
 			$sth->execute(array(':version' => $version));
3205
-		} catch(PDOException $e) {
3205
+		} catch (PDOException $e) {
3206 3206
 			return "error : ".$e->getMessage();
3207 3207
 		}
3208 3208
 	}
@@ -3214,7 +3214,7 @@  discard block
 block discarded – undo
3214 3214
 			$Connection = new Connection();
3215 3215
 			$sth = $Connection->db->prepare($query);
3216 3216
 			$sth->execute(array(':version' => $version));
3217
-		} catch(PDOException $e) {
3217
+		} catch (PDOException $e) {
3218 3218
 			return "error : ".$e->getMessage();
3219 3219
 		}
3220 3220
 	}
@@ -3226,7 +3226,7 @@  discard block
 block discarded – undo
3226 3226
 			$Connection = new Connection();
3227 3227
 			$sth = $Connection->db->prepare($query);
3228 3228
 			$sth->execute(array(':version' => $version));
3229
-		} catch(PDOException $e) {
3229
+		} catch (PDOException $e) {
3230 3230
 			return "error : ".$e->getMessage();
3231 3231
 		}
3232 3232
 	}
@@ -3238,7 +3238,7 @@  discard block
 block discarded – undo
3238 3238
 			$Connection = new Connection();
3239 3239
 			$sth = $Connection->db->prepare($query);
3240 3240
                         $sth->execute(array(':version' => $version));
3241
-                } catch(PDOException $e) {
3241
+                } catch (PDOException $e) {
3242 3242
                         return "error : ".$e->getMessage();
3243 3243
                 }
3244 3244
 	}
@@ -3250,7 +3250,7 @@  discard block
 block discarded – undo
3250 3250
 			$Connection = new Connection();
3251 3251
 			$sth = $Connection->db->prepare($query);
3252 3252
 			$sth->execute(array(':version' => $version));
3253
-		} catch(PDOException $e) {
3253
+		} catch (PDOException $e) {
3254 3254
 			return "error : ".$e->getMessage();
3255 3255
 		}
3256 3256
 	}
@@ -3262,7 +3262,7 @@  discard block
 block discarded – undo
3262 3262
 			$Connection = new Connection();
3263 3263
 			$sth = $Connection->db->prepare($query);
3264 3264
 			$sth->execute(array(':version' => $version));
3265
-		} catch(PDOException $e) {
3265
+		} catch (PDOException $e) {
3266 3266
 			return "error : ".$e->getMessage();
3267 3267
 		}
3268 3268
 	}
@@ -3278,7 +3278,7 @@  discard block
 block discarded – undo
3278 3278
 			$Connection = new Connection();
3279 3279
 			$sth = $Connection->db->prepare($query);
3280 3280
                         $sth->execute();
3281
-                } catch(PDOException $e) {
3281
+                } catch (PDOException $e) {
3282 3282
                         return "error : ".$e->getMessage();
3283 3283
                 }
3284 3284
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3293,7 +3293,7 @@  discard block
 block discarded – undo
3293 3293
 			$Connection = new Connection();
3294 3294
 			$sth = $Connection->db->prepare($query);
3295 3295
                         $sth->execute();
3296
-                } catch(PDOException $e) {
3296
+                } catch (PDOException $e) {
3297 3297
                         return "error : ".$e->getMessage();
3298 3298
                 }
3299 3299
 	}
@@ -3309,7 +3309,7 @@  discard block
 block discarded – undo
3309 3309
 			$Connection = new Connection();
3310 3310
 			$sth = $Connection->db->prepare($query);
3311 3311
                         $sth->execute();
3312
-                } catch(PDOException $e) {
3312
+                } catch (PDOException $e) {
3313 3313
                         return "error : ".$e->getMessage();
3314 3314
                 }
3315 3315
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3324,7 +3324,7 @@  discard block
 block discarded – undo
3324 3324
 			$Connection = new Connection();
3325 3325
 			$sth = $Connection->db->prepare($query);
3326 3326
                         $sth->execute();
3327
-                } catch(PDOException $e) {
3327
+                } catch (PDOException $e) {
3328 3328
                         return "error : ".$e->getMessage();
3329 3329
                 }
3330 3330
 	}
@@ -3340,7 +3340,7 @@  discard block
 block discarded – undo
3340 3340
 			$Connection = new Connection();
3341 3341
 			$sth = $Connection->db->prepare($query);
3342 3342
                         $sth->execute();
3343
-                } catch(PDOException $e) {
3343
+                } catch (PDOException $e) {
3344 3344
                         return "error : ".$e->getMessage();
3345 3345
                 }
3346 3346
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3355,7 +3355,7 @@  discard block
 block discarded – undo
3355 3355
 			$Connection = new Connection();
3356 3356
 			$sth = $Connection->db->prepare($query);
3357 3357
                         $sth->execute();
3358
-                } catch(PDOException $e) {
3358
+                } catch (PDOException $e) {
3359 3359
                         return "error : ".$e->getMessage();
3360 3360
                 }
3361 3361
 	}
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
 			$Connection = new Connection();
3372 3372
 			$sth = $Connection->db->prepare($query);
3373 3373
 			$sth->execute();
3374
-		} catch(PDOException $e) {
3374
+		} catch (PDOException $e) {
3375 3375
 			return "error : ".$e->getMessage();
3376 3376
 		}
3377 3377
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3386,7 +3386,7 @@  discard block
 block discarded – undo
3386 3386
 			$Connection = new Connection();
3387 3387
 			$sth = $Connection->db->prepare($query);
3388 3388
 			$sth->execute();
3389
-		} catch(PDOException $e) {
3389
+		} catch (PDOException $e) {
3390 3390
 			return "error : ".$e->getMessage();
3391 3391
 		}
3392 3392
 	}
@@ -3402,7 +3402,7 @@  discard block
 block discarded – undo
3402 3402
 			$Connection = new Connection();
3403 3403
 			$sth = $Connection->db->prepare($query);
3404 3404
 			$sth->execute();
3405
-		} catch(PDOException $e) {
3405
+		} catch (PDOException $e) {
3406 3406
 			return "error : ".$e->getMessage();
3407 3407
 		}
3408 3408
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3417,7 +3417,7 @@  discard block
 block discarded – undo
3417 3417
 			$Connection = new Connection();
3418 3418
 			$sth = $Connection->db->prepare($query);
3419 3419
 			$sth->execute();
3420
-		} catch(PDOException $e) {
3420
+		} catch (PDOException $e) {
3421 3421
 			return "error : ".$e->getMessage();
3422 3422
 		}
3423 3423
 	}
@@ -3433,7 +3433,7 @@  discard block
 block discarded – undo
3433 3433
 			$Connection = new Connection();
3434 3434
 			$sth = $Connection->db->prepare($query);
3435 3435
 			$sth->execute();
3436
-		} catch(PDOException $e) {
3436
+		} catch (PDOException $e) {
3437 3437
 			return "error : ".$e->getMessage();
3438 3438
 		}
3439 3439
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3448,7 +3448,7 @@  discard block
 block discarded – undo
3448 3448
 			$Connection = new Connection();
3449 3449
 			$sth = $Connection->db->prepare($query);
3450 3450
 			$sth->execute();
3451
-		} catch(PDOException $e) {
3451
+		} catch (PDOException $e) {
3452 3452
 			return "error : ".$e->getMessage();
3453 3453
 		}
3454 3454
 	}
@@ -3464,7 +3464,7 @@  discard block
 block discarded – undo
3464 3464
 			$Connection = new Connection();
3465 3465
 			$sth = $Connection->db->prepare($query);
3466 3466
                         $sth->execute();
3467
-                } catch(PDOException $e) {
3467
+                } catch (PDOException $e) {
3468 3468
                         return "error : ".$e->getMessage();
3469 3469
                 }
3470 3470
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3479,7 +3479,7 @@  discard block
 block discarded – undo
3479 3479
 			$Connection = new Connection();
3480 3480
 			$sth = $Connection->db->prepare($query);
3481 3481
 			$sth->execute();
3482
-		} catch(PDOException $e) {
3482
+		} catch (PDOException $e) {
3483 3483
 			return "error : ".$e->getMessage();
3484 3484
 		}
3485 3485
 	}
@@ -3495,7 +3495,7 @@  discard block
 block discarded – undo
3495 3495
 			$Connection = new Connection();
3496 3496
 			$sth = $Connection->db->prepare($query);
3497 3497
 			$sth->execute();
3498
-		} catch(PDOException $e) {
3498
+		} catch (PDOException $e) {
3499 3499
 			return "error : ".$e->getMessage();
3500 3500
 		}
3501 3501
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3510,7 +3510,7 @@  discard block
 block discarded – undo
3510 3510
 			$Connection = new Connection();
3511 3511
 			$sth = $Connection->db->prepare($query);
3512 3512
 			$sth->execute();
3513
-		} catch(PDOException $e) {
3513
+		} catch (PDOException $e) {
3514 3514
 			return "error : ".$e->getMessage();
3515 3515
 		}
3516 3516
 	}
@@ -3526,7 +3526,7 @@  discard block
 block discarded – undo
3526 3526
 			$Connection = new Connection();
3527 3527
 			$sth = $Connection->db->prepare($query);
3528 3528
 			$sth->execute();
3529
-		} catch(PDOException $e) {
3529
+		} catch (PDOException $e) {
3530 3530
 			return "error : ".$e->getMessage();
3531 3531
 		}
3532 3532
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
 			$Connection = new Connection();
3542 3542
 			$sth = $Connection->db->prepare($query);
3543 3543
 			$sth->execute();
3544
-		} catch(PDOException $e) {
3544
+		} catch (PDOException $e) {
3545 3545
 			return "error : ".$e->getMessage();
3546 3546
 		}
3547 3547
 	}
@@ -3557,7 +3557,7 @@  discard block
 block discarded – undo
3557 3557
 			$Connection = new Connection();
3558 3558
 			$sth = $Connection->db->prepare($query);
3559 3559
 			$sth->execute();
3560
-		} catch(PDOException $e) {
3560
+		} catch (PDOException $e) {
3561 3561
 			return "error : ".$e->getMessage();
3562 3562
 		}
3563 3563
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
 			$Connection = new Connection();
3573 3573
 			$sth = $Connection->db->prepare($query);
3574 3574
 			$sth->execute();
3575
-		} catch(PDOException $e) {
3575
+		} catch (PDOException $e) {
3576 3576
 			return "error : ".$e->getMessage();
3577 3577
 		}
3578 3578
 	}
@@ -3588,7 +3588,7 @@  discard block
 block discarded – undo
3588 3588
 			$Connection = new Connection();
3589 3589
 			$sth = $Connection->db->prepare($query);
3590 3590
 			$sth->execute();
3591
-		} catch(PDOException $e) {
3591
+		} catch (PDOException $e) {
3592 3592
 			return "error : ".$e->getMessage();
3593 3593
 		}
3594 3594
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3607,7 +3607,7 @@  discard block
 block discarded – undo
3607 3607
 			$Connection = new Connection();
3608 3608
 			$sth = $Connection->db->prepare($query);
3609 3609
 			$sth->execute();
3610
-		} catch(PDOException $e) {
3610
+		} catch (PDOException $e) {
3611 3611
 			return "error : ".$e->getMessage();
3612 3612
 		}
3613 3613
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3622,7 +3622,7 @@  discard block
 block discarded – undo
3622 3622
 			$Connection = new Connection();
3623 3623
 			$sth = $Connection->db->prepare($query);
3624 3624
 			$sth->execute();
3625
-		} catch(PDOException $e) {
3625
+		} catch (PDOException $e) {
3626 3626
 			return "error : ".$e->getMessage();
3627 3627
 		}
3628 3628
 	}
@@ -3634,7 +3634,7 @@  discard block
 block discarded – undo
3634 3634
 			$Connection = new Connection();
3635 3635
 			$sth = $Connection->db->prepare($query);
3636 3636
 			$sth->execute();
3637
-		} catch(PDOException $e) {
3637
+		} catch (PDOException $e) {
3638 3638
 			return "error : ".$e->getMessage();
3639 3639
 		}
3640 3640
 	}
@@ -3650,7 +3650,7 @@  discard block
 block discarded – undo
3650 3650
 			$Connection = new Connection();
3651 3651
 			$sth = $Connection->db->prepare($query);
3652 3652
                         $sth->execute();
3653
-                } catch(PDOException $e) {
3653
+                } catch (PDOException $e) {
3654 3654
                         return "error : ".$e->getMessage();
3655 3655
                 }
3656 3656
 	}
@@ -3665,7 +3665,7 @@  discard block
 block discarded – undo
3665 3665
 			$Connection = new Connection();
3666 3666
 			$sth = $Connection->db->prepare($query);
3667 3667
                         $sth->execute();
3668
-                } catch(PDOException $e) {
3668
+                } catch (PDOException $e) {
3669 3669
                         return "error : ".$e->getMessage();
3670 3670
                 }
3671 3671
 	}
Please login to merge, or discard this patch.
require/class.GeoidHeight.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 * Translated to PHP of GeographicLib/src/Geoid.cpp
12 12
 * by Ycarus <[email protected]> in 2017
13 13
 */
14
-class GeoidHeight  {
14
+class GeoidHeight {
15 15
 	private $c0 = 240;
16 16
 	private $c3 = [[9, -18, -88, 0, 96, 90, 0, 0, -60, -20], [-9, 18, 8, 0, -96, 30, 0, 0, 60, -20], [9, -88, -18, 90, 96, 0, -20, -60, 0, 0], [186, -42, -42, -150, -96, -150, 60, 60, 60, 60], [54, 162, -78, 30, -24, -90, -60, 60, -60, 60], [-9, -32, 18, 30, 24, 0, 20, -60, 0, 0], [-9, 8, 18, 30, -96, 0, -20, 60, 0, 0], [54, -78, 162, -90, -24, 30, 60, -60, 60, -60], [-54, 78, 78, 90, 144, 90, -60, -60, -60, -60], [9, -8, -18, -30, -24, 0, 20, 60, 0, 0], [-9, 18, -32, 0, 24, 30, 0, 0, -60, 20], [9, -18, -8, 0, -24, -30, 0, 0, 60, 20]];
17 17
 	private $c0n = 372;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	private $v10 = null;
35 35
 	private $v11 = null;
36 36
 
37
-	public function __construct($name='') {
37
+	public function __construct($name = '') {
38 38
 		global $globalGeoidSource;
39 39
 		//if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm';
40 40
 		if ($name == '') {
@@ -45,35 +45,35 @@  discard block
 block discarded – undo
45 45
 		if (file_exists($name) === FALSE) {
46 46
 			throw new Exception($name." doesn't exist");
47 47
 		}
48
-		$f = @fopen($name,"r");
48
+		$f = @fopen($name, "r");
49 49
 		if ($f === FALSE) {
50 50
 			throw new Exception("Can't open ".$name);
51 51
 		}
52
-		$line = fgets($f,4096);
52
+		$line = fgets($f, 4096);
53 53
 		if (trim($line) != 'P5') {
54 54
 			throw new Exception('No PGM header');
55 55
 		}
56 56
 		$headerlen = strlen($line);
57 57
 		while (true) {
58
-			$line = fgets($f,4096);
58
+			$line = fgets($f, 4096);
59 59
 			if ((strlen($line) == 0)) {
60 60
 				throw new Exception('EOF before end of file header');
61 61
 			}
62 62
 			$headerlen += strlen($line);
63
-			if (strpos($line,'# Offset ') !== FALSE) {
63
+			if (strpos($line, '# Offset ') !== FALSE) {
64 64
 				$this->offset = substr($line, 9);
65
-			} else if (strpos($line,'# Scale ') !== FALSE) {
65
+			} else if (strpos($line, '# Scale ') !== FALSE) {
66 66
 				$this->scale = substr($line, 8);
67
-			} else if ((strpos($line,'#') === FALSE)) {
68
-				list($this->width, $this->height) = preg_split('/\s+/',$line);
67
+			} else if ((strpos($line, '#') === FALSE)) {
68
+				list($this->width, $this->height) = preg_split('/\s+/', $line);
69 69
 				break;
70 70
 			}
71 71
 		}
72
-		$line = fgets($f,4096);
72
+		$line = fgets($f, 4096);
73 73
 		$headerlen += strlen($line);
74
-		$levels = (int)$line;
75
-		$this->width = (int)$this->width;
76
-		$this->height = (int)$this->height;
74
+		$levels = (int) $line;
75
+		$this->width = (int) $this->width;
76
+		$this->height = (int) $this->height;
77 77
 		if (($levels != 65535)) {
78 78
 			throw new Exception('PGM file must have 65535 gray levels ('.$levels.')');
79 79
 		}
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
 		}
89 89
 
90 90
 		$fullsize = filesize($name);
91
-		if ((($fullsize - $headerlen) != (($this->width * $this->height) * 2))) {
91
+		if ((($fullsize - $headerlen) != (($this->width*$this->height)*2))) {
92 92
 			throw new Exception('File has the wrong length');
93 93
 		}
94 94
 
95 95
 		$this->headerlen = $headerlen;
96
-		$this->raw= $f;
97
-		$this->rlonres = ($this->width / 360.0);
98
-		$this->rlatres = (($this->height - 1) / 180.0);
96
+		$this->raw = $f;
97
+		$this->rlonres = ($this->width/360.0);
98
+		$this->rlatres = (($this->height - 1)/180.0);
99 99
 	}
100 100
 
101
-	private function _rawval($ix,$iy) {
101
+	private function _rawval($ix, $iy) {
102 102
 		if (($iy < 0)) {
103 103
 			$iy = -$iy;
104
-			$ix += ($this->width / 2);
104
+			$ix += ($this->width/2);
105 105
 		} else if (($iy >= $this->height)) {
106
-			$iy = ((2 * ($this->height - 1)) - $iy);
107
-			$ix += ($this->width / 2);
106
+			$iy = ((2*($this->height - 1)) - $iy);
107
+			$ix += ($this->width/2);
108 108
 		}
109 109
 		if (($ix < 0)) {
110 110
 			$ix += $this->width;
111 111
 		} else if (($ix >= $this->width)) {
112 112
 			$ix -= $this->width;
113 113
 		}
114
-		$k = ((($iy * $this->width) + $ix) * 2) + $this->headerlen;
115
-		fseek($this->raw,$k);
116
-		return unpack('n',fread($this->raw,2))[1];
114
+		$k = ((($iy*$this->width) + $ix)*2) + $this->headerlen;
115
+		fseek($this->raw, $k);
116
+		return unpack('n', fread($this->raw, 2))[1];
117 117
 	}
118 118
 
119
-	public function get($lat,$lon,$cubic=true) {
119
+	public function get($lat, $lon, $cubic = true) {
120 120
 		if (($lon < 0)) {
121 121
 			$lon += 360;
122 122
 		}
123
-		$fy = ((90 - $lat) * $this->rlatres);
124
-		$fx = ($lon * $this->rlonres);
125
-		$iy = (int)$fy;
126
-		$ix = (int)$fx;
123
+		$fy = ((90 - $lat)*$this->rlatres);
124
+		$fx = ($lon*$this->rlonres);
125
+		$iy = (int) $fy;
126
+		$ix = (int) $fx;
127 127
 		$fx -= $ix;
128 128
 		$fy -= $iy;
129 129
 		$t = array();
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 					$c3x = $this->c3;
151 151
 					$c0x = $this->c0;
152 152
 				}
153
-				for ($i = 0; $i < 10;++$i) {
153
+				for ($i = 0; $i < 10; ++$i) {
154 154
 					$t[$i] = 0;
155 155
 					for ($j = 0; $j < 12; ++$j) {
156 156
 						$t[$i] += $v[$j]*$c3x[$j][$i];
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
 			$this->t = $t;
162 162
 		} else $t = $this->t;
163 163
 		if (!($cubic)) {
164
-			$a = (((1 - $fx) * $this->v00) + ($fx * $this->v01));
165
-			$b = (((1 - $fx) * $this->v10) + ($fx * $this->v11));
166
-			$h = (((1 - $fy) * $a) + ($fy * $b));
164
+			$a = (((1 - $fx)*$this->v00) + ($fx*$this->v01));
165
+			$b = (((1 - $fx)*$this->v10) + ($fx*$this->v11));
166
+			$h = (((1 - $fy)*$a) + ($fy*$b));
167 167
 		} else {
168
-			$h = (($t[0] + ($fx * ($t[1] + ($fx * ($t[3] + ($fx * $t[6])))))) + ($fy * (($t[2] + ($fx * ($t[4] + ($fx * $t[7])))) + ($fy * (($t[5] + ($fx * $t[8])) + ($fy * $t[9]))))));
168
+			$h = (($t[0] + ($fx*($t[1] + ($fx*($t[3] + ($fx*$t[6])))))) + ($fy*(($t[2] + ($fx*($t[4] + ($fx*$t[7])))) + ($fy*(($t[5] + ($fx*$t[8])) + ($fy*$t[9]))))));
169 169
 		}
170
-		return ((float)$this->offset + ((float)$this->scale * (float)$h));
170
+		return ((float) $this->offset + ((float) $this->scale*(float) $h));
171 171
 	}
172 172
 }
173 173
 /*
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Spacing   +643 added lines, -643 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 		if ($this->db === null) die('Error: No DB connection. (Stats)');
29 29
 	}
30 30
 
31
-	public function addLastStatsUpdate($type,$stats_date) {
31
+	public function addLastStatsUpdate($type, $stats_date) {
32 32
 		$query = "DELETE FROM config WHERE name = :type;
33 33
 			    INSERT INTO config (name,value) VALUES (:type,:stats_date);";
34
-		$query_values = array('type' => $type,':stats_date' => $stats_date);
34
+		$query_values = array('type' => $type, ':stats_date' => $stats_date);
35 35
 		try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute($query_values);
38
-		} catch(PDOException $e) {
38
+		} catch (PDOException $e) {
39 39
 			return "error : ".$e->getMessage();
40 40
 		}
41 41
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		try {
46 46
 			$sth = $this->db->prepare($query);
47 47
 			$sth->execute(array(':type' => $type));
48
-		} catch(PDOException $e) {
48
+		} catch (PDOException $e) {
49 49
 			echo "error : ".$e->getMessage();
50 50
 		}
51 51
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		try {
67 67
 			$sth = $this->db->prepare($query);
68 68
 			$sth->execute(array(':filter_name' => $filter_name));
69
-		} catch(PDOException $e) {
69
+		} catch (PDOException $e) {
70 70
 			return "error : ".$e->getMessage();
71 71
 		}
72 72
 	}
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		try {
80 80
 			$sth = $this->db->prepare($query);
81 81
 			$sth->execute();
82
-		} catch(PDOException $e) {
82
+		} catch (PDOException $e) {
83 83
 			return "error : ".$e->getMessage();
84 84
 		}
85 85
 		$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
86 86
 		try {
87 87
 			$sth = $this->db->prepare($query);
88 88
 			$sth->execute(array(':filter_name' => $filter_name));
89
-		} catch(PDOException $e) {
89
+		} catch (PDOException $e) {
90 90
 			return "error : ".$e->getMessage();
91 91
 		}
92 92
 	}
@@ -98,77 +98,77 @@  discard block
 block discarded – undo
98 98
 		 try {
99 99
 			$sth = $this->db->prepare($query);
100 100
 			$sth->execute(array(':filter_name' => $filter_name));
101
-		} catch(PDOException $e) {
101
+		} catch (PDOException $e) {
102 102
 			echo "error : ".$e->getMessage();
103 103
 		}
104 104
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
105 105
 		if (empty($all)) {
106 106
 			$filters = array();
107 107
 			if ($filter_name != '') {
108
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
108
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
109 109
 			}
110 110
 			$Spotter = new Spotter($this->db);
111
-			$all = $Spotter->getAllAirlineNames('',NULL,$filters);
111
+			$all = $Spotter->getAllAirlineNames('', NULL, $filters);
112 112
 		}
113 113
 		return $all;
114 114
 	}
115
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
115
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
118 118
 		try {
119 119
 			$sth = $this->db->prepare($query);
120
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-		} catch(PDOException $e) {
120
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+		} catch (PDOException $e) {
122 122
 			echo "error : ".$e->getMessage();
123 123
 		}
124 124
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125 125
 		return $all;
126 126
 	}
127
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
127
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
128 128
 		if ($filter_name == '') $filter_name = $this->filter_name;
129 129
 		$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
130 130
 		try {
131 131
 			$sth = $this->db->prepare($query);
132
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
133
-		} catch(PDOException $e) {
132
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
133
+		} catch (PDOException $e) {
134 134
 			echo "error : ".$e->getMessage();
135 135
 		}
136 136
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
137 137
 		return $all;
138 138
 	}
139
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
139
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
140 140
 		if ($filter_name == '') $filter_name = $this->filter_name;
141 141
 		$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
142 142
 		try {
143 143
 			$sth = $this->db->prepare($query);
144
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
145
-		} catch(PDOException $e) {
144
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
145
+		} catch (PDOException $e) {
146 146
 			echo "error : ".$e->getMessage();
147 147
 		}
148 148
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
149 149
 		return $all;
150 150
 	}
151 151
 
152
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
152
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
153 153
 		if ($filter_name == '') $filter_name = $this->filter_name;
154 154
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
155 155
 		try {
156 156
 			$sth = $this->db->prepare($query);
157
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
158
-		} catch(PDOException $e) {
157
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
158
+		} catch (PDOException $e) {
159 159
 			echo "error : ".$e->getMessage();
160 160
 		}
161 161
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
162 162
 		return $all;
163 163
 	}
164 164
 
165
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
165
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
166 166
 		if ($filter_name == '') $filter_name = $this->filter_name;
167 167
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
168 168
 		try {
169 169
 			$sth = $this->db->prepare($query);
170
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
171
-		} catch(PDOException $e) {
170
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
171
+		} catch (PDOException $e) {
172 172
 			echo "error : ".$e->getMessage();
173 173
 		}
174 174
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
 	}
177 177
 
178 178
 
179
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
179
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
182
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
183 183
 			$Spotter = new Spotter($this->db);
184
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
184
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
185 185
 			$alliance_airlines = array();
186 186
 			foreach ($airlines as $airline) {
187
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
187
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
188 188
 			}
189 189
 			if ($year == '' && $month == '') {
190
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
191
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
190
+				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
191
+				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
192 192
 				try {
193 193
 					$sth = $this->db->prepare($query);
194 194
 					$sth->execute(array(':filter_name' => $filter_name));
195
-				} catch(PDOException $e) {
195
+				} catch (PDOException $e) {
196 196
 					echo "error : ".$e->getMessage();
197 197
 				}
198 198
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -203,29 +203,29 @@  discard block
 block discarded – undo
203 203
 				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
204 204
 				try {
205 205
 					$sth = $this->db->prepare($query);
206
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
207
-				} catch(PDOException $e) {
206
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
207
+				} catch (PDOException $e) {
208 208
 					echo "error : ".$e->getMessage();
209 209
 				}
210 210
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
211 211
 			} else $all = array();
212 212
 		}
213 213
 		if (empty($all)) {
214
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
215
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
214
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
215
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
216 216
 			} else {
217
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
217
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
218 218
 			}
219 219
 			if ($filter_name != '') {
220
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
220
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
221 221
 			}
222 222
 			$Spotter = new Spotter($this->db);
223 223
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
224
-			$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
224
+			$all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
225 225
 		}
226 226
 		return $all;
227 227
 	}
228
-	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
228
+	public function countAllMarineTypes($limit = true, $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -234,23 +234,23 @@  discard block
 block discarded – undo
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236 236
 				$sth->execute(array(':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242 242
 		if (empty($all)) {
243
-			$filters = array('year' => $year,'month' => $month);
243
+			$filters = array('year' => $year, 'month' => $month);
244 244
 			if ($filter_name != '') {
245
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Marine = new Marine($this->db);
248 248
 			//$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
249
-			$all = $Marine->countAllMarineTypes($limit,0,'',$filters);
249
+			$all = $Marine->countAllMarineTypes($limit, 0, '', $filters);
250 250
 		}
251 251
 		return $all;
252 252
 	}
253
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
253
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
254 254
 		global $globalStatsFilters;
255 255
 		if ($filter_name == '') $filter_name = $this->filter_name;
256 256
 		if ($year == '' && $month == '') {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			try {
260 260
 				$sth = $this->db->prepare($query);
261 261
 				$sth->execute(array(':filter_name' => $filter_name));
262
-			} catch(PDOException $e) {
262
+			} catch (PDOException $e) {
263 263
 				echo "error : ".$e->getMessage();
264 264
 			}
265 265
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -267,32 +267,32 @@  discard block
 block discarded – undo
267 267
 		if (empty($all)) {
268 268
 			$Spotter = new Spotter($this->db);
269 269
 			$filters = array();
270
-			$filters = array('year' => $year,'month' => $month);
270
+			$filters = array('year' => $year, 'month' => $month);
271 271
 			if ($filter_name != '') {
272
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
272
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
273 273
 			}
274 274
 			//$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
275
-			$all = $Spotter->countAllAirlineCountries($limit,$filters);
275
+			$all = $Spotter->countAllAirlineCountries($limit, $filters);
276 276
 		}
277 277
 		return $all;
278 278
 	}
279
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
279
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
280 280
 		global $globalStatsFilters;
281 281
 		if ($filter_name == '') $filter_name = $this->filter_name;
282
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
282
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
283 283
 			$Spotter = new Spotter($this->db);
284
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
284
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
285 285
 			$alliance_airlines = array();
286 286
 			foreach ($airlines as $airline) {
287
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
287
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
288 288
 			}
289 289
 			if ($year == '' && $month == '') {
290
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
291
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
290
+				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
291
+				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
292 292
 				try {
293 293
 					$sth = $this->db->prepare($query);
294 294
 					$sth->execute(array(':filter_name' => $filter_name));
295
-				} catch(PDOException $e) {
295
+				} catch (PDOException $e) {
296 296
 					echo "error : ".$e->getMessage();
297 297
 				}
298 298
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -303,21 +303,21 @@  discard block
 block discarded – undo
303 303
 				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
304 304
 				try {
305 305
 					$sth = $this->db->prepare($query);
306
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
307
-				} catch(PDOException $e) {
306
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
307
+				} catch (PDOException $e) {
308 308
 					echo "error : ".$e->getMessage();
309 309
 				}
310 310
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
311 311
 			} else $all = array();
312 312
 		}
313 313
 		if (empty($all)) {
314
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
315
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
314
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
315
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
316 316
 			} else {
317
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
317
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
318 318
 			}
319 319
 			if ($filter_name != '') {
320
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
320
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
321 321
 			}
322 322
 			$Spotter = new Spotter($this->db);
323 323
 			//$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
@@ -326,23 +326,23 @@  discard block
 block discarded – undo
326 326
 		return $all;
327 327
 	}
328 328
 
329
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
329
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
330 330
 		global $globalStatsFilters;
331 331
 		if ($filter_name == '') $filter_name = $this->filter_name;
332
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
332
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
333 333
 			$Spotter = new Spotter($this->db);
334
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
334
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
335 335
 			$alliance_airlines = array();
336 336
 			foreach ($airlines as $airline) {
337
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
337
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
338 338
 			}
339 339
 			if ($year == '' && $month == '') {
340
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
341
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
340
+				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
341
+				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
342 342
 				try {
343 343
 					$sth = $this->db->prepare($query);
344 344
 					$sth->execute(array(':filter_name' => $filter_name));
345
-				} catch(PDOException $e) {
345
+				} catch (PDOException $e) {
346 346
 					echo "error : ".$e->getMessage();
347 347
 				}
348 348
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -353,61 +353,61 @@  discard block
 block discarded – undo
353 353
 				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
354 354
 				try {
355 355
 					$sth = $this->db->prepare($query);
356
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
357
-				} catch(PDOException $e) {
356
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
357
+				} catch (PDOException $e) {
358 358
 					echo "error : ".$e->getMessage();
359 359
 				}
360 360
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
361 361
 			} else $all = array();
362 362
 		}
363 363
 		if (empty($all)) {
364
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
365
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
364
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
365
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
366 366
 			} else {
367
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
367
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
368 368
 			}
369 369
 			if ($filter_name != '') {
370
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
370
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
371 371
 			}
372 372
 			$Spotter = new Spotter($this->db);
373 373
 			//$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
374
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
374
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
375 375
 		}
376 376
 		return $all;
377 377
 	}
378 378
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
379 379
 		global $globalStatsFilters;
380 380
 		if ($filter_name == '') $filter_name = $this->filter_name;
381
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
381
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
382 382
 			$Spotter = new Spotter($this->db);
383
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
383
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
384 384
 			$alliance_airlines = array();
385 385
 			foreach ($airlines as $airline) {
386
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
386
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
387 387
 			}
388
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
389
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
388
+			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
389
+			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
390 390
 			$query_values = array(':filter_name' => $filter_name);
391 391
 		} else {
392 392
 			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
393 393
 			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
394
-			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
394
+			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
395 395
 		}
396 396
 		try {
397 397
 			$sth = $this->db->prepare($query);
398 398
 			$sth->execute($query_values);
399
-		} catch(PDOException $e) {
399
+		} catch (PDOException $e) {
400 400
 			echo "error : ".$e->getMessage();
401 401
 		}
402 402
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
403 403
 		if (empty($all)) {
404
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
405
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
404
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
405
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
406 406
 			} else {
407
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
407
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
408 408
 			}
409 409
 			if ($filter_name != '') {
410
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
410
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
411 411
 			}
412 412
 			$Spotter = new Spotter($this->db);
413 413
 			//$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		return $all;
417 417
 	}
418 418
 
419
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
419
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
420 420
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
421 421
 		if ($filter_name == '') $filter_name = $this->filter_name;
422 422
 		if ($year == '' && $month == '') {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 			if (isset($forsource)) {
426 426
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
427 427
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
428
-				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
428
+				$query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource);
429 429
 			} else {
430 430
 				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
431 431
 				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 			try {
435 435
 				$sth = $this->db->prepare($query);
436 436
 				$sth->execute($query_values);
437
-			} catch(PDOException $e) {
437
+			} catch (PDOException $e) {
438 438
 				echo "error : ".$e->getMessage();
439 439
 			}
440 440
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -442,32 +442,32 @@  discard block
 block discarded – undo
442 442
                 if (empty($all)) {
443 443
 	                $Spotter = new Spotter($this->db);
444 444
             		$filters = array();
445
-			$filters = array('year' => $year,'month' => $month);
445
+			$filters = array('year' => $year, 'month' => $month);
446 446
             		if ($filter_name != '') {
447
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
447
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
448 448
 			}
449 449
 			//$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
450
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
450
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
451 451
                 }
452 452
                 return $all;
453 453
 	}
454
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
454
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
455 455
 		global $globalStatsFilters;
456 456
 		if ($filter_name == '') $filter_name = $this->filter_name;
457
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
457
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
458 458
 			$Spotter = new Spotter($this->db);
459
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
459
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
460 460
 			$alliance_airlines = array();
461 461
 			foreach ($airlines as $airline) {
462
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
462
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
463 463
 			}
464 464
 			if ($year == '' && $month == '') {
465
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
466
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
465
+				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
466
+				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
467 467
 				try {
468 468
 					$sth = $this->db->prepare($query);
469 469
 					$sth->execute(array(':filter_name' => $filter_name));
470
-				} catch(PDOException $e) {
470
+				} catch (PDOException $e) {
471 471
 					echo "error : ".$e->getMessage();
472 472
 				}
473 473
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -478,45 +478,45 @@  discard block
 block discarded – undo
478 478
 				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
479 479
 				try {
480 480
 					$sth = $this->db->prepare($query);
481
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
482
-				} catch(PDOException $e) {
481
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
482
+				} catch (PDOException $e) {
483 483
 					echo "error : ".$e->getMessage();
484 484
 				}
485 485
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486 486
 			} else $all = array();
487 487
 		}
488 488
 		if (empty($all)) {
489
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
490
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
489
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
490
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
491 491
 			} else {
492
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
492
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
493 493
 			}
494 494
 			if ($filter_name != '') {
495
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
495
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
496 496
 			}
497 497
 			$Spotter = new Spotter($this->db);
498 498
 			//$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
499
-			$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
499
+			$all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
500 500
 		}
501 501
 		return $all;
502 502
 	}
503
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
503
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
504 504
 		global $globalStatsFilters;
505 505
 		if ($filter_name == '') $filter_name = $this->filter_name;
506
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
506
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
507 507
 			$Spotter = new Spotter($this->db);
508
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
508
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
509 509
 			$alliance_airlines = array();
510 510
 			foreach ($airlines as $airline) {
511
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
511
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
512 512
 			}
513 513
 			if ($year == '' && $month == '') {
514
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
515
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
514
+				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
515
+				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
516 516
 				 try {
517 517
 					$sth = $this->db->prepare($query);
518 518
 					$sth->execute(array(':filter_name' => $filter_name));
519
-				} catch(PDOException $e) {
519
+				} catch (PDOException $e) {
520 520
 					echo "error : ".$e->getMessage();
521 521
 				}
522 522
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -527,46 +527,46 @@  discard block
 block discarded – undo
527 527
 				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
528 528
 				 try {
529 529
 					$sth = $this->db->prepare($query);
530
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
531
-				} catch(PDOException $e) {
530
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
531
+				} catch (PDOException $e) {
532 532
 					echo "error : ".$e->getMessage();
533 533
 				}
534 534
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
535 535
 			} else $all = array();
536 536
 		}
537 537
 		if (empty($all)) {
538
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
539
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
538
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
539
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
540 540
 			} else {
541
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
541
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
542 542
 			}
543 543
 			if ($filter_name != '') {
544
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
544
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
545 545
 			}
546 546
 			$Spotter = new Spotter($this->db);
547 547
 			//$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
548
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
548
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
549 549
 		}
550 550
 		return $all;
551 551
 	}
552
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
552
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
553 553
 		$Connection = new Connection($this->db);
554 554
 		if ($filter_name == '') $filter_name = $this->filter_name;
555 555
 		if ($Connection->tableExists('countries')) {
556
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
556
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
557 557
 				$Spotter = new Spotter($this->db);
558
-				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
558
+				$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
559 559
 				if ($year == '' && $month == '') {
560 560
 					$alliance_airlines = array();
561 561
 					foreach ($airlines as $airline) {
562
-						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
562
+						$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
563 563
 					}
564
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
565
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
564
+					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
565
+					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
566 566
 					 try {
567 567
 						$sth = $this->db->prepare($query);
568 568
 						$sth->execute(array(':filter_name' => $filter_name));
569
-					} catch(PDOException $e) {
569
+					} catch (PDOException $e) {
570 570
 						echo "error : ".$e->getMessage();
571 571
 					}
572 572
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
 					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
579 579
 					 try {
580 580
 						$sth = $this->db->prepare($query);
581
-						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
582
-					} catch(PDOException $e) {
581
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
582
+					} catch (PDOException $e) {
583 583
 						echo "error : ".$e->getMessage();
584 584
 					}
585 585
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			return $Spotter->countAllFlightOverCountries($limit);
591 591
 		} else return array();
592 592
 	}
593
-	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
593
+	public function countAllMarineOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
594 594
 		$Connection = new Connection($this->db);
595 595
 		if ($filter_name == '') $filter_name = $this->filter_name;
596 596
 		if ($Connection->tableExists('countries')) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 				 try {
602 602
 					$sth = $this->db->prepare($query);
603 603
 					$sth->execute(array(':filter_name' => $filter_name));
604
-				} catch(PDOException $e) {
604
+				} catch (PDOException $e) {
605 605
 					echo "error : ".$e->getMessage();
606 606
 				}
607 607
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -609,15 +609,15 @@  discard block
 block discarded – undo
609 609
 			if (empty($all)) {
610 610
 				$filters = array();
611 611
 				if ($filter_name != '') {
612
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
612
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
613 613
 				}
614 614
 				$Marine = new Marine($this->db);
615
-				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
615
+				$all = $Marine->countAllMarineOverCountries($limit, 0, '', $filters);
616 616
 			}
617 617
 			return $all;
618 618
 		} else return array();
619 619
 	}
620
-	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
620
+	public function countAllTrackerOverCountries($limit = true, $filter_name = '', $year = '', $month = '') {
621 621
 		global $globalStatsFilters;
622 622
 		$Connection = new Connection($this->db);
623 623
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 				 try {
630 630
 					$sth = $this->db->prepare($query);
631 631
 					$sth->execute(array(':filter_name' => $filter_name));
632
-				} catch(PDOException $e) {
632
+				} catch (PDOException $e) {
633 633
 					echo "error : ".$e->getMessage();
634 634
 				}
635 635
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -638,15 +638,15 @@  discard block
 block discarded – undo
638 638
 			if (empty($all)) {
639 639
 				$filters = array();
640 640
 				if ($filter_name != '') {
641
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
641
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
642 642
 				}
643 643
 				$Tracker = new Tracker($this->db);
644
-				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
644
+				$all = $Tracker->countAllTrackerOverCountries($limit, 0, '', $filters);
645 645
 			}
646 646
 			return $all;
647 647
 		} else return array();
648 648
 	}
649
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
649
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
650 650
 		global $globalStatsFilters;
651 651
 		if ($filter_name == '') $filter_name = $this->filter_name;
652 652
 		if ($year == '' && $month == '') {
@@ -654,41 +654,41 @@  discard block
 block discarded – undo
654 654
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
655 655
 			try {
656 656
 				$sth = $this->db->prepare($query);
657
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
658
-			} catch(PDOException $e) {
657
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
658
+			} catch (PDOException $e) {
659 659
 				echo "error : ".$e->getMessage();
660 660
 			}
661 661
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
662 662
 		} else $all = array();
663 663
 		if (empty($all)) {
664
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
664
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
665 665
 			if ($filter_name != '') {
666
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
666
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
667 667
 			}
668 668
 			$Spotter = new Spotter($this->db);
669 669
 			//$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
670
-			$all = $Spotter->countAllPilots($limit,0,'',$filters);
670
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters);
671 671
 		}
672 672
 		return $all;
673 673
 	}
674 674
 
675
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
675
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
676 676
 		global $globalStatsFilters;
677 677
 		if ($filter_name == '') $filter_name = $this->filter_name;
678
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
678
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
679 679
 			$Spotter = new Spotter($this->db);
680
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
680
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
681 681
 			if ($year == '' && $month == '') {
682 682
 				$alliance_airlines = array();
683 683
 				foreach ($airlines as $airline) {
684
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
684
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
685 685
 				}
686
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
687
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
686
+				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
687
+				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
688 688
 				try {
689 689
 					$sth = $this->db->prepare($query);
690 690
 					$sth->execute(array(':filter_name' => $filter_name));
691
-				} catch(PDOException $e) {
691
+				} catch (PDOException $e) {
692 692
 					echo "error : ".$e->getMessage();
693 693
 				}
694 694
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -699,45 +699,45 @@  discard block
 block discarded – undo
699 699
 				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
700 700
 				try {
701 701
 					$sth = $this->db->prepare($query);
702
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
703
-				} catch(PDOException $e) {
702
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
703
+				} catch (PDOException $e) {
704 704
 					echo "error : ".$e->getMessage();
705 705
 				}
706 706
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
707 707
 			} else $all = array();
708 708
 		}
709 709
 		if (empty($all)) {
710
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
711
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
710
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
711
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
712 712
 			} else {
713
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
713
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
714 714
 			}
715 715
 			if ($filter_name != '') {
716
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
716
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
717 717
 			}
718 718
 			$Spotter = new Spotter($this->db);
719 719
 			//$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
720
-			$all = $Spotter->countAllOwners($limit,0,'',$filters);
720
+			$all = $Spotter->countAllOwners($limit, 0, '', $filters);
721 721
 		}
722 722
 		return $all;
723 723
 	}
724
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
724
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
725 725
 		global $globalStatsFilters;
726 726
 		if ($filter_name == '') $filter_name = $this->filter_name;
727
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
727
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
728 728
 			$Spotter = new Spotter($this->db);
729
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
729
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
730 730
 			if ($year == '' && $month == '') {
731 731
 				$alliance_airlines = array();
732 732
 				foreach ($airlines as $airline) {
733
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
733
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
734 734
 				}
735
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
736
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
735
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
736
+				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
737 737
 				try {
738 738
 					$sth = $this->db->prepare($query);
739 739
 					$sth->execute(array(':filter_name' => $filter_name));
740
-				} catch(PDOException $e) {
740
+				} catch (PDOException $e) {
741 741
 					echo "error : ".$e->getMessage();
742 742
 				}
743 743
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -748,27 +748,27 @@  discard block
 block discarded – undo
748 748
 				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
749 749
 				try {
750 750
 					$sth = $this->db->prepare($query);
751
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
752
-				} catch(PDOException $e) {
751
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
752
+				} catch (PDOException $e) {
753 753
 					echo "error : ".$e->getMessage();
754 754
 				}
755 755
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
756 756
 			} else $all = array();
757 757
 		}
758 758
 		if (empty($all)) {
759
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
760
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
759
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
760
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
761 761
 			} else {
762
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
762
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
763 763
 			}
764 764
 			if ($filter_name != '') {
765
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
765
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
766 766
 			}
767 767
 			$Spotter = new Spotter($this->db);
768 768
 //            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
769 769
   //      		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
770
-			$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
771
-			$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
770
+			$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
771
+			$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
772 772
 			$all = array();
773 773
 			foreach ($pall as $value) {
774 774
 				$icao = $value['airport_departure_icao'];
@@ -784,27 +784,27 @@  discard block
 block discarded – undo
784 784
 			foreach ($all as $key => $row) {
785 785
 				$count[$key] = $row['airport_departure_icao_count'];
786 786
 			}
787
-			array_multisort($count,SORT_DESC,$all);
787
+			array_multisort($count, SORT_DESC, $all);
788 788
 		}
789 789
 		return $all;
790 790
 	}
791
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
791
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
792 792
 		global $globalStatsFilters;
793 793
 		if ($filter_name == '') $filter_name = $this->filter_name;
794
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
794
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
795 795
 			$Spotter = new Spotter($this->db);
796
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
796
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
797 797
 			if ($year == '' && $month == '') {
798 798
 				$alliance_airlines = array();
799 799
 				foreach ($airlines as $airline) {
800
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
800
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
801 801
 				}
802
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
803
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
802
+				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
803
+				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
804 804
 				try {
805 805
 					$sth = $this->db->prepare($query);
806 806
 					$sth->execute(array(':filter_name' => $filter_name));
807
-				} catch(PDOException $e) {
807
+				} catch (PDOException $e) {
808 808
 					echo "error : ".$e->getMessage();
809 809
 				}
810 810
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -815,27 +815,27 @@  discard block
 block discarded – undo
815 815
 				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
816 816
 				try {
817 817
 					$sth = $this->db->prepare($query);
818
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
819
-				} catch(PDOException $e) {
818
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
819
+				} catch (PDOException $e) {
820 820
 					echo "error : ".$e->getMessage();
821 821
 				}
822 822
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
823 823
 			} else $all = array();
824 824
 		}
825 825
 		if (empty($all)) {
826
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
827
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
826
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
827
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
828 828
 			} else {
829
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
829
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
830 830
 			}
831 831
 			if ($filter_name != '') {
832
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
832
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
833 833
 			}
834 834
 			$Spotter = new Spotter($this->db);
835 835
 //			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
836 836
 //			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
837
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
838
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
837
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
838
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
839 839
 			$all = array();
840 840
 			foreach ($pall as $value) {
841 841
 				$icao = $value['airport_arrival_icao'];
@@ -851,26 +851,26 @@  discard block
 block discarded – undo
851 851
 			foreach ($all as $key => $row) {
852 852
 				$count[$key] = $row['airport_arrival_icao_count'];
853 853
 			}
854
-			array_multisort($count,SORT_DESC,$all);
854
+			array_multisort($count, SORT_DESC, $all);
855 855
 		}
856 856
 		return $all;
857 857
 	}
858
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
858
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
859 859
 		global $globalDBdriver, $globalStatsFilters;
860 860
 		if ($filter_name == '') $filter_name = $this->filter_name;
861
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
861
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
862 862
 			$Spotter = new Spotter($this->db);
863
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
863
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
864 864
 			$alliance_airlines = array();
865 865
 			foreach ($airlines as $airline) {
866
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
866
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
867 867
 			}
868 868
 			if ($globalDBdriver == 'mysql') {
869
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
870
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
869
+				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
870
+				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
871 871
 			} else {
872
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
872
+				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
873
+				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
874 874
 			}
875 875
 			$query_data = array(':filter_name' => $filter_name);
876 876
 		} else {
@@ -881,23 +881,23 @@  discard block
 block discarded – undo
881 881
 				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
882 882
 				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
883 883
 			}
884
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
884
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
885 885
 		}
886 886
 		try {
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_data);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			echo "error : ".$e->getMessage();
891 891
 		}
892 892
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
893 893
 		if (empty($all)) {
894
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
895
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
894
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
895
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
896 896
 			} else {
897 897
 				$filters = array('airlines' => array($stats_airline));
898 898
 			}
899 899
 			if ($filter_name != '') {
900
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
900
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
901 901
 			}
902 902
 			$Spotter = new Spotter($this->db);
903 903
 			$all = $Spotter->countAllMonthsLastYear($filters);
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 		return $all;
906 906
 	}
907 907
 
908
-	public function countAllMarineMonthsLastYear($limit = true,$filter_name = '') {
908
+	public function countAllMarineMonthsLastYear($limit = true, $filter_name = '') {
909 909
 		global $globalDBdriver, $globalStatsFilters;
910 910
 		if ($filter_name == '') $filter_name = $this->filter_name;
911 911
 		if ($globalDBdriver == 'mysql') {
@@ -919,14 +919,14 @@  discard block
 block discarded – undo
919 919
 		try {
920 920
 			$sth = $this->db->prepare($query);
921 921
 			$sth->execute($query_data);
922
-		} catch(PDOException $e) {
922
+		} catch (PDOException $e) {
923 923
 			echo "error : ".$e->getMessage();
924 924
 		}
925 925
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
926 926
 		if (empty($all)) {
927 927
 			$filters = array();
928 928
 			if ($filter_name != '') {
929
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
929
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
930 930
 			}
931 931
 			$Marine = new Marine($this->db);
932 932
 			$all = $Marine->countAllMonthsLastYear($filters);
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 		return $all;
935 935
 	}
936 936
 
937
-	public function countAllTrackerMonthsLastYear($limit = true,$filter_name = '') {
937
+	public function countAllTrackerMonthsLastYear($limit = true, $filter_name = '') {
938 938
 		global $globalDBdriver, $globalStatsFilters;
939 939
 		if ($filter_name == '') $filter_name = $this->filter_name;
940 940
 		if ($globalDBdriver == 'mysql') {
@@ -948,14 +948,14 @@  discard block
 block discarded – undo
948 948
 		try {
949 949
 			$sth = $this->db->prepare($query);
950 950
 			$sth->execute($query_data);
951
-		} catch(PDOException $e) {
951
+		} catch (PDOException $e) {
952 952
 			echo "error : ".$e->getMessage();
953 953
 		}
954 954
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
955 955
 		if (empty($all)) {
956 956
 			$filters = array();
957 957
 			if ($filter_name != '') {
958
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
958
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
959 959
 			}
960 960
 			$Tracker = new Tracker($this->db);
961 961
 			$all = $Tracker->countAllMonthsLastYear($filters);
@@ -963,37 +963,37 @@  discard block
 block discarded – undo
963 963
 		return $all;
964 964
 	}
965 965
 	
966
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
966
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
967 967
 		global $globalStatsFilters;
968 968
 		if ($filter_name == '') $filter_name = $this->filter_name;
969
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
969
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
970 970
 			$Spotter = new Spotter($this->db);
971
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
971
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
972 972
 			$alliance_airlines = array();
973 973
 			foreach ($airlines as $airline) {
974
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
974
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
975 975
 			}
976
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
976
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline  IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
977 977
 			$query_data = array(':filter_name' => $filter_name);
978 978
 		} else {
979 979
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
980
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
980
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
981 981
 		}
982 982
 		try {
983 983
 			$sth = $this->db->prepare($query);
984 984
 			$sth->execute($query_data);
985
-		} catch(PDOException $e) {
985
+		} catch (PDOException $e) {
986 986
 			echo "error : ".$e->getMessage();
987 987
 		}
988 988
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
989 989
 		if (empty($all)) {
990
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
991
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
990
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
991
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
992 992
 			} else {
993 993
 				$filters = array('airlines' => array($stats_airline));
994 994
 			}
995 995
 			if ($filter_name != '') {
996
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
996
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
997 997
 			}
998 998
 			$Spotter = new Spotter($this->db);
999 999
 			$all = $Spotter->countAllDatesLastMonth($filters);
@@ -1008,14 +1008,14 @@  discard block
 block discarded – undo
1008 1008
 		try {
1009 1009
 			$sth = $this->db->prepare($query);
1010 1010
 			$sth->execute($query_data);
1011
-		} catch(PDOException $e) {
1011
+		} catch (PDOException $e) {
1012 1012
 			echo "error : ".$e->getMessage();
1013 1013
 		}
1014 1014
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1015 1015
 		if (empty($all)) {
1016 1016
 			$filters = array();
1017 1017
 			if ($filter_name != '') {
1018
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1018
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1019 1019
 			}
1020 1020
 			$Marine = new Marine($this->db);
1021 1021
 			$all = $Marine->countAllDatesLastMonth($filters);
@@ -1030,34 +1030,34 @@  discard block
 block discarded – undo
1030 1030
 		try {
1031 1031
 			$sth = $this->db->prepare($query);
1032 1032
 			$sth->execute($query_data);
1033
-		} catch(PDOException $e) {
1033
+		} catch (PDOException $e) {
1034 1034
 			echo "error : ".$e->getMessage();
1035 1035
 		}
1036 1036
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1037 1037
 		if (empty($all)) {
1038 1038
 			$filters = array();
1039 1039
 			if ($filter_name != '') {
1040
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1040
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1041 1041
 			}
1042 1042
 			$Tracker = new Tracker($this->db);
1043 1043
 			$all = $Tracker->countAllDatesLastMonth($filters);
1044 1044
 		}
1045 1045
 		return $all;
1046 1046
 	}
1047
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
1047
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
1048 1048
 		global $globalDBdriver, $globalStatsFilters;
1049 1049
 		if ($filter_name == '') $filter_name = $this->filter_name;
1050
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1050
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1051 1051
 			$Spotter = new Spotter($this->db);
1052
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1052
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1053 1053
 			$alliance_airlines = array();
1054 1054
 			foreach ($airlines as $airline) {
1055
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1055
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1056 1056
 			}
1057 1057
 			if ($globalDBdriver == 'mysql') {
1058
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1058
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1059 1059
 			} else {
1060
-				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1060
+				$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1061 1061
 			}
1062 1062
 			$query_data = array(':filter_name' => $filter_name);
1063 1063
 		} else {
@@ -1066,23 +1066,23 @@  discard block
 block discarded – undo
1066 1066
 			} else {
1067 1067
 				$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1068 1068
 			}
1069
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1069
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1070 1070
 		}
1071 1071
 		try {
1072 1072
 			$sth = $this->db->prepare($query);
1073 1073
 			$sth->execute($query_data);
1074
-		} catch(PDOException $e) {
1074
+		} catch (PDOException $e) {
1075 1075
 			echo "error : ".$e->getMessage();
1076 1076
 		}
1077 1077
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1078 1078
 		if (empty($all)) {
1079
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1080
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1079
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1080
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1081 1081
 			} else {
1082 1082
 				$filters = array('airlines' => array($stats_airline));
1083 1083
 			}
1084 1084
 			if ($filter_name != '') {
1085
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1085
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1086 1086
 			}
1087 1087
 			$Spotter = new Spotter($this->db);
1088 1088
 			$all = $Spotter->countAllDatesLast7Days($filters);
@@ -1101,14 +1101,14 @@  discard block
 block discarded – undo
1101 1101
 		try {
1102 1102
 			$sth = $this->db->prepare($query);
1103 1103
 			$sth->execute($query_data);
1104
-		} catch(PDOException $e) {
1104
+		} catch (PDOException $e) {
1105 1105
 			echo "error : ".$e->getMessage();
1106 1106
 		}
1107 1107
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1108 1108
 		if (empty($all)) {
1109 1109
 			$filters = array();
1110 1110
 			if ($filter_name != '') {
1111
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1111
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1112 1112
 			}
1113 1113
 			$Marine = new Marine($this->db);
1114 1114
 			$all = $Marine->countAllDatesLast7Days($filters);
@@ -1127,51 +1127,51 @@  discard block
 block discarded – undo
1127 1127
 		try {
1128 1128
 			$sth = $this->db->prepare($query);
1129 1129
 			$sth->execute($query_data);
1130
-		} catch(PDOException $e) {
1130
+		} catch (PDOException $e) {
1131 1131
 			echo "error : ".$e->getMessage();
1132 1132
 		}
1133 1133
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1134 1134
 		if (empty($all)) {
1135 1135
 			$filters = array();
1136 1136
 			if ($filter_name != '') {
1137
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1137
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1138 1138
 			}
1139 1139
 			$Tracker = new Tracker($this->db);
1140 1140
 			$all = $Tracker->countAllDatesLast7Days($filters);
1141 1141
 		}
1142 1142
 		return $all;
1143 1143
 	}
1144
-	public function countAllDates($stats_airline = '',$filter_name = '') {
1144
+	public function countAllDates($stats_airline = '', $filter_name = '') {
1145 1145
 		global $globalStatsFilters;
1146 1146
 		if ($filter_name == '') $filter_name = $this->filter_name;
1147
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1147
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1148 1148
 			$Spotter = new Spotter($this->db);
1149
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1149
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1150 1150
 			$alliance_airlines = array();
1151 1151
 			foreach ($airlines as $airline) {
1152
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1152
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1153 1153
 			}
1154
-			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1154
+			$query = "SELECT flight_date as date_name, SUM(cnt) as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date ORDER BY date_count DESC";
1155 1155
 			$query_data = array(':filter_name' => $filter_name);
1156 1156
 		} else {
1157 1157
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC";
1158
-			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1158
+			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1159 1159
 		}
1160 1160
 		try {
1161 1161
 			$sth = $this->db->prepare($query);
1162 1162
 			$sth->execute($query_data);
1163
-		} catch(PDOException $e) {
1163
+		} catch (PDOException $e) {
1164 1164
 			echo "error : ".$e->getMessage();
1165 1165
 		}
1166 1166
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1167 1167
 		if (empty($all)) {
1168
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1169
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1168
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1169
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1170 1170
 			} else {
1171 1171
 				$filters = array('airlines' => array($stats_airline));
1172 1172
 			}
1173 1173
 			if ($filter_name != '') {
1174
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1174
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1175 1175
 			}
1176 1176
 			$Spotter = new Spotter($this->db);
1177 1177
 			$all = $Spotter->countAllDates($filters);
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		try {
1187 1187
 			$sth = $this->db->prepare($query);
1188 1188
 			$sth->execute($query_data);
1189
-		} catch(PDOException $e) {
1189
+		} catch (PDOException $e) {
1190 1190
 			echo "error : ".$e->getMessage();
1191 1191
 		}
1192 1192
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 		try {
1209 1209
 			$sth = $this->db->prepare($query);
1210 1210
 			$sth->execute($query_data);
1211
-		} catch(PDOException $e) {
1211
+		} catch (PDOException $e) {
1212 1212
 			echo "error : ".$e->getMessage();
1213 1213
 		}
1214 1214
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1230,34 +1230,34 @@  discard block
 block discarded – undo
1230 1230
 		try {
1231 1231
 			$sth = $this->db->prepare($query);
1232 1232
 			$sth->execute($query_data);
1233
-		} catch(PDOException $e) {
1233
+		} catch (PDOException $e) {
1234 1234
 			echo "error : ".$e->getMessage();
1235 1235
 		}
1236 1236
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1237 1237
 		if (empty($all)) {
1238 1238
 			$filters = array();
1239 1239
 			if ($filter_name != '') {
1240
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1240
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1241 1241
 			}
1242 1242
 			$Spotter = new Spotter($this->db);
1243 1243
 			$all = $Spotter->countAllDatesByAirlines($filters);
1244 1244
 		}
1245 1245
 		return $all;
1246 1246
 	}
1247
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
1247
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
1248 1248
 		global $globalStatsFilters, $globalDBdriver;
1249 1249
 		if ($filter_name == '') $filter_name = $this->filter_name;
1250
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1250
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1251 1251
 			$Spotter = new Spotter($this->db);
1252
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1252
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1253 1253
 			$alliance_airlines = array();
1254 1254
 			foreach ($airlines as $airline) {
1255
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1255
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1256 1256
 			}
1257 1257
 			if ($globalDBdriver == 'mysql') {
1258
-				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1258
+				$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1259 1259
 			} else {
1260
-				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1260
+				$query = "SELECT EXTRACT(YEAR FROM stats_date) AS year_name,EXTRACT(MONTH FROM stats_date) AS month_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date ORDER BY date_count DESC";
1261 1261
 			}
1262 1262
 			$query_data = array(':filter_name' => $filter_name);
1263 1263
 		} else {
@@ -1271,18 +1271,18 @@  discard block
 block discarded – undo
1271 1271
 		try {
1272 1272
 			$sth = $this->db->prepare($query);
1273 1273
 			$sth->execute($query_data);
1274
-		} catch(PDOException $e) {
1274
+		} catch (PDOException $e) {
1275 1275
 			echo "error : ".$e->getMessage();
1276 1276
 		}
1277 1277
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1278 1278
 		if (empty($all)) {
1279
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1280
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1279
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1280
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1281 1281
 			} else {
1282 1282
 				$filters = array('airlines' => array($stats_airline));
1283 1283
 			}
1284 1284
 			if ($filter_name != '') {
1285
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1285
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1286 1286
 			}
1287 1287
 			$Spotter = new Spotter($this->db);
1288 1288
 			$all = $Spotter->countAllMonths($filters);
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 		try {
1300 1300
 			$sth = $this->db->prepare($query);
1301 1301
 			$sth->execute();
1302
-		} catch(PDOException $e) {
1302
+		} catch (PDOException $e) {
1303 1303
 			echo "error : ".$e->getMessage();
1304 1304
 		}
1305 1305
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 		try {
1320 1320
 			$sth = $this->db->prepare($query);
1321 1321
 			$sth->execute();
1322
-		} catch(PDOException $e) {
1322
+		} catch (PDOException $e) {
1323 1323
 			echo "error : ".$e->getMessage();
1324 1324
 		}
1325 1325
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1336,32 +1336,32 @@  discard block
 block discarded – undo
1336 1336
 		try {
1337 1337
 			$sth = $this->db->prepare($query);
1338 1338
 			$sth->execute(array(':filter_name' => $filter_name));
1339
-		} catch(PDOException $e) {
1339
+		} catch (PDOException $e) {
1340 1340
 			echo "error : ".$e->getMessage();
1341 1341
 		}
1342 1342
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1343 1343
 		if (empty($all)) {
1344 1344
 			$filters = array();
1345 1345
 			if ($filter_name != '') {
1346
-					$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1346
+					$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1347 1347
 			}
1348 1348
 			$Spotter = new Spotter($this->db);
1349 1349
 			$all = $Spotter->countAllMilitaryMonths($filters);
1350 1350
 		}
1351 1351
 		return $all;
1352 1352
 	}
1353
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1353
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
1354 1354
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1355 1355
 		if ($filter_name == '') $filter_name = $this->filter_name;
1356
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1356
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1357 1357
 			$Spotter = new Spotter($this->db);
1358
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1358
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1359 1359
 			$alliance_airlines = array();
1360 1360
 			foreach ($airlines as $airline) {
1361
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1361
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1362 1362
 			}
1363
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1364
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1363
+			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1364
+			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1365 1365
 			$query_data = array(':filter_name' => $filter_name);
1366 1366
 		} else {
1367 1367
 			if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1379,25 +1379,25 @@  discard block
 block discarded – undo
1379 1379
 		try {
1380 1380
 			$sth = $this->db->prepare($query);
1381 1381
 			$sth->execute($query_data);
1382
-		} catch(PDOException $e) {
1382
+		} catch (PDOException $e) {
1383 1383
 			echo "error : ".$e->getMessage();
1384 1384
 		}
1385 1385
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1386 1386
 		if (empty($all)) {
1387
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1388
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1387
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1388
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1389 1389
 			} else {
1390 1390
 				$filters = array('airlines' => array($stats_airline));
1391 1391
 			}
1392 1392
 			if ($filter_name != '') {
1393
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1393
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1394 1394
 			}
1395 1395
 			$Spotter = new Spotter($this->db);
1396
-			$all = $Spotter->countAllHours($orderby,$filters);
1396
+			$all = $Spotter->countAllHours($orderby, $filters);
1397 1397
 		}
1398 1398
 		return $all;
1399 1399
 	}
1400
-	public function countAllMarineHours($orderby = 'hour',$limit = true,$filter_name = '') {
1400
+	public function countAllMarineHours($orderby = 'hour', $limit = true, $filter_name = '') {
1401 1401
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1402 1402
 		if ($filter_name == '') $filter_name = $this->filter_name;
1403 1403
 		if ($limit) $query = "SELECT marine_date as hour_name, cnt as hour_count FROM stats_marine WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1414,21 +1414,21 @@  discard block
 block discarded – undo
1414 1414
 		try {
1415 1415
 			$sth = $this->db->prepare($query);
1416 1416
 			$sth->execute($query_data);
1417
-		} catch(PDOException $e) {
1417
+		} catch (PDOException $e) {
1418 1418
 			echo "error : ".$e->getMessage();
1419 1419
 		}
1420 1420
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1421 1421
 		if (empty($all)) {
1422 1422
 			$filters = array();
1423 1423
 			if ($filter_name != '') {
1424
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1424
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1425 1425
 			}
1426 1426
 			$Marine = new Marine($this->db);
1427
-			$all = $Marine->countAllHours($orderby,$filters);
1427
+			$all = $Marine->countAllHours($orderby, $filters);
1428 1428
 		}
1429 1429
 		return $all;
1430 1430
 	}
1431
-	public function countAllTrackerHours($orderby = 'hour',$limit = true,$filter_name = '') {
1431
+	public function countAllTrackerHours($orderby = 'hour', $limit = true, $filter_name = '') {
1432 1432
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1433 1433
 		if ($filter_name == '') $filter_name = $this->filter_name;
1434 1434
 		if ($limit) $query = "SELECT tracker_date as hour_name, cnt as hour_count FROM stats_tracker WHERE stats_type = 'hour' AND filter_name = :filter_name";
@@ -1445,33 +1445,33 @@  discard block
 block discarded – undo
1445 1445
 		try {
1446 1446
 			$sth = $this->db->prepare($query);
1447 1447
 			$sth->execute($query_data);
1448
-		} catch(PDOException $e) {
1448
+		} catch (PDOException $e) {
1449 1449
 			echo "error : ".$e->getMessage();
1450 1450
 		}
1451 1451
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1452 1452
 		if (empty($all)) {
1453 1453
 			$filters = array();
1454 1454
 			if ($filter_name != '') {
1455
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1455
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1456 1456
 			}
1457 1457
 			$Tracker = new Tracker($this->db);
1458
-			$all = $Tracker->countAllHours($orderby,$filters);
1458
+			$all = $Tracker->countAllHours($orderby, $filters);
1459 1459
 		}
1460 1460
 		return $all;
1461 1461
 	}
1462
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1462
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1463 1463
 		global $globalStatsFilters;
1464 1464
 		if ($filter_name == '') $filter_name = $this->filter_name;
1465 1465
 		if ($year == '') $year = date('Y');
1466
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1466
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
1467 1467
 		if (empty($all)) {
1468
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1469
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1468
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1469
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1470 1470
 			} else {
1471
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1471
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1472 1472
 			}
1473 1473
 			if ($filter_name != '') {
1474
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1474
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1475 1475
 			}
1476 1476
 			$Spotter = new Spotter($this->db);
1477 1477
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1479,15 +1479,15 @@  discard block
 block discarded – undo
1479 1479
 		}
1480 1480
 		return $all;
1481 1481
 	}
1482
-	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1482
+	public function countOverallMarine($filter_name = '', $year = '', $month = '') {
1483 1483
 		global $globalStatsFilters;
1484 1484
 		if ($filter_name == '') $filter_name = $this->filter_name;
1485 1485
 		if ($year == '') $year = date('Y');
1486
-		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1486
+		$all = $this->getSumStats('marine_bymonth', $year, '', $filter_name, $month);
1487 1487
 		if (empty($all)) {
1488
-			$filters = array('year' => $year,'month' => $month);
1488
+			$filters = array('year' => $year, 'month' => $month);
1489 1489
 			if ($filter_name != '') {
1490
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1490
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1491 1491
 			}
1492 1492
 			$Marine = new Marine($this->db);
1493 1493
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1495,15 +1495,15 @@  discard block
 block discarded – undo
1495 1495
 		}
1496 1496
 		return $all;
1497 1497
 	}
1498
-	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1498
+	public function countOverallTracker($filter_name = '', $year = '', $month = '') {
1499 1499
 		global $globalStatsFilters;
1500 1500
 		if ($filter_name == '') $filter_name = $this->filter_name;
1501 1501
 		if ($year == '') $year = date('Y');
1502
-		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1502
+		$all = $this->getSumStats('tracker_bymonth', $year, '', $filter_name, $month);
1503 1503
 		if (empty($all)) {
1504
-			$filters = array('year' => $year,'month' => $month);
1504
+			$filters = array('year' => $year, 'month' => $month);
1505 1505
 			if ($filter_name != '') {
1506
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1506
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1507 1507
 			}
1508 1508
 			$Tracker = new Tracker($this->db);
1509 1509
 			//$all = $Spotter->countOverallFlights($filters,$year,$month);
@@ -1511,16 +1511,16 @@  discard block
 block discarded – undo
1511 1511
 		}
1512 1512
 		return $all;
1513 1513
 	}
1514
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1514
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
1515 1515
 		global $globalStatsFilters;
1516 1516
 		if ($filter_name == '') $filter_name = $this->filter_name;
1517 1517
 		if ($year == '') $year = date('Y');
1518
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1518
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
1519 1519
 		if (empty($all)) {
1520 1520
 			$filters = array();
1521
-			$filters = array('year' => $year,'month' => $month);
1521
+			$filters = array('year' => $year, 'month' => $month);
1522 1522
 			if ($filter_name != '') {
1523
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1523
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1524 1524
 			}
1525 1525
 			$Spotter = new Spotter($this->db);
1526 1526
 			//$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -1528,19 +1528,19 @@  discard block
 block discarded – undo
1528 1528
 		}
1529 1529
 		return $all;
1530 1530
 	}
1531
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1531
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1532 1532
 		global $globalStatsFilters;
1533 1533
 		if ($filter_name == '') $filter_name = $this->filter_name;
1534 1534
 		if ($year == '') $year = date('Y');
1535
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1535
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
1536 1536
 		if (empty($all)) {
1537
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1538
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1537
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1538
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1539 1539
 			} else {
1540
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1540
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1541 1541
 			}
1542 1542
 			if ($filter_name != '') {
1543
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1543
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1544 1544
 			}
1545 1545
 			$Spotter = new Spotter($this->db);
1546 1546
 			//$all = $Spotter->countOverallArrival($filters,$year,$month);
@@ -1548,48 +1548,48 @@  discard block
 block discarded – undo
1548 1548
 		}
1549 1549
 		return $all;
1550 1550
 	}
1551
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1551
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1552 1552
 		global $globalStatsFilters;
1553 1553
 		if ($filter_name == '') $filter_name = $this->filter_name;
1554
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1554
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1555 1555
 			$Spotter = new Spotter($this->db);
1556
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1556
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1557 1557
 			if ($year == '' && $month == '') {
1558 1558
 				$alliance_airlines = array();
1559 1559
 				foreach ($airlines as $airline) {
1560
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1560
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1561 1561
 				}
1562
-				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1562
+				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1563 1563
 				try {
1564 1564
 					$sth = $this->db->prepare($query);
1565 1565
 					$sth->execute(array(':filter_name' => $filter_name));
1566
-				} catch(PDOException $e) {
1566
+				} catch (PDOException $e) {
1567 1567
 					echo "error : ".$e->getMessage();
1568 1568
 				}
1569 1569
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1570 1570
 				$all = $result[0]['nb'];
1571
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1571
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1572 1572
 		} else {
1573 1573
 			if ($year == '' && $month == '') {
1574 1574
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1575 1575
 				try {
1576 1576
 					$sth = $this->db->prepare($query);
1577
-					$sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline));
1578
-				} catch(PDOException $e) {
1577
+					$sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline));
1578
+				} catch (PDOException $e) {
1579 1579
 					echo "error : ".$e->getMessage();
1580 1580
 				}
1581 1581
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1582 1582
 				$all = $result[0]['nb'];
1583
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1583
+			} else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
1584 1584
 		}
1585 1585
 		if (empty($all)) {
1586
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1587
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1586
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1587
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1588 1588
 			} else {
1589
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1589
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1590 1590
 			}
1591 1591
 			if ($filter_name != '') {
1592
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1592
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1593 1593
 			}
1594 1594
 			$Spotter = new Spotter($this->db);
1595 1595
 			//$all = $Spotter->countOverallAircrafts($filters,$year,$month);
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
 		}
1598 1598
 		return $all;
1599 1599
 	}
1600
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1600
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
1601 1601
 		global $globalStatsFilters;
1602 1602
 		if ($filter_name == '') $filter_name = $this->filter_name;
1603 1603
 		if ($year == '' && $month == '') {
@@ -1605,17 +1605,17 @@  discard block
 block discarded – undo
1605 1605
 			try {
1606 1606
 				$sth = $this->db->prepare($query);
1607 1607
 				$sth->execute(array(':filter_name' => $filter_name));
1608
-			} catch(PDOException $e) {
1608
+			} catch (PDOException $e) {
1609 1609
 				echo "error : ".$e->getMessage();
1610 1610
 			}
1611 1611
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1612 1612
 			$all = $result[0]['nb_airline'];
1613
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1613
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
1614 1614
 		if (empty($all)) {
1615 1615
 			$filters = array();
1616
-			$filters = array('year' => $year,'month' => $month);
1616
+			$filters = array('year' => $year, 'month' => $month);
1617 1617
 			if ($filter_name != '') {
1618
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1618
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1619 1619
 			}
1620 1620
 			$Spotter = new Spotter($this->db);
1621 1621
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 		}
1624 1624
 		return $all;
1625 1625
 	}
1626
-	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1626
+	public function countOverallMarineTypes($filter_name = '', $year = '', $month = '') {
1627 1627
 		global $globalStatsFilters;
1628 1628
 		if ($filter_name == '') $filter_name = $this->filter_name;
1629 1629
 		$all = array();
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 			try {
1633 1633
 				$sth = $this->db->prepare($query);
1634 1634
 				$sth->execute(array(':filter_name' => $filter_name));
1635
-			} catch(PDOException $e) {
1635
+			} catch (PDOException $e) {
1636 1636
 				echo "error : ".$e->getMessage();
1637 1637
 			}
1638 1638
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1640,9 +1640,9 @@  discard block
 block discarded – undo
1640 1640
 		}
1641 1641
 		if (empty($all)) {
1642 1642
 			$filters = array();
1643
-			$filters = array('year' => $year,'month' => $month);
1643
+			$filters = array('year' => $year, 'month' => $month);
1644 1644
 			if ($filter_name != '') {
1645
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1645
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1646 1646
 			}
1647 1647
 			$Marine = new Marine($this->db);
1648 1648
 			//$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -1650,29 +1650,29 @@  discard block
 block discarded – undo
1650 1650
 		}
1651 1651
 		return $all;
1652 1652
 	}
1653
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1653
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1654 1654
 		global $globalStatsFilters;
1655 1655
 		if ($filter_name == '') $filter_name = $this->filter_name;
1656
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1656
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1657 1657
 			$Spotter = new Spotter($this->db);
1658
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1658
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1659 1659
 			if ($year == '' && $month == '') {
1660 1660
 				$alliance_airlines = array();
1661 1661
 				foreach ($airlines as $airline) {
1662
-					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1662
+					$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1663 1663
 				}
1664
-				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1664
+				$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1665 1665
 				$query_values = array(':filter_name' => $filter_name);
1666 1666
 				try {
1667 1667
 					$sth = $this->db->prepare($query);
1668 1668
 					$sth->execute($query_values);
1669
-				} catch(PDOException $e) {
1669
+				} catch (PDOException $e) {
1670 1670
 					echo "error : ".$e->getMessage();
1671 1671
 				}
1672 1672
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1673 1673
 				$all = $result[0]['nb'];
1674 1674
 			} else {
1675
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1675
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1676 1676
 			}
1677 1677
 		} else {
1678 1678
 			if ($year == '' && $month == '') {
@@ -1681,23 +1681,23 @@  discard block
 block discarded – undo
1681 1681
 				try {
1682 1682
 					$sth = $this->db->prepare($query);
1683 1683
 					$sth->execute($query_values);
1684
-				} catch(PDOException $e) {
1684
+				} catch (PDOException $e) {
1685 1685
 					echo "error : ".$e->getMessage();
1686 1686
 				}
1687 1687
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1688 1688
 				$all = $result[0]['nb'];
1689 1689
 			} else {
1690
-				$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
1690
+				$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
1691 1691
 			}
1692 1692
 		}
1693 1693
 		if (empty($all)) {
1694
-			if (strpos($stats_airline,'alliance_') !== FALSE) {
1695
-				$filters = array('alliance' => str_replace('_',' ',str_replace('alliance_','',$stats_airline)),'year' => $year,'month' => $month);
1694
+			if (strpos($stats_airline, 'alliance_') !== FALSE) {
1695
+				$filters = array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)), 'year' => $year, 'month' => $month);
1696 1696
 			} else {
1697
-				$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1697
+				$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1698 1698
 			}
1699 1699
 			if ($filter_name != '') {
1700
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1700
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1701 1701
 			}
1702 1702
 			$Spotter = new Spotter($this->db);
1703 1703
 			//$all = $Spotter->countOverallOwners($filters,$year,$month);
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 		}
1706 1706
 		return $all;
1707 1707
 	}
1708
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1708
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
1709 1709
 		global $globalStatsFilters;
1710 1710
 		if ($filter_name == '') $filter_name = $this->filter_name;
1711 1711
 		//if ($year == '') $year = date('Y');
@@ -1715,18 +1715,18 @@  discard block
 block discarded – undo
1715 1715
 			try {
1716 1716
 				$sth = $this->db->prepare($query);
1717 1717
 				$sth->execute($query_values);
1718
-			} catch(PDOException $e) {
1718
+			} catch (PDOException $e) {
1719 1719
 				echo "error : ".$e->getMessage();
1720 1720
 			}
1721 1721
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1722 1722
 			$all = $result[0]['nb'];
1723 1723
 		} else {
1724
-			$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
1724
+			$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
1725 1725
 		}
1726 1726
 		if (empty($all)) {
1727
-			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
1727
+			$filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month);
1728 1728
 			if ($filter_name != '') {
1729
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
1729
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
1730 1730
 			}
1731 1731
 			$Spotter = new Spotter($this->db);
1732 1732
 			//$all = $Spotter->countOverallPilots($filters,$year,$month);
@@ -1735,104 +1735,104 @@  discard block
 block discarded – undo
1735 1735
 		return $all;
1736 1736
 	}
1737 1737
 
1738
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1738
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
1739 1739
 		if ($filter_name == '') $filter_name = $this->filter_name;
1740
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1740
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1741 1741
 			$Spotter = new Spotter($this->db);
1742
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1742
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1743 1743
 			$alliance_airlines = array();
1744 1744
 			foreach ($airlines as $airline) {
1745
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1745
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1746 1746
 			}
1747
-			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1748
-			$query_values = array(':airport_icao' => $airport_icao,':filter_name' => $filter_name);
1747
+			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name ORDER BY date";
1748
+			$query_values = array(':airport_icao' => $airport_icao, ':filter_name' => $filter_name);
1749 1749
 		} else {
1750 1750
 			$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
1751
-			$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1751
+			$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1752 1752
 		}
1753 1753
 		try {
1754 1754
 			$sth = $this->db->prepare($query);
1755 1755
 			$sth->execute($query_values);
1756
-		} catch(PDOException $e) {
1756
+		} catch (PDOException $e) {
1757 1757
 			echo "error : ".$e->getMessage();
1758 1758
 		}
1759 1759
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1760 1760
 		return $all;
1761 1761
 	}
1762
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
1762
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
1763 1763
 		if ($filter_name == '') $filter_name = $this->filter_name;
1764 1764
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1765
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1765
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1766 1766
 		try {
1767 1767
 			$sth = $this->db->prepare($query);
1768 1768
 			$sth->execute($query_values);
1769
-		} catch(PDOException $e) {
1769
+		} catch (PDOException $e) {
1770 1770
 			echo "error : ".$e->getMessage();
1771 1771
 		}
1772 1772
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1773 1773
 		return $all;
1774 1774
 	}
1775
-	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1775
+	public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') {
1776 1776
 		if ($filter_name == '') $filter_name = $this->filter_name;
1777 1777
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1778
-		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1778
+		$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1779 1779
 		try {
1780 1780
 			$sth = $this->db->prepare($query);
1781 1781
 			$sth->execute($query_values);
1782
-		} catch(PDOException $e) {
1782
+		} catch (PDOException $e) {
1783 1783
 			echo "error : ".$e->getMessage();
1784 1784
 		}
1785 1785
 	}
1786
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1786
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
1787 1787
 		if ($filter_name == '') $filter_name = $this->filter_name;
1788 1788
 		global $globalArchiveMonths, $globalDBdriver;
1789
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1789
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1790 1790
 			$Spotter = new Spotter($this->db);
1791
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1791
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1792 1792
 			$alliance_airlines = array();
1793 1793
 			foreach ($airlines as $airline) {
1794
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1794
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1795 1795
 			}
1796 1796
 			if ($globalDBdriver == 'mysql') {
1797 1797
 				if ($month == '') {
1798
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1798
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1799 1799
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1800 1800
 				} else {
1801
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1802
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1801
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1802
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1803 1803
 				}
1804 1804
 			} else {
1805 1805
 				if ($month == '') {
1806
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1806
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1807 1807
 					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name);
1808 1808
 				} else {
1809
-					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1810
-					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name,':month' => $month);
1809
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1810
+					$query_values = array(':type' => $type, ':year' => $year, ':filter_name' => $filter_name, ':month' => $month);
1811 1811
 				}
1812 1812
 			}
1813 1813
 		} else {
1814 1814
 			if ($globalDBdriver == 'mysql') {
1815 1815
 				if ($month == '') {
1816 1816
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
1817
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1817
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1818 1818
 				} else {
1819 1819
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1820
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1820
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1821 1821
 				}
1822 1822
 			} else {
1823 1823
 				if ($month == '') {
1824 1824
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
1825
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1825
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1826 1826
 				} else {
1827 1827
 					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
1828
-					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
1828
+					$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
1829 1829
 				}
1830 1830
 			}
1831 1831
 		}
1832 1832
 		try {
1833 1833
 			$sth = $this->db->prepare($query);
1834 1834
 			$sth->execute($query_values);
1835
-		} catch(PDOException $e) {
1835
+		} catch (PDOException $e) {
1836 1836
 			echo "error : ".$e->getMessage();
1837 1837
 		}
1838 1838
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1841,17 +1841,17 @@  discard block
 block discarded – undo
1841 1841
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1842 1842
 		global $globalArchiveMonths, $globalDBdriver;
1843 1843
 		if ($filter_name == '') $filter_name = $this->filter_name;
1844
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1844
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1845 1845
 			$Spotter = new Spotter($this->db);
1846
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1846
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1847 1847
 			$alliance_airlines = array();
1848 1848
 			foreach ($airlines as $airline) {
1849
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1849
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1850 1850
 			}
1851 1851
 			if ($globalDBdriver == 'mysql') {
1852
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1852
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1853 1853
 			} else {
1854
-				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1854
+				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1855 1855
 			}
1856 1856
 			$query_values = array(':type' => $type, ':filter_name' => $filter_name);
1857 1857
 		} else {
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 		try {
1866 1866
 			$sth = $this->db->prepare($query);
1867 1867
 			$sth->execute($query_values);
1868
-		} catch(PDOException $e) {
1868
+		} catch (PDOException $e) {
1869 1869
 			echo "error : ".$e->getMessage();
1870 1870
 		}
1871 1871
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1874,17 +1874,17 @@  discard block
 block discarded – undo
1874 1874
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1875 1875
 		global $globalArchiveMonths, $globalDBdriver;
1876 1876
 		if ($filter_name == '') $filter_name = $this->filter_name;
1877
-		if (strpos($stats_airline,'alliance_') !== FALSE) {
1877
+		if (strpos($stats_airline, 'alliance_') !== FALSE) {
1878 1878
 			$Spotter = new Spotter($this->db);
1879
-			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
1879
+			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_', ' ', str_replace('alliance_', '', $stats_airline)));
1880 1880
 			$alliance_airlines = array();
1881 1881
 			foreach ($airlines as $airline) {
1882
-				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1882
+				$alliance_airlines = array_merge($alliance_airlines, array($airline['airline_icao']));
1883 1883
 			}
1884 1884
 			if ($globalDBdriver == 'mysql') {
1885
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1885
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1886 1886
 			} else {
1887
-				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name";
1887
+				$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline IN ('".implode("','", $alliance_airlines)."') AND filter_name = :filter_name";
1888 1888
 			}
1889 1889
 		} else {
1890 1890
 			if ($globalDBdriver == 'mysql') {
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 		try {
1897 1897
 			$sth = $this->db->prepare($query);
1898 1898
 			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
1899
-		} catch(PDOException $e) {
1899
+		} catch (PDOException $e) {
1900 1900
 			echo "error : ".$e->getMessage();
1901 1901
 		}
1902 1902
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 		try {
1914 1914
 			$sth = $this->db->prepare($query);
1915 1915
 			$sth->execute(array(':filter_name' => $filter_name));
1916
-		} catch(PDOException $e) {
1916
+		} catch (PDOException $e) {
1917 1917
 			echo "error : ".$e->getMessage();
1918 1918
 		}
1919 1919
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1930,20 +1930,20 @@  discard block
 block discarded – undo
1930 1930
 		try {
1931 1931
 			$sth = $this->db->prepare($query);
1932 1932
 			$sth->execute(array(':filter_name' => $filter_name));
1933
-		} catch(PDOException $e) {
1933
+		} catch (PDOException $e) {
1934 1934
 			echo "error : ".$e->getMessage();
1935 1935
 		}
1936 1936
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1937 1937
 		return $all[0]['total'];
1938 1938
 	}
1939
-	public function getStatsOwner($owner_name,$filter_name = '') {
1939
+	public function getStatsOwner($owner_name, $filter_name = '') {
1940 1940
 		global $globalArchiveMonths, $globalDBdriver;
1941 1941
 		if ($filter_name == '') $filter_name = $this->filter_name;
1942 1942
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1943 1943
 		try {
1944 1944
 			$sth = $this->db->prepare($query);
1945
-			$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
1946
-		} catch(PDOException $e) {
1945
+			$sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name));
1946
+		} catch (PDOException $e) {
1947 1947
 			echo "error : ".$e->getMessage();
1948 1948
 		}
1949 1949
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1961,20 +1961,20 @@  discard block
 block discarded – undo
1961 1961
 		try {
1962 1962
 			$sth = $this->db->prepare($query);
1963 1963
 			$sth->execute(array(':filter_name' => $filter_name));
1964
-		} catch(PDOException $e) {
1964
+		} catch (PDOException $e) {
1965 1965
 			echo "error : ".$e->getMessage();
1966 1966
 		}
1967 1967
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1968 1968
 		return $all[0]['total'];
1969 1969
 	}
1970
-	public function getStatsPilot($pilot,$filter_name = '') {
1970
+	public function getStatsPilot($pilot, $filter_name = '') {
1971 1971
 		global $globalArchiveMonths, $globalDBdriver;
1972 1972
 		if ($filter_name == '') $filter_name = $this->filter_name;
1973 1973
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1974 1974
 		try {
1975 1975
 			$sth = $this->db->prepare($query);
1976
-			$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1977
-		} catch(PDOException $e) {
1976
+			$sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot));
1977
+		} catch (PDOException $e) {
1978 1978
 			echo "error : ".$e->getMessage();
1979 1979
 		}
1980 1980
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 		else return 0;
1983 1983
 	}
1984 1984
 
1985
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1985
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
1986 1986
 		global $globalDBdriver;
1987 1987
 		if ($filter_name == '') $filter_name = $this->filter_name;
1988 1988
 		if ($globalDBdriver == 'mysql') {
@@ -1990,15 +1990,15 @@  discard block
 block discarded – undo
1990 1990
 		} else {
1991 1991
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1992 1992
 		}
1993
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1993
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1994 1994
 		try {
1995 1995
 			$sth = $this->db->prepare($query);
1996 1996
 			$sth->execute($query_values);
1997
-		} catch(PDOException $e) {
1997
+		} catch (PDOException $e) {
1998 1998
 			return "error : ".$e->getMessage();
1999 1999
 		}
2000 2000
 	}
2001
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
2001
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
2002 2002
 		global $globalDBdriver;
2003 2003
 		if ($filter_name == '') $filter_name = $this->filter_name;
2004 2004
 		if ($globalDBdriver == 'mysql') {
@@ -2007,11 +2007,11 @@  discard block
 block discarded – undo
2007 2007
 			//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
2008 2008
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2009 2009
 		}
2010
-		$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2010
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2011 2011
 		try {
2012 2012
 			$sth = $this->db->prepare($query);
2013 2013
 			$sth->execute($query_values);
2014
-		} catch(PDOException $e) {
2014
+		} catch (PDOException $e) {
2015 2015
 			return "error : ".$e->getMessage();
2016 2016
 		}
2017 2017
 	}
@@ -2035,95 +2035,95 @@  discard block
 block discarded – undo
2035 2035
         }
2036 2036
         */
2037 2037
 
2038
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
2038
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
2039 2039
 		global $globalDBdriver;
2040 2040
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
2041 2041
 		$query_values = array();
2042 2042
 		if ($globalDBdriver == 'mysql') {
2043 2043
 			if ($year != '') {
2044 2044
 				$query .= ' AND YEAR(stats_date) = :year';
2045
-				$query_values = array_merge($query_values,array(':year' => $year));
2045
+				$query_values = array_merge($query_values, array(':year' => $year));
2046 2046
 			}
2047 2047
 			if ($month != '') {
2048 2048
 				$query .= ' AND MONTH(stats_date) = :month';
2049
-				$query_values = array_merge($query_values,array(':month' => $month));
2049
+				$query_values = array_merge($query_values, array(':month' => $month));
2050 2050
 			}
2051 2051
 			if ($day != '') {
2052 2052
 				$query .= ' AND DAY(stats_date) = :day';
2053
-				$query_values = array_merge($query_values,array(':day' => $day));
2053
+				$query_values = array_merge($query_values, array(':day' => $day));
2054 2054
 			}
2055 2055
 		} else {
2056 2056
 			if ($year != '') {
2057 2057
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
2058
-				$query_values = array_merge($query_values,array(':year' => $year));
2058
+				$query_values = array_merge($query_values, array(':year' => $year));
2059 2059
 			}
2060 2060
 			if ($month != '') {
2061 2061
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
2062
-				$query_values = array_merge($query_values,array(':month' => $month));
2062
+				$query_values = array_merge($query_values, array(':month' => $month));
2063 2063
 			}
2064 2064
 			if ($day != '') {
2065 2065
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
2066
-				$query_values = array_merge($query_values,array(':day' => $day));
2066
+				$query_values = array_merge($query_values, array(':day' => $day));
2067 2067
 			}
2068 2068
 		}
2069 2069
 		$query .= " ORDER BY source_name";
2070
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
2070
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
2071 2071
 		try {
2072 2072
 			$sth = $this->db->prepare($query);
2073 2073
 			$sth->execute($query_values);
2074
-		} catch(PDOException $e) {
2074
+		} catch (PDOException $e) {
2075 2075
 			echo "error : ".$e->getMessage();
2076 2076
 		}
2077 2077
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
2078 2078
 		return $all;
2079 2079
 	}
2080 2080
 
2081
-	public function addStatSource($data,$source_name,$stats_type,$date) {
2081
+	public function addStatSource($data, $source_name, $stats_type, $date) {
2082 2082
 		global $globalDBdriver;
2083 2083
 		if ($globalDBdriver == 'mysql') {
2084 2084
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
2085 2085
 		} else {
2086 2086
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
2087 2087
 		}
2088
-		$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
2088
+		$query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
2089 2089
 		try {
2090 2090
 			$sth = $this->db->prepare($query);
2091 2091
 			$sth->execute($query_values);
2092
-		} catch(PDOException $e) {
2092
+		} catch (PDOException $e) {
2093 2093
 			return "error : ".$e->getMessage();
2094 2094
 		}
2095 2095
 	}
2096
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
2096
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
2097 2097
 		$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
2098
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2098
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2099 2099
 		try {
2100 2100
 			$sth = $this->db->prepare($query);
2101 2101
 			$sth->execute($query_values);
2102
-		} catch(PDOException $e) {
2102
+		} catch (PDOException $e) {
2103 2103
 			return "error : ".$e->getMessage();
2104 2104
 		}
2105 2105
 	}
2106
-	public function addStatMarine($type,$date_name,$cnt,$filter_name = '') {
2106
+	public function addStatMarine($type, $date_name, $cnt, $filter_name = '') {
2107 2107
 		$query = "INSERT INTO stats_marine (stats_type,marine_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2108
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2108
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2109 2109
 		try {
2110 2110
 			$sth = $this->db->prepare($query);
2111 2111
 			$sth->execute($query_values);
2112
-		} catch(PDOException $e) {
2112
+		} catch (PDOException $e) {
2113 2113
 			return "error : ".$e->getMessage();
2114 2114
 		}
2115 2115
 	}
2116
-	public function addStatTracker($type,$date_name,$cnt,$filter_name = '') {
2116
+	public function addStatTracker($type, $date_name, $cnt, $filter_name = '') {
2117 2117
 		$query = "INSERT INTO stats_tracker (stats_type,tracker_date,cnt,filter_name) VALUES (:type,:flight_date,:cnt,:filter_name)";
2118
-		$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt,':filter_name' => $filter_name);
2118
+		$query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2119 2119
 		try {
2120 2120
 			$sth = $this->db->prepare($query);
2121 2121
 			$sth->execute($query_values);
2122
-		} catch(PDOException $e) {
2122
+		} catch (PDOException $e) {
2123 2123
 			return "error : ".$e->getMessage();
2124 2124
 		}
2125 2125
 	}
2126
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
2126
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
2127 2127
 		global $globalDBdriver;
2128 2128
 		if ($globalDBdriver == 'mysql') {
2129 2129
 			if ($reset) {
@@ -2138,15 +2138,15 @@  discard block
 block discarded – undo
2138 2138
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2139 2139
 			}
2140 2140
 		}
2141
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2141
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2142 2142
 		try {
2143 2143
 			$sth = $this->db->prepare($query);
2144 2144
 			$sth->execute($query_values);
2145
-		} catch(PDOException $e) {
2145
+		} catch (PDOException $e) {
2146 2146
 			return "error : ".$e->getMessage();
2147 2147
 		}
2148 2148
 	}
2149
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
2149
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2150 2150
 		global $globalDBdriver;
2151 2151
 		if ($globalDBdriver == 'mysql') {
2152 2152
 			if ($reset) {
@@ -2161,15 +2161,15 @@  discard block
 block discarded – undo
2161 2161
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
2162 2162
 			}
2163 2163
 		}
2164
-		$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
2164
+		$query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
2165 2165
 		try {
2166 2166
 			$sth = $this->db->prepare($query);
2167 2167
 			$sth->execute($query_values);
2168
-		} catch(PDOException $e) {
2168
+		} catch (PDOException $e) {
2169 2169
 			return "error : ".$e->getMessage();
2170 2170
 		}
2171 2171
 	}
2172
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
2172
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
2173 2173
 		global $globalDBdriver;
2174 2174
 		if ($globalDBdriver == 'mysql') {
2175 2175
 			if ($reset) {
@@ -2184,15 +2184,15 @@  discard block
 block discarded – undo
2184 2184
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
2185 2185
 			}
2186 2186
 		}
2187
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
2187
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
2188 2188
 		try {
2189 2189
 			$sth = $this->db->prepare($query);
2190 2190
 			$sth->execute($query_values);
2191
-		} catch(PDOException $e) {
2191
+		} catch (PDOException $e) {
2192 2192
 			return "error : ".$e->getMessage();
2193 2193
 		}
2194 2194
 	}
2195
-	public function addStatCountryMarine($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2195
+	public function addStatCountryMarine($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2196 2196
 		global $globalDBdriver;
2197 2197
 		if ($globalDBdriver == 'mysql') {
2198 2198
 			if ($reset) {
@@ -2207,15 +2207,15 @@  discard block
 block discarded – undo
2207 2207
 				$query = "UPDATE stats_marine_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_marine_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2208 2208
 			}
2209 2209
 		}
2210
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2210
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2211 2211
 		try {
2212 2212
 			$sth = $this->db->prepare($query);
2213 2213
 			$sth->execute($query_values);
2214
-		} catch(PDOException $e) {
2214
+		} catch (PDOException $e) {
2215 2215
 			return "error : ".$e->getMessage();
2216 2216
 		}
2217 2217
 	}
2218
-	public function addStatCountryTracker($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
2218
+	public function addStatCountryTracker($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
2219 2219
 		global $globalDBdriver;
2220 2220
 		if ($globalDBdriver == 'mysql') {
2221 2221
 			if ($reset) {
@@ -2230,15 +2230,15 @@  discard block
 block discarded – undo
2230 2230
 				$query = "UPDATE stats_tracker_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_tracker_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
2231 2231
 			}
2232 2232
 		}
2233
-		$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
2233
+		$query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2234 2234
 		try {
2235 2235
 			$sth = $this->db->prepare($query);
2236 2236
 			$sth->execute($query_values);
2237
-		} catch(PDOException $e) {
2237
+		} catch (PDOException $e) {
2238 2238
 			return "error : ".$e->getMessage();
2239 2239
 		}
2240 2240
 	}
2241
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2241
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
2242 2242
 		global $globalDBdriver;
2243 2243
 		if ($globalDBdriver == 'mysql') {
2244 2244
 			if ($reset) {
@@ -2253,15 +2253,15 @@  discard block
 block discarded – undo
2253 2253
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2254 2254
 			}
2255 2255
 		}
2256
-		$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2256
+		$query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2257 2257
 		try {
2258 2258
 			$sth = $this->db->prepare($query);
2259 2259
 			$sth->execute($query_values);
2260
-		} catch(PDOException $e) {
2260
+		} catch (PDOException $e) {
2261 2261
 			return "error : ".$e->getMessage();
2262 2262
 		}
2263 2263
 	}
2264
-	public function addStatMarineType($type,$type_id,$cnt, $filter_name = '', $reset = false) {
2264
+	public function addStatMarineType($type, $type_id, $cnt, $filter_name = '', $reset = false) {
2265 2265
 		global $globalDBdriver;
2266 2266
 		if ($globalDBdriver == 'mysql') {
2267 2267
 			if ($reset) {
@@ -2276,15 +2276,15 @@  discard block
 block discarded – undo
2276 2276
 				$query = "UPDATE stats_marine_type SET cnt = cnt+:cnt, type = :type, filter_name = :filter_name WHERE type_id = :type_id AND filter_name = :filter_name; INSERT INTO stats_marine_type (type,type_id,cnt,filter_name) SELECT :type,:type_id,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_marine_type WHERE type_id = :type_id AND filter_name = :filter_name);"; 
2277 2277
 			}
2278 2278
 		}
2279
-		$query_values = array(':type' => $type,':type_id' => $type_id,':cnt' => $cnt, ':filter_name' => $filter_name);
2279
+		$query_values = array(':type' => $type, ':type_id' => $type_id, ':cnt' => $cnt, ':filter_name' => $filter_name);
2280 2280
 		try {
2281 2281
 			$sth = $this->db->prepare($query);
2282 2282
 			$sth->execute($query_values);
2283
-		} catch(PDOException $e) {
2283
+		} catch (PDOException $e) {
2284 2284
 			return "error : ".$e->getMessage();
2285 2285
 		}
2286 2286
 	}
2287
-	public function addStatTrackerType($type,$cnt, $filter_name = '', $reset = false) {
2287
+	public function addStatTrackerType($type, $cnt, $filter_name = '', $reset = false) {
2288 2288
 		global $globalDBdriver;
2289 2289
 		if ($globalDBdriver == 'mysql') {
2290 2290
 			if ($reset) {
@@ -2299,15 +2299,15 @@  discard block
 block discarded – undo
2299 2299
 				$query = "UPDATE stats_tracker_type SET cnt = cnt+:cnt WHERE type = :type AND filter_name = :filter_name; INSERT INTO stats_tracker_type (type,cnt,filter_name) SELECT :type,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_tracker_type WHERE type = :type AND filter_name = :filter_name);"; 
2300 2300
 			}
2301 2301
 		}
2302
-		$query_values = array(':type' => $type,':cnt' => $cnt, ':filter_name' => $filter_name);
2302
+		$query_values = array(':type' => $type, ':cnt' => $cnt, ':filter_name' => $filter_name);
2303 2303
 		try {
2304 2304
 			$sth = $this->db->prepare($query);
2305 2305
 			$sth->execute($query_values);
2306
-		} catch(PDOException $e) {
2306
+		} catch (PDOException $e) {
2307 2307
 			return "error : ".$e->getMessage();
2308 2308
 		}
2309 2309
 	}
2310
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
2310
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
2311 2311
 		global $globalDBdriver;
2312 2312
 		if ($globalDBdriver == 'mysql') {
2313 2313
 			if ($reset) {
@@ -2322,15 +2322,15 @@  discard block
 block discarded – undo
2322 2322
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
2323 2323
 			}
2324 2324
 		}
2325
-		$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
2325
+		$query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
2326 2326
 		try {
2327 2327
 			$sth = $this->db->prepare($query);
2328 2328
 			$sth->execute($query_values);
2329
-		} catch(PDOException $e) {
2329
+		} catch (PDOException $e) {
2330 2330
 			return "error : ".$e->getMessage();
2331 2331
 		}
2332 2332
 	}
2333
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
2333
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
2334 2334
 		global $globalDBdriver;
2335 2335
 		if ($globalDBdriver == 'mysql') {
2336 2336
 			if ($reset) {
@@ -2345,15 +2345,15 @@  discard block
 block discarded – undo
2345 2345
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2346 2346
 			}
2347 2347
 		}
2348
-		$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
2348
+		$query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
2349 2349
 		try {
2350 2350
 			$sth = $this->db->prepare($query);
2351 2351
 			$sth->execute($query_values);
2352
-		} catch(PDOException $e) {
2352
+		} catch (PDOException $e) {
2353 2353
 			return "error : ".$e->getMessage();
2354 2354
 		}
2355 2355
 	}
2356
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
2356
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
2357 2357
 		global $globalDBdriver;
2358 2358
 		if ($globalDBdriver == 'mysql') {
2359 2359
 			if ($reset) {
@@ -2368,15 +2368,15 @@  discard block
 block discarded – undo
2368 2368
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
2369 2369
 			}
2370 2370
 		}
2371
-		$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
2371
+		$query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
2372 2372
 		try {
2373 2373
 			$sth = $this->db->prepare($query);
2374 2374
 			$sth->execute($query_values);
2375
-		} catch(PDOException $e) {
2375
+		} catch (PDOException $e) {
2376 2376
 			return "error : ".$e->getMessage();
2377 2377
 		}
2378 2378
 	}
2379
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
2379
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
2380 2380
 		global $globalDBdriver;
2381 2381
 		if ($airport_icao != '') {
2382 2382
 			if ($globalDBdriver == 'mysql') {
@@ -2392,16 +2392,16 @@  discard block
 block discarded – undo
2392 2392
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
2393 2393
 				}
2394 2394
 			}
2395
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2395
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2396 2396
 			try {
2397 2397
 				$sth = $this->db->prepare($query);
2398 2398
 				$sth->execute($query_values);
2399
-			} catch(PDOException $e) {
2399
+			} catch (PDOException $e) {
2400 2400
 				return "error : ".$e->getMessage();
2401 2401
 			}
2402 2402
 		}
2403 2403
 	}
2404
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
2404
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
2405 2405
 		global $globalDBdriver;
2406 2406
 		if ($airport_icao != '') {
2407 2407
 			if ($globalDBdriver == 'mysql') {
@@ -2409,16 +2409,16 @@  discard block
 block discarded – undo
2409 2409
 			} else {
2410 2410
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2411 2411
 			}
2412
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2412
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2413 2413
 			 try {
2414 2414
 				$sth = $this->db->prepare($query);
2415 2415
 				$sth->execute($query_values);
2416
-			} catch(PDOException $e) {
2416
+			} catch (PDOException $e) {
2417 2417
 				return "error : ".$e->getMessage();
2418 2418
 			}
2419 2419
 		}
2420 2420
 	}
2421
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
2421
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
2422 2422
 		global $globalDBdriver;
2423 2423
 		if ($airport_icao != '') {
2424 2424
 			if ($globalDBdriver == 'mysql') {
@@ -2434,16 +2434,16 @@  discard block
 block discarded – undo
2434 2434
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
2435 2435
 				}
2436 2436
 			}
2437
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2437
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2438 2438
 			try {
2439 2439
 				$sth = $this->db->prepare($query);
2440 2440
 				$sth->execute($query_values);
2441
-			} catch(PDOException $e) {
2441
+			} catch (PDOException $e) {
2442 2442
 				return "error : ".$e->getMessage();
2443 2443
 			}
2444 2444
 		}
2445 2445
 	}
2446
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
2446
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
2447 2447
 		global $globalDBdriver;
2448 2448
 		if ($airport_icao != '') {
2449 2449
 			if ($globalDBdriver == 'mysql') {
@@ -2451,11 +2451,11 @@  discard block
 block discarded – undo
2451 2451
 			} else {
2452 2452
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
2453 2453
 			}
2454
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
2454
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
2455 2455
 			try {
2456 2456
 				$sth = $this->db->prepare($query);
2457 2457
 				$sth->execute($query_values);
2458
-			} catch(PDOException $e) {
2458
+			} catch (PDOException $e) {
2459 2459
 				return "error : ".$e->getMessage();
2460 2460
 			}
2461 2461
 		}
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
 		try {
2468 2468
 			$sth = $this->db->prepare($query);
2469 2469
 			$sth->execute($query_values);
2470
-		} catch(PDOException $e) {
2470
+		} catch (PDOException $e) {
2471 2471
 			return "error : ".$e->getMessage();
2472 2472
 		}
2473 2473
 	}
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
 		try {
2478 2478
 			$sth = $this->db->prepare($query);
2479 2479
 			$sth->execute($query_values);
2480
-		} catch(PDOException $e) {
2480
+		} catch (PDOException $e) {
2481 2481
 			return "error : ".$e->getMessage();
2482 2482
 		}
2483 2483
 	}
@@ -2487,7 +2487,7 @@  discard block
 block discarded – undo
2487 2487
 		try {
2488 2488
 			$sth = $this->db->prepare($query);
2489 2489
 			$sth->execute($query_values);
2490
-		} catch(PDOException $e) {
2490
+		} catch (PDOException $e) {
2491 2491
 			return "error : ".$e->getMessage();
2492 2492
 		}
2493 2493
 	}
@@ -2497,7 +2497,7 @@  discard block
 block discarded – undo
2497 2497
 		try {
2498 2498
 			$sth = $this->db->prepare($query);
2499 2499
 			$sth->execute($query_values);
2500
-		} catch(PDOException $e) {
2500
+		} catch (PDOException $e) {
2501 2501
 			return "error : ".$e->getMessage();
2502 2502
 		}
2503 2503
 	}
@@ -2507,13 +2507,13 @@  discard block
 block discarded – undo
2507 2507
 		try {
2508 2508
 			$sth = $this->db->prepare($query);
2509 2509
 			$sth->execute($query_values);
2510
-		} catch(PDOException $e) {
2510
+		} catch (PDOException $e) {
2511 2511
 			return "error : ".$e->getMessage();
2512 2512
 		}
2513 2513
 	}
2514 2514
 
2515 2515
 	public function addOldStats() {
2516
-		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents;
2516
+		global $globalMasterServer, $globalAircraft, $globalMarine, $globalTracker, $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents;
2517 2517
 		$Common = new Common();
2518 2518
 		$Connection = new Connection($this->db);
2519 2519
 		date_default_timezone_set('UTC');
@@ -2528,9 +2528,9 @@  discard block
 block discarded – undo
2528 2528
 			$filtername = 'marine';
2529 2529
 			if ($Connection->tableExists('countries')) {
2530 2530
 				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2531
-				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2531
+				$alldata = $Marine->countAllMarineOverCountries(false, 0, $last_update_day);
2532 2532
 				foreach ($alldata as $number) {
2533
-					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2533
+					echo $this->addStatCountryMarine($number['marine_country_iso2'], $number['marine_country_iso3'], $number['marine_country'], $number['marine_count'], '', '', $reset);
2534 2534
 				}
2535 2535
 			}
2536 2536
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2540,44 +2540,44 @@  discard block
 block discarded – undo
2540 2540
 			$lastyear = false;
2541 2541
 			foreach ($alldata as $number) {
2542 2542
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2543
-				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2543
+				$this->addStat('marine_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2544 2544
 			}
2545 2545
 			echo 'Marine data...'."\n";
2546 2546
 			$this->deleteStatMarine('month');
2547 2547
 			echo '-> countAllDatesLastMonth...'."\n";
2548 2548
 			$alldata = $Marine->countAllDatesLastMonth($filter_last_month);
2549 2549
 			foreach ($alldata as $number) {
2550
-				$this->addStatMarine('month',$number['date_name'],$number['date_count']);
2550
+				$this->addStatMarine('month', $number['date_name'], $number['date_count']);
2551 2551
 			}
2552 2552
 			echo '-> countAllDates...'."\n";
2553 2553
 			$previousdata = $this->countAllDatesMarine();
2554 2554
 			$this->deleteStatMarine('date');
2555
-			$alldata = $Common->array_merge_noappend($previousdata,$Marine->countAllDates($filter_last_month));
2555
+			$alldata = $Common->array_merge_noappend($previousdata, $Marine->countAllDates($filter_last_month));
2556 2556
 			$values = array();
2557 2557
 			foreach ($alldata as $cnt) {
2558 2558
 				$values[] = $cnt['date_count'];
2559 2559
 			}
2560
-			array_multisort($values,SORT_DESC,$alldata);
2561
-			array_splice($alldata,11);
2560
+			array_multisort($values, SORT_DESC, $alldata);
2561
+			array_splice($alldata, 11);
2562 2562
 			foreach ($alldata as $number) {
2563
-				$this->addStatMarine('date',$number['date_name'],$number['date_count']);
2563
+				$this->addStatMarine('date', $number['date_name'], $number['date_count']);
2564 2564
 			}
2565 2565
 			
2566 2566
 			$this->deleteStatMarine('hour');
2567 2567
 			echo '-> countAllHours...'."\n";
2568
-			$alldata = $Marine->countAllHours('hour',$filter_last_month);
2568
+			$alldata = $Marine->countAllHours('hour', $filter_last_month);
2569 2569
 			foreach ($alldata as $number) {
2570
-				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2570
+				$this->addStatMarine('hour', $number['hour_name'], $number['hour_count']);
2571 2571
 			}
2572 2572
 			if ($globalDebug) echo 'Count all types...'."\n";
2573
-			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2573
+			$alldata = $Marine->countAllMarineTypes(false, 0, $last_update_day);
2574 2574
 			foreach ($alldata as $number) {
2575
-				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
2575
+				$this->addStatMarineType($number['marine_type'], $number['marine_type_id'], $number['marine_type_count'], '', $reset);
2576 2576
 			}
2577 2577
 
2578 2578
 			echo 'Insert last stats update date...'."\n";
2579 2579
 			date_default_timezone_set('UTC');
2580
-			$this->addLastStatsUpdate('last_update_stats_marine',date('Y-m-d G:i:s'));
2580
+			$this->addLastStatsUpdate('last_update_stats_marine', date('Y-m-d G:i:s'));
2581 2581
 		}
2582 2582
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2583 2583
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
@@ -2589,9 +2589,9 @@  discard block
 block discarded – undo
2589 2589
 			$Tracker = new Tracker($this->db);
2590 2590
 			if ($Connection->tableExists('countries')) {
2591 2591
 				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2592
-				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2592
+				$alldata = $Tracker->countAllTrackerOverCountries(false, 0, $last_update_day);
2593 2593
 				foreach ($alldata as $number) {
2594
-					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2594
+					$this->addStatCountryTracker($number['tracker_country_iso2'], $number['tracker_country_iso3'], $number['tracker_country'], $number['tracker_count'], '', '', $reset);
2595 2595
 				}
2596 2596
 			}
2597 2597
 			if ($globalDebug) echo 'Count all vessels by months...'."\n";
@@ -2601,43 +2601,43 @@  discard block
 block discarded – undo
2601 2601
 			$lastyear = false;
2602 2602
 			foreach ($alldata as $number) {
2603 2603
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2604
-				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2604
+				$this->addStat('tracker_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2605 2605
 			}
2606 2606
 			echo 'Tracker data...'."\n";
2607 2607
 			$this->deleteStatTracker('month');
2608 2608
 			echo '-> countAllDatesLastMonth...'."\n";
2609 2609
 			$alldata = $Tracker->countAllDatesLastMonth($filter_last_month);
2610 2610
 			foreach ($alldata as $number) {
2611
-				$this->addStatTracker('month',$number['date_name'],$number['date_count']);
2611
+				$this->addStatTracker('month', $number['date_name'], $number['date_count']);
2612 2612
 			}
2613 2613
 			echo '-> countAllDates...'."\n";
2614 2614
 			$previousdata = $this->countAllDatesTracker();
2615 2615
 			$this->deleteStatTracker('date');
2616
-			$alldata = $Common->array_merge_noappend($previousdata,$Tracker->countAllDates($filter_last_month));
2616
+			$alldata = $Common->array_merge_noappend($previousdata, $Tracker->countAllDates($filter_last_month));
2617 2617
 			$values = array();
2618 2618
 			foreach ($alldata as $cnt) {
2619 2619
 				$values[] = $cnt['date_count'];
2620 2620
 			}
2621
-			array_multisort($values,SORT_DESC,$alldata);
2622
-			array_splice($alldata,11);
2621
+			array_multisort($values, SORT_DESC, $alldata);
2622
+			array_splice($alldata, 11);
2623 2623
 			foreach ($alldata as $number) {
2624
-				$this->addStatTracker('date',$number['date_name'],$number['date_count']);
2624
+				$this->addStatTracker('date', $number['date_name'], $number['date_count']);
2625 2625
 			}
2626 2626
 			
2627 2627
 			$this->deleteStatTracker('hour');
2628 2628
 			echo '-> countAllHours...'."\n";
2629
-			$alldata = $Tracker->countAllHours('hour',$filter_last_month);
2629
+			$alldata = $Tracker->countAllHours('hour', $filter_last_month);
2630 2630
 			foreach ($alldata as $number) {
2631
-				$this->addStatTracker('hour',$number['hour_name'],$number['hour_count']);
2631
+				$this->addStatTracker('hour', $number['hour_name'], $number['hour_count']);
2632 2632
 			}
2633 2633
 			if ($globalDebug) echo 'Count all types...'."\n";
2634
-			$alldata = $Tracker->countAllTrackerTypes(false,0,$last_update_day);
2634
+			$alldata = $Tracker->countAllTrackerTypes(false, 0, $last_update_day);
2635 2635
 			foreach ($alldata as $number) {
2636
-				$this->addStatTrackerType($number['tracker_type'],$number['tracker_type_count'],'',$reset);
2636
+				$this->addStatTrackerType($number['tracker_type'], $number['tracker_type_count'], '', $reset);
2637 2637
 			}
2638 2638
 			echo 'Insert last stats update date...'."\n";
2639 2639
 			date_default_timezone_set('UTC');
2640
-			$this->addLastStatsUpdate('last_update_stats_tracker',date('Y-m-d G:i:s'));
2640
+			$this->addLastStatsUpdate('last_update_stats_tracker', date('Y-m-d G:i:s'));
2641 2641
 		}
2642 2642
 
2643 2643
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
@@ -2655,41 +2655,41 @@  discard block
 block discarded – undo
2655 2655
 			$Spotter = new Spotter($this->db);
2656 2656
 
2657 2657
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2658
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2658
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
2659 2659
 			foreach ($alldata as $number) {
2660
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2660
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
2661 2661
 			}
2662 2662
 			if ($globalDebug) echo 'Count all airlines...'."\n";
2663
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2663
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
2664 2664
 			foreach ($alldata as $number) {
2665
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2665
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
2666 2666
 			}
2667 2667
 			if ($globalDebug) echo 'Count all registrations...'."\n";
2668
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2668
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
2669 2669
 			foreach ($alldata as $number) {
2670
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2670
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
2671 2671
 			}
2672 2672
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
2673
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2673
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
2674 2674
 			foreach ($alldata as $number) {
2675
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2675
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2676 2676
 			}
2677 2677
 			if ($globalDebug) echo 'Count all owners...'."\n";
2678
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2678
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
2679 2679
 			foreach ($alldata as $number) {
2680
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2680
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
2681 2681
 			}
2682 2682
 			if ($globalDebug) echo 'Count all pilots...'."\n";
2683
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2683
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
2684 2684
 			foreach ($alldata as $number) {
2685 2685
 				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2686
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2686
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
2687 2687
 			}
2688 2688
 			
2689 2689
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
2690
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2690
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
2691 2691
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2692
-			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2692
+			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
2693 2693
 			if ($globalDebug) echo 'Order departure airports...'."\n";
2694 2694
 			$alldata = array();
2695 2695
 			foreach ($pall as $value) {
@@ -2706,14 +2706,14 @@  discard block
 block discarded – undo
2706 2706
 			foreach ($alldata as $key => $row) {
2707 2707
 				$count[$key] = $row['airport_departure_icao_count'];
2708 2708
 			}
2709
-			array_multisort($count,SORT_DESC,$alldata);
2709
+			array_multisort($count, SORT_DESC, $alldata);
2710 2710
 			foreach ($alldata as $number) {
2711
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
2711
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
2712 2712
 			}
2713 2713
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2714
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2714
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
2715 2715
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2716
-			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2716
+			$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
2717 2717
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
2718 2718
 			$alldata = array();
2719 2719
 			foreach ($pall as $value) {
@@ -2730,18 +2730,18 @@  discard block
 block discarded – undo
2730 2730
 			foreach ($alldata as $key => $row) {
2731 2731
 				$count[$key] = $row['airport_arrival_icao_count'];
2732 2732
 			}
2733
-			array_multisort($count,SORT_DESC,$alldata);
2733
+			array_multisort($count, SORT_DESC, $alldata);
2734 2734
 			foreach ($alldata as $number) {
2735
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
2735
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
2736 2736
 			}
2737 2737
 			if ($Connection->tableExists('countries')) {
2738 2738
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2739 2739
 				//$SpotterArchive = new SpotterArchive();
2740 2740
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2741 2741
 				$Spotter = new Spotter($this->db);
2742
-				$alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day);
2742
+				$alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day);
2743 2743
 				foreach ($alldata as $number) {
2744
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
2744
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
2745 2745
 				}
2746 2746
 			}
2747 2747
 			
@@ -2751,12 +2751,12 @@  discard block
 block discarded – undo
2751 2751
 				$this->deleteStatsByType('fatalities_byyear');
2752 2752
 				$alldata = $Accident->countFatalitiesByYear();
2753 2753
 				foreach ($alldata as $number) {
2754
-					$this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year'])));
2754
+					$this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year'])));
2755 2755
 				}
2756 2756
 				$this->deleteStatsByType('fatalities_bymonth');
2757 2757
 				$alldata = $Accident->countFatalitiesLast12Months();
2758 2758
 				foreach ($alldata as $number) {
2759
-					$this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year'])));
2759
+					$this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year'])));
2760 2760
 				}
2761 2761
 			}
2762 2762
 
@@ -2770,37 +2770,37 @@  discard block
 block discarded – undo
2770 2770
 			$lastyear = false;
2771 2771
 			foreach ($alldata as $number) {
2772 2772
 				if ($number['year_name'] != date('Y')) $lastyear = true;
2773
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2773
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2774 2774
 			}
2775 2775
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2776 2776
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2777 2777
 			foreach ($alldata as $number) {
2778
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2778
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2779 2779
 			}
2780 2780
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
2781 2781
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2782 2782
 			foreach ($alldata as $number) {
2783
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2783
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2784 2784
 			}
2785 2785
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2786 2786
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2787 2787
 			foreach ($alldata as $number) {
2788
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2788
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2789 2789
 			}
2790 2790
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2791 2791
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2792 2792
 			foreach ($alldata as $number) {
2793
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2793
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2794 2794
 			}
2795 2795
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2796 2796
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2797 2797
 			foreach ($alldata as $number) {
2798
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2798
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2799 2799
 			}
2800 2800
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2801 2801
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2802 2802
 			foreach ($alldata as $number) {
2803
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2803
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
2804 2804
 			}
2805 2805
 			if ($globalDebug) echo 'Airports data...'."\n";
2806 2806
 			if ($globalDebug) echo '...Departure'."\n";
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
 			}
2846 2846
 			$alldata = $pall;
2847 2847
 			foreach ($alldata as $number) {
2848
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
2848
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
2849 2849
 			}
2850 2850
 			echo '...Arrival'."\n";
2851 2851
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -2886,7 +2886,7 @@  discard block
 block discarded – undo
2886 2886
 			}
2887 2887
 			$alldata = $pall;
2888 2888
 			foreach ($alldata as $number) {
2889
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
2889
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
2890 2890
 			}
2891 2891
 
2892 2892
 			echo 'Flights data...'."\n";
@@ -2894,28 +2894,28 @@  discard block
 block discarded – undo
2894 2894
 			echo '-> countAllDatesLastMonth...'."\n";
2895 2895
 			$alldata = $Spotter->countAllDatesLastMonth($filter_last_month);
2896 2896
 			foreach ($alldata as $number) {
2897
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
2897
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
2898 2898
 			}
2899 2899
 			echo '-> countAllDates...'."\n";
2900 2900
 			$previousdata = $this->countAllDates();
2901 2901
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
2902 2902
 			$this->deleteStatFlight('date');
2903
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month));
2903
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month));
2904 2904
 			$values = array();
2905 2905
 			foreach ($alldata as $cnt) {
2906 2906
 				$values[] = $cnt['date_count'];
2907 2907
 			}
2908
-			array_multisort($values,SORT_DESC,$alldata);
2909
-			array_splice($alldata,11);
2908
+			array_multisort($values, SORT_DESC, $alldata);
2909
+			array_splice($alldata, 11);
2910 2910
 			foreach ($alldata as $number) {
2911
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
2911
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
2912 2912
 			}
2913 2913
 			
2914 2914
 			$this->deleteStatFlight('hour');
2915 2915
 			echo '-> countAllHours...'."\n";
2916
-			$alldata = $Spotter->countAllHours('hour',$filter_last_month);
2916
+			$alldata = $Spotter->countAllHours('hour', $filter_last_month);
2917 2917
 			foreach ($alldata as $number) {
2918
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
2918
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
2919 2919
 			}
2920 2920
 
2921 2921
 			// Count by airlines
@@ -2924,42 +2924,42 @@  discard block
 block discarded – undo
2924 2924
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2925 2925
 				$SpotterArchive = new SpotterArchive($this->db);
2926 2926
 				//$Spotter = new Spotter($this->db);
2927
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2927
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
2928 2928
 				//$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
2929 2929
 				foreach ($alldata as $number) {
2930
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2930
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
2931 2931
 				}
2932 2932
 			}
2933 2933
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2934 2934
 			$Spotter = new Spotter($this->db);
2935
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2935
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
2936 2936
 			foreach ($alldata as $number) {
2937
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2937
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
2938 2938
 			}
2939 2939
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2940
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2940
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
2941 2941
 			foreach ($alldata as $number) {
2942
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2942
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
2943 2943
 			}
2944 2944
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2945
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2945
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
2946 2946
 			foreach ($alldata as $number) {
2947
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2947
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
2948 2948
 			}
2949 2949
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2950
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2950
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
2951 2951
 			foreach ($alldata as $number) {
2952
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2952
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
2953 2953
 			}
2954 2954
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2955
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2955
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
2956 2956
 			foreach ($alldata as $number) {
2957
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2957
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
2958 2958
 			}
2959 2959
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2960
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2960
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
2961 2961
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2962
-			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2962
+			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
2963 2963
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2964 2964
 			//$alldata = array();
2965 2965
 			foreach ($dall as $value) {
@@ -2979,12 +2979,12 @@  discard block
 block discarded – undo
2979 2979
 			}
2980 2980
 			$alldata = $pall;
2981 2981
 			foreach ($alldata as $number) {
2982
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
2982
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset);
2983 2983
 			}
2984 2984
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2985
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2985
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
2986 2986
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2987
-			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2987
+			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
2988 2988
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2989 2989
 			//$alldata = array();
2990 2990
 			foreach ($dall as $value) {
@@ -3004,7 +3004,7 @@  discard block
 block discarded – undo
3004 3004
 			}
3005 3005
 			$alldata = $pall;
3006 3006
 			foreach ($alldata as $number) {
3007
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
3007
+				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset);
3008 3008
 			}
3009 3009
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
3010 3010
 			$Spotter = new Spotter($this->db);
@@ -3012,27 +3012,27 @@  discard block
 block discarded – undo
3012 3012
 			$lastyear = false;
3013 3013
 			foreach ($alldata as $number) {
3014 3014
 				if ($number['year_name'] != date('Y')) $lastyear = true;
3015
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3015
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3016 3016
 			}
3017 3017
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3018 3018
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
3019 3019
 			foreach ($alldata as $number) {
3020
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3020
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3021 3021
 			}
3022 3022
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3023 3023
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
3024 3024
 			foreach ($alldata as $number) {
3025
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3025
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3026 3026
 			}
3027 3027
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3028 3028
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
3029 3029
 			foreach ($alldata as $number) {
3030
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3030
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3031 3031
 			}
3032 3032
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3033 3033
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
3034 3034
 			foreach ($alldata as $number) {
3035
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
3035
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
3036 3036
 			}
3037 3037
 			if ($globalDebug) echo '...Departure'."\n";
3038 3038
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -3055,7 +3055,7 @@  discard block
 block discarded – undo
3055 3055
 			}
3056 3056
 			$alldata = $pall;
3057 3057
 			foreach ($alldata as $number) {
3058
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
3058
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']);
3059 3059
 			}
3060 3060
 			if ($globalDebug) echo '...Arrival'."\n";
3061 3061
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -3078,32 +3078,32 @@  discard block
 block discarded – undo
3078 3078
 			}
3079 3079
 			$alldata = $pall;
3080 3080
 			foreach ($alldata as $number) {
3081
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
3081
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']);
3082 3082
 			}
3083 3083
 
3084 3084
 			if ($globalDebug) echo 'Flights data...'."\n";
3085 3085
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3086 3086
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
3087 3087
 			foreach ($alldata as $number) {
3088
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
3088
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
3089 3089
 			}
3090 3090
 			if ($globalDebug) echo '-> countAllDates...'."\n";
3091 3091
 			//$previousdata = $this->countAllDatesByAirlines();
3092
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
3092
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month));
3093 3093
 			$values = array();
3094 3094
 			foreach ($alldata as $cnt) {
3095 3095
 				$values[] = $cnt['date_count'];
3096 3096
 			}
3097
-			array_multisort($values,SORT_DESC,$alldata);
3098
-			array_splice($alldata,11);
3097
+			array_multisort($values, SORT_DESC, $alldata);
3098
+			array_splice($alldata, 11);
3099 3099
 			foreach ($alldata as $number) {
3100
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
3100
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
3101 3101
 			}
3102 3102
 			
3103 3103
 			if ($globalDebug) echo '-> countAllHours...'."\n";
3104
-			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
3104
+			$alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month);
3105 3105
 			foreach ($alldata as $number) {
3106
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
3106
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
3107 3107
 			}
3108 3108
 
3109 3109
 			// Stats by filters
@@ -3127,7 +3127,7 @@  discard block
 block discarded – undo
3127 3127
 							$last_update_day = date('Y').'-01-01 00:00:00';
3128 3128
 						}
3129 3129
 					}
3130
-					if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) {
3130
+					if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) {
3131 3131
 						$last_update_day = date('Y').'-01-01 00:00:00';
3132 3132
 						$reset = true;
3133 3133
 					}
@@ -3135,38 +3135,38 @@  discard block
 block discarded – undo
3135 3135
 					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3136 3136
 					$Spotter = new Spotter($this->db);
3137 3137
 					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3138
-					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
3138
+					$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
3139 3139
 					foreach ($alldata as $number) {
3140
-						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
3140
+						$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
3141 3141
 					}
3142 3142
 					if ($globalDebug) echo 'Count all airlines...'."\n";
3143
-					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
3143
+					$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
3144 3144
 					foreach ($alldata as $number) {
3145
-						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
3145
+						$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
3146 3146
 					}
3147 3147
 					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3148
-					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
3148
+					$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
3149 3149
 					foreach ($alldata as $number) {
3150
-						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
3150
+						$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
3151 3151
 					}
3152 3152
 					if ($globalDebug) echo 'Count all callsigns...'."\n";
3153
-					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
3153
+					$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
3154 3154
 					foreach ($alldata as $number) {
3155
-						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
3155
+						$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
3156 3156
 					}
3157 3157
 					if ($globalDebug) echo 'Count all owners...'."\n";
3158
-					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
3158
+					$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
3159 3159
 					foreach ($alldata as $number) {
3160
-						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
3160
+						$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
3161 3161
 					}
3162 3162
 					if ($globalDebug) echo 'Count all pilots...'."\n";
3163
-					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
3163
+					$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
3164 3164
 					foreach ($alldata as $number) {
3165
-						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
3165
+						$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
3166 3166
 					}
3167 3167
 					if ($globalDebug) echo 'Count departure airports...'."\n";
3168
-					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
3169
-					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
3168
+					$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
3169
+					$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
3170 3170
 					$alldata = array();
3171 3171
 					foreach ($pall as $value) {
3172 3172
 						$icao = $value['airport_departure_icao'];
@@ -3182,13 +3182,13 @@  discard block
 block discarded – undo
3182 3182
 					foreach ($alldata as $key => $row) {
3183 3183
 						$count[$key] = $row['airport_departure_icao_count'];
3184 3184
 					}
3185
-					array_multisort($count,SORT_DESC,$alldata);
3185
+					array_multisort($count, SORT_DESC, $alldata);
3186 3186
 					foreach ($alldata as $number) {
3187
-						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
3187
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
3188 3188
 					}
3189 3189
 					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3190
-					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
3191
-					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
3190
+					$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
3191
+					$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
3192 3192
 					$alldata = array();
3193 3193
 					foreach ($pall as $value) {
3194 3194
 						$icao = $value['airport_arrival_icao'];
@@ -3204,9 +3204,9 @@  discard block
 block discarded – undo
3204 3204
 					foreach ($alldata as $key => $row) {
3205 3205
 						$count[$key] = $row['airport_arrival_icao_count'];
3206 3206
 					}
3207
-					array_multisort($count,SORT_DESC,$alldata);
3207
+					array_multisort($count, SORT_DESC, $alldata);
3208 3208
 					foreach ($alldata as $number) {
3209
-						echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
3209
+						echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
3210 3210
 					}
3211 3211
 					if ($globalDebug) echo 'Count all months...'."\n";
3212 3212
 					$Spotter = new Spotter($this->db);
@@ -3214,36 +3214,36 @@  discard block
 block discarded – undo
3214 3214
 					$lastyear = false;
3215 3215
 					foreach ($alldata as $number) {
3216 3216
 						if ($number['year_name'] != date('Y')) $lastyear = true;
3217
-						$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3217
+						$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3218 3218
 					}
3219 3219
 					if ($globalDebug) echo 'Count all owners by months...'."\n";
3220 3220
 					$alldata = $Spotter->countAllMonthsOwners($filter);
3221 3221
 					foreach ($alldata as $number) {
3222
-						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3222
+						$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3223 3223
 					}
3224 3224
 					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3225 3225
 					$alldata = $Spotter->countAllMonthsPilots($filter);
3226 3226
 					foreach ($alldata as $number) {
3227
-						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3227
+						$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3228 3228
 					}
3229 3229
 					if ($globalDebug) echo 'Count all military by months...'."\n";
3230 3230
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
3231 3231
 					foreach ($alldata as $number) {
3232
-						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3232
+						$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3233 3233
 					}
3234 3234
 					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3235 3235
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
3236 3236
 				    	foreach ($alldata as $number) {
3237
-			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3237
+			    			$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3238 3238
 					}
3239 3239
 					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3240 3240
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
3241 3241
 					foreach ($alldata as $number) {
3242
-						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
3242
+						$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
3243 3243
 					}
3244 3244
 					echo '...Departure'."\n";
3245
-					$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
3246
-					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
3245
+					$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
3246
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
3247 3247
 					foreach ($dall as $value) {
3248 3248
 						$icao = $value['departure_airport_icao'];
3249 3249
 						$ddate = $value['date'];
@@ -3261,11 +3261,11 @@  discard block
 block discarded – undo
3261 3261
 					}
3262 3262
 					$alldata = $pall;
3263 3263
 					foreach ($alldata as $number) {
3264
-						$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
3264
+						$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
3265 3265
 					}
3266 3266
 					echo '...Arrival'."\n";
3267
-					$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
3268
-					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
3267
+					$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
3268
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
3269 3269
 					foreach ($dall as $value) {
3270 3270
 						$icao = $value['arrival_airport_icao'];
3271 3271
 						$ddate = $value['date'];
@@ -3283,39 +3283,39 @@  discard block
 block discarded – undo
3283 3283
 					}
3284 3284
 					$alldata = $pall;
3285 3285
 					foreach ($alldata as $number) {
3286
-						$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
3286
+						$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
3287 3287
 					}
3288 3288
 					echo 'Flights data...'."\n";
3289 3289
 					echo '-> countAllDatesLastMonth...'."\n";
3290 3290
 					$alldata = $Spotter->countAllDatesLastMonth($filter);
3291 3291
 					foreach ($alldata as $number) {
3292
-						$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
3292
+						$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
3293 3293
 					}
3294 3294
 					echo '-> countAllDates...'."\n";
3295
-					$previousdata = $this->countAllDates('',$filter_name);
3296
-					$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
3295
+					$previousdata = $this->countAllDates('', $filter_name);
3296
+					$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
3297 3297
 					$values = array();
3298 3298
 					foreach ($alldata as $cnt) {
3299 3299
 						$values[] = $cnt['date_count'];
3300 3300
 					}
3301
-					array_multisort($values,SORT_DESC,$alldata);
3302
-					array_splice($alldata,11);
3301
+					array_multisort($values, SORT_DESC, $alldata);
3302
+					array_splice($alldata, 11);
3303 3303
 					foreach ($alldata as $number) {
3304
-						$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
3304
+						$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
3305 3305
 					}
3306 3306
 				
3307 3307
 					echo '-> countAllHours...'."\n";
3308
-					$alldata = $Spotter->countAllHours('hour',$filter);
3308
+					$alldata = $Spotter->countAllHours('hour', $filter);
3309 3309
 					foreach ($alldata as $number) {
3310
-						$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
3310
+						$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
3311 3311
 					}
3312 3312
 					echo 'Insert last stats update date...'."\n";
3313 3313
 					date_default_timezone_set('UTC');
3314
-					$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
3314
+					$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
3315 3315
 					if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
3316
-						if (date('Y',strtotime($last_update_day)) != date('Y')) {
3316
+						if (date('Y', strtotime($last_update_day)) != date('Y')) {
3317 3317
 							$this->deleteOldStats($filter_name);
3318
-							$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
3318
+							$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
3319 3319
 						}
3320 3320
 					}
3321 3321
 				}
@@ -3328,16 +3328,16 @@  discard block
 block discarded – undo
3328 3328
 				// SUM all previous month to put as year
3329 3329
 				$previous_year = date('Y');
3330 3330
 				$previous_year--;
3331
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3332
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3333
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3334
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
3331
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3332
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3333
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3334
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
3335 3335
 				$allairlines = $this->getAllAirlineNames();
3336 3336
 				foreach ($allairlines as $data) {
3337
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3338
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3339
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3340
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
3337
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3338
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3339
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3340
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
3341 3341
 				}
3342 3342
 				
3343 3343
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -3346,21 +3346,21 @@  discard block
 block discarded – undo
3346 3346
 						try {
3347 3347
 							$sth = $this->db->prepare($query);
3348 3348
 							$sth->execute();
3349
-						} catch(PDOException $e) {
3349
+						} catch (PDOException $e) {
3350 3350
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3351 3351
 						}
3352 3352
 						$query = "INSERT INTO tracker_archive_output SELECT * FROM tracker_output WHERE tracker_output.date < '".date('Y')."-01-01 00:00:00'";
3353 3353
 						try {
3354 3354
 							$sth = $this->db->prepare($query);
3355 3355
 							$sth->execute();
3356
-						} catch(PDOException $e) {
3356
+						} catch (PDOException $e) {
3357 3357
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3358 3358
 						}
3359 3359
 						$query = "INSERT INTO marine_archive_output SELECT * FROM marine_output WHERE marine_output.date < '".date('Y')."-01-01 00:00:00'";
3360 3360
 						try {
3361 3361
 							$sth = $this->db->prepare($query);
3362 3362
 							$sth->execute();
3363
-						} catch(PDOException $e) {
3363
+						} catch (PDOException $e) {
3364 3364
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
3365 3365
 						}
3366 3366
 					}
@@ -3373,7 +3373,7 @@  discard block
 block discarded – undo
3373 3373
 					try {
3374 3374
 						$sth = $this->db->prepare($query);
3375 3375
 						$sth->execute();
3376
-					} catch(PDOException $e) {
3376
+					} catch (PDOException $e) {
3377 3377
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3378 3378
 					}
3379 3379
 					if ($globalDBdriver == 'mysql') {
@@ -3384,7 +3384,7 @@  discard block
 block discarded – undo
3384 3384
 					try {
3385 3385
 						$sth = $this->db->prepare($query);
3386 3386
 						$sth->execute();
3387
-					} catch(PDOException $e) {
3387
+					} catch (PDOException $e) {
3388 3388
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3389 3389
 					}
3390 3390
 					if ($globalDBdriver == 'mysql') {
@@ -3395,15 +3395,15 @@  discard block
 block discarded – undo
3395 3395
 					try {
3396 3396
 						$sth = $this->db->prepare($query);
3397 3397
 						$sth->execute();
3398
-					} catch(PDOException $e) {
3398
+					} catch (PDOException $e) {
3399 3399
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
3400 3400
 					}
3401 3401
 				}
3402 3402
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
3403 3403
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
3404
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
3404
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
3405 3405
 						$this->deleteOldStats();
3406
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
3406
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
3407 3407
 						$lastyearupdate = true;
3408 3408
 					}
3409 3409
 				}
@@ -3425,7 +3425,7 @@  discard block
 block discarded – undo
3425 3425
 					try {
3426 3426
 						$sth = $this->db->prepare($query);
3427 3427
 						$sth->execute();
3428
-					} catch(PDOException $e) {
3428
+					} catch (PDOException $e) {
3429 3429
 						return "error : ".$e->getMessage();
3430 3430
 					}
3431 3431
 					echo 'Archive old tracker data...'."\n";
@@ -3441,7 +3441,7 @@  discard block
 block discarded – undo
3441 3441
 					try {
3442 3442
 						$sth = $this->db->prepare($query);
3443 3443
 						$sth->execute();
3444
-					} catch(PDOException $e) {
3444
+					} catch (PDOException $e) {
3445 3445
 						return "error : ".$e->getMessage();
3446 3446
 					}
3447 3447
 					echo 'Archive old marine data...'."\n";
@@ -3457,7 +3457,7 @@  discard block
 block discarded – undo
3457 3457
 					try {
3458 3458
 						$sth = $this->db->prepare($query);
3459 3459
 						$sth->execute();
3460
-					} catch(PDOException $e) {
3460
+					} catch (PDOException $e) {
3461 3461
 						return "error : ".$e->getMessage();
3462 3462
 					}
3463 3463
 				}
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
 				try {
3471 3471
 					$sth = $this->db->prepare($query);
3472 3472
 					$sth->execute();
3473
-				} catch(PDOException $e) {
3473
+				} catch (PDOException $e) {
3474 3474
 					return "error : ".$e->getMessage();
3475 3475
 				}
3476 3476
 				echo 'Deleting old tracker data...'."\n";
@@ -3482,7 +3482,7 @@  discard block
 block discarded – undo
3482 3482
 				try {
3483 3483
 					$sth = $this->db->prepare($query);
3484 3484
 					$sth->execute();
3485
-				} catch(PDOException $e) {
3485
+				} catch (PDOException $e) {
3486 3486
 					return "error : ".$e->getMessage();
3487 3487
 				}
3488 3488
 				echo 'Deleting old marine data...'."\n";
@@ -3494,14 +3494,14 @@  discard block
 block discarded – undo
3494 3494
 				try {
3495 3495
 					$sth = $this->db->prepare($query);
3496 3496
 					$sth->execute();
3497
-				} catch(PDOException $e) {
3497
+				} catch (PDOException $e) {
3498 3498
 					return "error : ".$e->getMessage();
3499 3499
 				}
3500 3500
 			}
3501 3501
 			if (!isset($lastyearupdate)) {
3502 3502
 				echo 'Insert last stats update date...'."\n";
3503 3503
 				date_default_timezone_set('UTC');
3504
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
3504
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
3505 3505
 			}
3506 3506
 			if ($globalStatsResetYear) {
3507 3507
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
aircraft-data.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 $from_archive = false;
13 13
 if (isset($_GET['ident'])) {
14
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
14
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
15 15
 	if (isset($_GET['currenttime'])) {
16
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
16
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
17 17
 		$currenttime = round($currenttime/1000);
18
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime);
18
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime);
19 19
 		if (empty($spotter_array)) {
20 20
 			$from_archive = true;
21
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime);
21
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime);
22 22
 		}
23 23
 	} else {
24 24
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 }
31 31
 if (isset($_GET['flightaware_id'])) {
32
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
32
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
33 33
 	if (isset($_GET['currenttime'])) {
34
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
34
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
35 35
 		$currenttime = round($currenttime/1000);
36
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime);
36
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime);
37 37
 		if (empty($spotter_array)) {
38 38
 			$from_archive = true;
39 39
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
40
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime);
40
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime);
41 41
 		}
42 42
 	} else {
43 43
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
58 58
 	{
59 59
 		if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
60
-			$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
60
+			$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
61 61
 		} else $image = $spotter_item['image_thumbnail'];
62 62
 	}
63 63
 	/* else {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
81 81
 		if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
82 82
 			if ($spotter_item['departure_airport_time'] > 2460) {
83
-				print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
83
+				print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>';
84 84
 			} else {
85 85
 				print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
86 86
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
90 90
 		if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
91 91
 			if ($spotter_item['arrival_airport_time'] > 2460) {
92
-				print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
92
+				print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>';
93 93
 			} else {
94 94
 				print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
95 95
 			}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	print '<span>'._("Aircraft").'</span>';
109 109
 	if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
110 110
 	if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') {
111
-		$aircraft_names = explode('/',$spotter_item['aircraft_name']);
111
+		$aircraft_names = explode('/', $spotter_item['aircraft_name']);
112 112
 		if (count($aircraft_names) == 1) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
113 113
 		else print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].' ('.$spotter_item['aircraft_type'].')</a>';
114 114
 	} elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	print '<div id ="altitude"><span>'._("Altitude").'</span>';
119 119
 	if (isset($globalGroundAltitude) && $globalGroundAltitude) {
120 120
 		try {
121
-			$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
122
-		} catch(Exception $e) {
121
+			$groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']);
122
+		} catch (Exception $e) {
123 123
 			// If catched not exist
124 124
 		}
125 125
 	}
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 	if (isset($globalCam) && $globalCam) {
159 159
 		require_once(dirname(__FILE__).'/require/class.Common.php');
160 160
 		$Common = new Common();
161
-		$azimuth = round($Common->azimuth($globalCenterLatitude,$globalCenterLongitude,$spotter_item['latitude'],$spotter_item['longitude']));
162
-		$distance = $Common->distance($globalCenterLatitude,$globalCenterLongitude,$spotter_item['latitude'],$spotter_item['longitude'],'m');
163
-		$plunge = round($Common->plunge($globalCenterAltitude,$spotter_item['real_altitude'],$distance));
161
+		$azimuth = round($Common->azimuth($globalCenterLatitude, $globalCenterLongitude, $spotter_item['latitude'], $spotter_item['longitude']));
162
+		$distance = $Common->distance($globalCenterLatitude, $globalCenterLongitude, $spotter_item['latitude'], $spotter_item['longitude'], 'm');
163
+		$plunge = round($Common->plunge($globalCenterAltitude, $spotter_item['real_altitude'], $distance));
164 164
 		print '<div id="camcoordinates"><span>'._("Cam Coordinates").'</span>';
165 165
 		print 'azimuth: '.$azimuth;
166 166
 		print ' / ';
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
 		print '</div>';
171 171
 		//echo $Common->getData('http://127.0.0.1/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
172 172
 		//echo $Common->getData('file://'.dirname(__FILE__).'/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
173
-		echo $Common->getData('http://'.$_SERVER['SERVER_NAME'].'/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
173
+		echo $Common->getData('http://'.$_SERVER['SERVER_NAME'].'/camera.php?azimuth='.$azimuth.'&plunge='.$plunge, 'get', '', '', '', '', '', '', false, true);
174 174
 	}
175 175
   
176 176
 	print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
177 177
 	if (isset($spotter_item['verticalrate']) && $spotter_item['verticalrate'] != '') {
178 178
 		print '<div id="verticalrate"><span>'._("Vertical rate").'</span>';
179 179
 		if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
180
-			print $spotter_item['verticalrate']. ' ft/min';
180
+			print $spotter_item['verticalrate'].' ft/min';
181 181
 		} else {
182
-			print round($spotter_item['verticalrate']*0.3048). ' m/min';
182
+			print round($spotter_item['verticalrate']*0.3048).' m/min';
183 183
 		}
184 184
 		print '</div>';
185 185
 	}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	print '</div>';
215 215
 	if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
216 216
 	if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
217
-	if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
217
+	if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>';
218 218
 	if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
219 219
 	print '</div>';
220 220
 }
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false) {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		if ($sizelimit === true) {
69 69
 			curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
70 70
 			curl_setopt($ch, CURLOPT_NOPROGRESS, false);
71
-			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){
71
+			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) {
72 72
 				return ($downloaded > (3*1024)) ? 1 : 0;
73 73
 			});
74 74
 		}
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 		$result = curl_exec($ch);
80 80
 		$info = curl_getinfo($ch);
81 81
 		curl_close($ch);
82
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
82
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
83 83
 			echo "Cloudflare Detected\n";
84 84
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
85 85
 			$useragent = UAgent::random();
86 86
 			cloudflare::useUserAgent($useragent);
87 87
 			if ($clearanceCookie = cloudflare::bypass($url)) {
88
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
88
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
89 89
 			}
90 90
 		} else {
91 91
 			return $result;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110 110
 		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
111 111
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
112
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
113 113
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
114 114
 			}
115 115
 		}
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 		fclose($fp);
125 125
 	}
126 126
 
127
-	public static function gunzip($in_file,$out_file_name = '') {
127
+	public static function gunzip($in_file, $out_file_name = '') {
128 128
 		//echo $in_file.' -> '.$out_file_name."\n";
129 129
 		$buffer_size = 4096; // read 4kb at a time
130 130
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
131 131
 		if ($in_file != '' && file_exists($in_file)) {
132 132
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
133
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
134
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
135 135
 			else {
136 136
 				echo 'gzopen not available';
137 137
 				die;
138 138
 			}
139 139
 			$out_file = fopen($out_file_name, 'wb'); 
140
-			while(!gzeof($file)) {
140
+			while (!gzeof($file)) {
141 141
 				fwrite($out_file, gzread($file, $buffer_size));
142 142
 			}  
143 143
 			fclose($out_file);
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 	}
147 147
 
148
-	public static function bunzip2($in_file,$out_file_name = '') {
148
+	public static function bunzip2($in_file, $out_file_name = '') {
149 149
 		//echo $in_file.' -> '.$out_file_name."\n";
150 150
 		$buffer_size = 4096; // read 4kb at a time
151 151
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
152 152
 		if ($in_file != '' && file_exists($in_file)) {
153 153
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
154
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
155 155
 			else {
156 156
 				echo 'bzopen not available';
157 157
 				die;
158 158
 			}
159 159
 			$out_file = fopen($out_file_name, 'wb'); 
160
-			while(!feof($file)) {
160
+			while (!feof($file)) {
161 161
 				fwrite($out_file, bzread($file, $buffer_size));
162 162
 			}  
163 163
 			fclose($out_file);
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 		if ($data == '') return array();
176 176
 		$html = str_get_html($data);
177 177
 		if ($html === false) return array();
178
-		$tabledata=array();
179
-		foreach($html->find('tr') as $element)
178
+		$tabledata = array();
179
+		foreach ($html->find('tr') as $element)
180 180
 		{
181 181
 			$td = array();
182
-			foreach( $element->find('th') as $row)
182
+			foreach ($element->find('th') as $row)
183 183
 			{
184 184
 				$td [] = trim($row->plaintext);
185 185
 			}
186
-			$td=array_filter($td);
186
+			$td = array_filter($td);
187 187
 			$tabledata[] = $td;
188 188
 
189 189
 			$td = array();
190 190
 			$tdi = array();
191
-			foreach( $element->find('td') as $row)
191
+			foreach ($element->find('td') as $row)
192 192
 			{
193 193
 				$td [] = trim($row->plaintext);
194 194
 				$tdi [] = trim($row->innertext);
195 195
 			}
196
-			$td=array_filter($td);
197
-			$tdi=array_filter($tdi);
198
-			$tabledata[]=array_merge($td,$tdi);
196
+			$td = array_filter($td);
197
+			$tdi = array_filter($tdi);
198
+			$tabledata[] = array_merge($td, $tdi);
199 199
 		}
200 200
 		$html->clear();
201 201
 		unset($html);
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
213
-		$tabledata=array();
214
-		foreach($html->find('p') as $element)
213
+		$tabledata = array();
214
+		foreach ($html->find('p') as $element)
215 215
 		{
216 216
 			$tabledata [] = trim($element->plaintext);
217 217
 		}
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	*/
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
234
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
235 235
 		if ($unit == "km") {
236
-			return round($dist * 1.609344);
236
+			return round($dist*1.609344);
237 237
 		} elseif ($unit == "m") {
238
-			return round($dist * 1.609344 * 1000);
238
+			return round($dist*1.609344*1000);
239 239
 		} elseif ($unit == "mile" || $unit == "mi") {
240 240
 			return round($dist);
241 241
 		} elseif ($unit == "nm") {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	* @param String $distance distance between two points in m
253 253
 	* @return Float plunge
254 254
 	*/
255
-	public function plunge($initial_altitude,$final_altitude,$distance) {
256
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
255
+	public function plunge($initial_altitude, $final_altitude, $distance) {
256
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
257 257
 		/*
258 258
 		$siter = 6378137.0 + $initial_altitude;
259 259
 		$planer = 6378137.0 + $final_altitude;
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 	public function azimuth($lat, $lon, $latc, $lonc) {
276 276
 		$dX = $latc - $lat;
277 277
 		$dY = $lonc - $lon;
278
-		$azimuth = rad2deg(atan2($dY,$dX));
279
-		if ($azimuth < 0) return $azimuth+360;
278
+		$azimuth = rad2deg(atan2($dY, $dX));
279
+		if ($azimuth < 0) return $azimuth + 360;
280 280
 		return $azimuth;
281 281
 	}
282 282
 	
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	* @param float $distance distance covered
288 288
 	* @return whether distance is realistic
289 289
 	*/
290
-	public function withinThreshold ($timeDifference, $distance) {
290
+	public function withinThreshold($timeDifference, $distance) {
291 291
 		$x = abs($timeDifference);
292 292
 		$d = abs($distance);
293 293
 		if ($x == 0 || $d == 0) return true;
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 		return ($array !== array_values($array));
304 304
 	}
305 305
 
306
-	public function isInteger($input){
306
+	public function isInteger($input) {
307 307
 		//return(ctype_digit(strval($input)));
308
-		return preg_match('/^-?[0-9]+$/', (string)$input) ? true : false;
308
+		return preg_match('/^-?[0-9]+$/', (string) $input) ? true : false;
309 309
 	}
310 310
 
311 311
 
312
-	public function convertDec($dms,$latlong) {
312
+	public function convertDec($dms, $latlong) {
313 313
 		if ($latlong == 'latitude') {
314 314
 			$deg = substr($dms, 0, 2);
315 315
 			$min = substr($dms, 2, 4);
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 			$deg = substr($dms, 0, 3);
318 318
 			$min = substr($dms, 3, 5);
319 319
 		}
320
-		return $deg+(($min*60)/3600);
320
+		return $deg + (($min*60)/3600);
321 321
 	}
322 322
 	
323
-	public function convertDM($coord,$latlong) {
323
+	public function convertDM($coord, $latlong) {
324 324
 		if ($latlong == 'latitude') {
325 325
 			if ($coord < 0) $NSEW = 'S';
326 326
 			else $NSEW = 'N';
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 		}
331 331
 		$coord = abs($coord);
332 332
 		$deg = floor($coord);
333
-		$coord = ($coord-$deg)*60;
333
+		$coord = ($coord - $deg)*60;
334 334
 		$min = $coord;
335
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
335
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
336 336
 	}
337 337
 	
338 338
 	/**
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
 	public function xcopy($source, $dest)
345 345
 	{
346 346
 		$files = glob($source.'*.*');
347
-		foreach($files as $file){
348
-			$file_to_go = str_replace($source,$dest,$file);
347
+		foreach ($files as $file) {
348
+			$file_to_go = str_replace($source, $dest, $file);
349 349
 			copy($file, $file_to_go);
350 350
 		}
351 351
 		return true;
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	* @param	String $url url to check
357 357
 	* @return	bool Return true on succes false on failure
358 358
 	*/
359
-	public function urlexist($url){
360
-		$headers=get_headers($url);
361
-		return stripos($headers[0],"200 OK")?true:false;
359
+	public function urlexist($url) {
360
+		$headers = get_headers($url);
361
+		return stripos($headers[0], "200 OK") ?true:false;
362 362
 	}
363 363
 	
364 364
 	/**
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	public function hex2str($hex) {
370 370
 		$str = '';
371 371
 		$hexln = strlen($hex);
372
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
372
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
373 373
 		return $str;
374 374
 	}
375 375
 	
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	* @return	String Return result
380 380
 	*/
381 381
 	public function hex2rgb($hex) {
382
-		$hex = str_replace('#','',$hex);
382
+		$hex = str_replace('#', '', $hex);
383 383
 		return sscanf($hex, "%02x%02x%02x"); 
384 384
 	}
385 385
 	
@@ -387,33 +387,33 @@  discard block
 block discarded – undo
387 387
 		//difference in longitudinal coordinates
388 388
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
389 389
 		//difference in the phi of latitudinal coordinates
390
-		$dPhi = log(tan(deg2rad($lat2) / 2 + M_PI / 4) / tan(deg2rad($lat1) / 2 + M_PI / 4));
390
+		$dPhi = log(tan(deg2rad($lat2)/2 + M_PI/4)/tan(deg2rad($lat1)/2 + M_PI/4));
391 391
 		//we need to recalculate $dLon if it is greater than pi
392
-		if(abs($dLon) > M_PI) {
393
-			if($dLon > 0) {
394
-				$dLon = (2 * M_PI - $dLon) * -1;
392
+		if (abs($dLon) > M_PI) {
393
+			if ($dLon > 0) {
394
+				$dLon = (2*M_PI - $dLon)*-1;
395 395
 			} else {
396
-				$dLon = 2 * M_PI + $dLon;
396
+				$dLon = 2*M_PI + $dLon;
397 397
 			}
398 398
 		}
399 399
 		//return the angle, normalized
400
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
400
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
401 401
 	}
402 402
 
403
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
403
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
404 404
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
405
-		$a = -($lon2-$lon1);
405
+		$a = -($lon2 - $lon1);
406 406
 		$b = $lat2 - $lat1;
407
-		$c = -($a*$lat1+$b*$lon1);
408
-		$d = $a*$lat3+$b*$lon3+$c;
407
+		$c = -($a*$lat1 + $b*$lon1);
408
+		$d = $a*$lat3 + $b*$lon3 + $c;
409 409
 		if ($d > -$approx && $d < $approx) return true;
410 410
 		else return false;
411 411
 	}
412 412
 	
413 413
 	public function array_merge_noappend() {
414 414
 		$output = array();
415
-		foreach(func_get_args() as $array) {
416
-			foreach($array as $key => $value) {
415
+		foreach (func_get_args() as $array) {
416
+			foreach ($array as $key => $value) {
417 417
 				$output[$key] = isset($output[$key]) ?
418 418
 				array_merge($output[$key], $value) : $value;
419 419
 			}
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		return $result;
478 478
 	}
479 479
 
480
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
480
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
481 481
 		global $globalMapRefresh;
482 482
 		if ($seconds == '') {
483 483
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -488,27 +488,27 @@  discard block
 block discarded – undo
488 488
 		$latitude = deg2rad($latitude);
489 489
 		$longitude = deg2rad($longitude);
490 490
 		$bearing = deg2rad($heading); 
491
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
492
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
493
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
491
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
492
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
493
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
494 494
 	}
495 495
 	
496
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
496
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
497 497
 		// distance in meter
498 498
 		$R = 6378.14;
499
-		$latitude1 = $latitude * (M_PI/180);
500
-		$longitude1 = $longitude * (M_PI/180);
501
-		$brng = $bearing * (M_PI/180);
499
+		$latitude1 = $latitude*(M_PI/180);
500
+		$longitude1 = $longitude*(M_PI/180);
501
+		$brng = $bearing*(M_PI/180);
502 502
 		$d = $distance;
503 503
 
504 504
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
505
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
505
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
506 506
 
507
-		$latitude2 = $latitude2 * (180/M_PI);
508
-		$longitude2 = $longitude2 * (180/M_PI);
507
+		$latitude2 = $latitude2*(180/M_PI);
508
+		$longitude2 = $longitude2*(180/M_PI);
509 509
 
510
-		$flat = round ($latitude2,6);
511
-		$flong = round ($longitude2,6);
510
+		$flat = round($latitude2, 6);
511
+		$flong = round($longitude2, 6);
512 512
 /*
513 513
 		$dx = $distance*cos($bearing);
514 514
 		$dy = $distance*sin($bearing);
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		$flong = $longitude + $dlong;
518 518
 		$flat = $latitude + $dlat;
519 519
 */
520
-		return array('latitude' => $flat,'longitude' => $flong);
520
+		return array('latitude' => $flat, 'longitude' => $flong);
521 521
 	}
522 522
 
523 523
 	/**
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
 	 * @param integer $level GZIP compression level (default: 9)
532 532
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
533 533
 	 */
534
-	public function gzCompressFile($source, $level = 9){ 
535
-		$dest = $source . '.gz'; 
536
-		$mode = 'wb' . $level; 
534
+	public function gzCompressFile($source, $level = 9) { 
535
+		$dest = $source.'.gz'; 
536
+		$mode = 'wb'.$level; 
537 537
 		$error = false; 
538 538
 		if ($fp_out = gzopen($dest, $mode)) { 
539
-			if ($fp_in = fopen($source,'rb')) { 
539
+			if ($fp_in = fopen($source, 'rb')) { 
540 540
 				while (!feof($fp_in)) 
541
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
541
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
542 542
 				fclose($fp_in); 
543 543
 			} else {
544 544
 				$error = true; 
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 	} 
555 555
 	
556 556
 	public function remove_accents($string) {
557
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
557
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
558 558
 		$chars = array(
559 559
 		    // Decompositions for Latin-1 Supplement
560 560
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
612 612
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
613 613
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
614
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
614
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
615 615
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
616 616
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
617 617
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
628 628
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
629 629
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
630
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
631
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
632
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
633
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
634
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
635
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
636
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
630
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
631
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
632
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
633
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
634
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
635
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
636
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
637 637
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
638 638
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
639 639
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
668 668
 			if (is_numeric($string[$i]) && $concat_flag) {
669 669
 				$int .= $string[$i];
670
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
670
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
671 671
 				$concat_flag = false;
672 672
 			}
673 673
 		}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 			$slice = array_slice($arr, $offset + 1, $length);
714 714
 			return implode("", $slice);
715 715
 		} else {
716
-			return mb_substr($string,$offset,$length,'UTF-8');
716
+			return mb_substr($string, $offset, $length, 'UTF-8');
717 717
 		}
718 718
 	}
719 719
 
@@ -723,14 +723,14 @@  discard block
 block discarded – undo
723 723
 		//NOTE: use a trailing slash for folders!!!
724 724
 		//see http://bugs.php.net/bug.php?id=27609
725 725
 		//see http://bugs.php.net/bug.php?id=30931
726
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
726
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
727 727
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
728 728
 		else if (is_dir($path))
729 729
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
730 730
 		// check tmp file for read/write capabilities
731 731
 		$rm = file_exists($path);
732 732
 		$f = @fopen($path, 'a');
733
-		if ($f===false)
733
+		if ($f === false)
734 734
 			return false;
735 735
 		fclose($f);
736 736
 		if (!$rm)
@@ -749,29 +749,29 @@  discard block
 block discarded – undo
749 749
 	 * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline
750 750
 	 * @return Array Coordinate of the route
751 751
 	*/
752
-	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
753
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
752
+	public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) {
753
+		if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
754 754
 		$sx = deg2rad($begin_lon);
755 755
 		$sy = deg2rad($begin_lat);
756 756
 		$ex = deg2rad($end_lon);
757 757
 		$ey = deg2rad($end_lat);
758 758
 		$w = $sx - $ex;
759 759
 		$h = $sy - $ey;
760
-		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
760
+		$z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2);
761 761
 		$g = 2.0*asin(sqrt($z));
762
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
762
+		if ($g == M_PI || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
763 763
 		$first_pass = array();
764
-		$delta = 1.0/($nbpts-1);
765
-		for ($i =0; $i < $nbpts; ++$i) {
764
+		$delta = 1.0/($nbpts - 1);
765
+		for ($i = 0; $i < $nbpts; ++$i) {
766 766
 			$step = $delta*$i;
767
-			$A = sin((1 - $step) * $g) / sin($g);
768
-			$B = sin($step * $g) / sin($g);
769
-			$x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex);
770
-			$y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex);
771
-			$z = $A * sin($sy) + $B * sin($ey);
767
+			$A = sin((1 - $step)*$g)/sin($g);
768
+			$B = sin($step*$g)/sin($g);
769
+			$x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex);
770
+			$y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex);
771
+			$z = $A*sin($sy) + $B*sin($ey);
772 772
 			$lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2))));
773 773
 			$lon = rad2deg(atan2($y, $x));
774
-			$first_pass[] = array($lon,$lat);
774
+			$first_pass[] = array($lon, $lat);
775 775
 		}
776 776
 		$bHasBigDiff = false;
777 777
 		$dfMaxSmallDiffLong = 0;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 		// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
787 787
 		$first_pass_ln = count($first_pass);
788 788
 		for ($j = 1; $j < $first_pass_ln; ++$j) {
789
-			$dfPrevX = $first_pass[$j-1][0];
789
+			$dfPrevX = $first_pass[$j - 1][0];
790 790
 			$dfX = $first_pass[$j][0];
791 791
 			$dfDiffLong = abs($dfX - $dfPrevX);
792 792
 			if ($dfDiffLong > $dfDiffSpace &&
@@ -804,14 +804,14 @@  discard block
 block discarded – undo
804 804
 			//$poMulti[] = $poNewLS;
805 805
 			for ($k = 0; $k < $first_pass_ln; ++$k) {
806 806
 				$dfX0 = floatval($first_pass[$k][0]);
807
-				if ($k > 0 &&  abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) {
808
-					$dfX1 = floatval($first_pass[$k-1][0]);
809
-					$dfY1 = floatval($first_pass[$k-1][1]);
807
+				if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) {
808
+					$dfX1 = floatval($first_pass[$k - 1][0]);
809
+					$dfY1 = floatval($first_pass[$k - 1][1]);
810 810
 					$dfX2 = floatval($first_pass[$k][0]);
811 811
 					$dfY2 = floatval($first_pass[$k][1]);
812 812
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
813
-					    $k+1 < count($first_pass) &&
814
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
813
+					    $k + 1 < count($first_pass) &&
814
+					    $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX)
815 815
 					{
816 816
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
817 817
 						$k++;
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
820 820
 						continue;
821 821
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
822
-					    $k+1 < $first_pass_ln &&
823
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
822
+					    $k + 1 < $first_pass_ln &&
823
+					    $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180)
824 824
 					{
825 825
 						$poNewLS[] = array(180, $first_pass[$k][1]);
826 826
 						$k++;
@@ -843,12 +843,12 @@  discard block
 block discarded – undo
843 843
 					}
844 844
 					if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2)
845 845
 					{
846
-						$dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1);
847
-						$dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1;
848
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
846
+						$dfRatio = (180 - $dfX1)/($dfX2 - $dfX1);
847
+						$dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1;
848
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
849 849
 						$poMulti[] = $poNewLS;
850 850
 						$poNewLS = array();
851
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
851
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
852 852
 						//$poMulti[] = $poNewLS;
853 853
 					} else {
854 854
 						//$poNewLS[] = array();
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 			$poNewLS0 = array();
867 867
 			//$poMulti[] = $poNewLS0;
868 868
 			for ($l = 0; $l < $first_pass_ln; ++$l) {
869
-				$poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]);
869
+				$poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]);
870 870
 			}
871 871
 			$poMulti[] = $poNewLS0;
872 872
 		}
Please login to merge, or discard this patch.
install/index.php 1 patch
Spacing   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 require_once(dirname(__FILE__).'/class.create_db.php');
23 23
 require_once(dirname(__FILE__).'/class.update_schema.php');
24 24
 require_once(dirname(__FILE__).'/class.settings.php');
25
-$title="Install";
25
+$title = "Install";
26 26
 require(dirname(__FILE__).'/../require/settings.php');
27 27
 require_once(dirname(__FILE__).'/../require/class.Common.php');
28 28
 require(dirname(__FILE__).'/header.php');
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	if (!extension_loaded('curl')) {
94 94
 		$error[] = "Curl is not loaded.";
95 95
 	}
96
-	if(function_exists('apache_get_modules') ){
97
-		if(!in_array('mod_rewrite',apache_get_modules())) {
96
+	if (function_exists('apache_get_modules')) {
97
+		if (!in_array('mod_rewrite', apache_get_modules())) {
98 98
 			$error[] = "mod_rewrite is not available.";
99 99
 		}
100 100
 	/*
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
112 112
 		if (function_exists('get_headers')) {
113 113
 			//$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
114
-			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'live/geojson?test',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
115
-			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
114
+			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'live/geojson?test', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
115
+			if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
116 116
 				print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
117 117
 			} else {
118
-				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
119
-				if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
118
+				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'search', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
119
+				if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
120 120
 					print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
121 121
 				}
122 122
 			}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
197 197
 					if (isset($_SERVER['REQUEST_URI'])) {
198 198
 						$URL = $_SERVER['REQUEST_URI'];
199
-						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
199
+						$globalURL = str_replace('/install', '', str_replace('/install/', '', str_replace('/install/index.php', '', $URL)));
200 200
 					}
201 201
 				    }
202 202
 				?>
@@ -519,13 +519,13 @@  discard block
 block discarded – undo
519 519
 ?>
520 520
 							<tr>
521 521
 								<?php
522
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
522
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
523 523
 								?>
524 524
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
525 525
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
526 526
 								<?php
527 527
 								    } else {
528
-									$hostport = explode(':',$source['host']);
528
+									$hostport = explode(':', $source['host']);
529 529
 									if (isset($hostport[1])) {
530 530
 										$host = $hostport[0];
531 531
 										$port = $hostport[1];
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 									<select name="timezones[]" id="timezones">
576 576
 								<?php
577 577
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
578
-									foreach($timezonelist as $timezones){
578
+									foreach ($timezonelist as $timezones) {
579 579
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
580 580
 											print '<option selected>'.$timezones.'</option>';
581 581
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 									<select name="timezones[]" id="timezones">
631 631
 								<?php
632 632
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
633
-									foreach($timezonelist as $timezones){
633
+									foreach ($timezonelist as $timezones) {
634 634
 										if ($timezones == 'UTC') {
635 635
 											print '<option selected>'.$timezones.'</option>';
636 636
 										} else print '<option>'.$timezones.'</option>';
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 			<br />
1090 1090
 			<p>
1091 1091
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1092
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1092
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
1093 1093
 			</p>
1094 1094
 			<br />
1095 1095
 			<p>
@@ -1151,14 +1151,14 @@  discard block
 block discarded – undo
1151 1151
 $error = '';
1152 1152
 
1153 1153
 if (isset($_POST['dbtype'])) {
1154
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
1155
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
1156
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
1157
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
1158
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
1159
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
1160
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1161
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1154
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
1155
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
1156
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
1157
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
1158
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
1159
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
1160
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
1161
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
1162 1162
 
1163 1163
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1164 1164
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -1178,49 +1178,49 @@  discard block
 block discarded – undo
1178 1178
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1179 1179
 	*/
1180 1180
 	
1181
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1181
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
1182 1182
 
1183
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
1184
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
1185
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
1186
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
1187
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
1183
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
1184
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
1185
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
1186
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
1187
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
1188 1188
 
1189
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
1190
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
1191
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
1192
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
1193
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
1194
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
1195
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
1196
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
1197
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
1198
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
1189
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
1190
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
1191
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
1192
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
1193
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
1194
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
1195
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
1196
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
1197
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
1198
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
1199 1199
 	
1200
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1201
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1202
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1203
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1204
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1205
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1200
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
1201
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
1202
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
1203
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
1204
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
1205
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
1206 1206
 
1207
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1208
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1207
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
1208
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
1209 1209
 
1210
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1211
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1212
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1210
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
1211
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
1212
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
1213 1213
 
1214
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1214
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
1215 1215
 	if ($acars == 'acars') {
1216
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1216
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
1217 1217
 	} else {
1218
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1218
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1219 1219
 	}
1220 1220
 
1221
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1222
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1223
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1221
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1222
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1223
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1224 1224
 	
1225 1225
 	$source_name = $_POST['source_name'];
1226 1226
 	$source_latitude = $_POST['source_latitude'];
@@ -1234,8 +1234,8 @@  discard block
 block discarded – undo
1234 1234
 	
1235 1235
 	$sources = array();
1236 1236
 	foreach ($source_name as $keys => $name) {
1237
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1238
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1237
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
1238
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
1239 1239
 	}
1240 1240
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1241 1241
 
@@ -1244,16 +1244,16 @@  discard block
 block discarded – undo
1244 1244
 	$newstype = $_POST['newstype'];
1245 1245
 	
1246 1246
 	$newsfeeds = array();
1247
-	foreach($newsurl as $newskey => $url) {
1247
+	foreach ($newsurl as $newskey => $url) {
1248 1248
 	    if ($url != '') {
1249 1249
 		$type = $newstype[$newskey];
1250 1250
 		$lng = $newslng[$newskey];
1251 1251
 		if (isset($newsfeeds[$type][$lng])) {
1252
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1252
+		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng], array($url));
1253 1253
 		} else $newsfeeds[$type][$lng] = array($url);
1254 1254
 	    }
1255 1255
 	}
1256
-	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1256
+	$settings = array_merge($settings, array('globalNewsFeeds' => $newsfeeds));
1257 1257
 
1258 1258
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1259 1259
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1264,27 +1264,27 @@  discard block
 block discarded – undo
1264 1264
 	$sbsurl = $_POST['sbsurl'];
1265 1265
 	*/
1266 1266
 
1267
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1268
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1269
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1270
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1271
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1272
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1273
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1274
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1267
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1268
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1269
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1270
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1271
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1272
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1273
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1274
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1275 1275
 
1276
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1277
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1278
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1279
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1280
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1281
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1282
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1283
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1284
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1285
-	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1286
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1287
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1276
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1277
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1278
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1279
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1280
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1281
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1282
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1283
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1284
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1285
+	$globalsatellite = filter_input(INPUT_POST, 'globalsatellite', FILTER_SANITIZE_STRING);
1286
+	if ($globalsatellite == 'satellite') $settings = array_merge($settings, array('globalSatellite' => 'TRUE'));
1287
+	else $settings = array_merge($settings, array('globalSatellite' => 'FALSE'));
1288 1288
 
1289 1289
 /*	
1290 1290
 	$globalSBS1Hosts = array();
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
 	}
1301 1301
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1302 1302
 */
1303
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1303
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1304 1304
 	$host = $_POST['host'];
1305 1305
 	$port = $_POST['port'];
1306 1306
 	$name = $_POST['name'];
@@ -1317,115 +1317,115 @@  discard block
 block discarded – undo
1317 1317
 		else $cov = 'FALSE';
1318 1318
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1319 1319
 		else $arch = 'FALSE';
1320
-		if (strpos($format[$key],'_callback')) {
1321
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1320
+		if (strpos($format[$key], '_callback')) {
1321
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1322 1322
 		} elseif ($h != '' || $name[$key] != '') {
1323
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1323
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1324 1324
 		}
1325 1325
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1326 1326
 	}
1327
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1327
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1328 1328
 
1329 1329
 /*
1330 1330
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1331 1331
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1332 1332
 */
1333
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1334
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1335
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1333
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1334
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1335
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1336 1336
 
1337
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1338
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1337
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1338
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1339 1339
 
1340
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1341
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1340
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1341
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1342 1342
 
1343
-	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1344
-	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1343
+	$map3dtile = filter_input(INPUT_POST, 'map3dtileset', FILTER_SANITIZE_STRING);
1344
+	$settings = array_merge($settings, array('globalMap3DTiles' => $map3dtile));
1345 1345
 
1346
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1347
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1348
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1349
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1346
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1347
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1348
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1349
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1350 1350
 
1351
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1352
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1353
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1351
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1352
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1353
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1354 1354
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1355
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1356
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1355
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1356
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1357 1357
 
1358
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1359
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1360
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1361
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1362
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1363
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1364
-	$minfetch = filter_input(INPUT_POST,'minfetch',FILTER_SANITIZE_NUMBER_INT);
1365
-	$settings = array_merge($settings,array('globalMinFetch' => $minfetch));
1366
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1367
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1358
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1359
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1360
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1361
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1362
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1363
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1364
+	$minfetch = filter_input(INPUT_POST, 'minfetch', FILTER_SANITIZE_NUMBER_INT);
1365
+	$settings = array_merge($settings, array('globalMinFetch' => $minfetch));
1366
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1367
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1368 1368
 
1369
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1370
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1369
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1370
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1371 1371
 
1372
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1373
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1372
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1373
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1374 1374
 	
1375
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1375
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1376 1376
 	if ($archiveyear == "archiveyear") {
1377
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1377
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1378 1378
 	} else {
1379
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1379
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1380 1380
 	}
1381
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1382
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1383
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1384
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1381
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1382
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1383
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1384
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1385 1385
 
1386
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1387
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1388
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1389
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1386
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1387
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1388
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1389
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1390 1390
 
1391
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1392
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1393
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1391
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1392
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1393
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1394 1394
 
1395 1395
 	// Create in settings.php keys not yet configurable if not already here
1396 1396
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1397
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1397
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1398 1398
 
1399
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1399
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1400 1400
 	if ($resetyearstats == 'resetyearstats') {
1401
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1401
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1402 1402
 	} else {
1403
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1403
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1404 1404
 	}
1405 1405
 
1406
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1406
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1407 1407
 	if ($archive == 'archive') {
1408
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1408
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1409 1409
 	} else {
1410
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1410
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1411 1411
 	}
1412
-	$archiveresults = filter_input(INPUT_POST,'archiveresults',FILTER_SANITIZE_STRING);
1412
+	$archiveresults = filter_input(INPUT_POST, 'archiveresults', FILTER_SANITIZE_STRING);
1413 1413
 	if ($archiveresults == 'archiveresults') {
1414
-		$settings = array_merge($settings,array('globalArchiveResults' => 'TRUE'));
1414
+		$settings = array_merge($settings, array('globalArchiveResults' => 'TRUE'));
1415 1415
 	} else {
1416
-		$settings = array_merge($settings,array('globalArchiveResults' => 'FALSE'));
1416
+		$settings = array_merge($settings, array('globalArchiveResults' => 'FALSE'));
1417 1417
 	}
1418
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1418
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1419 1419
 	if ($daemon == 'daemon') {
1420
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1420
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1421 1421
 	} else {
1422
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1422
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1423 1423
 	}
1424
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1424
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1425 1425
 	if ($schedules == 'schedules') {
1426
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1426
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1427 1427
 	} else {
1428
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1428
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1429 1429
 	}
1430 1430
 
1431 1431
 /*
@@ -1436,280 +1436,280 @@  discard block
 block discarded – undo
1436 1436
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1437 1437
 	}
1438 1438
 */
1439
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1440
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1441
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1442
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1443
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1439
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1440
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1441
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1442
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1443
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1444 1444
 	$va = false;
1445 1445
 	if ($globalivao == 'ivao') {
1446
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1446
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1447 1447
 		$va = true;
1448
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1448
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1449 1449
 	if ($globalvatsim == 'vatsim') {
1450
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1450
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1451 1451
 		$va = true;
1452
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1452
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1453 1453
 	if ($globalphpvms == 'phpvms') {
1454
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1454
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1455 1455
 		$va = true;
1456
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1456
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1457 1457
 	if ($globalvam == 'vam') {
1458
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1458
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1459 1459
 		$va = true;
1460
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1460
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1461 1461
 	if ($va) {
1462
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1463
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1462
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1463
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1464 1464
 	if ($globalva == 'va' || $va) {
1465
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1466
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1465
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1466
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1467 1467
 	} else {
1468
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1469
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1470
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1468
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1469
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1470
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1471 1471
 	}
1472 1472
 	
1473 1473
 	
1474
-	$mapoffline = filter_input(INPUT_POST,'mapoffline',FILTER_SANITIZE_STRING);
1474
+	$mapoffline = filter_input(INPUT_POST, 'mapoffline', FILTER_SANITIZE_STRING);
1475 1475
 	if ($mapoffline == 'mapoffline') {
1476
-		$settings = array_merge($settings,array('globalMapOffline' => 'TRUE'));
1476
+		$settings = array_merge($settings, array('globalMapOffline' => 'TRUE'));
1477 1477
 	} else {
1478
-		$settings = array_merge($settings,array('globalMapOffline' => 'FALSE'));
1478
+		$settings = array_merge($settings, array('globalMapOffline' => 'FALSE'));
1479 1479
 	}
1480
-	$globaloffline = filter_input(INPUT_POST,'globaloffline',FILTER_SANITIZE_STRING);
1480
+	$globaloffline = filter_input(INPUT_POST, 'globaloffline', FILTER_SANITIZE_STRING);
1481 1481
 	if ($globaloffline == 'globaloffline') {
1482
-		$settings = array_merge($settings,array('globalOffline' => 'TRUE'));
1482
+		$settings = array_merge($settings, array('globalOffline' => 'TRUE'));
1483 1483
 	} else {
1484
-		$settings = array_merge($settings,array('globalOffline' => 'FALSE'));
1484
+		$settings = array_merge($settings, array('globalOffline' => 'FALSE'));
1485 1485
 	}
1486 1486
 
1487
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1487
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1488 1488
 	if ($notam == 'notam') {
1489
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1489
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1490 1490
 	} else {
1491
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1491
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1492 1492
 	}
1493
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1493
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1494 1494
 	if ($owner == 'owner') {
1495
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1495
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1496 1496
 	} else {
1497
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1497
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1498 1498
 	}
1499
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1499
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1500 1500
 	if ($map3d == 'map3d') {
1501
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1501
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1502 1502
 	} else {
1503
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1503
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1504 1504
 	}
1505
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1505
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1506 1506
 	if ($crash == 'crash') {
1507
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1507
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1508 1508
 	} else {
1509
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1509
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1510 1510
 	}
1511
-	$fires = filter_input(INPUT_POST,'fires',FILTER_SANITIZE_STRING);
1511
+	$fires = filter_input(INPUT_POST, 'fires', FILTER_SANITIZE_STRING);
1512 1512
 	if ($fires == 'fires') {
1513
-		$settings = array_merge($settings,array('globalMapFires' => 'TRUE'));
1513
+		$settings = array_merge($settings, array('globalMapFires' => 'TRUE'));
1514 1514
 	} else {
1515
-		$settings = array_merge($settings,array('globalMapFires' => 'FALSE'));
1515
+		$settings = array_merge($settings, array('globalMapFires' => 'FALSE'));
1516 1516
 	}
1517
-	$firessupport = filter_input(INPUT_POST,'firessupport',FILTER_SANITIZE_STRING);
1517
+	$firessupport = filter_input(INPUT_POST, 'firessupport', FILTER_SANITIZE_STRING);
1518 1518
 	if ($firessupport == 'firessupport') {
1519
-		$settings = array_merge($settings,array('globalFires' => 'TRUE'));
1519
+		$settings = array_merge($settings, array('globalFires' => 'TRUE'));
1520 1520
 	} else {
1521
-		$settings = array_merge($settings,array('globalFires' => 'FALSE'));
1521
+		$settings = array_merge($settings, array('globalFires' => 'FALSE'));
1522 1522
 	}
1523
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1523
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1524 1524
 	if ($mapsatellites == 'mapsatellites') {
1525
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1525
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1526 1526
 	} else {
1527
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1527
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1528 1528
 	}
1529
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1529
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1530 1530
 	if ($map3ddefault == 'map3ddefault') {
1531
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1531
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1532 1532
 	} else {
1533
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1533
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1534 1534
 	}
1535
-	$one3dmodel = filter_input(INPUT_POST,'one3dmodel',FILTER_SANITIZE_STRING);
1535
+	$one3dmodel = filter_input(INPUT_POST, 'one3dmodel', FILTER_SANITIZE_STRING);
1536 1536
 	if ($one3dmodel == 'one3dmodel') {
1537
-		$settings = array_merge($settings,array('globalMap3DOneModel' => 'TRUE'));
1537
+		$settings = array_merge($settings, array('globalMap3DOneModel' => 'TRUE'));
1538 1538
 	} else {
1539
-		$settings = array_merge($settings,array('globalMap3DOneModel' => 'FALSE'));
1539
+		$settings = array_merge($settings, array('globalMap3DOneModel' => 'FALSE'));
1540 1540
 	}
1541
-	$map3dliveries = filter_input(INPUT_POST,'map3dliveries',FILTER_SANITIZE_STRING);
1541
+	$map3dliveries = filter_input(INPUT_POST, 'map3dliveries', FILTER_SANITIZE_STRING);
1542 1542
 	if ($map3dliveries == 'map3dliveries') {
1543
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'TRUE'));
1543
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'TRUE'));
1544 1544
 	} else {
1545
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'FALSE'));
1545
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'FALSE'));
1546 1546
 	}
1547
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1547
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1548 1548
 	if ($translate == 'translate') {
1549
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1549
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1550 1550
 	} else {
1551
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1551
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1552 1552
 	}
1553
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1553
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1554 1554
 	if ($realairlines == 'realairlines') {
1555
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1555
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1556 1556
 	} else {
1557
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1557
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1558 1558
 	}
1559
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1559
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1560 1560
 	if ($estimation == 'estimation') {
1561
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1561
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1562 1562
 	} else {
1563
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1563
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1564 1564
 	}
1565
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1565
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1566 1566
 	if ($metar == 'metar') {
1567
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1567
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1568 1568
 	} else {
1569
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1569
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1570 1570
 	}
1571
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1571
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1572 1572
 	if ($metarcycle == 'metarcycle') {
1573
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1573
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1574 1574
 	} else {
1575
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1575
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1576 1576
 	}
1577
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1577
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1578 1578
 	if ($fork == 'fork') {
1579
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1579
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1580 1580
 	} else {
1581
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1581
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1582 1582
 	}
1583 1583
 
1584
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1584
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1585 1585
 	if ($colormap == 'colormap') {
1586
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1586
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1587 1587
 	} else {
1588
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1588
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1589 1589
 	}
1590 1590
 	
1591 1591
 	if (isset($_POST['aircrafticoncolor'])) {
1592
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1593
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1592
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1593
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1594 1594
 	}
1595 1595
 
1596
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1597
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1596
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1597
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1598 1598
 
1599
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1600
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1601
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1602
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1603
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1604
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1599
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1600
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1601
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1602
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1603
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1604
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1605 1605
 
1606
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1606
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1607 1607
 	if ($mappopup == 'mappopup') {
1608
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1608
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1609 1609
 	} else {
1610
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1610
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1611 1611
 	}
1612
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1612
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1613 1613
 	if ($airportpopup == 'airportpopup') {
1614
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1614
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1615 1615
 	} else {
1616
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1616
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1617 1617
 	}
1618
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1618
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1619 1619
 	if ($maphistory == 'maphistory') {
1620
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1620
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1621 1621
 	} else {
1622
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1622
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1623 1623
 	}
1624
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1624
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1625 1625
 	if ($maptooltip == 'maptooltip') {
1626
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1626
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1627 1627
 	} else {
1628
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1628
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1629 1629
 	}
1630
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1630
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1631 1631
 	if ($flightroute == 'flightroute') {
1632
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1632
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1633 1633
 	} else {
1634
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1634
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1635 1635
 	}
1636
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1636
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1637 1637
 	if ($flightremainingroute == 'flightremainingroute') {
1638
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1638
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1639 1639
 	} else {
1640
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1640
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1641 1641
 	}
1642
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1642
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1643 1643
 	if ($allflights == 'allflights') {
1644
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1644
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1645 1645
 	} else {
1646
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1646
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1647 1647
 	}
1648
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1648
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1649 1649
 	if ($bbox == 'bbox') {
1650
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1650
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1651 1651
 	} else {
1652
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1652
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1653 1653
 	}
1654
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1654
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1655 1655
 	if ($groundaltitude == 'groundaltitude') {
1656
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1656
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1657 1657
 	} else {
1658
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1658
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1659 1659
 	}
1660
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1660
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1661 1661
 	if ($waypoints == 'waypoints') {
1662
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1662
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1663 1663
 	} else {
1664
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1664
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1665 1665
 	}
1666
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1666
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1667 1667
 	if ($geoid == 'geoid') {
1668
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1668
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1669 1669
 	} else {
1670
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1670
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1671 1671
 	}
1672
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1673
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1672
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1673
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1674 1674
 
1675
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1675
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1676 1676
 	if ($noairlines == 'noairlines') {
1677
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1677
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1678 1678
 	} else {
1679
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1679
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1680 1680
 	}
1681 1681
 
1682
-	$tsk = filter_input(INPUT_POST,'tsk',FILTER_SANITIZE_STRING);
1682
+	$tsk = filter_input(INPUT_POST, 'tsk', FILTER_SANITIZE_STRING);
1683 1683
 	if ($tsk == 'tsk') {
1684
-		$settings = array_merge($settings,array('globalTSK' => 'TRUE'));
1684
+		$settings = array_merge($settings, array('globalTSK' => 'TRUE'));
1685 1685
 	} else {
1686
-		$settings = array_merge($settings,array('globalTSK' => 'FALSE'));
1686
+		$settings = array_merge($settings, array('globalTSK' => 'FALSE'));
1687 1687
 	}
1688
-	$mapmatching = filter_input(INPUT_POST,'mapmatching',FILTER_SANITIZE_STRING);
1688
+	$mapmatching = filter_input(INPUT_POST, 'mapmatching', FILTER_SANITIZE_STRING);
1689 1689
 	if ($mapmatching == 'mapmatching') {
1690
-		$settings = array_merge($settings,array('globalMapMatching' => 'TRUE'));
1690
+		$settings = array_merge($settings, array('globalMapMatching' => 'TRUE'));
1691 1691
 	} else {
1692
-		$settings = array_merge($settings,array('globalMapMatching' => 'FALSE'));
1692
+		$settings = array_merge($settings, array('globalMapMatching' => 'FALSE'));
1693 1693
 	}
1694
-	$mapmatchingsource = filter_input(INPUT_POST,'mapmatchingsource',FILTER_SANITIZE_STRING);
1695
-	$settings = array_merge($settings,array('globalMapMatchingSource' => $mapmatchingsource));
1696
-	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1697
-	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1694
+	$mapmatchingsource = filter_input(INPUT_POST, 'mapmatchingsource', FILTER_SANITIZE_STRING);
1695
+	$settings = array_merge($settings, array('globalMapMatchingSource' => $mapmatchingsource));
1696
+	$graphhopper = filter_input(INPUT_POST, 'graphhopper', FILTER_SANITIZE_STRING);
1697
+	$settings = array_merge($settings, array('globalGraphHopperKey' => $graphhopper));
1698 1698
 
1699
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1699
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1700 1700
 
1701 1701
 	// Set some defaults values...
1702 1702
 	if (!isset($globalAircraftImageSources)) {
1703
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1704
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1703
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1704
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1705 1705
 	}
1706 1706
 
1707 1707
 	if (!isset($globalSchedulesSources)) {
1708
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1709
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1708
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1709
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1710 1710
     	}
1711 1711
 
1712
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1712
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1713 1713
 
1714 1714
 	if ($error == '') settings::modify_settings($settings);
1715 1715
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
statistics-sub-menu.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 					$Spotter = new Spotter();
29 29
 					$alliances = $Spotter->getAllAllianceNames();
30 30
 					if (!empty($alliances)) {
31
-						foreach($alliances as $alliance) {
32
-							if (isset($airline_icao) && str_replace('_',' ',str_replace('alliance_','',$airline_icao)) == $alliance['alliance']) {
33
-								print '<option value="alliance_'.str_replace(' ','_',$alliance['alliance']).'" selected>'.$alliance['alliance'].'</option>';
31
+						foreach ($alliances as $alliance) {
32
+							if (isset($airline_icao) && str_replace('_', ' ', str_replace('alliance_', '', $airline_icao)) == $alliance['alliance']) {
33
+								print '<option value="alliance_'.str_replace(' ', '_', $alliance['alliance']).'" selected>'.$alliance['alliance'].'</option>';
34 34
 							} else {
35
-								print '<option value="alliance_'.str_replace(' ','_',$alliance['alliance']).'">'.$alliance['alliance'].'</option>';
35
+								print '<option value="alliance_'.str_replace(' ', '_', $alliance['alliance']).'">'.$alliance['alliance'].'</option>';
36 36
 							}
37 37
 						}
38 38
 						print '<option disabled>──────────</option>';
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 					$Stats = new Stats();
41 41
 					if (!isset($filter_name)) $filter_name = '';
42 42
 					$airlines = $Stats->getAllAirlineNames($filter_name);
43
-					foreach($airlines as $airline) {
43
+					foreach ($airlines as $airline) {
44 44
 						if ($airline['airline_icao'] != '') {
45 45
 							if (isset($airline_icao) && $airline_icao != 'all' && $airline_icao == $airline['airline_icao']) {
46 46
 								print '<option value="'.$airline['airline_icao'].'" selected>'.$airline['airline_name'].'</option>';
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	if (!isset($type) || $type == 'aircraft') {
66 66
 ?>
67 67
 		<li class="dropdown">
68
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" >
68
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" >
69 69
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
70 70
 		    </a>
71 71
 		    <ul class="dropdown-menu">
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		    </ul>
77 77
 		</li>
78 78
 		<li class="dropdown">
79
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
79
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#">
80 80
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
81 81
 		    </a>
82 82
 		    <ul class="dropdown-menu" role="menu">
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		    </ul>
93 93
 		</li>
94 94
 		<li class="dropdown">
95
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
95
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
96 96
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
97 97
 		    </a>
98 98
 		    <ul class="dropdown-menu" role="menu">
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		    </ul>
104 104
 		</li>
105 105
 		<li class="dropdown">
106
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
106
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#">
107 107
 		      <?php echo _("Route"); ?> <span class="caret"></span>
108 108
 		    </a>
109 109
 		    <ul class="dropdown-menu" role="menu">
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		    </ul>
113 113
 		</li>
114 114
 		<li class="dropdown">
115
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
115
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
116 116
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
117 117
 		    </a>
118 118
 		    <ul class="dropdown-menu" role="menu">
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
125 125
 		?>
126 126
 		<li class="dropdown">
127
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
127
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#">
128 128
 		      <?php echo _("Fatalities"); ?> <span class="caret"></span>
129 129
 		    </a>
130 130
 		    <ul class="dropdown-menu" role="menu">
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	} elseif ($type == 'marine' || $type == 'tracker') {
140 140
 ?>
141 141
 		<li class="dropdown">
142
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
142
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
143 143
 			<?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
144 144
 		    </a>
145 145
 		    <ul class="dropdown-menu" role="menu">
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	if (!isset($type) || $type == 'aircraft') {
170 170
 ?>
171 171
 		<li class="dropdown">
172
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" >
172
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" >
173 173
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
174 174
 		    </a>
175 175
 		    <ul class="dropdown-menu">
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		    </ul>
181 181
 		</li>
182 182
 		<li class="dropdown">
183
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
183
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#">
184 184
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
185 185
 		    </a>
186 186
 		    <ul class="dropdown-menu" role="menu">
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		    </ul>
197 197
 		</li>
198 198
 		<li class="dropdown">
199
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
199
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
200 200
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
201 201
 		    </a>
202 202
 		    <ul class="dropdown-menu" role="menu">
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		</li>
209 209
 		<!--
210 210
 		<li class="dropdown">
211
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
211
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#">
212 212
 		      <?php echo _("Route"); ?> <span class="caret"></span>
213 213
 		    </a>
214 214
 		    <ul class="dropdown-menu" role="menu">
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		-->
220 220
 		<!--
221 221
 		<li class="dropdown">
222
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
222
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
223 223
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
224 224
 		    </a>
225 225
 		    <ul class="dropdown-menu" role="menu">
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		?>
234 234
 		<!--
235 235
 		<li class="dropdown">
236
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
236
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#">
237 237
 		      <?php echo _("Fatalities"); ?> <span class="caret"></span>
238 238
 		    </a>
239 239
 		    <ul class="dropdown-menu" role="menu">
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	} elseif ($type == 'marine' || $type == 'tracker') {
250 250
 ?>
251 251
 		<li class="dropdown">
252
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
252
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#">
253 253
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
254 254
 		    </a>
255 255
 		    <ul class="dropdown-menu" role="menu">
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -175,8 +175,7 @@  discard block
 block discarded – undo
175 175
 		'\~' => 'TNC Stream SW');
176 176
 
177 177
 	private function urshift($n, $s) {
178
-		return ($n >= 0) ? ($n >> $s) :
179
-		    (($n & 0x7fffffff) >> $s) | 
178
+		return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
180 179
 		    (0x40000000 >> ($s - 1));
181 180
 	}
182 181
 
@@ -192,7 +191,7 @@  discard block
 block discarded – undo
192 191
 		$input_len = strlen($input);
193 192
 		
194 193
 		/* Find the end of header checking for NULL bytes while doing it. */
195
-		$splitpos = strpos($input,':');
194
+		$splitpos = strpos($input, ':');
196 195
 		
197 196
 		/* Check that end was found and body has at least one byte. */
198 197
 		if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -202,14 +201,14 @@  discard block
 block discarded – undo
202 201
 		
203 202
 		if ($debug) echo 'input : '.$input."\n";
204 203
 		/* Save header and body. */
205
-		$body = substr($input,$splitpos+1,$input_len);
204
+		$body = substr($input, $splitpos + 1, $input_len);
206 205
 		$body_len = strlen($body);
207
-		$header = substr($input,0,$splitpos);
206
+		$header = substr($input, 0, $splitpos);
208 207
 		if ($debug) echo 'header : '.$header."\n";
209 208
 		
210 209
 		/* Parse source, target and path. */
211 210
 		//FLRDF0A52>APRS,qAS,LSTB
212
-		if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
211
+		if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
213 212
 			$ident = $matches[1];
214 213
 			$all_elements = $matches[2];
215 214
 			if ($ident == 'AIRCRAFT') {
@@ -226,13 +225,13 @@  discard block
 block discarded – undo
226 225
 			if ($debug) 'No ident'."\n";
227 226
 			return false;
228 227
 		}
229
-		$elements = explode(',',$all_elements);
228
+		$elements = explode(',', $all_elements);
230 229
 		$source = end($elements);
231 230
 		$result['source'] = $source;
232 231
 		foreach ($elements as $element) {
233
-			if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
232
+			if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
234 233
 			//if ($element == 'TCPIP*') return false;
235
-			} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
234
+			} elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
236 235
 				if ($debug) echo 'element : '.$element."\n";
237 236
 				return false;
238 237
 			}
@@ -245,14 +244,14 @@  discard block
 block discarded – undo
245 244
 			*/
246 245
 		}
247 246
 		
248
-		$type = substr($body,0,1);
247
+		$type = substr($body, 0, 1);
249 248
 		if ($debug) echo 'type : '.$type."\n";
250 249
 		if ($type == ';') {
251 250
 			if (isset($result['source_type']) && $result['source_type'] == 'modes') {
252
-				$result['address'] = trim(substr($body,1,9));
251
+				$result['address'] = trim(substr($body, 1, 9));
253 252
 			} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
254
-				$result['mmsi'] = trim(substr($body,1,9));
255
-			} else $result['ident'] = trim(substr($body,1,9));
253
+				$result['mmsi'] = trim(substr($body, 1, 9));
254
+			} else $result['ident'] = trim(substr($body, 1, 9));
256 255
 		} elseif ($type == ',') {
257 256
 			// Invalid data or test data
258 257
 			return false;
@@ -260,20 +259,20 @@  discard block
 block discarded – undo
260 259
 		
261 260
 		// Check for Timestamp
262 261
 		$find = false;
263
-		$body_parse = substr($body,1);
264
-		if (preg_match('/^;(.){9}\*/',$body,$matches)) {
265
-			$body_parse = substr($body_parse,10);
262
+		$body_parse = substr($body, 1);
263
+		if (preg_match('/^;(.){9}\*/', $body, $matches)) {
264
+			$body_parse = substr($body_parse, 10);
266 265
 			$find = true;
267 266
 		}
268
-		if (preg_match('/^`(.*)\//',$body,$matches)) {
269
-			$body_parse = substr($body_parse,strlen($matches[1])-1);
267
+		if (preg_match('/^`(.*)\//', $body, $matches)) {
268
+			$body_parse = substr($body_parse, strlen($matches[1]) - 1);
270 269
 			$find = true;
271 270
 		}
272
-		if (preg_match("/^'(.*)\//",$body,$matches)) {
273
-			$body_parse = substr($body_parse,strlen($matches[1])-1);
271
+		if (preg_match("/^'(.*)\//", $body, $matches)) {
272
+			$body_parse = substr($body_parse, strlen($matches[1]) - 1);
274 273
 			$find = true;
275 274
 		}
276
-		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
275
+		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
277 276
 			$find = true;
278 277
 			$timestamp = $matches[0];
279 278
 			if ($matches[4] == 'h') {
@@ -286,17 +285,17 @@  discard block
 block discarded – undo
286 285
 				// This work or not ?
287 286
 				$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
288 287
 			}
289
-			$body_parse = substr($body_parse,7);
288
+			$body_parse = substr($body_parse, 7);
290 289
 			$result['timestamp'] = $timestamp;
291 290
 		}
292
-		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
291
+		if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
293 292
 			$find = true;
294 293
 			$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
295
-			$body_parse = substr($body_parse,8);
294
+			$body_parse = substr($body_parse, 8);
296 295
 			$result['timestamp'] = $timestamp;
297 296
 		}
298 297
 		//if (strlen($body_parse) > 19) {
299
-		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
298
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
300 299
 			$find = true;
301 300
 			// 4658.70N/00707.78Ez
302 301
 			$sind = strtoupper($matches[3]);
@@ -318,11 +317,11 @@  discard block
 block discarded – undo
318 317
 			    */
319 318
 			$latitude = $lat + floatval($lat_min)/60;
320 319
 			$longitude = $lon + floatval($lon_min)/60;
321
-			if ($sind == 'S') $latitude = 0-$latitude;
322
-			if ($wind == 'W') $longitude = 0-$longitude;
320
+			if ($sind == 'S') $latitude = 0 - $latitude;
321
+			if ($wind == 'W') $longitude = 0 - $longitude;
323 322
 			$result['latitude'] = $latitude;
324 323
 			$result['longitude'] = $longitude;
325
-			$body_parse = substr($body_parse,18);
324
+			$body_parse = substr($body_parse, 18);
326 325
 			$body_parse_len = strlen($body_parse);
327 326
 		}
328 327
 		$body_parse_len = strlen($body_parse);
@@ -349,22 +348,22 @@  discard block
 block discarded – undo
349 348
 				//'
350 349
 				//if ($type != ';' && $type != '>') {
351 350
 				if ($type != '') {
352
-					$body_parse = substr($body_parse,1);
351
+					$body_parse = substr($body_parse, 1);
353 352
 					$body_parse_len = strlen($body_parse);
354 353
 					$result['symbol_code'] = $symbol_code;
355 354
 					if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
356 355
 					if ($symbol_code != '_') {
357 356
 					}
358 357
 					if ($body_parse_len >= 7) {
359
-						if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
360
-							$course = substr($body_parse,0,3);
358
+						if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
359
+							$course = substr($body_parse, 0, 3);
361 360
 							$tmp_s = intval($course);
362 361
 							if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
363
-							$speed = substr($body_parse,4,3);
362
+							$speed = substr($body_parse, 4, 3);
364 363
 							if ($speed != '...') {
365 364
 								$result['speed'] = intval($speed);
366 365
 							}
367
-							$body_parse = substr($body_parse,7);
366
+							$body_parse = substr($body_parse, 7);
368 367
 						}
369 368
 						// Check PHGR, PHG, RNG
370 369
 					} 
@@ -374,11 +373,11 @@  discard block
 block discarded – undo
374 373
 					}
375 374
 					*/
376 375
 					if (strlen($body_parse) > 0) {
377
-						if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
376
+						if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
378 377
 							$altitude = intval($matches[1]);
379 378
 							$result['altitude'] = $altitude;
380 379
 							//$body_parse = trim(substr($body_parse,strlen($matches[0])));
381
-							$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
380
+							$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
382 381
 						}
383 382
 					}
384 383
 					// Telemetry
@@ -388,58 +387,58 @@  discard block
 block discarded – undo
388 387
 					}
389 388
 					*/
390 389
 					// DAO
391
-					if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
390
+					if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
392 391
 						$dao = $matches[1];
393
-						if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
392
+						if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
394 393
 							$dao_split = str_split($dao);
395
-							$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
396
-							$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
394
+							$lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
395
+							$lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
397 396
 							if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
398 397
 							else $result['latitude'] += $lat_off;
399 398
 							if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
400 399
 							else $result['longitude'] += $lon_off;
401 400
 						}
402
-						$body_parse = substr($body_parse,6);
401
+						$body_parse = substr($body_parse, 6);
403 402
 					}
404
-					if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
405
-						$result['ident'] = str_replace('_',' ',$matches[1]);
403
+					if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
404
+						$result['ident'] = str_replace('_', ' ', $matches[1]);
406 405
 					}
407
-					if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
406
+					if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
408 407
 						$result['squawk'] = $matches[1];
409 408
 					}
410
-					if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
409
+					if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
411 410
 						$result['aircraft_icao'] = $matches[1];
412 411
 					}
413
-					if (preg_match('/VR=([-0-9]*)/',$body_parse,$matches)) {
412
+					if (preg_match('/VR=([-0-9]*)/', $body_parse, $matches)) {
414 413
 						$result['verticalrate'] = $matches[1];
415 414
 					}
416
-					if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
415
+					if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
417 416
 						$result['typeid'] = $matches[1];
418 417
 					}
419
-					if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
418
+					if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
420 419
 						$result['statusid'] = $matches[1];
421 420
 					}
422
-					if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
421
+					if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
423 422
 						$result['imo'] = $matches[1];
424 423
 					}
425
-					if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
424
+					if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
426 425
 						$result['arrival_date'] = $matches[1];
427 426
 					}
428
-					if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
429
-						$result['arrival_code'] = str_replace('_',' ',$matches[1]);
427
+					if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
428
+						$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
430 429
 					}
431 430
 					// OGN comment
432 431
 					//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
433
-					if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
432
+					if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
434 433
 						$id = $matches[1];
435 434
 						//$mode = substr($id,0,2);
436
-						$address = substr($id,2);
437
-						$addressType = (intval(substr($id,0,2),16))&3;
435
+						$address = substr($id, 2);
436
+						$addressType = (intval(substr($id, 0, 2), 16))&3;
438 437
 						if ($addressType == 0) $result['addresstype'] = "RANDOM";
439 438
 						elseif ($addressType == 1) $result['addresstype'] = "ICAO";
440 439
 						elseif ($addressType == 2) $result['addresstype'] = "FLARM";
441 440
 						elseif ($addressType == 3) $result['addresstype'] = "OGN";
442
-						$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
441
+						$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
443 442
 						$result['aircrafttype_code'] = $aircraftType;
444 443
 						if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
445 444
 						elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -456,110 +455,110 @@  discard block
 block discarded – undo
456 455
 						elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
457 456
 						elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
458 457
 						elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
459
-						$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
458
+						$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
460 459
 						$result['stealth'] = $stealth;
461 460
 						$result['address'] = $address;
462 461
 					}
463 462
 					//Comment
464 463
 					$result['comment'] = trim($body_parse);
465 464
 					// parse weather
466
-					if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
465
+					if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
467 466
 						$result['wind_dir'] = intval($matches[1]);
468
-						$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
469
-						$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
470
-						$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
471
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
472
-					} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
467
+						$result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
468
+						$result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
469
+						$result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
470
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
471
+					} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
473 472
 						$result['wind_dir'] = intval($matches[1]);
474
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
475
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
476
-						$result['temp'] = round(5/9*(($matches[4])-32),1);
477
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
478
-					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
473
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
474
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
475
+						$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
476
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
477
+					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
479 478
 						$result['wind_dir'] = intval($matches[1]);
480
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
481
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
482
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
483
-					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
479
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
480
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
481
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
482
+					} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
484 483
 						$result['wind_dir'] = intval($matches[1]);
485
-						$result['wind_speed'] = round($matches[2]*1.60934,1);
486
-						$result['wind_gust'] = round($matches[3]*1.60934,1);
487
-						$body_parse = substr($body_parse,strlen($matches[0])+1);
484
+						$result['wind_speed'] = round($matches[2]*1.60934, 1);
485
+						$result['wind_gust'] = round($matches[3]*1.60934, 1);
486
+						$body_parse = substr($body_parse, strlen($matches[0]) + 1);
488 487
 					}
489 488
 					// temperature
490 489
 					//g012t088r000p000P000h38b10110
491 490
 					//g011t086r000p000P000h29b10198
492
-					if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
493
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
494
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
495
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
496
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
497
-						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
491
+					if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
492
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
493
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
494
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
495
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
496
+						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
498 497
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
499
-						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
500
-						$body_parse = substr($body_parse,strlen($matches[0]));
501
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
502
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
503
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
504
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
505
-						if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
506
-						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
498
+						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
499
+						$body_parse = substr($body_parse, strlen($matches[0]));
500
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
501
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
502
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
503
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
504
+						if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
505
+						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
507 506
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
508
-						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
509
-						$body_parse = substr($body_parse,strlen($matches[0]));
510
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
511
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
512
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
513
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
514
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
515
-						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
507
+						if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
508
+						$body_parse = substr($body_parse, strlen($matches[0]));
509
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
510
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
511
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
512
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
513
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
514
+						if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
516 515
 						if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
517
-						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
518
-						$body_parse = substr($body_parse,strlen($matches[0]));
519
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
520
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
523
-						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
516
+						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
517
+						$body_parse = substr($body_parse, strlen($matches[0]));
518
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
519
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
520
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
521
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
522
+						if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
524 523
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
525
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
526
-						$body_parse = substr($body_parse,strlen($matches[0]));
527
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
528
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
529
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
530
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
531
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
524
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
525
+						$body_parse = substr($body_parse, strlen($matches[0]));
526
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
527
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
528
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
529
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
530
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
532 531
 						if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
533
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
534
-						$body_parse = substr($body_parse,strlen($matches[0]));
535
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
536
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
537
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
538
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
539
-						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
532
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
533
+						$body_parse = substr($body_parse, strlen($matches[0]));
534
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
535
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
536
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
537
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
538
+						if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
540 539
 						if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
541
-						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
542
-						$body_parse = substr($body_parse,strlen($matches[0]));
543
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
544
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
545
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540
+						if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
541
+						$body_parse = substr($body_parse, strlen($matches[0]));
542
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
543
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
544
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
546 545
 						if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
547
-						if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
548
-						$body_parse = substr($body_parse,strlen($matches[0]));
549
-					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
550
-						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
551
-						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
552
-						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
546
+						if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
547
+						$body_parse = substr($body_parse, strlen($matches[0]));
548
+					} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
549
+						if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
550
+						if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
551
+						if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
553 552
 						if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
554
-						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
555
-						$body_parse = substr($body_parse,strlen($matches[0]));
553
+						if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
554
+						$body_parse = substr($body_parse, strlen($matches[0]));
556 555
 					}
557 556
 					$result['comment'] = trim($body_parse);
558 557
 				}
559 558
 			} else $result['comment'] = trim($body_parse);
560 559
 		}
561
-		if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
562
-		if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
560
+		if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
561
+		if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
563 562
 		if ($debug) print_r($result);
564 563
 		return $result;
565 564
 	}
@@ -568,34 +567,34 @@  discard block
 block discarded – undo
568 567
 	 * Connect to APRS server
569 568
 	*/
570 569
 	public function connect() {
571
-		global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
570
+		global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
572 571
 		$aprs_connect = 0;
573 572
 		$aprs_keep = 120;
574 573
 		$aprs_last_tx = time();
575 574
 		if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
576
-		else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
575
+		else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
577 576
 		if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
578
-		else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
577
+		else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
579 578
 		if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
580 579
 		else $aprs_pass = '-1';
581
-		$aprs_filter  = '';
580
+		$aprs_filter = '';
582 581
 		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
583 582
 		$Common = new Common();
584
-		$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
583
+		$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
585 584
 		if ($s !== false) {
586 585
 			echo 'Connected to APRS server! '."\n";
587 586
 			$authstart = time();
588 587
 			$this->socket = $s;
589
-			$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
590
-			socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
591
-			while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
588
+			$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
589
+			socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
590
+			while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
592 591
 				if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
593 592
 					echo 'APRS user verified !'."\n";
594 593
 					$this->connected = true;
595 594
 					return true;
596 595
 					break;
597 596
 				}
598
-				if (time()-$authstart > 5) {
597
+				if (time() - $authstart > 5) {
599 598
 					echo 'APRS timeout'."\n";
600 599
 					break;
601 600
 				}
@@ -617,7 +616,7 @@  discard block
 block discarded – undo
617 616
 	public function send($data) {
618 617
 		global $globalDebug;
619 618
 		if ($this->connected === false) $this->connect();
620
-		$send = socket_send( $this->socket  , $data , strlen($data),0);
619
+		$send = socket_send($this->socket, $data, strlen($data), 0);
621 620
 		if ($send === FALSE) {
622 621
 			if ($globalDebug) echo 'Reconnect...';
623 622
 			socket_close($this->socket);
@@ -627,17 +626,17 @@  discard block
 block discarded – undo
627 626
 }
628 627
 
629 628
 class APRSSpotter extends APRS {
630
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
629
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
631 630
 		$Common = new Common();
632 631
 		date_default_timezone_set('UTC');
633 632
 		if ($latitude != '' && $longitude != '') {
634 633
 			$lat = $latitude;
635 634
 			$long = $longitude;
636
-			$latitude = $Common->convertDM($latitude,'latitude');
637
-			$longitude = $Common->convertDM($longitude,'longitude');
638
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
639
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
640
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
635
+			$latitude = $Common->convertDM($latitude, 'latitude');
636
+			$longitude = $Common->convertDM($longitude, 'longitude');
637
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
638
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
639
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
641 640
 			$w = $w1.$w2;
642 641
 			//$w = '00';
643 642
 			$custom = '';
@@ -664,26 +663,26 @@  discard block
 block discarded – undo
664 663
 			$geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
665 664
 			$altitude_real = round($altitude_real + $geoid);
666 665
 			*/
667
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
666
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
668 667
 		}
669 668
 	}
670 669
 }
671 670
 class APRSMarine extends APRS {
672
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
671
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
673 672
 		$Common = new Common();
674 673
 		date_default_timezone_set('UTC');
675 674
 		if ($latitude != '' && $longitude != '') {
676
-			$latitude = $Common->convertDM($latitude,'latitude');
677
-			$longitude = $Common->convertDM($longitude,'longitude');
678
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
679
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
680
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
675
+			$latitude = $Common->convertDM($latitude, 'latitude');
676
+			$longitude = $Common->convertDM($longitude, 'longitude');
677
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
678
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
679
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
681 680
 			$w = $w1.$w2;
682 681
 			//$w = '00';
683 682
 			$custom = '';
684 683
 			if ($ident != '') {
685 684
 				if ($custom != '') $custom .= '/';
686
-				$custom .= 'CS='.str_replace(' ','_',$ident);
685
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
687 686
 			}
688 687
 			if ($typeid != '') {
689 688
 				if ($custom != '') $custom .= '/';
@@ -703,11 +702,11 @@  discard block
 block discarded – undo
703 702
 			}
704 703
 			if ($arrival_code != '') {
705 704
 				if ($custom != '') $custom .= '/';
706
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
705
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
707 706
 			}
708 707
 			if ($custom != '') $custom = ' '.$custom;
709 708
 			$altitude = 0;
710
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
709
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
711 710
 		}
712 711
 	}
713 712
 }
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +155 added lines, -155 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 (".$e.")\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,8 +112,8 @@  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']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$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
+		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']);
117 117
        }
118 118
 	$Spotter->db = null;
119 119
 	$Schedule->db = null;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 141
     		    $Spotter = new Spotter($this->db);
142 142
         	    $real_arrival = $this->arrival($key);
143
-        	    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
+        	    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']);
144 144
         	}
145 145
 	    }
146 146
 	}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $airport_time = '';
155 155
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
156 156
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
158 158
     	    if (isset($closestAirports[0])) {
159 159
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 160
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         		    break;
170 170
         		}
171 171
         	    }
172
-        	} 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
+        	} 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))) {
173 173
         		$airport_icao = $closestAirports[0]['icao'];
174 174
         		$airport_time = $this->all_flights[$key]['datetime'];
175 175
         	} else {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         } else {
183 183
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184 184
         }
185
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
186 186
     }
187 187
 
188 188
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
194 194
 	foreach ($this->all_flights as $key => $flight) {
195 195
 	    if (isset($flight['lastupdate'])) {
196
-		if ($flight['lastupdate'] < (time()-1800)) {
196
+		if ($flight['lastupdate'] < (time() - 1800)) {
197 197
 		    $this->delKey($key);
198 198
 		}
199 199
 	    }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$real_arrival = $this->arrival($key);
210 210
 			$Spotter = new Spotter($this->db);
211 211
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
212
-				$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
+				$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']);
213 213
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
214 214
 			}
215 215
 		}
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	$send = false;
243 243
 	
244 244
 	// SBS format is CSV format
245
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
246 246
 	    //print_r($line);
247 247
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
248
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
248
+  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
249 249
 
250 250
 		// Increment message number
251 251
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
@@ -278,25 +278,25 @@  discard block
 block discarded – undo
278 278
 		if (!isset($this->all_flights[$id])) {
279 279
 		    if ($globalDebug) echo 'New flight...'."\n";
280 280
 		    $this->all_flights[$id] = array();
281
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
282
-		    $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' => ''));
283
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
281
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
282
+		    $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' => ''));
283
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
284 284
 		    if (!isset($line['id'])) {
285 285
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
286 286
 //			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')));
287 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') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
288
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')));
289 289
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
290
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
291 291
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
292 292
 		}
293 293
 		if (isset($line['source_type']) && $line['source_type'] != '') {
294
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
294
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
295 295
 		}
296 296
 		
297 297
 		//print_r($this->all_flights);
298 298
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
299
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
299
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
300 300
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
301 301
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
302 302
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -305,20 +305,20 @@  discard block
 block discarded – undo
305 305
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
306 306
 			    $Spotter = new Spotter($this->db);
307 307
 			    if (isset($this->all_flights[$id]['source_type'])) {
308
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
308
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
309 309
 			    } else {
310 310
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
311 311
 			    }
312 312
 			    $Spotter->db = null;
313
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
314
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
313
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
314
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
315 315
 			}
316 316
 		    }
317 317
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
318 318
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
319 319
 		}
320 320
 	        if (isset($line['id']) && !isset($line['hex'])) {
321
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
321
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
322 322
 	        }
323 323
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
324 324
 			$icao = $line['aircraft_icao'];
@@ -327,14 +327,14 @@  discard block
 block discarded – undo
327 327
 				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
328 328
 				$Spotter->db = null;
329 329
 			}
330
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
330
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
331 331
 		} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
332 332
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
333 333
 				// Get aircraft ICAO from aircraft name
334 334
 				$Spotter = new Spotter($this->db);
335 335
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
336 336
 				$Spotter->db = null;
337
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
337
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
338 338
 			}
339 339
 		}
340 340
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -342,15 +342,15 @@  discard block
 block discarded – undo
342 342
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
343 343
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
344 344
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
345
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
345
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
346 346
 		}
347 347
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
348
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
348
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
349 349
 		}
350 350
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
351
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
351
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
352 352
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
353
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
353
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
354 354
 		    } else {
355 355
 				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";
356 356
 				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";
@@ -361,31 +361,31 @@  discard block
 block discarded – undo
361 361
 				*/
362 362
 				return '';
363 363
 		    }
364
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
364
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
365 365
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
366 366
 			return '';
367
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
367
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
368 368
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
369 369
 			return '';
370 370
 		} elseif (!isset($line['datetime'])) {
371 371
 			date_default_timezone_set('UTC');
372
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
372
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
373 373
 		} else {
374 374
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
375 375
 			return '';
376 376
 		}
377 377
 
378 378
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
379
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
379
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
380 380
 		}
381 381
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
382
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
382
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
383 383
 		}
384 384
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
385
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
385
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
386 386
 		}
387 387
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
388
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
388
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
389 389
 		}
390 390
  
391 391
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
394 394
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
395 395
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
396
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
397
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
398
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')));
399
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
400
-				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']));
396
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
397
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
398
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')));
399
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
400
+				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']));
401 401
 			} else {
402
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
402
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
403 403
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
404 404
 				$timeelapsed = microtime(true);
405 405
             			$Spotter = new Spotter($this->db);
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
410 410
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
411 411
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
412
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
412
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
413 413
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
414 414
 				$Spotter->db = null;
415
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
415
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
416 416
 			    }
417 417
 			}
418
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
419 419
 		    
420 420
 /*
421 421
 		    if (!isset($line['id'])) {
@@ -425,25 +425,25 @@  discard block
 block discarded – undo
425 425
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426 426
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
427 427
   */
428
-		    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']));
428
+		    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']));
429 429
 
430 430
 		    //$putinarchive = true;
431 431
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
432
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
432
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
433 433
 		    }
434 434
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
435
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
435
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
436 436
 		    }
437 437
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
438
-		    		$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' => ''));
438
+		    		$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' => ''));
439 439
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
440 440
 			$timeelapsed = microtime(true);
441 441
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
442 442
 				$Spotter = new Spotter($this->db);
443 443
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
444 444
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
445
-		    		$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' => ''));
446
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
445
+		    		$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' => ''));
446
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
447 447
                         }
448 448
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
449 449
 			$timeelapsed = microtime(true);
@@ -457,35 +457,35 @@  discard block
 block discarded – undo
457 457
 				$Translation->db = null;
458 458
 			    }
459 459
 			    $Spotter->db = null;
460
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
460
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
461 461
                     	}
462 462
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
463 463
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
464 464
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
465 465
 				//    $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']));
466
-		    		$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']));
466
+		    		$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']));
467 467
 		    	    }
468 468
 			}
469 469
 			if (!isset($globalFork)) $globalFork = TRUE;
470 470
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
471
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
471
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
472 472
 			}
473 473
 		    }
474 474
 		}
475 475
 
476 476
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
477 477
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
478
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
479
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
478
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
479
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
480 480
 		    //$dataFound = true;
481 481
 		} 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'])) {
482
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
482
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
483 483
 		    if ($distance > 1000 && $distance < 10000) {
484 484
 		    // use datetime
485 485
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
486 486
 			$speed = $speed*3.6;
487 487
 			if ($speed < 1000) {
488
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
488
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
489 489
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
490 490
 	  		} else {
491 491
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
501 501
 	    	    	return false;
502 502
 	    	    }
503
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
503
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
504 504
 	    	    else unset($timediff);
505
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
505
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
506 506
 	    	    else unset($timediff_archive);
507 507
 	    	    if ($this->tmd > 5
508 508
 	    	        || (isset($line['format_source']) 
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 	    	    	|| ($timediff > 30 
528 528
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
529 529
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
530
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
530
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
531 531
 	    	    	    )
532 532
 	    	    	) {
533 533
 
534 534
 			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']))) {
535 535
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
536 536
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
537
-				|| !$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'])) {
537
+				|| !$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'])) {
538 538
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
539 539
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
540 540
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 				    $timeelapsed = microtime(true);
545 545
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
546 546
 					$Spotter = new Spotter($this->db);
547
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
547
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
548 548
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
549 549
 					else $this->all_flights[$id]['over_country'] = '';
550 550
 					$Spotter->db = null;
551
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
551
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
552 552
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
553 553
 				    }
554 554
 				}
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
 					$this->all_flights[$id]['time_last_coord'] = time();
575 575
 				}
576 576
 				//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)) {
577
-				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)) {
577
+				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)) {
578 578
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
579 579
 				    $dataFound = true;
580 580
 				    $this->all_flights[$id]['time_last_coord'] = time();
581 581
 				}
582 582
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
583
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
583
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
584 584
 				/*
585 585
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
586 586
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -602,13 +602,13 @@  discard block
 block discarded – undo
602 602
 					$this->all_flights[$id]['time_last_coord'] = time();
603 603
 				}
604 604
 				//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)) {
605
-				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)) {
605
+				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)) {
606 606
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
607 607
 				    $dataFound = true;
608 608
 				    $this->all_flights[$id]['time_last_coord'] = time();
609 609
 				}
610 610
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
611
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
611
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
612 612
 				/*
613 613
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
614 614
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -626,46 +626,46 @@  discard block
 block discarded – undo
626 626
 		    } else if ($globalDebug && $timediff > 30) {
627 627
 			$this->tmd = $this->tmd + 1;
628 628
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
629
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
630
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
629
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
630
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
631 631
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
632 632
 		    }
633 633
 		}
634 634
 		if (isset($line['last_update']) && $line['last_update'] != '') {
635 635
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
636
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
637 637
 		}
638 638
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
639
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
639
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
640 640
 		    //$dataFound = true;
641 641
 		}
642 642
 		if (isset($line['format_source']) && $line['format_source'] != '') {
643
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
643
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
644 644
 		}
645 645
 		if (isset($line['source_name']) && $line['source_name'] != '') {
646
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
646
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
647 647
 		}
648 648
 		if (isset($line['emergency']) && $line['emergency'] != '') {
649
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
649
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
650 650
 		    //$dataFound = true;
651 651
 		}
652 652
 		if (isset($line['ground']) && $line['ground'] != '') {
653 653
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
654 654
 			// Here we force archive of flight because after ground it's a new one (or should be)
655
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
656
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
657
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')));
658
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
659
-			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']));
655
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
656
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
657
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')));
658
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
659
+			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']));
660 660
 		    }
661 661
 		    if ($line['ground'] != 1) $line['ground'] = 0;
662
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
662
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
663 663
 		    //$dataFound = true;
664 664
 		}
665 665
 		if (isset($line['squawk']) && $line['squawk'] != '') {
666 666
 		    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'])) {
667 667
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
668
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
668
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
669 669
 			    $highlight = '';
670 670
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
671 671
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -674,66 +674,66 @@  discard block
 block discarded – undo
674 674
 				$timeelapsed = microtime(true);
675 675
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
676 676
 				    $Spotter = new Spotter($this->db);
677
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
677
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
678 678
 				    $Spotter->db = null;
679
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
679
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
680 680
 				}
681 681
 				//$putinarchive = true;
682 682
 				//$highlight = '';
683 683
 			    }
684 684
 			    
685
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
685
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
686 686
 		    //$dataFound = true;
687 687
 		}
688 688
 
689 689
 		if (isset($line['altitude']) && $line['altitude'] != '') {
690 690
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
691 691
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
692
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
692
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
693 693
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
694 694
 					$line['altitude'] = $line['altitude'] - $geoid;
695 695
 				}
696 696
 			}
697 697
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
698
-			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;
699
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
700
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
698
+			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;
699
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
700
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
701 701
 			//$dataFound = true;
702 702
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
703 703
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
704 704
 			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) {
705 705
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
706
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
707
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
708
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')));
709
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
710
-				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']));
706
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
707
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
708
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')));
709
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
710
+				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']));
711 711
 			}
712 712
 		    }
713
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
713
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
714 714
 		}
715 715
 
716 716
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
717
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
717
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
718 718
 		}
719 719
 		
720 720
 		if (isset($line['heading']) && $line['heading'] != '') {
721
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
722
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
723
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
721
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
722
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
723
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
724 724
 		    //$dataFound = true;
725 725
   		} 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']) {
726
-  		    $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']);
727
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
728
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
726
+  		    $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']);
727
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
728
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
729 729
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
730 730
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
731 731
   		    // If not enough messages and ACARS set heading to 0
732
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
732
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
733 733
   		}
734
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
736
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
734
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
735
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
736
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
737 737
 
738 738
 //		print_r($this->all_flights[$id]);
739 739
 		//gets the callsign from the last hour
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
745 745
 		    $this->all_flights[$id]['lastupdate'] = time();
746 746
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
747
-		        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'])) {
747
+		        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'])) {
748 748
 			    //print_r($this->all_flights);
749 749
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
750 750
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -755,61 +755,61 @@  discard block
 block discarded – undo
755 755
 				    $SpotterLive = new SpotterLive($this->db);
756 756
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')) {
757 757
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
758
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
758
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
759 759
 				    } elseif (isset($line['id'])) {
760 760
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
761
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
761
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
762 762
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
763 763
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
764
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
764
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
765 765
 				    } else $recent_ident = '';
766
-				    $SpotterLive->db=null;
766
+				    $SpotterLive->db = null;
767 767
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
768 768
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
769 769
 				} else $recent_ident = '';
770 770
 			    } else {
771 771
 				$recent_ident = '';
772
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
772
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
773 773
 			    }
774 774
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
775
-			    if($recent_ident == "")
775
+			    if ($recent_ident == "")
776 776
 			    {
777 777
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
778 778
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
779 779
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
780 780
 				//adds the spotter data for the archive
781 781
 				$ignoreImport = false;
782
-				foreach($globalAirportIgnore as $airportIgnore) {
782
+				foreach ($globalAirportIgnore as $airportIgnore) {
783 783
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
784 784
 					$ignoreImport = true;
785 785
 				    }
786 786
 				}
787 787
 				if (count($globalAirportAccept) > 0) {
788 788
 				    $ignoreImport = true;
789
-				    foreach($globalAirportIgnore as $airportIgnore) {
789
+				    foreach ($globalAirportIgnore as $airportIgnore) {
790 790
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
791 791
 					    $ignoreImport = false;
792 792
 					}
793 793
 				    }
794 794
 				}
795 795
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
796
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
797
-					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)) {
796
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
797
+					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)) {
798 798
 					    $ignoreImport = true;
799 799
 					}
800 800
 				    }
801 801
 				}
802 802
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
803 803
 				    $ignoreImport = true;
804
-				    foreach($globalAirlineAccept as $airlineAccept) {
805
-					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)) {
804
+				    foreach ($globalAirlineAccept as $airlineAccept) {
805
+					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)) {
806 806
 					    $ignoreImport = false;
807 807
 					}
808 808
 				    }
809 809
 				}
810 810
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
811 811
 				    $ignoreImport = true;
812
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
812
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
813 813
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
814 814
 					    $ignoreImport = false;
815 815
 					}
@@ -821,32 +821,32 @@  discard block
 block discarded – undo
821 821
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
822 822
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
823 823
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
824
-				    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')));
824
+				    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')));
825 825
 				    $timeelapsed = microtime(true);
826 826
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
827 827
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
828 828
 					    $Spotter = new Spotter($this->db);
829
-					    $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']);
829
+					    $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']);
830 830
 					    $Spotter->db = null;
831 831
 					    if ($globalDebug && isset($result)) echo $result."\n";
832 832
 					}
833 833
 				    }
834
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
834
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
835 835
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836 836
 
837 837
 				    // Add source stat in DB
838 838
 				    $Stats = new Stats($this->db);
839 839
 				    if (!empty($this->stats)) {
840 840
 					if ($globalDebug) echo 'Add source stats : ';
841
-				        foreach($this->stats as $date => $data) {
842
-					    foreach($data as $source => $sourced) {
841
+				        foreach ($this->stats as $date => $data) {
842
+					    foreach ($data as $source => $sourced) {
843 843
 					        //print_r($sourced);
844
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
845
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
844
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
845
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
846 846
 				    		if (isset($sourced['msg'])) {
847 847
 				    		    if (time() - $sourced['msg']['date'] > 10) {
848 848
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
849
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
849
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
850 850
 			    			        unset($this->stats[$date][$source]['msg']);
851 851
 			    			    }
852 852
 			    			}
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
885 885
 					    $SpotterLive = new SpotterLive($this->db);
886 886
 					    $SpotterLive->deleteLiveSpotterData();
887
-					    $SpotterLive->db=null;
887
+					    $SpotterLive->db = null;
888 888
 					}
889 889
 				    }
890 890
 				    if ($globalDebug) echo " Done\n";
891 891
 				    $this->last_delete = time();
892 892
 				}
893 893
 			    } else {
894
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')) {
894
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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')) {
895 895
 				    $this->all_flights[$id]['id'] = $recent_ident;
896 896
 				    $this->all_flights[$id]['addedSpotter'] = 1;
897 897
 				}
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
900 900
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
901 901
 					    $Spotter = new Spotter($this->db);
902
-					    $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']);
902
+					    $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']);
903 903
 					    $Spotter->db = null;
904 904
 					}
905 905
 				    }
@@ -925,37 +925,37 @@  discard block
 block discarded – undo
925 925
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
926 926
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
927 927
 
928
-		    foreach($globalAirportIgnore as $airportIgnore) {
928
+		    foreach ($globalAirportIgnore as $airportIgnore) {
929 929
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
930 930
 			    $ignoreImport = true;
931 931
 			}
932 932
 		    }
933 933
 		    if (count($globalAirportAccept) > 0) {
934 934
 		        $ignoreImport = true;
935
-		        foreach($globalAirportIgnore as $airportIgnore) {
935
+		        foreach ($globalAirportIgnore as $airportIgnore) {
936 936
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
937 937
 				$ignoreImport = false;
938 938
 			    }
939 939
 			}
940 940
 		    }
941 941
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
942
-			foreach($globalAirlineIgnore as $airlineIgnore) {
943
-			    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)) {
942
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
943
+			    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)) {
944 944
 				$ignoreImport = true;
945 945
 			    }
946 946
 			}
947 947
 		    }
948 948
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
949 949
 			$ignoreImport = true;
950
-			foreach($globalAirlineAccept as $airlineAccept) {
951
-			    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)) {
950
+			foreach ($globalAirlineAccept as $airlineAccept) {
951
+			    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)) {
952 952
 				$ignoreImport = false;
953 953
 			    }
954 954
 			}
955 955
 		    }
956 956
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
957 957
 			$ignoreImport = true;
958
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
958
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
959 959
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
960 960
 			        $ignoreImport = false;
961 961
 			    }
@@ -963,23 +963,23 @@  discard block
 block discarded – undo
963 963
 		    }
964 964
 
965 965
 		    if (!$ignoreImport) {
966
-			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'])) {
967
-				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')));
966
+			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'])) {
967
+				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')));
968 968
 				$timeelapsed = microtime(true);
969 969
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
970 970
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
971 971
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
972 972
 					$SpotterLive = new SpotterLive($this->db);
973
-					$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']);
973
+					$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']);
974 974
 					$SpotterLive->db = null;
975 975
 					if ($globalDebug) echo $result."\n";
976 976
 				    }
977 977
 				}
978 978
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
979
-					$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']);
979
+					$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']);
980 980
 				}
981 981
 				$this->all_flights[$id]['putinarchive'] = false;
982
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
982
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
983 983
 
984 984
 				// Put statistics in $this->stats variable
985 985
 				//if ($line['format_source'] != 'aprs') {
@@ -998,19 +998,19 @@  discard block
 block discarded – undo
998 998
 							$latitude = $globalCenterLatitude;
999 999
 							$longitude = $globalCenterLongitude;
1000 1000
 						}
1001
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
1001
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
1002 1002
 					} else {
1003 1003
 						$latitude = $this->source_location[$source]['latitude'];
1004 1004
 						$longitude = $this->source_location[$source]['longitude'];
1005 1005
 					}
1006
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1006
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1007 1007
 					//$stats_heading = $stats_heading%22.5;
1008 1008
 					$stats_heading = round($stats_heading/22.5);
1009
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1009
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1010 1010
 					$current_date = date('Y-m-d');
1011 1011
 					if ($stats_heading == 16) $stats_heading = 0;
1012 1012
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1013
-						for ($i=0;$i<=15;$i++) {
1013
+						for ($i = 0; $i <= 15; $i++) {
1014 1014
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1015 1015
 						}
1016 1016
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1025,9 +1025,9 @@  discard block
 block discarded – undo
1025 1025
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1026 1026
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1027 1027
 						    end($this->stats[$current_date][$source]['hist']);
1028
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1028
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1029 1029
 						} else $mini = 0;
1030
-						for ($i=$mini;$i<=$distance;$i+=10) {
1030
+						for ($i = $mini; $i <= $distance; $i += 10) {
1031 1031
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1032 1032
 						}
1033 1033
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 				$this->all_flights[$id]['lastupdate'] = time();
1041 1041
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1042 1042
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1043
-			} 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";
1043
+			} 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";
1044 1044
 			//$this->del();
1045 1045
 			
1046 1046
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.