Completed
Push — master ( 932a16...3c5f23 )
by Yannick
34:57
created
install/class.update_db.php 1 patch
Spacing   +418 added lines, -418 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(array(':source' => 'website_fam'));
1298
-		} catch(PDOException $e) {
1298
+		} catch (PDOException $e) {
1299 1299
 			return "error : ".$e->getMessage();
1300 1300
 		}
1301 1301
 		$Connection = new Connection();
@@ -1308,12 +1308,12 @@  discard block
 block discarded – undo
1308 1308
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
1309 1309
 				try {
1310 1310
 					$sth = $Connection->db->prepare($query);
1311
-					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1312
-				} catch(PDOException $e) {
1311
+					$sth->execute(array(':callSign' => trim($data), ':source' => 'website_fam'));
1312
+				} catch (PDOException $e) {
1313 1313
 					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1314 1314
 					die();
1315 1315
 				}
1316
-				if ($globalTransaction && $i % 2000 == 0) {
1316
+				if ($globalTransaction && $i%2000 == 0) {
1317 1317
 					$Connection->db->commit();
1318 1318
 					if ($globalDebug) echo '.';
1319 1319
 					$Connection->db->beginTransaction();
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 			$Connection = new Connection();
1334 1334
 			$sth = $Connection->db->prepare($query);
1335 1335
                         $sth->execute();
1336
-                } catch(PDOException $e) {
1336
+                } catch (PDOException $e) {
1337 1337
                         return "error : ".$e->getMessage();
1338 1338
                 }
1339 1339
 
@@ -1354,8 +1354,8 @@  discard block
 block discarded – undo
1354 1354
 					$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)';
1355 1355
 					try {
1356 1356
 						$sth = $Connection->db->prepare($query);
1357
-						$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]));
1358
-					} catch(PDOException $e) {
1357
+						$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]));
1358
+					} catch (PDOException $e) {
1359 1359
 						return "error : ".$e->getMessage();
1360 1360
 					}
1361 1361
 				}
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 			$Connection = new Connection();
1375 1375
 			$sth = $Connection->db->prepare($query);
1376 1376
 			$sth->execute();
1377
-		} catch(PDOException $e) {
1377
+		} catch (PDOException $e) {
1378 1378
 			return "error : ".$e->getMessage();
1379 1379
 		}
1380 1380
 		$delimiter = "\t";
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
 					    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)';
1392 1392
 					try {
1393 1393
 						$sth = $Connection->db->prepare($query);
1394
-						$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]));
1395
-					} catch(PDOException $e) {
1394
+						$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]));
1395
+					} catch (PDOException $e) {
1396 1396
 						return "error : ".$e->getMessage();
1397 1397
 					}
1398 1398
 				}
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 			$Connection = new Connection();
1412 1412
 			$sth = $Connection->db->prepare($query);
1413 1413
 			$sth->execute();
1414
-		} catch(PDOException $e) {
1414
+		} catch (PDOException $e) {
1415 1415
 			return "error : ".$e->getMessage();
1416 1416
 		}
1417 1417
 
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 					try {
1428 1428
 						$sth = $Connection->db->prepare($query);
1429 1429
 						$sth->execute(array(':icao' => $icao));
1430
-					} catch(PDOException $e) {
1430
+					} catch (PDOException $e) {
1431 1431
 						return "error : ".$e->getMessage();
1432 1432
 					}
1433 1433
 				}
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
 		return '';
1439 1439
         }
1440 1440
 
1441
-	public static function tle($filename,$tletype) {
1441
+	public static function tle($filename, $tletype) {
1442 1442
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1443 1443
 		global $tmp_dir, $globalTransaction;
1444 1444
 		//$Spotter = new Spotter();
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 			$Connection = new Connection();
1449 1449
 			$sth = $Connection->db->prepare($query);
1450 1450
                         $sth->execute(array(':source' => $filename));
1451
-                } catch(PDOException $e) {
1451
+                } catch (PDOException $e) {
1452 1452
                         return "error : ".$e->getMessage();
1453 1453
                 }
1454 1454
 		
@@ -1473,8 +1473,8 @@  discard block
 block discarded – undo
1473 1473
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1474 1474
 					try {
1475 1475
 						$sth = $Connection->db->prepare($query);
1476
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1477
-					} catch(PDOException $e) {
1476
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1477
+					} catch (PDOException $e) {
1478 1478
 						return "error : ".$e->getMessage();
1479 1479
 					}
1480 1480
 
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 			$Connection = new Connection();
1496 1496
 			$sth = $Connection->db->prepare($query);
1497 1497
 			$sth->execute(array(':source' => $filename));
1498
-		} catch(PDOException $e) {
1498
+		} catch (PDOException $e) {
1499 1499
 			return "error : ".$e->getMessage();
1500 1500
 		}
1501 1501
 		
@@ -1506,13 +1506,13 @@  discard block
 block discarded – undo
1506 1506
 			$i = 0;
1507 1507
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1508 1508
 			//$Connection->db->beginTransaction();
1509
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1509
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1510 1510
 			{
1511 1511
 				if ($i > 0 && $data[0] != '') {
1512 1512
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1513
-					$period = str_replace(',','',$data[14]);
1514
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1515
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1513
+					$period = str_replace(',', '', $data[14]);
1514
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1515
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1516 1516
 					else $launch_date = NULL;
1517 1517
 					$data = array_map(function($value) {
1518 1518
 						return trim($value) === '' ? null : $value;
@@ -1522,8 +1522,8 @@  discard block
 block discarded – undo
1522 1522
 					    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)';
1523 1523
 					try {
1524 1524
 						$sth = $Connection->db->prepare($query);
1525
-						$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));
1526
-					} catch(PDOException $e) {
1525
+						$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));
1526
+					} catch (PDOException $e) {
1527 1527
 						return "error : ".$e->getMessage();
1528 1528
 					}
1529 1529
 				}
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1564 1564
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1565 1565
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1566
-			'EST' => array('country' => 'Estonia','owner' => ''),
1566
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1567 1567
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1568 1568
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1569 1569
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1687,10 +1687,10 @@  discard block
 block discarded – undo
1687 1687
 			{
1688 1688
 				if ($data != '') {
1689 1689
 				$result = array();
1690
-				$result['cospar'] = trim(substr($data,0,11));
1691
-				$result['norad'] = trim(substr($data,13,6));
1692
-				$result['operational'] = trim(substr($data,21,1));
1693
-				$result['name'] = trim(substr($data,23,24));
1690
+				$result['cospar'] = trim(substr($data, 0, 11));
1691
+				$result['norad'] = trim(substr($data, 13, 6));
1692
+				$result['operational'] = trim(substr($data, 21, 1));
1693
+				$result['name'] = trim(substr($data, 23, 24));
1694 1694
 				/*
1695 1695
 				    * R/B(1) = Rocket body, first stage
1696 1696
 				    * R/B(2) = Rocket body, second stage
@@ -1702,29 +1702,29 @@  discard block
 block discarded – undo
1702 1702
 				    * An ampersand (&) indicates two or more objects are attached
1703 1703
 				*/
1704 1704
 				
1705
-				$owner_code = trim(substr($data,49,5));
1705
+				$owner_code = trim(substr($data, 49, 5));
1706 1706
 				
1707 1707
 				if (!isset($satcat_sources[$owner_code])) {
1708 1708
 					echo $data;
1709 1709
 					echo 'owner_code: '.$owner_code."\n";
1710 1710
 				}
1711
-				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1712
-					echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1711
+				if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1712
+					echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n";
1713 1713
 				}
1714 1714
 				
1715
-				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
1715
+				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1716 1716
 					$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1717 1717
 					$result['owner'] = $satcat_sources[$owner_code]['owner'];
1718
-					$result['launch_date'] = trim(substr($data,56,10));
1719
-					$launch_site_code = trim(substr($data,68,5));
1718
+					$result['launch_date'] = trim(substr($data, 56, 10));
1719
+					$launch_site_code = trim(substr($data, 68, 5));
1720 1720
 					$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1721
-					$result['lifetime'] = trim(substr($data,75,10));
1722
-					$result['period'] = trim(substr($data,87,7));
1723
-					$result['inclination'] = trim(substr($data,96,5));
1724
-					$result['apogee'] = trim(substr($data,103,6));
1725
-					$result['perigee'] = trim(substr($data,111,6));
1721
+					$result['lifetime'] = trim(substr($data, 75, 10));
1722
+					$result['period'] = trim(substr($data, 87, 7));
1723
+					$result['inclination'] = trim(substr($data, 96, 5));
1724
+					$result['apogee'] = trim(substr($data, 103, 6));
1725
+					$result['perigee'] = trim(substr($data, 111, 6));
1726 1726
 					//$result['radarcross'] = trim(substr($data,119,8));
1727
-					$result['status'] = trim(substr($data,129,3));
1727
+					$result['status'] = trim(substr($data, 129, 3));
1728 1728
 					//print_r($result);
1729 1729
 					$result = array_map(function($value) {
1730 1730
 						return trim($value) === '' ? null : $value;
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
 							$sth = $Connection->db->prepare($query);
1738 1738
 							$sth->execute(array(':cospar' => $result['cospar']));
1739 1739
 							$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1740
-						} catch(PDOException $e) {
1740
+						} catch (PDOException $e) {
1741 1741
 							return "error : ".$e->getMessage();
1742 1742
 						}
1743 1743
 						if (empty($exist)) {
@@ -1749,10 +1749,10 @@  discard block
 block discarded – undo
1749 1749
 								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1750 1750
 								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1751 1751
 								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1752
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1752
+								    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1753 1753
 								    )
1754 1754
 								);
1755
-							} catch(PDOException $e) {
1755
+							} catch (PDOException $e) {
1756 1756
 								return "error : ".$e->getMessage();
1757 1757
 							}
1758 1758
 						} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1760,8 +1760,8 @@  discard block
 block discarded – undo
1760 1760
 							try {
1761 1761
 								$Connection = new Connection();
1762 1762
 								$sth = $Connection->db->prepare($query);
1763
-								$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1764
-							} catch(PDOException $e) {
1763
+								$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1764
+							} catch (PDOException $e) {
1765 1765
 								return "error : ".$e->getMessage();
1766 1766
 							}
1767 1767
 						}
@@ -1880,13 +1880,13 @@  discard block
 block discarded – undo
1880 1880
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1881 1881
 			{
1882 1882
 				$i++;
1883
-				if($i > 3 && count($row) > 2) {
1883
+				if ($i > 3 && count($row) > 2) {
1884 1884
 					$data = array_values(array_filter($row));
1885 1885
 					$cntdata = count($data);
1886 1886
 					if ($cntdata > 10) {
1887 1887
 						$value = $data[9];
1888 1888
 						
1889
-						for ($i =10;$i < $cntdata;$i++) {
1889
+						for ($i = 10; $i < $cntdata; $i++) {
1890 1890
 							$value .= ' '.$data[$i];
1891 1891
 						}
1892 1892
 						$data[9] = $value;
@@ -1896,8 +1896,8 @@  discard block
 block discarded – undo
1896 1896
 						$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)';
1897 1897
 						try {
1898 1898
 							$sth = $Connection->db->prepare($query);
1899
-							$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]));
1900
-						} catch(PDOException $e) {
1899
+							$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]));
1900
+						} catch (PDOException $e) {
1901 1901
 							return "error : ".$e->getMessage();
1902 1902
 						}
1903 1903
 					}
@@ -1914,22 +1914,22 @@  discard block
 block discarded – undo
1914 1914
 		require_once(dirname(__FILE__).'/../require/class.Source.php');
1915 1915
 		$delimiter = ',';
1916 1916
 		$Common = new Common();
1917
-		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv');
1917
+		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv');
1918 1918
 		$Connection = new Connection();
1919 1919
 		$Source = new Source();
1920 1920
 		$Source->deleteLocationByType('fires');
1921 1921
 		$i = 0;
1922
-		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1922
+		if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) {
1923 1923
 			if ($globalTransaction) $Connection->db->beginTransaction();
1924
-			while (($row = fgetcsv($handle,1000)) !== false) {
1924
+			while (($row = fgetcsv($handle, 1000)) !== false) {
1925 1925
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1926
-					$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]);
1926
+					$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]);
1927 1927
 					$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)";
1928
-					$query_values = array(':name' => '',':latitude' => $row[0], ':longitude' => $row[1],':altitude' => null,':city' => '',':country' => '',':logo' => 'fire.png',':source' => 'NASA',':type' => 'fires',':source_id' => 0,':last_seen' => $row[5].' '.substr($row[6],0,2).':'.substr($row[6],2,2),':location_id' => 0,':description' => json_encode($description));
1928
+					$query_values = array(':name' => '', ':latitude' => $row[0], ':longitude' => $row[1], ':altitude' => null, ':city' => '', ':country' => '', ':logo' => 'fire.png', ':source' => 'NASA', ':type' => 'fires', ':source_id' => 0, ':last_seen' => $row[5].' '.substr($row[6], 0, 2).':'.substr($row[6], 2, 2), ':location_id' => 0, ':description' => json_encode($description));
1929 1929
 					try {
1930 1930
 						$sth = $Connection->db->prepare($query);
1931 1931
 						$sth->execute($query_values);
1932
-					} catch(PDOException $e) {
1932
+					} catch (PDOException $e) {
1933 1933
 						echo "error : ".$e->getMessage();
1934 1934
 					}
1935 1935
 				}
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 			$Connection = new Connection();
1949 1949
 			$sth = $Connection->db->prepare($query);
1950 1950
 			$sth->execute();
1951
-		} catch(PDOException $e) {
1951
+		} catch (PDOException $e) {
1952 1952
 			return "error : ".$e->getMessage();
1953 1953
 		}
1954 1954
 		$header = NULL;
@@ -1959,12 +1959,12 @@  discard block
 block discarded – undo
1959 1959
 			if ($globalTransaction) $Connection->db->beginTransaction();
1960 1960
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1961 1961
 			{
1962
-				if(count($row) > 1) {
1962
+				if (count($row) > 1) {
1963 1963
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1964 1964
 					try {
1965 1965
 						$sth = $Connection->db->prepare($query);
1966
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1967
-					} catch(PDOException $e) {
1966
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1967
+					} catch (PDOException $e) {
1968 1968
 						return "error : ".$e->getMessage();
1969 1969
 					}
1970 1970
 				}
@@ -1984,21 +1984,21 @@  discard block
 block discarded – undo
1984 1984
 			try {
1985 1985
 				$sth = $Connection->db->prepare($query);
1986 1986
                     		$sth->execute();
1987
-	                } catch(PDOException $e) {
1987
+	                } catch (PDOException $e) {
1988 1988
 				return "error : ".$e->getMessage();
1989 1989
 	                }
1990 1990
 	        }
1991 1991
 
1992 1992
 
1993
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1993
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1994 1994
 		else {
1995
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1995
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1996 1996
 			$query = "CREATE EXTENSION postgis";
1997
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1997
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1998 1998
 			try {
1999 1999
 				$sth = $Connection->db->prepare($query);
2000 2000
 				$sth->execute();
2001
-			} catch(PDOException $e) {
2001
+			} catch (PDOException $e) {
2002 2002
 				return "error : ".$e->getMessage();
2003 2003
 			}
2004 2004
 		}
@@ -2011,13 +2011,13 @@  discard block
 block discarded – undo
2011 2011
 		include_once('class.create_db.php');
2012 2012
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2013 2013
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2014
-		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2014
+		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5');
2015 2015
 		$error = '';
2016 2016
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
2017
-			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
2017
+			$notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5'));
2018 2018
 			$notam_md5 = $notam_md5_file[0];
2019 2019
 			if (!update_db::check_notam_version($notam_md5)) {
2020
-				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2020
+				update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
2021 2021
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2022 2022
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2023 2023
 						if ($globalDebug) echo "Gunzip...";
@@ -2053,14 +2053,14 @@  discard block
 block discarded – undo
2053 2053
 			try {
2054 2054
 				$sth = $Connection->db->prepare($query);
2055 2055
             	        	$sth->execute();
2056
-	                } catch(PDOException $e) {
2056
+	                } catch (PDOException $e) {
2057 2057
     	                	echo "error : ".$e->getMessage();
2058 2058
 	                }
2059 2059
 		}
2060 2060
 		if ($globalDBdriver == 'mysql') {
2061
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
2061
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
2062 2062
 		} else {
2063
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
2063
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
2064 2064
 		}
2065 2065
 		$error = create_db::import_file($tmp_dir.'countries.sql');
2066 2066
 		return $error;
@@ -2073,7 +2073,7 @@  discard block
 block discarded – undo
2073 2073
 //		update_db::unzip($tmp_dir.'AptNav.zip');
2074 2074
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
2075 2075
 //		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');
2076
-		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');
2076
+		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');
2077 2077
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
2078 2078
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
2079 2079
 		return $error;
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2095 2095
 				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2096 2096
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2097
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2097
+					if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2098 2098
 				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2099 2099
 			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2100 2100
 		} else $error = "ZIP module not loaded but required for IVAO.";
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 		global $tmp_dir, $globalDebug;
2109 2109
 		$error = '';
2110 2110
 		if ($globalDebug) echo "Routes : Download...";
2111
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2111
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
2112 2112
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2113 2113
 			if ($globalDebug) echo "Gunzip...";
2114 2114
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
 		global $tmp_dir, $globalDebug;
2125 2125
 		$error = '';
2126 2126
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
2127
-		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2127
+		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
2128 2128
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2129 2129
 			if ($globalDebug) echo "Gunzip...";
2130 2130
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -2140,7 +2140,7 @@  discard block
 block discarded – undo
2140 2140
 		global $tmp_dir, $globalDebug;
2141 2141
 		$error = '';
2142 2142
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
2143
-		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2143
+		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
2144 2144
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2145 2145
 			if ($globalDebug) echo "Gunzip...";
2146 2146
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
 */
2169 2169
 		if ($globalDebug) echo "Modes : Download...";
2170 2170
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2171
-		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2171
+		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2172 2172
 
2173 2173
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2174 2174
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2188,7 +2188,7 @@  discard block
 block discarded – undo
2188 2188
 	public static function update_ModeS_faa() {
2189 2189
 		global $tmp_dir, $globalDebug;
2190 2190
 		if ($globalDebug) echo "Modes FAA: Download...";
2191
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2191
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2192 2192
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2193 2193
 			if ($globalDebug) echo "Unzip...";
2194 2194
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2204,7 +2204,7 @@  discard block
 block discarded – undo
2204 2204
 	public static function update_ModeS_flarm() {
2205 2205
 		global $tmp_dir, $globalDebug;
2206 2206
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2207
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2207
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2208 2208
 		if (file_exists($tmp_dir.'data.fln')) {
2209 2209
 			if ($globalDebug) echo "Add to DB...";
2210 2210
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2218,7 +2218,7 @@  discard block
 block discarded – undo
2218 2218
 	public static function update_ModeS_ogn() {
2219 2219
 		global $tmp_dir, $globalDebug;
2220 2220
 		if ($globalDebug) echo "Modes OGN: Download...";
2221
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2221
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2222 2222
 		if (file_exists($tmp_dir.'ogn.csv')) {
2223 2223
 			if ($globalDebug) echo "Add to DB...";
2224 2224
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2233,201 +2233,201 @@  discard block
 block discarded – undo
2233 2233
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2234 2234
 		
2235 2235
 		if ($globalDebug) echo "Owner France: Download...";
2236
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2236
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2237 2237
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2238 2238
 			if ($globalDebug) echo "Add to DB...";
2239
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2239
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2240 2240
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2241 2241
 		if ($error != '') {
2242 2242
 			return $error;
2243 2243
 		} elseif ($globalDebug) echo "Done\n";
2244 2244
 		
2245 2245
 		if ($globalDebug) echo "Owner Ireland: Download...";
2246
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2246
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2247 2247
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2248 2248
 			if ($globalDebug) echo "Add to DB...";
2249
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2249
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2250 2250
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2251 2251
 		if ($error != '') {
2252 2252
 			return $error;
2253 2253
 		} elseif ($globalDebug) echo "Done\n";
2254 2254
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2255
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2255
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2256 2256
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2257 2257
 			if ($globalDebug) echo "Add to DB...";
2258
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2258
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2259 2259
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2260 2260
 		if ($error != '') {
2261 2261
 			return $error;
2262 2262
 		} elseif ($globalDebug) echo "Done\n";
2263 2263
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2264
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2264
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2265 2265
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2266 2266
 			if ($globalDebug) echo "Add to DB...";
2267
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2267
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2268 2268
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2269 2269
 		if ($error != '') {
2270 2270
 			return $error;
2271 2271
 		} elseif ($globalDebug) echo "Done\n";
2272 2272
 		if ($globalDebug) echo "Owner Australia: Download...";
2273
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2273
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2274 2274
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2275 2275
 			if ($globalDebug) echo "Add to DB...";
2276
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2276
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2277 2277
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2278 2278
 		if ($error != '') {
2279 2279
 			return $error;
2280 2280
 		} elseif ($globalDebug) echo "Done\n";
2281 2281
 		if ($globalDebug) echo "Owner Austria: Download...";
2282
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2282
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2283 2283
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2284 2284
 			if ($globalDebug) echo "Add to DB...";
2285
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2285
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2286 2286
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2287 2287
 		if ($error != '') {
2288 2288
 			return $error;
2289 2289
 		} elseif ($globalDebug) echo "Done\n";
2290 2290
 		if ($globalDebug) echo "Owner Chile: Download...";
2291
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2291
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2292 2292
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2293 2293
 			if ($globalDebug) echo "Add to DB...";
2294
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2294
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2295 2295
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2296 2296
 		if ($error != '') {
2297 2297
 			return $error;
2298 2298
 		} elseif ($globalDebug) echo "Done\n";
2299 2299
 		if ($globalDebug) echo "Owner Colombia: Download...";
2300
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2300
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2301 2301
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2302 2302
 			if ($globalDebug) echo "Add to DB...";
2303
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2303
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2304 2304
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2305 2305
 		if ($error != '') {
2306 2306
 			return $error;
2307 2307
 		} elseif ($globalDebug) echo "Done\n";
2308 2308
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2309
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2309
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2310 2310
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2311 2311
 			if ($globalDebug) echo "Add to DB...";
2312
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2312
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2313 2313
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2314 2314
 		if ($error != '') {
2315 2315
 			return $error;
2316 2316
 		} elseif ($globalDebug) echo "Done\n";
2317 2317
 		if ($globalDebug) echo "Owner Brazil: Download...";
2318
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2318
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2319 2319
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2320 2320
 			if ($globalDebug) echo "Add to DB...";
2321
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2321
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2322 2322
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2323 2323
 		if ($error != '') {
2324 2324
 			return $error;
2325 2325
 		} elseif ($globalDebug) echo "Done\n";
2326 2326
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2327
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2327
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2328 2328
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2329 2329
 			if ($globalDebug) echo "Add to DB...";
2330
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2330
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2331 2331
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2332 2332
 		if ($error != '') {
2333 2333
 			return $error;
2334 2334
 		} elseif ($globalDebug) echo "Done\n";
2335 2335
 		if ($globalDebug) echo "Owner Croatia: Download...";
2336
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2336
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2337 2337
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2338 2338
 			if ($globalDebug) echo "Add to DB...";
2339
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2339
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2340 2340
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2341 2341
 		if ($error != '') {
2342 2342
 			return $error;
2343 2343
 		} elseif ($globalDebug) echo "Done\n";
2344 2344
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2345
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2345
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2346 2346
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2347 2347
 			if ($globalDebug) echo "Add to DB...";
2348
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2348
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2349 2349
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2350 2350
 		if ($error != '') {
2351 2351
 			return $error;
2352 2352
 		} elseif ($globalDebug) echo "Done\n";
2353 2353
 		if ($globalDebug) echo "Owner Maldives: Download...";
2354
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2354
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2355 2355
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2356 2356
 			if ($globalDebug) echo "Add to DB...";
2357
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2357
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2358 2358
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2359 2359
 		if ($error != '') {
2360 2360
 			return $error;
2361 2361
 		} elseif ($globalDebug) echo "Done\n";
2362 2362
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2363
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2363
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2364 2364
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2365 2365
 			if ($globalDebug) echo "Add to DB...";
2366
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2366
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2367 2367
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2368 2368
 		if ($error != '') {
2369 2369
 			return $error;
2370 2370
 		} elseif ($globalDebug) echo "Done\n";
2371 2371
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2372
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2372
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2373 2373
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2374 2374
 			if ($globalDebug) echo "Add to DB...";
2375
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2375
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2376 2376
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2377 2377
 		if ($error != '') {
2378 2378
 			return $error;
2379 2379
 		} elseif ($globalDebug) echo "Done\n";
2380 2380
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2381
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2381
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2382 2382
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2383 2383
 			if ($globalDebug) echo "Add to DB...";
2384
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2384
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2385 2385
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2386 2386
 		if ($error != '') {
2387 2387
 			return $error;
2388 2388
 		} elseif ($globalDebug) echo "Done\n";
2389 2389
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2390
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2390
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2391 2391
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2392 2392
 			if ($globalDebug) echo "Add to DB...";
2393
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2393
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2394 2394
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2395 2395
 		if ($error != '') {
2396 2396
 			return $error;
2397 2397
 		} elseif ($globalDebug) echo "Done\n";
2398 2398
 		if ($globalDebug) echo "Owner Iceland: Download...";
2399
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2399
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2400 2400
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2401 2401
 			if ($globalDebug) echo "Add to DB...";
2402
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2402
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2403 2403
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2404 2404
 		if ($error != '') {
2405 2405
 			return $error;
2406 2406
 		} elseif ($globalDebug) echo "Done\n";
2407 2407
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2408
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2408
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2409 2409
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2410 2410
 			if ($globalDebug) echo "Add to DB...";
2411
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2411
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2412 2412
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2413 2413
 		if ($error != '') {
2414 2414
 			return $error;
2415 2415
 		} elseif ($globalDebug) echo "Done\n";
2416 2416
 		if ($globalMasterSource) {
2417 2417
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2418
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2418
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2419 2419
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2420 2420
 				if ($globalDebug) echo "Add to DB...";
2421
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2421
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2422 2422
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2423 2423
 			if ($error != '') {
2424 2424
 				return $error;
2425 2425
 			} elseif ($globalDebug) echo "Done\n";
2426 2426
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2427
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2427
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2428 2428
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2429 2429
 				if ($globalDebug) echo "Add to DB...";
2430
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2430
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2431 2431
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2432 2432
 			if ($error != '') {
2433 2433
 				return $error;
@@ -2440,7 +2440,7 @@  discard block
 block discarded – undo
2440 2440
 		global $tmp_dir, $globalDebug;
2441 2441
 		$error = '';
2442 2442
 		if ($globalDebug) echo "Translation : Download...";
2443
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2443
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2444 2444
 		if (file_exists($tmp_dir.'translation.zip')) {
2445 2445
 			if ($globalDebug) echo "Unzip...";
2446 2446
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2457,10 +2457,10 @@  discard block
 block discarded – undo
2457 2457
 		global $tmp_dir, $globalDebug;
2458 2458
 		$error = '';
2459 2459
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2460
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2461
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2460
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2461
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5');
2462 2462
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2463
-			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2463
+			$translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2464 2464
 			$translation_md5 = $translation_md5_file[0];
2465 2465
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2466 2466
 				if ($globalDebug) echo "Gunzip...";
@@ -2478,10 +2478,10 @@  discard block
 block discarded – undo
2478 2478
 		global $tmp_dir, $globalDebug;
2479 2479
 		$error = '';
2480 2480
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2481
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2482
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2481
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2482
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5');
2483 2483
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2484
-			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2484
+			$modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2485 2485
 			$modes_md5 = $modes_md5_file[0];
2486 2486
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2487 2487
 				if ($globalDebug) echo "Gunzip...";
@@ -2500,12 +2500,12 @@  discard block
 block discarded – undo
2500 2500
 		global $tmp_dir, $globalDebug;
2501 2501
 		$error = '';
2502 2502
 		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2503
-		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2503
+		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5');
2504 2504
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2505
-			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2505
+			$airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2506 2506
 			$airlines_md5 = $airlines_md5_file[0];
2507 2507
 			if (!update_db::check_airlines_version($airlines_md5)) {
2508
-				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2508
+				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz');
2509 2509
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2510 2510
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2511 2511
 						if ($globalDebug) echo "Gunzip...";
@@ -2530,14 +2530,14 @@  discard block
 block discarded – undo
2530 2530
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2531 2531
 		$error = '';
2532 2532
 		if ($globalOwner === TRUE) {
2533
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2534
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2533
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2534
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2535 2535
 		} else {
2536
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2537
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2536
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2537
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2538 2538
 		}
2539 2539
 		if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) {
2540
-			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2540
+			$owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2541 2541
 			$owners_md5 = $owners_md5_file[0];
2542 2542
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2543 2543
 				if ($globalDebug) echo "Gunzip...";
@@ -2554,10 +2554,10 @@  discard block
 block discarded – undo
2554 2554
 	public static function update_routes_fam() {
2555 2555
 		global $tmp_dir, $globalDebug;
2556 2556
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2557
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2558
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2557
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2558
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5');
2559 2559
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2560
-			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2560
+			$routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2561 2561
 			$routes_md5 = $routes_md5_file[0];
2562 2562
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2563 2563
 				if ($globalDebug) echo "Gunzip...";
@@ -2574,10 +2574,10 @@  discard block
 block discarded – undo
2574 2574
 	public static function update_block_fam() {
2575 2575
 		global $tmp_dir, $globalDebug;
2576 2576
 		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
2577
-		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2578
-		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2577
+		update_db::download('http://data.flightairmap.com/data/block.tsv.gz', $tmp_dir.'block.tsv.gz');
2578
+		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5', $tmp_dir.'block.tsv.gz.md5');
2579 2579
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2580
-			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2580
+			$block_md5_file = explode(' ', file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2581 2581
 			$block_md5 = $block_md5_file[0];
2582 2582
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2583 2583
 				if ($globalDebug) echo "Gunzip...";
@@ -2593,13 +2593,13 @@  discard block
 block discarded – undo
2593 2593
 	}
2594 2594
 	public static function update_marine_identity_fam() {
2595 2595
 		global $tmp_dir, $globalDebug;
2596
-		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2596
+		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2597 2597
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2598
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2598
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2599 2599
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2600 2600
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2601 2601
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2602
-				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2602
+				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2603 2603
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2604 2604
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2605 2605
 						if ($globalDebug) echo "Gunzip...";
@@ -2621,13 +2621,13 @@  discard block
 block discarded – undo
2621 2621
 
2622 2622
 	public static function update_satellite_fam() {
2623 2623
 		global $tmp_dir, $globalDebug;
2624
-		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2624
+		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2625 2625
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2626
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2626
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2627 2627
 			$satellite_md5 = $satellite_md5_file[0];
2628 2628
 			if (!update_db::check_satellite_version($satellite_md5)) {
2629 2629
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2630
-				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2630
+				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2631 2631
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2632 2632
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2633 2633
 						if ($globalDebug) echo "Gunzip...";
@@ -2649,7 +2649,7 @@  discard block
 block discarded – undo
2649 2649
 	public static function update_banned_fam() {
2650 2650
 		global $tmp_dir, $globalDebug;
2651 2651
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2652
-		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2652
+		update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2653 2653
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2654 2654
 			//if ($globalDebug) echo "Gunzip...";
2655 2655
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2668,18 +2668,18 @@  discard block
 block discarded – undo
2668 2668
 		$error = '';
2669 2669
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2670 2670
 		if ($globalDBdriver == 'mysql') {
2671
-			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2671
+			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2672 2672
 		} else {
2673
-			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2673
+			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2674 2674
 		}
2675 2675
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2676
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2676
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2677 2677
 			$airspace_md5 = $airspace_md5_file[0];
2678 2678
 			if (!update_db::check_airspace_version($airspace_md5)) {
2679 2679
 				if ($globalDBdriver == 'mysql') {
2680
-					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2680
+					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2681 2681
 				} else {
2682
-					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2682
+					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2683 2683
 				}
2684 2684
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2685 2685
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
@@ -2692,7 +2692,7 @@  discard block
 block discarded – undo
2692 2692
 							try {
2693 2693
 								$sth = $Connection->db->prepare($query);
2694 2694
 								$sth->execute();
2695
-							} catch(PDOException $e) {
2695
+							} catch (PDOException $e) {
2696 2696
 								return "error : ".$e->getMessage();
2697 2697
 							}
2698 2698
 						}
@@ -2712,16 +2712,16 @@  discard block
 block discarded – undo
2712 2712
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2713 2713
 		$error = '';
2714 2714
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2715
-		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2715
+		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2716 2716
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2717
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2717
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2718 2718
 			$geoid_md5 = $geoid_md5_file[0];
2719 2719
 			if (!update_db::check_geoid_version($geoid_md5)) {
2720
-				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2720
+				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2721 2721
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2722 2722
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2723 2723
 						if ($globalDebug) echo "Gunzip...";
2724
-						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2724
+						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2725 2725
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2726 2726
 							update_db::insert_geoid_version($geoid_md5);
2727 2727
 						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
@@ -2738,15 +2738,15 @@  discard block
 block discarded – undo
2738 2738
 	public static function update_tle() {
2739 2739
 		global $tmp_dir, $globalDebug;
2740 2740
 		if ($globalDebug) echo "Download TLE : Download...";
2741
-		$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',
2742
-		'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',
2743
-		'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');
2741
+		$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',
2742
+		'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',
2743
+		'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');
2744 2744
 		foreach ($alltle as $filename) {
2745 2745
 			if ($globalDebug) echo "downloading ".$filename.'...';
2746
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2746
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2747 2747
 			if (file_exists($tmp_dir.$filename)) {
2748 2748
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2749
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2749
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2750 2750
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2751 2751
 			if ($error != '') {
2752 2752
 				echo $error."\n";
@@ -2758,7 +2758,7 @@  discard block
 block discarded – undo
2758 2758
 	public static function update_ucsdb() {
2759 2759
 		global $tmp_dir, $globalDebug;
2760 2760
 		if ($globalDebug) echo "Download UCS DB : Download...";
2761
-		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt',$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2761
+		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt', $tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2762 2762
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2763 2763
 			if ($globalDebug) echo "Add to DB...";
2764 2764
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
@@ -2772,7 +2772,7 @@  discard block
 block discarded – undo
2772 2772
 	public static function update_celestrak() {
2773 2773
 		global $tmp_dir, $globalDebug;
2774 2774
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2775
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2775
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2776 2776
 		if (file_exists($tmp_dir.'satcat.txt')) {
2777 2777
 			if ($globalDebug) echo "Add to DB...";
2778 2778
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2791,62 +2791,62 @@  discard block
 block discarded – undo
2791 2791
 			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
2792 2792
 			return '';
2793 2793
 		}
2794
-		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2794
+		update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2795 2795
 		if (file_exists($tmp_dir.'models.md5sum')) {
2796 2796
 			if ($globalDebug) echo "Check files...\n";
2797 2797
 			$newmodelsdb = array();
2798
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2799
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2798
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2799
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2800 2800
 					$model = trim($row[2]);
2801 2801
 					$newmodelsdb[$model] = trim($row[0]);
2802 2802
 				}
2803 2803
 			}
2804 2804
 			$modelsdb = array();
2805 2805
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2806
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2807
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2806
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2807
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2808 2808
 						$model = trim($row[2]);
2809 2809
 						$modelsdb[$model] = trim($row[0]);
2810 2810
 					}
2811 2811
 				}
2812 2812
 			}
2813
-			$diff = array_diff($newmodelsdb,$modelsdb);
2813
+			$diff = array_diff($newmodelsdb, $modelsdb);
2814 2814
 			foreach ($diff as $key => $value) {
2815 2815
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2816
-				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2816
+				update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2817 2817
 			}
2818
-			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2818
+			update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2819 2819
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2820 2820
 		if ($error != '') {
2821 2821
 			return $error;
2822 2822
 		} elseif ($globalDebug) echo "Done\n";
2823 2823
 		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
2824
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2824
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum');
2825 2825
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2826 2826
 			if ($globalDebug) echo "Check files...\n";
2827 2827
 			$newmodelsdb = array();
2828
-			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2829
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2828
+			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) {
2829
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2830 2830
 					$model = trim($row[2]);
2831 2831
 					$newmodelsdb[$model] = trim($row[0]);
2832 2832
 				}
2833 2833
 			}
2834 2834
 			$modelsdb = array();
2835 2835
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) {
2836
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) {
2837
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2836
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) {
2837
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2838 2838
 						$model = trim($row[2]);
2839 2839
 						$modelsdb[$model] = trim($row[0]);
2840 2840
 					}
2841 2841
 				}
2842 2842
 			}
2843
-			$diff = array_diff($newmodelsdb,$modelsdb);
2843
+			$diff = array_diff($newmodelsdb, $modelsdb);
2844 2844
 			foreach ($diff as $key => $value) {
2845 2845
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2846
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2846
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key);
2847 2847
 				
2848 2848
 			}
2849
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2849
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum');
2850 2850
 		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
2851 2851
 		if ($error != '') {
2852 2852
 			return $error;
@@ -2862,32 +2862,32 @@  discard block
 block discarded – undo
2862 2862
 			return '';
2863 2863
 		}
2864 2864
 		if ($globalDebug) echo "Weather Models from FlightAirMap website : Download...";
2865
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum');
2865
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', $tmp_dir.'modelsweather.md5sum');
2866 2866
 		if (file_exists($tmp_dir.'modelsweather.md5sum')) {
2867 2867
 			if ($globalDebug) echo "Check files...\n";
2868 2868
 			$newmodelsdb = array();
2869
-			if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) {
2870
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2869
+			if (($handle = fopen($tmp_dir.'modelsweather.md5sum', 'r')) !== FALSE) {
2870
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2871 2871
 					$model = trim($row[2]);
2872 2872
 					$newmodelsdb[$model] = trim($row[0]);
2873 2873
 				}
2874 2874
 			}
2875 2875
 			$modelsdb = array();
2876 2876
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum')) {
2877
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum','r')) !== FALSE) {
2878
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2877
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum', 'r')) !== FALSE) {
2878
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2879 2879
 						$model = trim($row[2]);
2880 2880
 						$modelsdb[$model] = trim($row[0]);
2881 2881
 					}
2882 2882
 				}
2883 2883
 			}
2884
-			$diff = array_diff($newmodelsdb,$modelsdb);
2884
+			$diff = array_diff($newmodelsdb, $modelsdb);
2885 2885
 			foreach ($diff as $key => $value) {
2886 2886
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2887
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2887
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key, dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2888 2888
 				
2889 2889
 			}
2890
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2890
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2891 2891
 		} else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
2892 2892
 		if ($error != '') {
2893 2893
 			return $error;
@@ -2899,32 +2899,32 @@  discard block
 block discarded – undo
2899 2899
 		global $tmp_dir, $globalDebug;
2900 2900
 		$error = '';
2901 2901
 		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
2902
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2902
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum');
2903 2903
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2904 2904
 			if ($globalDebug) echo "Check files...\n";
2905 2905
 			$newmodelsdb = array();
2906
-			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2907
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2906
+			if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) {
2907
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2908 2908
 					$model = trim($row[2]);
2909 2909
 					$newmodelsdb[$model] = trim($row[0]);
2910 2910
 				}
2911 2911
 			}
2912 2912
 			$modelsdb = array();
2913 2913
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) {
2914
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) {
2915
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2914
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) {
2915
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2916 2916
 						$model = trim($row[2]);
2917 2917
 						$modelsdb[$model] = trim($row[0]);
2918 2918
 					}
2919 2919
 				}
2920 2920
 			}
2921
-			$diff = array_diff($newmodelsdb,$modelsdb);
2921
+			$diff = array_diff($newmodelsdb, $modelsdb);
2922 2922
 			foreach ($diff as $key => $value) {
2923 2923
 				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
2924
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2924
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2925 2925
 				
2926 2926
 			}
2927
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2927
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2928 2928
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2929 2929
 		if ($error != '') {
2930 2930
 			return $error;
@@ -2940,32 +2940,32 @@  discard block
 block discarded – undo
2940 2940
 			return '';
2941 2941
 		}
2942 2942
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2943
-		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2943
+		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2944 2944
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2945 2945
 			if ($globalDebug) echo "Check files...\n";
2946 2946
 			$newmodelsdb = array();
2947
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2948
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2947
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2948
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2949 2949
 					$model = trim($row[2]);
2950 2950
 					$newmodelsdb[$model] = trim($row[0]);
2951 2951
 				}
2952 2952
 			}
2953 2953
 			$modelsdb = array();
2954 2954
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2955
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2956
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2955
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2956
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2957 2957
 						$model = trim($row[2]);
2958 2958
 						$modelsdb[$model] = trim($row[0]);
2959 2959
 					}
2960 2960
 				}
2961 2961
 			}
2962
-			$diff = array_diff($newmodelsdb,$modelsdb);
2962
+			$diff = array_diff($newmodelsdb, $modelsdb);
2963 2963
 			foreach ($diff as $key => $value) {
2964 2964
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2965
-				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2965
+				update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2966 2966
 				
2967 2967
 			}
2968
-			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2968
+			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2969 2969
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2970 2970
 		if ($error != '') {
2971 2971
 			return $error;
@@ -2981,32 +2981,32 @@  discard block
 block discarded – undo
2981 2981
 			return '';
2982 2982
 		}
2983 2983
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2984
-		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2984
+		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2985 2985
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2986 2986
 			if ($globalDebug) echo "Check files...\n";
2987 2987
 			$newmodelsdb = array();
2988
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2989
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2988
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2989
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2990 2990
 					$model = trim($row[2]);
2991 2991
 					$newmodelsdb[$model] = trim($row[0]);
2992 2992
 				}
2993 2993
 			}
2994 2994
 			$modelsdb = array();
2995 2995
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2996
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2997
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2996
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2997
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2998 2998
 						$model = trim($row[2]);
2999 2999
 						$modelsdb[$model] = trim($row[0]);
3000 3000
 					}
3001 3001
 				}
3002 3002
 			}
3003
-			$diff = array_diff($newmodelsdb,$modelsdb);
3003
+			$diff = array_diff($newmodelsdb, $modelsdb);
3004 3004
 			foreach ($diff as $key => $value) {
3005 3005
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3006
-				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
3006
+				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
3007 3007
 				
3008 3008
 			}
3009
-			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3009
+			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3010 3010
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3011 3011
 		if ($error != '') {
3012 3012
 			return $error;
@@ -3018,8 +3018,8 @@  discard block
 block discarded – undo
3018 3018
 		global $tmp_dir, $globalDebug;
3019 3019
 		date_default_timezone_set('UTC');
3020 3020
 		$Common = new Common();
3021
-		$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);
3022
-		$all = json_decode($data,true);
3021
+		$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);
3022
+		$all = json_decode($data, true);
3023 3023
 		$Connection = new Connection();
3024 3024
 		$querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao";
3025 3025
 		$sth = $Connection->db->prepare($querychk);
@@ -3031,8 +3031,8 @@  discard block
 block discarded – undo
3031 3031
 		foreach ($all as $model) {
3032 3032
 			$icao = $model['Designator'];
3033 3033
 			if (!isset($allicao[$icao])) {
3034
-				$aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png';
3035
-				$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']);
3034
+				$aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png';
3035
+				$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']);
3036 3036
 			} else {
3037 3037
 				$allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName'];
3038 3038
 			}
@@ -3044,9 +3044,9 @@  discard block
 block discarded – undo
3044 3044
 				if ($exist[0]['nb'] == 0) {
3045 3045
 					$sthins->execute($airdata);
3046 3046
 				} else {
3047
-					$sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao));
3047
+					$sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao));
3048 3048
 				}
3049
-			} catch(PDOException $e) {
3049
+			} catch (PDOException $e) {
3050 3050
 				return "error : ".$e->getMessage();
3051 3051
 			}
3052 3052
 		}
@@ -3078,23 +3078,23 @@  discard block
 block discarded – undo
3078 3078
 			$Connection = new Connection();
3079 3079
 			$sth = $Connection->db->prepare($query);
3080 3080
                         $sth->execute();
3081
-                } catch(PDOException $e) {
3081
+                } catch (PDOException $e) {
3082 3082
                         return "error : ".$e->getMessage();
3083 3083
                 }
3084 3084
 
3085 3085
 		$error = '';
3086 3086
 		if ($globalDebug) echo "Notam : Download...";
3087
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3087
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
3088 3088
 		if (file_exists($tmp_dir.'notam.rss')) {
3089
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
3089
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
3090 3090
 			foreach ($notams['channel']['item'] as $notam) {
3091
-				$title = explode(':',$notam['title']);
3091
+				$title = explode(':', $notam['title']);
3092 3092
 				$data['ref'] = trim($title[0]);
3093 3093
 				unset($title[0]);
3094
-				$data['title'] = trim(implode(':',$title));
3095
-				$description = strip_tags($notam['description'],'<pre>');
3096
-				preg_match(':^(.*?)<pre>:',$description,$match);
3097
-				$q = explode('/',$match[1]);
3094
+				$data['title'] = trim(implode(':', $title));
3095
+				$description = strip_tags($notam['description'], '<pre>');
3096
+				preg_match(':^(.*?)<pre>:', $description, $match);
3097
+				$q = explode('/', $match[1]);
3098 3098
 				$data['fir'] = $q[0];
3099 3099
 				$data['code'] = $q[1];
3100 3100
 				$ifrvfr = $q[2];
@@ -3110,30 +3110,30 @@  discard block
 block discarded – undo
3110 3110
 				$data['lower_limit'] = $q[5];
3111 3111
 				$data['upper_limit'] = $q[6];
3112 3112
 				$latlonrad = $q[7];
3113
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3114
-				$latitude = $Common->convertDec($las,'latitude');
3115
-				$longitude = $Common->convertDec($lns,'longitude');
3113
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
3114
+				$latitude = $Common->convertDec($las, 'latitude');
3115
+				$longitude = $Common->convertDec($lns, 'longitude');
3116 3116
 				if ($lac == 'S') $latitude = '-'.$latitude;
3117 3117
 				if ($lnc == 'W') $longitude = '-'.$longitude;
3118 3118
 				$data['center_latitude'] = $latitude;
3119 3119
 				$data['center_longitude'] = $longitude;
3120 3120
 				$data['radius'] = intval($radius);
3121 3121
 				
3122
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
3122
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
3123 3123
 				$data['text'] = $match[1];
3124
-				preg_match(':</pre>(.*?)$:',$description,$match);
3124
+				preg_match(':</pre>(.*?)$:', $description, $match);
3125 3125
 				$fromto = $match[1];
3126
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
3126
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
3127 3127
 				$fromall = trim($match[1]);
3128
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
3128
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
3129 3129
 				$from = trim($match[1]);
3130
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
3131
-				preg_match('#TO:(.*?)$#',$fromto,$match);
3130
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
3131
+				preg_match('#TO:(.*?)$#', $fromto, $match);
3132 3132
 				$toall = trim($match[1]);
3133
-				if (!preg_match(':Permanent:',$toall)) {
3134
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
3133
+				if (!preg_match(':Permanent:', $toall)) {
3134
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
3135 3135
 					$to = trim($match[1]);
3136
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3136
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
3137 3137
 					$data['permanent'] = 0;
3138 3138
 				} else {
3139 3139
 				    $data['date_end'] = NULL;
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
 				}
3142 3142
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3143 3143
 				$NOTAM = new NOTAM();
3144
-				$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']);
3144
+				$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']);
3145 3145
 				unset($data);
3146 3146
 			} 
3147 3147
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -3164,16 +3164,16 @@  discard block
 block discarded – undo
3164 3164
 				$Connection = new Connection();
3165 3165
 				$sth = $Connection->db->prepare($query);
3166 3166
 				$sth->execute();
3167
-			} catch(PDOException $e) {
3167
+			} catch (PDOException $e) {
3168 3168
 				return "error : ".$e->getMessage();
3169 3169
 			}
3170 3170
 		}
3171 3171
 		$Common = new Common();
3172 3172
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3173
-		$airspace_json = json_decode($airspace_lst,true);
3173
+		$airspace_json = json_decode($airspace_lst, true);
3174 3174
 		foreach ($airspace_json['records'] as $airspace) {
3175 3175
 			if ($globalDebug) echo $airspace['name']."...\n";
3176
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3176
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
3177 3177
 			if (file_exists($tmp_dir.$airspace['name'])) {
3178 3178
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
3179 3179
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -3195,7 +3195,7 @@  discard block
 block discarded – undo
3195 3195
 				$Connection = new Connection();
3196 3196
 				$sth = $Connection->db->prepare($query);
3197 3197
 				$sth->execute(array(':new' => $new, ':old' => $old));
3198
-			} catch(PDOException $e) {
3198
+			} catch (PDOException $e) {
3199 3199
 				return "error : ".$e->getMessage();
3200 3200
 			}
3201 3201
 		}
@@ -3212,7 +3212,7 @@  discard block
 block discarded – undo
3212 3212
 			$Connection = new Connection();
3213 3213
 			$sth = $Connection->db->prepare($query);
3214 3214
                         $sth->execute();
3215
-                } catch(PDOException $e) {
3215
+                } catch (PDOException $e) {
3216 3216
                         return "error : ".$e->getMessage();
3217 3217
                 }
3218 3218
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3227,7 +3227,7 @@  discard block
 block discarded – undo
3227 3227
 			$Connection = new Connection();
3228 3228
 			$sth = $Connection->db->prepare($query);
3229 3229
                         $sth->execute();
3230
-                } catch(PDOException $e) {
3230
+                } catch (PDOException $e) {
3231 3231
                         return "error : ".$e->getMessage();
3232 3232
                 }
3233 3233
 	}
@@ -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
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3252,7 +3252,7 @@  discard block
 block discarded – undo
3252 3252
 			$Connection = new Connection();
3253 3253
 			$sth = $Connection->db->prepare($query);
3254 3254
                         $sth->execute(array(':version' => $version));
3255
-                } catch(PDOException $e) {
3255
+                } catch (PDOException $e) {
3256 3256
                         return "error : ".$e->getMessage();
3257 3257
                 }
3258 3258
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3266,7 +3266,7 @@  discard block
 block discarded – undo
3266 3266
 			$Connection = new Connection();
3267 3267
 			$sth = $Connection->db->prepare($query);
3268 3268
 			$sth->execute(array(':version' => $version));
3269
-		} catch(PDOException $e) {
3269
+		} catch (PDOException $e) {
3270 3270
 			return "error : ".$e->getMessage();
3271 3271
 		}
3272 3272
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3280,7 +3280,7 @@  discard block
 block discarded – undo
3280 3280
 			$Connection = new Connection();
3281 3281
 			$sth = $Connection->db->prepare($query);
3282 3282
 			$sth->execute(array(':version' => $version));
3283
-		} catch(PDOException $e) {
3283
+		} catch (PDOException $e) {
3284 3284
 			return "error : ".$e->getMessage();
3285 3285
 		}
3286 3286
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3294,7 +3294,7 @@  discard block
 block discarded – undo
3294 3294
 			$Connection = new Connection();
3295 3295
 			$sth = $Connection->db->prepare($query);
3296 3296
 			$sth->execute(array(':version' => $version));
3297
-		} catch(PDOException $e) {
3297
+		} catch (PDOException $e) {
3298 3298
 			return "error : ".$e->getMessage();
3299 3299
 		}
3300 3300
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3308,7 +3308,7 @@  discard block
 block discarded – undo
3308 3308
 			$Connection = new Connection();
3309 3309
 			$sth = $Connection->db->prepare($query);
3310 3310
 			$sth->execute(array(':version' => $version));
3311
-		} catch(PDOException $e) {
3311
+		} catch (PDOException $e) {
3312 3312
 			return "error : ".$e->getMessage();
3313 3313
 		}
3314 3314
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3323,7 +3323,7 @@  discard block
 block discarded – undo
3323 3323
 			$Connection = new Connection();
3324 3324
 			$sth = $Connection->db->prepare($query);
3325 3325
 			$sth->execute(array(':version' => $version));
3326
-		} catch(PDOException $e) {
3326
+		} catch (PDOException $e) {
3327 3327
 			return "error : ".$e->getMessage();
3328 3328
 		}
3329 3329
 	}
@@ -3335,7 +3335,7 @@  discard block
 block discarded – undo
3335 3335
 			$Connection = new Connection();
3336 3336
 			$sth = $Connection->db->prepare($query);
3337 3337
 			$sth->execute(array(':version' => $version));
3338
-		} catch(PDOException $e) {
3338
+		} catch (PDOException $e) {
3339 3339
 			return "error : ".$e->getMessage();
3340 3340
 		}
3341 3341
 	}
@@ -3347,7 +3347,7 @@  discard block
 block discarded – undo
3347 3347
 			$Connection = new Connection();
3348 3348
 			$sth = $Connection->db->prepare($query);
3349 3349
 			$sth->execute(array(':version' => $version));
3350
-		} catch(PDOException $e) {
3350
+		} catch (PDOException $e) {
3351 3351
 			return "error : ".$e->getMessage();
3352 3352
 		}
3353 3353
 	}
@@ -3359,7 +3359,7 @@  discard block
 block discarded – undo
3359 3359
 			$Connection = new Connection();
3360 3360
 			$sth = $Connection->db->prepare($query);
3361 3361
                         $sth->execute(array(':version' => $version));
3362
-                } catch(PDOException $e) {
3362
+                } catch (PDOException $e) {
3363 3363
                         return "error : ".$e->getMessage();
3364 3364
                 }
3365 3365
 	}
@@ -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(array(':version' => $version));
3374
-		} catch(PDOException $e) {
3374
+		} catch (PDOException $e) {
3375 3375
 			return "error : ".$e->getMessage();
3376 3376
 		}
3377 3377
 	}
@@ -3383,7 +3383,7 @@  discard block
 block discarded – undo
3383 3383
 			$Connection = new Connection();
3384 3384
 			$sth = $Connection->db->prepare($query);
3385 3385
 			$sth->execute(array(':version' => $version));
3386
-		} catch(PDOException $e) {
3386
+		} catch (PDOException $e) {
3387 3387
 			return "error : ".$e->getMessage();
3388 3388
 		}
3389 3389
 	}
@@ -3399,7 +3399,7 @@  discard block
 block discarded – undo
3399 3399
 			$Connection = new Connection();
3400 3400
 			$sth = $Connection->db->prepare($query);
3401 3401
                         $sth->execute();
3402
-                } catch(PDOException $e) {
3402
+                } catch (PDOException $e) {
3403 3403
                         return "error : ".$e->getMessage();
3404 3404
                 }
3405 3405
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3414,7 +3414,7 @@  discard block
 block discarded – undo
3414 3414
 			$Connection = new Connection();
3415 3415
 			$sth = $Connection->db->prepare($query);
3416 3416
                         $sth->execute();
3417
-                } catch(PDOException $e) {
3417
+                } catch (PDOException $e) {
3418 3418
                         return "error : ".$e->getMessage();
3419 3419
                 }
3420 3420
 	}
@@ -3430,7 +3430,7 @@  discard block
 block discarded – undo
3430 3430
 			$Connection = new Connection();
3431 3431
 			$sth = $Connection->db->prepare($query);
3432 3432
                         $sth->execute();
3433
-                } catch(PDOException $e) {
3433
+                } catch (PDOException $e) {
3434 3434
                         return "error : ".$e->getMessage();
3435 3435
                 }
3436 3436
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3445,7 +3445,7 @@  discard block
 block discarded – undo
3445 3445
 			$Connection = new Connection();
3446 3446
 			$sth = $Connection->db->prepare($query);
3447 3447
                         $sth->execute();
3448
-                } catch(PDOException $e) {
3448
+                } catch (PDOException $e) {
3449 3449
                         return "error : ".$e->getMessage();
3450 3450
                 }
3451 3451
 	}
@@ -3461,7 +3461,7 @@  discard block
 block discarded – undo
3461 3461
 			$Connection = new Connection();
3462 3462
 			$sth = $Connection->db->prepare($query);
3463 3463
                         $sth->execute();
3464
-                } catch(PDOException $e) {
3464
+                } catch (PDOException $e) {
3465 3465
                         return "error : ".$e->getMessage();
3466 3466
                 }
3467 3467
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3476,7 +3476,7 @@  discard block
 block discarded – undo
3476 3476
 			$Connection = new Connection();
3477 3477
 			$sth = $Connection->db->prepare($query);
3478 3478
                         $sth->execute();
3479
-                } catch(PDOException $e) {
3479
+                } catch (PDOException $e) {
3480 3480
                         return "error : ".$e->getMessage();
3481 3481
                 }
3482 3482
 	}
@@ -3492,7 +3492,7 @@  discard block
 block discarded – undo
3492 3492
 			$Connection = new Connection();
3493 3493
 			$sth = $Connection->db->prepare($query);
3494 3494
 			$sth->execute();
3495
-		} catch(PDOException $e) {
3495
+		} catch (PDOException $e) {
3496 3496
 			return "error : ".$e->getMessage();
3497 3497
 		}
3498 3498
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3507,7 +3507,7 @@  discard block
 block discarded – undo
3507 3507
 			$Connection = new Connection();
3508 3508
 			$sth = $Connection->db->prepare($query);
3509 3509
 			$sth->execute();
3510
-		} catch(PDOException $e) {
3510
+		} catch (PDOException $e) {
3511 3511
 			return "error : ".$e->getMessage();
3512 3512
 		}
3513 3513
 	}
@@ -3523,7 +3523,7 @@  discard block
 block discarded – undo
3523 3523
 			$Connection = new Connection();
3524 3524
 			$sth = $Connection->db->prepare($query);
3525 3525
 			$sth->execute();
3526
-		} catch(PDOException $e) {
3526
+		} catch (PDOException $e) {
3527 3527
 			return "error : ".$e->getMessage();
3528 3528
 		}
3529 3529
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3538,7 +3538,7 @@  discard block
 block discarded – undo
3538 3538
 			$Connection = new Connection();
3539 3539
 			$sth = $Connection->db->prepare($query);
3540 3540
 			$sth->execute();
3541
-		} catch(PDOException $e) {
3541
+		} catch (PDOException $e) {
3542 3542
 			return "error : ".$e->getMessage();
3543 3543
 		}
3544 3544
 	}
@@ -3554,7 +3554,7 @@  discard block
 block discarded – undo
3554 3554
 			$Connection = new Connection();
3555 3555
 			$sth = $Connection->db->prepare($query);
3556 3556
 			$sth->execute();
3557
-		} catch(PDOException $e) {
3557
+		} catch (PDOException $e) {
3558 3558
 			return "error : ".$e->getMessage();
3559 3559
 		}
3560 3560
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3569,7 +3569,7 @@  discard block
 block discarded – undo
3569 3569
 			$Connection = new Connection();
3570 3570
 			$sth = $Connection->db->prepare($query);
3571 3571
 			$sth->execute();
3572
-		} catch(PDOException $e) {
3572
+		} catch (PDOException $e) {
3573 3573
 			return "error : ".$e->getMessage();
3574 3574
 		}
3575 3575
 	}
@@ -3585,7 +3585,7 @@  discard block
 block discarded – undo
3585 3585
 			$Connection = new Connection();
3586 3586
 			$sth = $Connection->db->prepare($query);
3587 3587
                         $sth->execute();
3588
-                } catch(PDOException $e) {
3588
+                } catch (PDOException $e) {
3589 3589
                         return "error : ".$e->getMessage();
3590 3590
                 }
3591 3591
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3600,7 +3600,7 @@  discard block
 block discarded – undo
3600 3600
 			$Connection = new Connection();
3601 3601
 			$sth = $Connection->db->prepare($query);
3602 3602
 			$sth->execute();
3603
-		} catch(PDOException $e) {
3603
+		} catch (PDOException $e) {
3604 3604
 			return "error : ".$e->getMessage();
3605 3605
 		}
3606 3606
 	}
@@ -3616,7 +3616,7 @@  discard block
 block discarded – undo
3616 3616
 			$Connection = new Connection();
3617 3617
 			$sth = $Connection->db->prepare($query);
3618 3618
 			$sth->execute();
3619
-		} catch(PDOException $e) {
3619
+		} catch (PDOException $e) {
3620 3620
 			return "error : ".$e->getMessage();
3621 3621
 		}
3622 3622
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3631,7 +3631,7 @@  discard block
 block discarded – undo
3631 3631
 			$Connection = new Connection();
3632 3632
 			$sth = $Connection->db->prepare($query);
3633 3633
 			$sth->execute();
3634
-		} catch(PDOException $e) {
3634
+		} catch (PDOException $e) {
3635 3635
 			return "error : ".$e->getMessage();
3636 3636
 		}
3637 3637
 	}
@@ -3647,7 +3647,7 @@  discard block
 block discarded – undo
3647 3647
 			$Connection = new Connection();
3648 3648
 			$sth = $Connection->db->prepare($query);
3649 3649
 			$sth->execute();
3650
-		} catch(PDOException $e) {
3650
+		} catch (PDOException $e) {
3651 3651
 			return "error : ".$e->getMessage();
3652 3652
 		}
3653 3653
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3662,7 +3662,7 @@  discard block
 block discarded – undo
3662 3662
 			$Connection = new Connection();
3663 3663
 			$sth = $Connection->db->prepare($query);
3664 3664
 			$sth->execute();
3665
-		} catch(PDOException $e) {
3665
+		} catch (PDOException $e) {
3666 3666
 			return "error : ".$e->getMessage();
3667 3667
 		}
3668 3668
 	}
@@ -3678,7 +3678,7 @@  discard block
 block discarded – undo
3678 3678
 			$Connection = new Connection();
3679 3679
 			$sth = $Connection->db->prepare($query);
3680 3680
 			$sth->execute();
3681
-		} catch(PDOException $e) {
3681
+		} catch (PDOException $e) {
3682 3682
 			return "error : ".$e->getMessage();
3683 3683
 		}
3684 3684
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3693,7 +3693,7 @@  discard block
 block discarded – undo
3693 3693
 			$Connection = new Connection();
3694 3694
 			$sth = $Connection->db->prepare($query);
3695 3695
 			$sth->execute();
3696
-		} catch(PDOException $e) {
3696
+		} catch (PDOException $e) {
3697 3697
 			return "error : ".$e->getMessage();
3698 3698
 		}
3699 3699
 	}
@@ -3709,7 +3709,7 @@  discard block
 block discarded – undo
3709 3709
 			$Connection = new Connection();
3710 3710
 			$sth = $Connection->db->prepare($query);
3711 3711
 			$sth->execute();
3712
-		} catch(PDOException $e) {
3712
+		} catch (PDOException $e) {
3713 3713
 			return "error : ".$e->getMessage();
3714 3714
 		}
3715 3715
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3728,7 +3728,7 @@  discard block
 block discarded – undo
3728 3728
 			$Connection = new Connection();
3729 3729
 			$sth = $Connection->db->prepare($query);
3730 3730
 			$sth->execute();
3731
-		} catch(PDOException $e) {
3731
+		} catch (PDOException $e) {
3732 3732
 			return "error : ".$e->getMessage();
3733 3733
 		}
3734 3734
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3743,7 +3743,7 @@  discard block
 block discarded – undo
3743 3743
 			$Connection = new Connection();
3744 3744
 			$sth = $Connection->db->prepare($query);
3745 3745
 			$sth->execute();
3746
-		} catch(PDOException $e) {
3746
+		} catch (PDOException $e) {
3747 3747
 			return "error : ".$e->getMessage();
3748 3748
 		}
3749 3749
 	}
@@ -3755,7 +3755,7 @@  discard block
 block discarded – undo
3755 3755
 			$Connection = new Connection();
3756 3756
 			$sth = $Connection->db->prepare($query);
3757 3757
 			$sth->execute();
3758
-		} catch(PDOException $e) {
3758
+		} catch (PDOException $e) {
3759 3759
 			return "error : ".$e->getMessage();
3760 3760
 		}
3761 3761
 	}
@@ -3771,7 +3771,7 @@  discard block
 block discarded – undo
3771 3771
 			$Connection = new Connection();
3772 3772
 			$sth = $Connection->db->prepare($query);
3773 3773
                         $sth->execute();
3774
-                } catch(PDOException $e) {
3774
+                } catch (PDOException $e) {
3775 3775
                         return "error : ".$e->getMessage();
3776 3776
                 }
3777 3777
 	}
@@ -3786,7 +3786,7 @@  discard block
 block discarded – undo
3786 3786
 			$Connection = new Connection();
3787 3787
 			$sth = $Connection->db->prepare($query);
3788 3788
                         $sth->execute();
3789
-                } catch(PDOException $e) {
3789
+                } catch (PDOException $e) {
3790 3790
                         return "error : ".$e->getMessage();
3791 3791
                 }
3792 3792
 	}
Please login to merge, or discard this patch.
location-geojson.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,47 +11,47 @@  discard block
 block discarded – undo
11 11
 $spotter_array = array();
12 12
 if (isset($_GET['coord'])) 
13 13
 {
14
-	$coords = explode(',',$_GET['coord']);
14
+	$coords = explode(',', $_GET['coord']);
15 15
 	if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
16 16
 	    || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
17 17
 		//$spotter_array = $Source->getAllLocationInfo();
18
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords));
18
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs', $coords));
19 19
 	}
20 20
 	if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
21 21
 	    || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
22
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords));
22
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx', $coords));
23 23
 	}
24 24
 	if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
25 25
 	    || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
26
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords));
26
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning', $coords));
27 27
 	}
28 28
 	if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') 
29 29
 	    || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
30
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true));
30
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('fires', $coords, true));
31 31
 	}
32 32
 	if (!isset($globalDemo)) {
33
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
33
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType(''));
34 34
 	}
35 35
 } else {
36 36
 	if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
37 37
 	    || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
38 38
 		//$spotter_array = $Source->getAllLocationInfo();
39
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
39
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs'));
40 40
 	}
41 41
 	if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
42 42
 	    || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
43
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
43
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx'));
44 44
 	}
45 45
 	if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
46 46
 	    || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
47
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
47
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning'));
48 48
 	}
49 49
 	if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true') 
50 50
 	    || (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
51
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',array(),true));
51
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('fires', array(), true));
52 52
 	}
53 53
 	if (!isset($globalDemo)) {
54
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
54
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType(''));
55 55
 	}
56 56
 }
57 57
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 $output = '{"type": "FeatureCollection","features": [';
60 60
 if (!empty($spotter_array) && count($spotter_array) > 0)
61 61
 {
62
-	foreach($spotter_array as $spotter_item)
62
+	foreach ($spotter_array as $spotter_item)
63 63
 	{
64 64
 		date_default_timezone_set('UTC');
65 65
 		$output .= '{"type": "Feature",';
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 		$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
79 79
 		$output .= '"type": "'.$spotter_item['type'].'",';
80 80
 		if ($spotter_item['type'] == 'wx') {
81
-			$weather = json_decode($spotter_item['description'],true);
82
-			if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
81
+			$weather = json_decode($spotter_item['description'], true);
82
+			if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",';
83 83
 		}
84 84
 		$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
85 85
 		$output .= '},';
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$output .= '}';
90 90
 		$output .= '},';
91 91
 	}
92
-	$output  = substr($output, 0, -1);
92
+	$output = substr($output, 0, -1);
93 93
 }
94 94
 $output .= ']}';
95 95
 print $output;
Please login to merge, or discard this patch.