Completed
Push — master ( 35bdef...4e6661 )
by Yannick
13:26
created
install/class.update_db.php 1 patch
Spacing   +426 added lines, -426 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		$ch = curl_init();
27 27
 		curl_setopt($ch, CURLOPT_URL, $url);
28 28
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
29
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
29
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
30 30
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
31 31
 			}
32 32
 		}
@@ -44,20 +44,20 @@  discard block
 block discarded – undo
44 44
 		fclose($fp);
45 45
 	}
46 46
 
47
-	public static function gunzip($in_file,$out_file_name = '') {
47
+	public static function gunzip($in_file, $out_file_name = '') {
48 48
 		//echo $in_file.' -> '.$out_file_name."\n";
49 49
 		$buffer_size = 4096; // read 4kb at a time
50 50
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
51 51
 		if ($in_file != '' && file_exists($in_file)) {
52 52
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
53
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
54
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
53
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
54
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
55 55
 			else {
56 56
 				echo 'gzopen not available';
57 57
 				die;
58 58
 			}
59 59
 			$out_file = fopen($out_file_name, 'wb'); 
60
-			while(!gzeof($file)) {
60
+			while (!gzeof($file)) {
61 61
 				fwrite($out_file, gzread($file, $buffer_size));
62 62
 			}  
63 63
 			fclose($out_file);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		try {
82 82
 			self::$db_sqlite = new PDO('sqlite:'.$database);
83 83
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
84
-		} catch(PDOException $e) {
84
+		} catch (PDOException $e) {
85 85
 			return "error : ".$e->getMessage();
86 86
 		}
87 87
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			//$Connection = new Connection();
97 97
 			$sth = $Connection->db->prepare($query);
98 98
                         $sth->execute(array(':source' => $database_file));
99
-                } catch(PDOException $e) {
99
+                } catch (PDOException $e) {
100 100
                         return "error : ".$e->getMessage();
101 101
                 }
102 102
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		try {
108 108
                         $sth = update_db::$db_sqlite->prepare($query);
109 109
                         $sth->execute();
110
-                } catch(PDOException $e) {
110
+                } catch (PDOException $e) {
111 111
                         return "error : ".$e->getMessage();
112 112
                 }
113 113
 		//$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)';
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 			if ($globalTransaction) $Connection->db->beginTransaction();
119 119
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
120 120
 				//$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);
121
-				$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);
121
+				$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);
122 122
 				$sth_dest->execute($query_dest_values);
123 123
             		}
124 124
 			if ($globalTransaction) $Connection->db->commit();
125
-		} catch(PDOException $e) {
125
+		} catch (PDOException $e) {
126 126
 			if ($globalTransaction) $Connection->db->rollBack(); 
127 127
 			return "error : ".$e->getMessage();
128 128
 		}
@@ -138,26 +138,26 @@  discard block
 block discarded – undo
138 138
 			//$Connection = new Connection();
139 139
 			$sth = $Connection->db->prepare($query);
140 140
                         $sth->execute(array(':source' => 'oneworld'));
141
-                } catch(PDOException $e) {
141
+                } catch (PDOException $e) {
142 142
                         return "error : ".$e->getMessage();
143 143
                 }
144 144
 
145 145
     		if ($globalDebug) echo " - Add routes to DB -";
146 146
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
147 147
 		$Spotter = new Spotter();
148
-		if ($fh = fopen($database_file,"r")) {
148
+		if ($fh = fopen($database_file, "r")) {
149 149
 			$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)';
150 150
 			$Connection = new Connection();
151 151
 			$sth_dest = $Connection->db->prepare($query_dest);
152 152
 			if ($globalTransaction) $Connection->db->beginTransaction();
153 153
 			while (!feof($fh)) {
154
-				$line = fgetcsv($fh,9999,',');
154
+				$line = fgetcsv($fh, 9999, ',');
155 155
 				if ($line[0] != '') {
156 156
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
157 157
 						try {
158
-							$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');
158
+							$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');
159 159
 							$sth_dest->execute($query_dest_values);
160
-						} catch(PDOException $e) {
160
+						} catch (PDOException $e) {
161 161
 							if ($globalTransaction) $Connection->db->rollBack(); 
162 162
 							return "error : ".$e->getMessage();
163 163
 						}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			//$Connection = new Connection();
180 180
 			$sth = $Connection->db->prepare($query);
181 181
                         $sth->execute(array(':source' => 'skyteam'));
182
-                } catch(PDOException $e) {
182
+                } catch (PDOException $e) {
183 183
                         return "error : ".$e->getMessage();
184 184
                 }
185 185
 
@@ -187,24 +187,24 @@  discard block
 block discarded – undo
187 187
 
188 188
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
189 189
 		$Spotter = new Spotter();
190
-		if ($fh = fopen($database_file,"r")) {
190
+		if ($fh = fopen($database_file, "r")) {
191 191
 			$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)';
192 192
 			$Connection = new Connection();
193 193
 			$sth_dest = $Connection->db->prepare($query_dest);
194 194
 			try {
195 195
 				if ($globalTransaction) $Connection->db->beginTransaction();
196 196
 				while (!feof($fh)) {
197
-					$line = fgetcsv($fh,9999,',');
197
+					$line = fgetcsv($fh, 9999, ',');
198 198
 					if ($line[0] != '') {
199
-						$datebe = explode('  -  ',$line[2]);
199
+						$datebe = explode('  -  ', $line[2]);
200 200
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
201
-							$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');
201
+							$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');
202 202
 							$sth_dest->execute($query_dest_values);
203 203
 						}
204 204
 					}
205 205
 				}
206 206
 				if ($globalTransaction) $Connection->db->commit();
207
-			} catch(PDOException $e) {
207
+			} catch (PDOException $e) {
208 208
 				if ($globalTransaction) $Connection->db->rollBack(); 
209 209
 				return "error : ".$e->getMessage();
210 210
 			}
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			$Connection = new Connection();
220 220
 			$sth = $Connection->db->prepare($query);
221 221
                         $sth->execute(array(':source' => $database_file));
222
-                } catch(PDOException $e) {
222
+                } catch (PDOException $e) {
223 223
                         return "error : ".$e->getMessage();
224 224
                 }
225 225
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			$Connection = new Connection();
228 228
 			$sth = $Connection->db->prepare($query);
229 229
                         $sth->execute(array(':source' => $database_file));
230
-                } catch(PDOException $e) {
230
+                } catch (PDOException $e) {
231 231
                         return "error : ".$e->getMessage();
232 232
                 }
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		try {
237 237
                         $sth = update_db::$db_sqlite->prepare($query);
238 238
                         $sth->execute();
239
-                } catch(PDOException $e) {
239
+                } catch (PDOException $e) {
240 240
                         return "error : ".$e->getMessage();
241 241
                 }
242 242
 		//$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)';
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
 			//$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']);
254 254
 				if ($values['UserString4'] == 'M') $type = 'military';
255 255
 				else $type = null;
256
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
256
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
257 257
 				$sth_dest->execute($query_dest_values);
258 258
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
259
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
259
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
260 260
 				    $sth_dest_owner->execute($query_dest_owner_values);
261 261
 				}
262 262
             		}
263 263
 			if ($globalTransaction) $Connection->db->commit();
264
-		} catch(PDOException $e) {
264
+		} catch (PDOException $e) {
265 265
 			return "error : ".$e->getMessage();
266 266
 		}
267 267
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 			$Connection = new Connection();
272 272
 			$sth = $Connection->db->prepare($query);
273 273
                         $sth->execute(array(':source' => $database_file));
274
-                } catch(PDOException $e) {
274
+                } catch (PDOException $e) {
275 275
                         return "error : ".$e->getMessage();
276 276
                 }
277 277
 		return '';
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
 			$Connection = new Connection();
287 287
 			$sth = $Connection->db->prepare($query);
288 288
                         $sth->execute(array(':source' => $database_file));
289
-                } catch(PDOException $e) {
289
+                } catch (PDOException $e) {
290 290
                         return "error : ".$e->getMessage();
291 291
                 }
292 292
 		
293
-		if ($fh = fopen($database_file,"r")) {
293
+		if ($fh = fopen($database_file, "r")) {
294 294
 			//$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)';
295 295
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
296 296
 		
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 				if ($globalTransaction) $Connection->db->beginTransaction();
301 301
             			while (!feof($fh)) {
302 302
             				$values = array();
303
-            				$line = $Common->hex2str(fgets($fh,9999));
303
+            				$line = $Common->hex2str(fgets($fh, 9999));
304 304
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
305
-            				$values['ModeS'] = substr($line,0,6);
306
-            				$values['Registration'] = trim(substr($line,69,6));
307
-            				$aircraft_name = trim(substr($line,48,6));
305
+            				$values['ModeS'] = substr($line, 0, 6);
306
+            				$values['Registration'] = trim(substr($line, 69, 6));
307
+            				$aircraft_name = trim(substr($line, 48, 6));
308 308
             				// Check if we can find ICAO, else set it to GLID
309
-            				$aircraft_name_split = explode(' ',$aircraft_name);
309
+            				$aircraft_name_split = explode(' ', $aircraft_name);
310 310
             				$search_more = '';
311 311
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
312 312
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 	            				if (isset($result['icao']) && $result['icao'] != '') {
319 319
 	            				    $values['ICAOTypeCode'] = $result['icao'];
320 320
 	            				} 
321
-					} catch(PDOException $e) {
321
+					} catch (PDOException $e) {
322 322
 						return "error : ".$e->getMessage();
323 323
 					}
324 324
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
325 325
 					// Add data to db
326 326
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
327 327
 						//$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']);
328
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
328
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
329 329
 						//print_r($query_dest_values);
330 330
 						$sth_dest->execute($query_dest_values);
331 331
 					}
332 332
 				}
333 333
 				if ($globalTransaction) $Connection->db->commit();
334
-			} catch(PDOException $e) {
334
+			} catch (PDOException $e) {
335 335
 				return "error : ".$e->getMessage();
336 336
 			}
337 337
 		}
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 			$Connection = new Connection();
342 342
 			$sth = $Connection->db->prepare($query);
343 343
                         $sth->execute(array(':source' => $database_file));
344
-                } catch(PDOException $e) {
344
+                } catch (PDOException $e) {
345 345
                         return "error : ".$e->getMessage();
346 346
                 }
347 347
 		return '';
@@ -355,11 +355,11 @@  discard block
 block discarded – undo
355 355
 			$Connection = new Connection();
356 356
 			$sth = $Connection->db->prepare($query);
357 357
                         $sth->execute(array(':source' => $database_file));
358
-                } catch(PDOException $e) {
358
+                } catch (PDOException $e) {
359 359
                         return "error : ".$e->getMessage();
360 360
                 }
361 361
 		
362
-		if ($fh = fopen($database_file,"r")) {
362
+		if ($fh = fopen($database_file, "r")) {
363 363
 			//$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)';
364 364
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
365 365
 		
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
 			$sth_dest = $Connection->db->prepare($query_dest);
368 368
 			try {
369 369
 				if ($globalTransaction) $Connection->db->beginTransaction();
370
-				$tmp = fgetcsv($fh,9999,',',"'");
370
+				$tmp = fgetcsv($fh, 9999, ',', "'");
371 371
             			while (!feof($fh)) {
372
-            				$line = fgetcsv($fh,9999,',',"'");
372
+            				$line = fgetcsv($fh, 9999, ',', "'");
373 373
             				
374 374
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
375 375
 					//print_r($line);
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             				$values['ICAOTypeCode'] = '';
379 379
             				$aircraft_name = $line[2];
380 380
             				// Check if we can find ICAO, else set it to GLID
381
-            				$aircraft_name_split = explode(' ',$aircraft_name);
381
+            				$aircraft_name_split = explode(' ', $aircraft_name);
382 382
             				$search_more = '';
383 383
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
384 384
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -387,20 +387,20 @@  discard block
 block discarded – undo
387 387
                                     		$sth_search->execute();
388 388
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
389 389
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
390
-					} catch(PDOException $e) {
390
+					} catch (PDOException $e) {
391 391
 						return "error : ".$e->getMessage();
392 392
 					}
393 393
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
394 394
 					// Add data to db
395 395
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
396 396
 						//$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']);
397
-						$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');
397
+						$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');
398 398
 						//print_r($query_dest_values);
399 399
 						$sth_dest->execute($query_dest_values);
400 400
 					}
401 401
 				}
402 402
 				if ($globalTransaction) $Connection->db->commit();
403
-			} catch(PDOException $e) {
403
+			} catch (PDOException $e) {
404 404
 				return "error : ".$e->getMessage();
405 405
 			}
406 406
 		}
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
 			$Connection = new Connection();
411 411
 			$sth = $Connection->db->prepare($query);
412 412
                         $sth->execute(array(':source' => $database_file));
413
-                } catch(PDOException $e) {
413
+                } catch (PDOException $e) {
414 414
                         return "error : ".$e->getMessage();
415 415
                 }
416 416
 		return '';
417 417
 	}
418 418
 
419
-	public static function retrieve_owner($database_file,$country = 'F') {
419
+	public static function retrieve_owner($database_file, $country = 'F') {
420 420
 		global $globalTransaction, $globalMasterSource;
421 421
 		//$query = 'TRUNCATE TABLE aircraft_modes';
422 422
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -424,12 +424,12 @@  discard block
 block discarded – undo
424 424
 			$Connection = new Connection();
425 425
 			$sth = $Connection->db->prepare($query);
426 426
                         $sth->execute(array(':source' => $database_file));
427
-                } catch(PDOException $e) {
427
+                } catch (PDOException $e) {
428 428
                         return "error : ".$e->getMessage();
429 429
                 }
430 430
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
431 431
 		$Spotter = new Spotter();
432
-		if ($fh = fopen($database_file,"r")) {
432
+		if ($fh = fopen($database_file, "r")) {
433 433
 			//$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)';
434 434
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
435 435
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 			$sth_modes = $Connection->db->prepare($query_modes);
440 440
 			try {
441 441
 				if ($globalTransaction) $Connection->db->beginTransaction();
442
-				$tmp = fgetcsv($fh,9999,',','"');
442
+				$tmp = fgetcsv($fh, 9999, ',', '"');
443 443
             			while (!feof($fh)) {
444
-            				$line = fgetcsv($fh,9999,',','"');
444
+            				$line = fgetcsv($fh, 9999, ',', '"');
445 445
             				$values = array();
446 446
             				//print_r($line);
447 447
             				if ($country == 'F') {
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
             				    $values['base'] = $line[4];
450 450
             				    $values['owner'] = $line[5];
451 451
             				    if ($line[6] == '') $values['date_first_reg'] = null;
452
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
452
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
453 453
 					    $values['cancel'] = $line[7];
454 454
 					} elseif ($country == 'EI') {
455 455
 					    // TODO : add modeS & reg to aircraft_modes
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             				    $values['base'] = $line[3];
458 458
             				    $values['owner'] = $line[2];
459 459
             				    if ($line[1] == '') $values['date_first_reg'] = null;
460
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
460
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
461 461
 					    $values['cancel'] = '';
462 462
 					    $values['modes'] = $line[7];
463 463
 					    $values['icao'] = $line[8];
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
             				    $values['base'] = null;
478 478
             				    $values['owner'] = $line[5];
479 479
             				    if ($line[18] == '') $values['date_first_reg'] = null;
480
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
480
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
481 481
 					    $values['cancel'] = '';
482 482
 					} elseif ($country == 'VH') {
483 483
 					    // TODO : add modeS & reg to aircraft_modes
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
             				    $values['base'] = null;
486 486
             				    $values['owner'] = $line[12];
487 487
             				    if ($line[28] == '') $values['date_first_reg'] = null;
488
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
488
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
489 489
 
490 490
 					    $values['cancel'] = $line[39];
491 491
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -505,28 +505,28 @@  discard block
 block discarded – undo
505 505
             				    $values['base'] = null;
506 506
             				    $values['owner'] = $line[8];
507 507
             				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
508
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
509 509
 					    $values['cancel'] = '';
510 510
 					} elseif ($country == 'PP') {
511 511
             				    $values['registration'] = $line[0];
512 512
             				    $values['base'] = null;
513 513
             				    $values['owner'] = $line[4];
514 514
             				    if ($line[6] == '') $values['date_first_reg'] = null;
515
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
515
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
516 516
 					    $values['cancel'] = $line[7];
517 517
 					} elseif ($country == 'E7') {
518 518
             				    $values['registration'] = $line[0];
519 519
             				    $values['base'] = null;
520 520
             				    $values['owner'] = $line[4];
521 521
             				    if ($line[5] == '') $values['date_first_reg'] = null;
522
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
522
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
523 523
 					    $values['cancel'] = '';
524 524
 					} elseif ($country == '8Q') {
525 525
             				    $values['registration'] = $line[0];
526 526
             				    $values['base'] = null;
527 527
             				    $values['owner'] = $line[3];
528 528
             				    if ($line[7] == '') $values['date_first_reg'] = null;
529
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
529
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
530 530
 					    $values['cancel'] = '';
531 531
 					} elseif ($country == 'ZK') {
532 532
             				    $values['registration'] = $line[0];
@@ -540,18 +540,18 @@  discard block
 block discarded – undo
540 540
             				    $values['registration'] = $line[0];
541 541
             				    $values['base'] = null;
542 542
             				    $values['owner'] = $line[6];
543
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
544
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
543
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
544
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
545 545
 					    $values['modes'] = $line[4];
546 546
 					    $values['icao'] = $line[10];
547 547
 					} elseif ($country == 'OY') {
548 548
             				    $values['registration'] = $line[0];
549
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
549
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
550 550
 					    $values['modes'] = $line[5];
551 551
 					    $values['icao'] = $line[6];
552 552
 					} elseif ($country == 'PH') {
553 553
             				    $values['registration'] = $line[0];
554
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
554
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
555 555
 					    $values['modes'] = $line[4];
556 556
 					    $values['icao'] = $line[5];
557 557
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -562,17 +562,17 @@  discard block
 block discarded – undo
562 562
 					    $values['cancel'] = '';
563 563
 					}
564 564
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
565
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
565
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
566 566
 						$sth_dest->execute($query_dest_values);
567 567
 					}
568 568
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
569 569
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
570
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
570
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
571 571
 						$sth_modes->execute($query_modes_values);
572 572
 					}
573 573
 				}
574 574
 				if ($globalTransaction) $Connection->db->commit();
575
-			} catch(PDOException $e) {
575
+			} catch (PDOException $e) {
576 576
 				return "error : ".$e->getMessage();
577 577
 			}
578 578
 		}
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 		if ($globalTransaction) $Connection->db->beginTransaction();
711 711
   
712 712
 		$i = 0;
713
-		while($row = sparql_fetch_array($result))
713
+		while ($row = sparql_fetch_array($result))
714 714
 		{
715 715
 			if ($i >= 1) {
716 716
 			//print_r($row);
@@ -730,33 +730,33 @@  discard block
 block discarded – undo
730 730
 				$row['image'] = '';
731 731
 				$row['image_thumb'] = '';
732 732
 			} else {
733
-				$image = str_replace(' ','_',$row['image']);
733
+				$image = str_replace(' ', '_', $row['image']);
734 734
 				$digest = md5($image);
735
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
736
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
737
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
738
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
735
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
736
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
737
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
738
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
739 739
 			}
740 740
 			
741
-			$country = explode('-',$row['country']);
741
+			$country = explode('-', $row['country']);
742 742
 			$row['country'] = $country[0];
743 743
 			
744 744
 			$row['type'] = trim($row['type']);
745
-			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'])) {
745
+			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'])) {
746 746
 				$row['type'] = 'military';
747 747
 			} 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') {
748 748
 				$row['type'] = 'small_airport';
749 749
 			}
750 750
 			
751
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
752
-			$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']);
751
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
752
+			$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']);
753 753
 			//print_r($query_dest_values);
754 754
 			
755 755
 			if ($row['icao'] != '') {
756 756
 				try {
757 757
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
758 758
 					$sth->execute(array(':icao' => $row['icao']));
759
-				} catch(PDOException $e) {
759
+				} catch (PDOException $e) {
760 760
 					return "error : ".$e->getMessage();
761 761
 				}
762 762
 					if ($sth->fetchColumn() > 0) {
@@ -764,15 +764,15 @@  discard block
 block discarded – undo
764 764
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
765 765
 						try {
766 766
 							$sth = $Connection->db->prepare($query);
767
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
768
-						} catch(PDOException $e) {
767
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
768
+						} catch (PDOException $e) {
769 769
 							return "error : ".$e->getMessage();
770 770
 						}
771 771
 						echo $row['icao'].' : '.$row['type']."\n";
772 772
 					} else {
773 773
 						try {
774 774
 							$sth_dest->execute($query_dest_values);
775
-						} catch(PDOException $e) {
775
+						} catch (PDOException $e) {
776 776
 							return "error : ".$e->getMessage();
777 777
 						}
778 778
 					}
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 		echo "Download data from ourairports.com...\n";
824 824
 		$delimiter = ',';
825 825
 		$out_file = $tmp_dir.'airports.csv';
826
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
826
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
827 827
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
828 828
 		echo "Add data from ourairports.com...\n";
829 829
 
@@ -834,33 +834,33 @@  discard block
 block discarded – undo
834 834
 			//$Connection->db->beginTransaction();
835 835
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
836 836
 			{
837
-				if(!$header) $header = $row;
837
+				if (!$header) $header = $row;
838 838
 				else {
839 839
 					$data = array();
840 840
 					$data = array_combine($header, $row);
841 841
 					try {
842 842
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
843 843
 						$sth->execute(array(':icao' => $data['ident']));
844
-					} catch(PDOException $e) {
844
+					} catch (PDOException $e) {
845 845
 						return "error : ".$e->getMessage();
846 846
 					}
847 847
 					if ($sth->fetchColumn() > 0) {
848 848
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
849 849
 						try {
850 850
 							$sth = $Connection->db->prepare($query);
851
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
852
-						} catch(PDOException $e) {
851
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
852
+						} catch (PDOException $e) {
853 853
 							return "error : ".$e->getMessage();
854 854
 						}
855 855
 					} else {
856 856
 						if ($data['gps_code'] == $data['ident']) {
857 857
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
858 858
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
859
-						$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']);
859
+						$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']);
860 860
 						try {
861 861
 							$sth = $Connection->db->prepare($query);
862 862
 							$sth->execute($query_values);
863
-						} catch(PDOException $e) {
863
+						} catch (PDOException $e) {
864 864
 							return "error : ".$e->getMessage();
865 865
 						}
866 866
 						$i++;
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 		
876 876
 		echo "Download data from another free database...\n";
877 877
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
878
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
878
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
879 879
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
880 880
 		update_db::unzip($out_file);
881 881
 		$header = NULL;
@@ -887,15 +887,15 @@  discard block
 block discarded – undo
887 887
 			//$Connection->db->beginTransaction();
888 888
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
889 889
 			{
890
-				if(!$header) $header = $row;
890
+				if (!$header) $header = $row;
891 891
 				else {
892 892
 					$data = $row;
893 893
 
894 894
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
895 895
 					try {
896 896
 						$sth = $Connection->db->prepare($query);
897
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
898
-					} catch(PDOException $e) {
897
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
898
+					} catch (PDOException $e) {
899 899
 						return "error : ".$e->getMessage();
900 900
 					}
901 901
 				}
@@ -909,15 +909,15 @@  discard block
 block discarded – undo
909 909
 		try {
910 910
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
911 911
 			$sth->execute();
912
-		} catch(PDOException $e) {
912
+		} catch (PDOException $e) {
913 913
 			return "error : ".$e->getMessage();
914 914
 		}
915 915
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
916 916
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
917 917
 			try {
918 918
 				$sth2 = $Connection->db->prepare($query2);
919
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
920
-			} catch(PDOException $e) {
919
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
920
+			} catch (PDOException $e) {
921 921
 				return "error : ".$e->getMessage();
922 922
 			}
923 923
 		}
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 			$Connection = new Connection();
939 939
 			$sth = $Connection->db->prepare($query);
940 940
                         $sth->execute(array(':source' => 'translation.csv'));
941
-                } catch(PDOException $e) {
941
+                } catch (PDOException $e) {
942 942
                         return "error : ".$e->getMessage();
943 943
                 }
944 944
 
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
956 956
 			{
957 957
 				$i++;
958
-				if($i > 12) {
958
+				if ($i > 12) {
959 959
 					$data = $row;
960 960
 					$operator = $data[2];
961 961
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
                                                 //echo substr($operator, 0, 2)."\n";;
964 964
                                                 if (count($airline_array) > 0) {
965 965
 							//print_r($airline_array);
966
-							$operator = $airline_array[0]['icao'].substr($operator,2);
966
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
967 967
                                                 }
968 968
                                         }
969 969
 					
@@ -971,14 +971,14 @@  discard block
 block discarded – undo
971 971
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
972 972
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
973 973
                                                 if (count($airline_array) > 0) {
974
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
974
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
975 975
                                             	}
976 976
                                         }
977 977
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
978 978
 					try {
979 979
 						$sth = $Connection->db->prepare($query);
980
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
981
-					} catch(PDOException $e) {
980
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
981
+					} catch (PDOException $e) {
982 982
 						return "error : ".$e->getMessage();
983 983
 					}
984 984
 				}
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 			$Connection = new Connection();
997 997
 			$sth = $Connection->db->prepare($query);
998 998
 			$sth->execute(array(':source' => 'website_fam'));
999
-		} catch(PDOException $e) {
999
+		} catch (PDOException $e) {
1000 1000
 			return "error : ".$e->getMessage();
1001 1001
 		}
1002 1002
 		//update_db::unzip($out_file);
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
1015 1015
 					try {
1016 1016
 						$sth = $Connection->db->prepare($query);
1017
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
1018
-					} catch(PDOException $e) {
1017
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
1018
+					} catch (PDOException $e) {
1019 1019
 						return "error : ".$e->getMessage();
1020 1020
 					}
1021 1021
 				}
@@ -1037,11 +1037,11 @@  discard block
 block discarded – undo
1037 1037
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1038 1038
 			{
1039 1039
 				$query = 'UPDATE airport SET diagram_pdf = :diagrampdf, diagram_png = :diagrampng WHERE icao = :icao';
1040
-				$icao = str_replace('.pdf','',$data[2]);
1040
+				$icao = str_replace('.pdf', '', $data[2]);
1041 1041
 				try {
1042 1042
 					$sth = $Connection->db->prepare($query);
1043
-					$sth->execute(array(':icao' => $icao,':diagrampdf' => 'https://data.flightairmap.com/data/diagrams/'.$icao.'.pdf',':diagrampng' => 'https://data.flightairmap.com/data/diagrams/'.$icao.'.png'));
1044
-				} catch(PDOException $e) {
1043
+					$sth->execute(array(':icao' => $icao, ':diagrampdf' => 'https://data.flightairmap.com/data/diagrams/'.$icao.'.pdf', ':diagrampng' => 'https://data.flightairmap.com/data/diagrams/'.$icao.'.png'));
1044
+				} catch (PDOException $e) {
1045 1045
 					echo "error : ".$e->getMessage();
1046 1046
 					return "error : ".$e->getMessage();
1047 1047
 				}
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 			$Connection = new Connection();
1064 1064
 			$sth = $Connection->db->prepare($query);
1065 1065
                         $sth->execute(array(':source' => 'website_faa'));
1066
-                } catch(PDOException $e) {
1066
+                } catch (PDOException $e) {
1067 1067
                         return "error : ".$e->getMessage();
1068 1068
                 }
1069 1069
 
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 			$Connection = new Connection();
1073 1073
 			$sth = $Connection->db->prepare($query);
1074 1074
                         $sth->execute(array(':source' => 'website_faa'));
1075
-                } catch(PDOException $e) {
1075
+                } catch (PDOException $e) {
1076 1076
                         return "error : ".$e->getMessage();
1077 1077
                 }
1078 1078
 
@@ -1089,8 +1089,8 @@  discard block
 block discarded – undo
1089 1089
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1090 1090
 					try {
1091 1091
 						$sths = $Connection->db->prepare($query_search);
1092
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1093
-					} catch(PDOException $e) {
1092
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1093
+					} catch (PDOException $e) {
1094 1094
 						return "error s : ".$e->getMessage();
1095 1095
 					}
1096 1096
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
 							//}
1104 1104
 						try {
1105 1105
 							$sthi = $Connection->db->prepare($queryi);
1106
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1107
-						} catch(PDOException $e) {
1106
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1107
+						} catch (PDOException $e) {
1108 1108
 							return "error u : ".$e->getMessage();
1109 1109
 						}
1110 1110
 					} else {
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 						try {
1113 1113
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1114 1114
 							$sthsm->execute(array(':mfr' => $data[2]));
1115
-						} catch(PDOException $e) {
1115
+						} catch (PDOException $e) {
1116 1116
 							return "error mfr : ".$e->getMessage();
1117 1117
 						}
1118 1118
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1122,8 +1122,8 @@  discard block
 block discarded – undo
1122 1122
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1123 1123
 							try {
1124 1124
 								$sthf = $Connection->db->prepare($queryf);
1125
-								$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'));
1126
-							} catch(PDOException $e) {
1125
+								$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'));
1126
+							} catch (PDOException $e) {
1127 1127
 								return "error f : ".$e->getMessage();
1128 1128
 							}
1129 1129
 						}
@@ -1133,13 +1133,13 @@  discard block
 block discarded – undo
1133 1133
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1134 1134
 						try {
1135 1135
 							$sth = $Connection->db->prepare($query);
1136
-							$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'));
1137
-						} catch(PDOException $e) {
1136
+							$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'));
1137
+						} catch (PDOException $e) {
1138 1138
 							return "error i : ".$e->getMessage();
1139 1139
 						}
1140 1140
 					}
1141 1141
 				}
1142
-				if ($i % 90 == 0) {
1142
+				if ($i%90 == 0) {
1143 1143
 					if ($globalTransaction) $Connection->db->commit();
1144 1144
 					if ($globalTransaction) $Connection->db->beginTransaction();
1145 1145
 				}
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 			$Connection = new Connection();
1159 1159
 			$sth = $Connection->db->prepare($query);
1160 1160
 			$sth->execute(array(':source' => 'website_fam'));
1161
-		} catch(PDOException $e) {
1161
+		} catch (PDOException $e) {
1162 1162
 			return "error : ".$e->getMessage();
1163 1163
 		}
1164 1164
 		$delimiter = "\t";
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1175 1175
 					try {
1176 1176
 						$sth = $Connection->db->prepare($query);
1177
-						$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'));
1178
-					} catch(PDOException $e) {
1177
+						$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'));
1178
+					} catch (PDOException $e) {
1179 1179
 						return "error : ".$e->getMessage();
1180 1180
 					}
1181 1181
 				}
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 		try {
1208 1208
 			$sth = $Connection->db->prepare($query);
1209 1209
 			$sth->execute();
1210
-		} catch(PDOException $e) {
1210
+		} catch (PDOException $e) {
1211 1211
 			return "error : ".$e->getMessage();
1212 1212
 		}
1213 1213
 		$delimiter = "\t";
@@ -1222,8 +1222,8 @@  discard block
 block discarded – undo
1222 1222
 					$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)';
1223 1223
 					try {
1224 1224
 						$sth = $Connection->db->prepare($query);
1225
-						$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]));
1226
-					} catch(PDOException $e) {
1225
+						$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]));
1226
+					} catch (PDOException $e) {
1227 1227
 						return "error : ".$e->getMessage();
1228 1228
 					}
1229 1229
 				}
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 			$Connection = new Connection();
1252 1252
 			$sth = $Connection->db->prepare($query);
1253 1253
                         $sth->execute(array(':source' => 'website_fam'));
1254
-                } catch(PDOException $e) {
1254
+                } catch (PDOException $e) {
1255 1255
                         return "error : ".$e->getMessage();
1256 1256
                 }
1257 1257
 
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1268 1268
 					try {
1269 1269
 						$sth = $Connection->db->prepare($query);
1270
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1271
-					} catch(PDOException $e) {
1270
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1271
+					} catch (PDOException $e) {
1272 1272
 						//print_r($data);
1273 1273
 						return "error : ".$e->getMessage();
1274 1274
 					}
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 			$Connection = new Connection();
1289 1289
 			$sth = $Connection->db->prepare($query);
1290 1290
 			$sth->execute(array(':source' => 'website_fam'));
1291
-		} catch(PDOException $e) {
1291
+		} catch (PDOException $e) {
1292 1292
 			return "error : ".$e->getMessage();
1293 1293
 		}
1294 1294
 		$delimiter = "\t";
@@ -1304,13 +1304,13 @@  discard block
 block discarded – undo
1304 1304
 					$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)';
1305 1305
 					try {
1306 1306
 						$sth = $Connection->db->prepare($query);
1307
-						$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'));
1308
-					} catch(PDOException $e) {
1309
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1307
+						$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'));
1308
+					} catch (PDOException $e) {
1309
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1310 1310
 						die();
1311 1311
 					}
1312 1312
 				}
1313
-				if ($globalTransaction && $i % 2000 == 0) {
1313
+				if ($globalTransaction && $i%2000 == 0) {
1314 1314
 					$Connection->db->commit();
1315 1315
 					if ($globalDebug) echo '.';
1316 1316
 					$Connection->db->beginTransaction();
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 			$Connection = new Connection();
1331 1331
 			$sth = $Connection->db->prepare($query);
1332 1332
 			$sth->execute(array(':source' => 'website_fam'));
1333
-		} catch(PDOException $e) {
1333
+		} catch (PDOException $e) {
1334 1334
 			return "error : ".$e->getMessage();
1335 1335
 		}
1336 1336
 		$Connection = new Connection();
@@ -1343,12 +1343,12 @@  discard block
 block discarded – undo
1343 1343
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
1344 1344
 				try {
1345 1345
 					$sth = $Connection->db->prepare($query);
1346
-					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1347
-				} catch(PDOException $e) {
1346
+					$sth->execute(array(':callSign' => trim($data), ':source' => 'website_fam'));
1347
+				} catch (PDOException $e) {
1348 1348
 					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1349 1349
 					die();
1350 1350
 				}
1351
-				if ($globalTransaction && $i % 2000 == 0) {
1351
+				if ($globalTransaction && $i%2000 == 0) {
1352 1352
 					$Connection->db->commit();
1353 1353
 					if ($globalDebug) echo '.';
1354 1354
 					$Connection->db->beginTransaction();
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
 			$Connection = new Connection();
1369 1369
 			$sth = $Connection->db->prepare($query);
1370 1370
                         $sth->execute();
1371
-                } catch(PDOException $e) {
1371
+                } catch (PDOException $e) {
1372 1372
                         return "error : ".$e->getMessage();
1373 1373
                 }
1374 1374
 
@@ -1389,8 +1389,8 @@  discard block
 block discarded – undo
1389 1389
 					$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)';
1390 1390
 					try {
1391 1391
 						$sth = $Connection->db->prepare($query);
1392
-						$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]));
1393
-					} catch(PDOException $e) {
1392
+						$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]));
1393
+					} catch (PDOException $e) {
1394 1394
 						return "error : ".$e->getMessage();
1395 1395
 					}
1396 1396
 				}
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 			$Connection = new Connection();
1410 1410
 			$sth = $Connection->db->prepare($query);
1411 1411
 			$sth->execute();
1412
-		} catch(PDOException $e) {
1412
+		} catch (PDOException $e) {
1413 1413
 			return "error : ".$e->getMessage();
1414 1414
 		}
1415 1415
 		$delimiter = "\t";
@@ -1426,8 +1426,8 @@  discard block
 block discarded – undo
1426 1426
 					    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)';
1427 1427
 					try {
1428 1428
 						$sth = $Connection->db->prepare($query);
1429
-						$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]));
1430
-					} catch(PDOException $e) {
1429
+						$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]));
1430
+					} catch (PDOException $e) {
1431 1431
 						return "error : ".$e->getMessage();
1432 1432
 					}
1433 1433
 				}
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
 			$Connection = new Connection();
1447 1447
 			$sth = $Connection->db->prepare($query);
1448 1448
 			$sth->execute();
1449
-		} catch(PDOException $e) {
1449
+		} catch (PDOException $e) {
1450 1450
 			return "error : ".$e->getMessage();
1451 1451
 		}
1452 1452
 
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 					try {
1463 1463
 						$sth = $Connection->db->prepare($query);
1464 1464
 						$sth->execute(array(':icao' => $icao));
1465
-					} catch(PDOException $e) {
1465
+					} catch (PDOException $e) {
1466 1466
 						return "error : ".$e->getMessage();
1467 1467
 					}
1468 1468
 				}
@@ -1473,7 +1473,7 @@  discard block
 block discarded – undo
1473 1473
 		return '';
1474 1474
         }
1475 1475
 
1476
-	public static function tle($filename,$tletype) {
1476
+	public static function tle($filename, $tletype) {
1477 1477
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1478 1478
 		global $tmp_dir, $globalTransaction;
1479 1479
 		//$Spotter = new Spotter();
@@ -1483,7 +1483,7 @@  discard block
 block discarded – undo
1483 1483
 			$Connection = new Connection();
1484 1484
 			$sth = $Connection->db->prepare($query);
1485 1485
                         $sth->execute(array(':source' => $filename));
1486
-                } catch(PDOException $e) {
1486
+                } catch (PDOException $e) {
1487 1487
                         return "error : ".$e->getMessage();
1488 1488
                 }
1489 1489
 		
@@ -1508,8 +1508,8 @@  discard block
 block discarded – undo
1508 1508
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1509 1509
 					try {
1510 1510
 						$sth = $Connection->db->prepare($query);
1511
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1512
-					} catch(PDOException $e) {
1511
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1512
+					} catch (PDOException $e) {
1513 1513
 						return "error : ".$e->getMessage();
1514 1514
 					}
1515 1515
 
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 			$Connection = new Connection();
1531 1531
 			$sth = $Connection->db->prepare($query);
1532 1532
 			$sth->execute(array(':source' => $filename));
1533
-		} catch(PDOException $e) {
1533
+		} catch (PDOException $e) {
1534 1534
 			return "error : ".$e->getMessage();
1535 1535
 		}
1536 1536
 		
@@ -1541,13 +1541,13 @@  discard block
 block discarded – undo
1541 1541
 			$i = 0;
1542 1542
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1543 1543
 			//$Connection->db->beginTransaction();
1544
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1544
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1545 1545
 			{
1546 1546
 				if ($i > 0 && $data[0] != '') {
1547 1547
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1548
-					$period = str_replace(',','',$data[14]);
1549
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1550
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1548
+					$period = str_replace(',', '', $data[14]);
1549
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1550
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1551 1551
 					else $launch_date = NULL;
1552 1552
 					$data = array_map(function($value) {
1553 1553
 						return trim($value) === '' ? null : $value;
@@ -1557,8 +1557,8 @@  discard block
 block discarded – undo
1557 1557
 					    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)';
1558 1558
 					try {
1559 1559
 						$sth = $Connection->db->prepare($query);
1560
-						$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));
1561
-					} catch(PDOException $e) {
1560
+						$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));
1561
+					} catch (PDOException $e) {
1562 1562
 						return "error : ".$e->getMessage();
1563 1563
 					}
1564 1564
 				}
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1599 1599
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1600 1600
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1601
-			'EST' => array('country' => 'Estonia','owner' => ''),
1601
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1602 1602
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1603 1603
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1604 1604
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1722,10 +1722,10 @@  discard block
 block discarded – undo
1722 1722
 			{
1723 1723
 				if ($data != '') {
1724 1724
 				$result = array();
1725
-				$result['cospar'] = trim(substr($data,0,11));
1726
-				$result['norad'] = trim(substr($data,13,6));
1727
-				$result['operational'] = trim(substr($data,21,1));
1728
-				$result['name'] = trim(substr($data,23,24));
1725
+				$result['cospar'] = trim(substr($data, 0, 11));
1726
+				$result['norad'] = trim(substr($data, 13, 6));
1727
+				$result['operational'] = trim(substr($data, 21, 1));
1728
+				$result['name'] = trim(substr($data, 23, 24));
1729 1729
 				/*
1730 1730
 				    * R/B(1) = Rocket body, first stage
1731 1731
 				    * R/B(2) = Rocket body, second stage
@@ -1737,28 +1737,28 @@  discard block
 block discarded – undo
1737 1737
 				    * An ampersand (&) indicates two or more objects are attached
1738 1738
 				*/
1739 1739
 				
1740
-				$owner_code = trim(substr($data,49,5));
1740
+				$owner_code = trim(substr($data, 49, 5));
1741 1741
 				
1742 1742
 				if (!isset($satcat_sources[$owner_code]) && $owner_code != 'TBD') {
1743 1743
 					if ($globalDebug) echo $data.'owner_code: '.$owner_code."\n";
1744 1744
 				}
1745
-				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1746
-					if ($globalDebug) echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1745
+				if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1746
+					if ($globalDebug) echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n";
1747 1747
 				}
1748 1748
 				
1749
-				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
1749
+				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1750 1750
 					$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1751 1751
 					$result['owner'] = $satcat_sources[$owner_code]['owner'];
1752
-					$result['launch_date'] = trim(substr($data,56,10));
1753
-					$launch_site_code = trim(substr($data,68,5));
1752
+					$result['launch_date'] = trim(substr($data, 56, 10));
1753
+					$launch_site_code = trim(substr($data, 68, 5));
1754 1754
 					$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1755
-					$result['lifetime'] = trim(substr($data,75,10));
1756
-					$result['period'] = trim(substr($data,87,7));
1757
-					$result['inclination'] = trim(substr($data,96,5));
1758
-					$result['apogee'] = trim(substr($data,103,6));
1759
-					$result['perigee'] = trim(substr($data,111,6));
1755
+					$result['lifetime'] = trim(substr($data, 75, 10));
1756
+					$result['period'] = trim(substr($data, 87, 7));
1757
+					$result['inclination'] = trim(substr($data, 96, 5));
1758
+					$result['apogee'] = trim(substr($data, 103, 6));
1759
+					$result['perigee'] = trim(substr($data, 111, 6));
1760 1760
 					//$result['radarcross'] = trim(substr($data,119,8));
1761
-					$result['status'] = trim(substr($data,129,3));
1761
+					$result['status'] = trim(substr($data, 129, 3));
1762 1762
 					//print_r($result);
1763 1763
 					$result = array_map(function($value) {
1764 1764
 						return trim($value) === '' ? null : $value;
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
 							$sth = $Connection->db->prepare($query);
1772 1772
 							$sth->execute(array(':cospar' => $result['cospar']));
1773 1773
 							$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1774
-						} catch(PDOException $e) {
1774
+						} catch (PDOException $e) {
1775 1775
 							return "error : ".$e->getMessage();
1776 1776
 						}
1777 1777
 						if (empty($exist)) {
@@ -1783,10 +1783,10 @@  discard block
 block discarded – undo
1783 1783
 								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1784 1784
 								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1785 1785
 								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1786
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1786
+								    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1787 1787
 								    )
1788 1788
 								);
1789
-							} catch(PDOException $e) {
1789
+							} catch (PDOException $e) {
1790 1790
 								return "error : ".$e->getMessage();
1791 1791
 							}
1792 1792
 						} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1794,8 +1794,8 @@  discard block
 block discarded – undo
1794 1794
 							try {
1795 1795
 								$Connection = new Connection();
1796 1796
 								$sth = $Connection->db->prepare($query);
1797
-								$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1798
-							} catch(PDOException $e) {
1797
+								$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1798
+							} catch (PDOException $e) {
1799 1799
 								return "error : ".$e->getMessage();
1800 1800
 							}
1801 1801
 						}
@@ -1914,13 +1914,13 @@  discard block
 block discarded – undo
1914 1914
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1915 1915
 			{
1916 1916
 				$i++;
1917
-				if($i > 3 && count($row) > 2) {
1917
+				if ($i > 3 && count($row) > 2) {
1918 1918
 					$data = array_values(array_filter($row));
1919 1919
 					$cntdata = count($data);
1920 1920
 					if ($cntdata > 10) {
1921 1921
 						$value = $data[9];
1922 1922
 						
1923
-						for ($i =10;$i < $cntdata;$i++) {
1923
+						for ($i = 10; $i < $cntdata; $i++) {
1924 1924
 							$value .= ' '.$data[$i];
1925 1925
 						}
1926 1926
 						$data[9] = $value;
@@ -1930,8 +1930,8 @@  discard block
 block discarded – undo
1930 1930
 						$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)';
1931 1931
 						try {
1932 1932
 							$sth = $Connection->db->prepare($query);
1933
-							$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]));
1934
-						} catch(PDOException $e) {
1933
+							$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]));
1934
+						} catch (PDOException $e) {
1935 1935
 							return "error : ".$e->getMessage();
1936 1936
 						}
1937 1937
 					}
@@ -1948,22 +1948,22 @@  discard block
 block discarded – undo
1948 1948
 		require_once(dirname(__FILE__).'/../require/class.Source.php');
1949 1949
 		$delimiter = ',';
1950 1950
 		$Common = new Common();
1951
-		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv');
1951
+		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv');
1952 1952
 		$Connection = new Connection();
1953 1953
 		$Source = new Source();
1954 1954
 		$Source->deleteLocationByType('fires');
1955 1955
 		$i = 0;
1956
-		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1956
+		if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) {
1957 1957
 			if ($globalTransaction) $Connection->db->beginTransaction();
1958
-			while (($row = fgetcsv($handle,1000)) !== false) {
1958
+			while (($row = fgetcsv($handle, 1000)) !== false) {
1959 1959
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1960
-					$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]);
1960
+					$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]);
1961 1961
 					$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)";
1962
-					$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));
1962
+					$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));
1963 1963
 					try {
1964 1964
 						$sth = $Connection->db->prepare($query);
1965 1965
 						$sth->execute($query_values);
1966
-					} catch(PDOException $e) {
1966
+					} catch (PDOException $e) {
1967 1967
 						echo "error : ".$e->getMessage();
1968 1968
 					}
1969 1969
 				}
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 			$Connection = new Connection();
1983 1983
 			$sth = $Connection->db->prepare($query);
1984 1984
 			$sth->execute();
1985
-		} catch(PDOException $e) {
1985
+		} catch (PDOException $e) {
1986 1986
 			return "error : ".$e->getMessage();
1987 1987
 		}
1988 1988
 		$header = NULL;
@@ -1993,12 +1993,12 @@  discard block
 block discarded – undo
1993 1993
 			if ($globalTransaction) $Connection->db->beginTransaction();
1994 1994
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1995 1995
 			{
1996
-				if(count($row) > 1) {
1996
+				if (count($row) > 1) {
1997 1997
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1998 1998
 					try {
1999 1999
 						$sth = $Connection->db->prepare($query);
2000
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
2001
-					} catch(PDOException $e) {
2000
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
2001
+					} catch (PDOException $e) {
2002 2002
 						return "error : ".$e->getMessage();
2003 2003
 					}
2004 2004
 				}
@@ -2018,21 +2018,21 @@  discard block
 block discarded – undo
2018 2018
 			try {
2019 2019
 				$sth = $Connection->db->prepare($query);
2020 2020
                     		$sth->execute();
2021
-	                } catch(PDOException $e) {
2021
+	                } catch (PDOException $e) {
2022 2022
 				return "error : ".$e->getMessage();
2023 2023
 	                }
2024 2024
 	        }
2025 2025
 
2026 2026
 
2027
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2027
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
2028 2028
 		else {
2029
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
2029
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
2030 2030
 			$query = "CREATE EXTENSION postgis";
2031
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
2031
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
2032 2032
 			try {
2033 2033
 				$sth = $Connection->db->prepare($query);
2034 2034
 				$sth->execute();
2035
-			} catch(PDOException $e) {
2035
+			} catch (PDOException $e) {
2036 2036
 				return "error : ".$e->getMessage();
2037 2037
 			}
2038 2038
 		}
@@ -2045,13 +2045,13 @@  discard block
 block discarded – undo
2045 2045
 		include_once('class.create_db.php');
2046 2046
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2047 2047
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2048
-		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2048
+		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5');
2049 2049
 		$error = '';
2050 2050
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
2051
-			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
2051
+			$notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5'));
2052 2052
 			$notam_md5 = $notam_md5_file[0];
2053 2053
 			if (!update_db::check_notam_version($notam_md5)) {
2054
-				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2054
+				update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
2055 2055
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2056 2056
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2057 2057
 						if ($globalDebug) echo "Gunzip...";
@@ -2087,14 +2087,14 @@  discard block
 block discarded – undo
2087 2087
 			try {
2088 2088
 				$sth = $Connection->db->prepare($query);
2089 2089
             	        	$sth->execute();
2090
-	                } catch(PDOException $e) {
2090
+	                } catch (PDOException $e) {
2091 2091
     	                	echo "error : ".$e->getMessage();
2092 2092
 	                }
2093 2093
 		}
2094 2094
 		if ($globalDBdriver == 'mysql') {
2095
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
2095
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
2096 2096
 		} else {
2097
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
2097
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
2098 2098
 		}
2099 2099
 		$error = create_db::import_file($tmp_dir.'countries.sql');
2100 2100
 		return $error;
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
 //		update_db::unzip($tmp_dir.'AptNav.zip');
2108 2108
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
2109 2109
 //		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');
2110
-		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');
2110
+		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');
2111 2111
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
2112 2112
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
2113 2113
 		return $error;
@@ -2128,7 +2128,7 @@  discard block
 block discarded – undo
2128 2128
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2129 2129
 				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2130 2130
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2131
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2131
+					if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2132 2132
 				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2133 2133
 			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2134 2134
 		} else $error = "ZIP module not loaded but required for IVAO.";
@@ -2142,7 +2142,7 @@  discard block
 block discarded – undo
2142 2142
 		global $tmp_dir, $globalDebug;
2143 2143
 		$error = '';
2144 2144
 		if ($globalDebug) echo "Routes : Download...";
2145
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2145
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
2146 2146
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2147 2147
 			if ($globalDebug) echo "Gunzip...";
2148 2148
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -2158,7 +2158,7 @@  discard block
 block discarded – undo
2158 2158
 		global $tmp_dir, $globalDebug;
2159 2159
 		$error = '';
2160 2160
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
2161
-		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2161
+		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
2162 2162
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2163 2163
 			if ($globalDebug) echo "Gunzip...";
2164 2164
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -2174,7 +2174,7 @@  discard block
 block discarded – undo
2174 2174
 		global $tmp_dir, $globalDebug;
2175 2175
 		$error = '';
2176 2176
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
2177
-		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2177
+		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
2178 2178
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2179 2179
 			if ($globalDebug) echo "Gunzip...";
2180 2180
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2202,7 +2202,7 @@  discard block
 block discarded – undo
2202 2202
 */
2203 2203
 		if ($globalDebug) echo "Modes : Download...";
2204 2204
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2205
-		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2205
+		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2206 2206
 
2207 2207
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2208 2208
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
 	public static function update_ModeS_faa() {
2223 2223
 		global $tmp_dir, $globalDebug;
2224 2224
 		if ($globalDebug) echo "Modes FAA: Download...";
2225
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2225
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2226 2226
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2227 2227
 			if ($globalDebug) echo "Unzip...";
2228 2228
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2238,7 +2238,7 @@  discard block
 block discarded – undo
2238 2238
 	public static function update_ModeS_flarm() {
2239 2239
 		global $tmp_dir, $globalDebug;
2240 2240
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2241
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2241
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2242 2242
 		if (file_exists($tmp_dir.'data.fln')) {
2243 2243
 			if ($globalDebug) echo "Add to DB...";
2244 2244
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2252,7 +2252,7 @@  discard block
 block discarded – undo
2252 2252
 	public static function update_ModeS_ogn() {
2253 2253
 		global $tmp_dir, $globalDebug;
2254 2254
 		if ($globalDebug) echo "Modes OGN: Download...";
2255
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2255
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2256 2256
 		if (file_exists($tmp_dir.'ogn.csv')) {
2257 2257
 			if ($globalDebug) echo "Add to DB...";
2258 2258
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2267,201 +2267,201 @@  discard block
 block discarded – undo
2267 2267
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2268 2268
 		
2269 2269
 		if ($globalDebug) echo "Owner France: Download...";
2270
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2270
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2271 2271
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2272 2272
 			if ($globalDebug) echo "Add to DB...";
2273
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2273
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2274 2274
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2275 2275
 		if ($error != '') {
2276 2276
 			return $error;
2277 2277
 		} elseif ($globalDebug) echo "Done\n";
2278 2278
 		
2279 2279
 		if ($globalDebug) echo "Owner Ireland: Download...";
2280
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2280
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2281 2281
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2282 2282
 			if ($globalDebug) echo "Add to DB...";
2283
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2283
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2284 2284
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2285 2285
 		if ($error != '') {
2286 2286
 			return $error;
2287 2287
 		} elseif ($globalDebug) echo "Done\n";
2288 2288
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2289
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2289
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2290 2290
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2291 2291
 			if ($globalDebug) echo "Add to DB...";
2292
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2292
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2293 2293
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2294 2294
 		if ($error != '') {
2295 2295
 			return $error;
2296 2296
 		} elseif ($globalDebug) echo "Done\n";
2297 2297
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2298
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2298
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2299 2299
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2300 2300
 			if ($globalDebug) echo "Add to DB...";
2301
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2301
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2302 2302
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2303 2303
 		if ($error != '') {
2304 2304
 			return $error;
2305 2305
 		} elseif ($globalDebug) echo "Done\n";
2306 2306
 		if ($globalDebug) echo "Owner Australia: Download...";
2307
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2307
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2308 2308
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2309 2309
 			if ($globalDebug) echo "Add to DB...";
2310
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2310
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2311 2311
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2312 2312
 		if ($error != '') {
2313 2313
 			return $error;
2314 2314
 		} elseif ($globalDebug) echo "Done\n";
2315 2315
 		if ($globalDebug) echo "Owner Austria: Download...";
2316
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2316
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2317 2317
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2318 2318
 			if ($globalDebug) echo "Add to DB...";
2319
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2319
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2320 2320
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2321 2321
 		if ($error != '') {
2322 2322
 			return $error;
2323 2323
 		} elseif ($globalDebug) echo "Done\n";
2324 2324
 		if ($globalDebug) echo "Owner Chile: Download...";
2325
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2325
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2326 2326
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2327 2327
 			if ($globalDebug) echo "Add to DB...";
2328
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2328
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2329 2329
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2330 2330
 		if ($error != '') {
2331 2331
 			return $error;
2332 2332
 		} elseif ($globalDebug) echo "Done\n";
2333 2333
 		if ($globalDebug) echo "Owner Colombia: Download...";
2334
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2334
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2335 2335
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2336 2336
 			if ($globalDebug) echo "Add to DB...";
2337
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2337
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2338 2338
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2339 2339
 		if ($error != '') {
2340 2340
 			return $error;
2341 2341
 		} elseif ($globalDebug) echo "Done\n";
2342 2342
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2343
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2343
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2344 2344
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2345 2345
 			if ($globalDebug) echo "Add to DB...";
2346
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2346
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2347 2347
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2348 2348
 		if ($error != '') {
2349 2349
 			return $error;
2350 2350
 		} elseif ($globalDebug) echo "Done\n";
2351 2351
 		if ($globalDebug) echo "Owner Brazil: Download...";
2352
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2352
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2353 2353
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2354 2354
 			if ($globalDebug) echo "Add to DB...";
2355
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2355
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2356 2356
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2357 2357
 		if ($error != '') {
2358 2358
 			return $error;
2359 2359
 		} elseif ($globalDebug) echo "Done\n";
2360 2360
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2361
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2361
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2362 2362
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2363 2363
 			if ($globalDebug) echo "Add to DB...";
2364
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2364
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2365 2365
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2366 2366
 		if ($error != '') {
2367 2367
 			return $error;
2368 2368
 		} elseif ($globalDebug) echo "Done\n";
2369 2369
 		if ($globalDebug) echo "Owner Croatia: Download...";
2370
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2370
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2371 2371
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2372 2372
 			if ($globalDebug) echo "Add to DB...";
2373
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2373
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2374 2374
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2375 2375
 		if ($error != '') {
2376 2376
 			return $error;
2377 2377
 		} elseif ($globalDebug) echo "Done\n";
2378 2378
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2379
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2379
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2380 2380
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2381 2381
 			if ($globalDebug) echo "Add to DB...";
2382
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2382
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2383 2383
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2384 2384
 		if ($error != '') {
2385 2385
 			return $error;
2386 2386
 		} elseif ($globalDebug) echo "Done\n";
2387 2387
 		if ($globalDebug) echo "Owner Maldives: Download...";
2388
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2388
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2389 2389
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2390 2390
 			if ($globalDebug) echo "Add to DB...";
2391
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2391
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2392 2392
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2393 2393
 		if ($error != '') {
2394 2394
 			return $error;
2395 2395
 		} elseif ($globalDebug) echo "Done\n";
2396 2396
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2397
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2397
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2398 2398
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2399 2399
 			if ($globalDebug) echo "Add to DB...";
2400
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2400
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2401 2401
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2402 2402
 		if ($error != '') {
2403 2403
 			return $error;
2404 2404
 		} elseif ($globalDebug) echo "Done\n";
2405 2405
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2406
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2406
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2407 2407
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2408 2408
 			if ($globalDebug) echo "Add to DB...";
2409
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2409
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2410 2410
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2411 2411
 		if ($error != '') {
2412 2412
 			return $error;
2413 2413
 		} elseif ($globalDebug) echo "Done\n";
2414 2414
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2415
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2415
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2416 2416
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2417 2417
 			if ($globalDebug) echo "Add to DB...";
2418
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2418
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2419 2419
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2420 2420
 		if ($error != '') {
2421 2421
 			return $error;
2422 2422
 		} elseif ($globalDebug) echo "Done\n";
2423 2423
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2424
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2424
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2425 2425
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2426 2426
 			if ($globalDebug) echo "Add to DB...";
2427
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2427
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2428 2428
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2429 2429
 		if ($error != '') {
2430 2430
 			return $error;
2431 2431
 		} elseif ($globalDebug) echo "Done\n";
2432 2432
 		if ($globalDebug) echo "Owner Iceland: Download...";
2433
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2433
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2434 2434
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2435 2435
 			if ($globalDebug) echo "Add to DB...";
2436
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2436
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2437 2437
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2438 2438
 		if ($error != '') {
2439 2439
 			return $error;
2440 2440
 		} elseif ($globalDebug) echo "Done\n";
2441 2441
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2442
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2442
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2443 2443
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2444 2444
 			if ($globalDebug) echo "Add to DB...";
2445
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2445
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2446 2446
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2447 2447
 		if ($error != '') {
2448 2448
 			return $error;
2449 2449
 		} elseif ($globalDebug) echo "Done\n";
2450 2450
 		if ($globalMasterSource) {
2451 2451
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2452
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2452
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2453 2453
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2454 2454
 				if ($globalDebug) echo "Add to DB...";
2455
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2455
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2456 2456
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2457 2457
 			if ($error != '') {
2458 2458
 				return $error;
2459 2459
 			} elseif ($globalDebug) echo "Done\n";
2460 2460
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2461
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2461
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2462 2462
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2463 2463
 				if ($globalDebug) echo "Add to DB...";
2464
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2464
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2465 2465
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2466 2466
 			if ($error != '') {
2467 2467
 				return $error;
@@ -2474,7 +2474,7 @@  discard block
 block discarded – undo
2474 2474
 		global $tmp_dir, $globalDebug;
2475 2475
 		$error = '';
2476 2476
 		if ($globalDebug) echo "Translation : Download...";
2477
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2477
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2478 2478
 		if (file_exists($tmp_dir.'translation.zip')) {
2479 2479
 			if ($globalDebug) echo "Unzip...";
2480 2480
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2491,10 +2491,10 @@  discard block
 block discarded – undo
2491 2491
 		global $tmp_dir, $globalDebug;
2492 2492
 		$error = '';
2493 2493
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2494
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2495
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2494
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2495
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5');
2496 2496
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2497
-			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2497
+			$translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2498 2498
 			$translation_md5 = $translation_md5_file[0];
2499 2499
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2500 2500
 				if ($globalDebug) echo "Gunzip...";
@@ -2512,10 +2512,10 @@  discard block
 block discarded – undo
2512 2512
 		global $tmp_dir, $globalDebug;
2513 2513
 		$error = '';
2514 2514
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2515
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2516
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2515
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2516
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5');
2517 2517
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2518
-			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2518
+			$modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2519 2519
 			$modes_md5 = $modes_md5_file[0];
2520 2520
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2521 2521
 				if ($globalDebug) echo "Gunzip...";
@@ -2534,12 +2534,12 @@  discard block
 block discarded – undo
2534 2534
 		global $tmp_dir, $globalDebug;
2535 2535
 		$error = '';
2536 2536
 		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2537
-		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2537
+		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5');
2538 2538
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2539
-			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2539
+			$airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2540 2540
 			$airlines_md5 = $airlines_md5_file[0];
2541 2541
 			if (!update_db::check_airlines_version($airlines_md5)) {
2542
-				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2542
+				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz');
2543 2543
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2544 2544
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2545 2545
 						if ($globalDebug) echo "Gunzip...";
@@ -2564,14 +2564,14 @@  discard block
 block discarded – undo
2564 2564
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2565 2565
 		$error = '';
2566 2566
 		if ($globalOwner === TRUE) {
2567
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2568
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2567
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2568
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2569 2569
 		} else {
2570
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2571
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2570
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2571
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2572 2572
 		}
2573 2573
 		if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) {
2574
-			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2574
+			$owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2575 2575
 			$owners_md5 = $owners_md5_file[0];
2576 2576
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2577 2577
 				if ($globalDebug) echo "Gunzip...";
@@ -2588,10 +2588,10 @@  discard block
 block discarded – undo
2588 2588
 	public static function update_routes_fam() {
2589 2589
 		global $tmp_dir, $globalDebug;
2590 2590
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2591
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2592
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2591
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2592
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5');
2593 2593
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2594
-			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2594
+			$routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2595 2595
 			$routes_md5 = $routes_md5_file[0];
2596 2596
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2597 2597
 				if ($globalDebug) echo "Gunzip...";
@@ -2608,10 +2608,10 @@  discard block
 block discarded – undo
2608 2608
 	public static function update_block_fam() {
2609 2609
 		global $tmp_dir, $globalDebug;
2610 2610
 		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
2611
-		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2612
-		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2611
+		update_db::download('http://data.flightairmap.com/data/block.tsv.gz', $tmp_dir.'block.tsv.gz');
2612
+		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5', $tmp_dir.'block.tsv.gz.md5');
2613 2613
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2614
-			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2614
+			$block_md5_file = explode(' ', file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2615 2615
 			$block_md5 = $block_md5_file[0];
2616 2616
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2617 2617
 				if ($globalDebug) echo "Gunzip...";
@@ -2627,13 +2627,13 @@  discard block
 block discarded – undo
2627 2627
 	}
2628 2628
 	public static function update_marine_identity_fam() {
2629 2629
 		global $tmp_dir, $globalDebug;
2630
-		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2630
+		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2631 2631
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2632
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2632
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2633 2633
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2634 2634
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2635 2635
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2636
-				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2636
+				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2637 2637
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2638 2638
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2639 2639
 						if ($globalDebug) echo "Gunzip...";
@@ -2655,13 +2655,13 @@  discard block
 block discarded – undo
2655 2655
 
2656 2656
 	public static function update_satellite_fam() {
2657 2657
 		global $tmp_dir, $globalDebug;
2658
-		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2658
+		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2659 2659
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2660
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2660
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2661 2661
 			$satellite_md5 = $satellite_md5_file[0];
2662 2662
 			if (!update_db::check_satellite_version($satellite_md5)) {
2663 2663
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2664
-				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2664
+				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2665 2665
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2666 2666
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2667 2667
 						if ($globalDebug) echo "Gunzip...";
@@ -2682,13 +2682,13 @@  discard block
 block discarded – undo
2682 2682
 	}
2683 2683
 	public static function update_diagrams_fam() {
2684 2684
 		global $tmp_dir, $globalDebug;
2685
-		update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf.md5',$tmp_dir.'diagramspdf.md5');
2685
+		update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf.md5', $tmp_dir.'diagramspdf.md5');
2686 2686
 		if (file_exists($tmp_dir.'diagramspdf.md5')) {
2687
-			$diagrams_md5_file = explode(' ',file_get_contents($tmp_dir.'diagramspdf.md5'));
2687
+			$diagrams_md5_file = explode(' ', file_get_contents($tmp_dir.'diagramspdf.md5'));
2688 2688
 			$diagrams_md5 = $diagrams_md5_file[0];
2689 2689
 			if (!update_db::check_diagrams_version($diagrams_md5)) {
2690 2690
 				if ($globalDebug) echo "Airports diagrams from FlightAirMap website : Download...";
2691
-				update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf',$tmp_dir.'diagramspdf');
2691
+				update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf', $tmp_dir.'diagramspdf');
2692 2692
 				if (file_exists($tmp_dir.'diagramspdf')) {
2693 2693
 					if (md5_file($tmp_dir.'diagramspdf') == $diagrams_md5) {
2694 2694
 						if ($globalDebug) echo "Add to DB...";
@@ -2708,7 +2708,7 @@  discard block
 block discarded – undo
2708 2708
 	public static function update_banned_fam() {
2709 2709
 		global $tmp_dir, $globalDebug;
2710 2710
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2711
-		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2711
+		update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2712 2712
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2713 2713
 			//if ($globalDebug) echo "Gunzip...";
2714 2714
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2727,18 +2727,18 @@  discard block
 block discarded – undo
2727 2727
 		$error = '';
2728 2728
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2729 2729
 		if ($globalDBdriver == 'mysql') {
2730
-			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2730
+			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2731 2731
 		} else {
2732
-			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2732
+			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2733 2733
 		}
2734 2734
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2735
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2735
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2736 2736
 			$airspace_md5 = $airspace_md5_file[0];
2737 2737
 			if (!update_db::check_airspace_version($airspace_md5)) {
2738 2738
 				if ($globalDBdriver == 'mysql') {
2739
-					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2739
+					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2740 2740
 				} else {
2741
-					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2741
+					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2742 2742
 				}
2743 2743
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2744 2744
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
@@ -2751,7 +2751,7 @@  discard block
 block discarded – undo
2751 2751
 							try {
2752 2752
 								$sth = $Connection->db->prepare($query);
2753 2753
 								$sth->execute();
2754
-							} catch(PDOException $e) {
2754
+							} catch (PDOException $e) {
2755 2755
 								return "error : ".$e->getMessage();
2756 2756
 							}
2757 2757
 						}
@@ -2771,16 +2771,16 @@  discard block
 block discarded – undo
2771 2771
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2772 2772
 		$error = '';
2773 2773
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2774
-		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2774
+		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2775 2775
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2776
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2776
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2777 2777
 			$geoid_md5 = $geoid_md5_file[0];
2778 2778
 			if (!update_db::check_geoid_version($geoid_md5)) {
2779
-				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2779
+				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2780 2780
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2781 2781
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2782 2782
 						if ($globalDebug) echo "Gunzip...";
2783
-						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2783
+						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2784 2784
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2785 2785
 							update_db::insert_geoid_version($geoid_md5);
2786 2786
 						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
@@ -2797,15 +2797,15 @@  discard block
 block discarded – undo
2797 2797
 	public static function update_tle() {
2798 2798
 		global $tmp_dir, $globalDebug;
2799 2799
 		if ($globalDebug) echo "Download TLE : Download...";
2800
-		$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',
2801
-		'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',
2802
-		'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');
2800
+		$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',
2801
+		'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',
2802
+		'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');
2803 2803
 		foreach ($alltle as $filename) {
2804 2804
 			if ($globalDebug) echo "downloading ".$filename.'...';
2805
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2805
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2806 2806
 			if (file_exists($tmp_dir.$filename)) {
2807 2807
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2808
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2808
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2809 2809
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2810 2810
 			if ($error != '') {
2811 2811
 				echo $error."\n";
@@ -2817,7 +2817,7 @@  discard block
 block discarded – undo
2817 2817
 	public static function update_ucsdb() {
2818 2818
 		global $tmp_dir, $globalDebug;
2819 2819
 		if ($globalDebug) echo "Download UCS DB : Download...";
2820
-		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/5-9-19-update/UCS_Satellite_Database_officialname_4-1-2019.txt',$tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt');
2820
+		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/5-9-19-update/UCS_Satellite_Database_officialname_4-1-2019.txt', $tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt');
2821 2821
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt')) {
2822 2822
 			if ($globalDebug) echo "Add to DB...";
2823 2823
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_4-1-2019.txt');
@@ -2831,7 +2831,7 @@  discard block
 block discarded – undo
2831 2831
 	public static function update_celestrak() {
2832 2832
 		global $tmp_dir, $globalDebug;
2833 2833
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2834
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2834
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2835 2835
 		if (file_exists($tmp_dir.'satcat.txt')) {
2836 2836
 			if ($globalDebug) echo "Add to DB...";
2837 2837
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2850,62 +2850,62 @@  discard block
 block discarded – undo
2850 2850
 			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
2851 2851
 			return '';
2852 2852
 		}
2853
-		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2853
+		update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2854 2854
 		if (file_exists($tmp_dir.'models.md5sum')) {
2855 2855
 			if ($globalDebug) echo "Check files...\n";
2856 2856
 			$newmodelsdb = array();
2857
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2858
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2857
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2858
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2859 2859
 					$model = trim($row[2]);
2860 2860
 					$newmodelsdb[$model] = trim($row[0]);
2861 2861
 				}
2862 2862
 			}
2863 2863
 			$modelsdb = array();
2864 2864
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2865
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2866
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2865
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2866
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2867 2867
 						$model = trim($row[2]);
2868 2868
 						$modelsdb[$model] = trim($row[0]);
2869 2869
 					}
2870 2870
 				}
2871 2871
 			}
2872
-			$diff = array_diff($newmodelsdb,$modelsdb);
2872
+			$diff = array_diff($newmodelsdb, $modelsdb);
2873 2873
 			foreach ($diff as $key => $value) {
2874 2874
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2875
-				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2875
+				update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2876 2876
 			}
2877
-			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2877
+			update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2878 2878
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2879 2879
 		if ($error != '') {
2880 2880
 			return $error;
2881 2881
 		} elseif ($globalDebug) echo "Done\n";
2882 2882
 		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
2883
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2883
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum');
2884 2884
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2885 2885
 			if ($globalDebug) echo "Check files...\n";
2886 2886
 			$newmodelsdb = array();
2887
-			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2888
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2887
+			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) {
2888
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2889 2889
 					$model = trim($row[2]);
2890 2890
 					$newmodelsdb[$model] = trim($row[0]);
2891 2891
 				}
2892 2892
 			}
2893 2893
 			$modelsdb = array();
2894 2894
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) {
2895
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) {
2896
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2895
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) {
2896
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2897 2897
 						$model = trim($row[2]);
2898 2898
 						$modelsdb[$model] = trim($row[0]);
2899 2899
 					}
2900 2900
 				}
2901 2901
 			}
2902
-			$diff = array_diff($newmodelsdb,$modelsdb);
2902
+			$diff = array_diff($newmodelsdb, $modelsdb);
2903 2903
 			foreach ($diff as $key => $value) {
2904 2904
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2905
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2905
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key);
2906 2906
 				
2907 2907
 			}
2908
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2908
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum');
2909 2909
 		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
2910 2910
 		if ($error != '') {
2911 2911
 			return $error;
@@ -2921,32 +2921,32 @@  discard block
 block discarded – undo
2921 2921
 			return '';
2922 2922
 		}
2923 2923
 		if ($globalDebug) echo "Weather Models from FlightAirMap website : Download...";
2924
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum');
2924
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', $tmp_dir.'modelsweather.md5sum');
2925 2925
 		if (file_exists($tmp_dir.'modelsweather.md5sum')) {
2926 2926
 			if ($globalDebug) echo "Check files...\n";
2927 2927
 			$newmodelsdb = array();
2928
-			if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) {
2929
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2928
+			if (($handle = fopen($tmp_dir.'modelsweather.md5sum', 'r')) !== FALSE) {
2929
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2930 2930
 					$model = trim($row[2]);
2931 2931
 					$newmodelsdb[$model] = trim($row[0]);
2932 2932
 				}
2933 2933
 			}
2934 2934
 			$modelsdb = array();
2935 2935
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum')) {
2936
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum','r')) !== FALSE) {
2937
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2936
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum', 'r')) !== FALSE) {
2937
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2938 2938
 						$model = trim($row[2]);
2939 2939
 						$modelsdb[$model] = trim($row[0]);
2940 2940
 					}
2941 2941
 				}
2942 2942
 			}
2943
-			$diff = array_diff($newmodelsdb,$modelsdb);
2943
+			$diff = array_diff($newmodelsdb, $modelsdb);
2944 2944
 			foreach ($diff as $key => $value) {
2945 2945
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2946
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2946
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key, dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2947 2947
 				
2948 2948
 			}
2949
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2949
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2950 2950
 		} else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
2951 2951
 		if ($error != '') {
2952 2952
 			return $error;
@@ -2958,32 +2958,32 @@  discard block
 block discarded – undo
2958 2958
 		global $tmp_dir, $globalDebug;
2959 2959
 		$error = '';
2960 2960
 		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
2961
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2961
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum');
2962 2962
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2963 2963
 			if ($globalDebug) echo "Check files...\n";
2964 2964
 			$newmodelsdb = array();
2965
-			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2966
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2965
+			if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) {
2966
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2967 2967
 					$model = trim($row[2]);
2968 2968
 					$newmodelsdb[$model] = trim($row[0]);
2969 2969
 				}
2970 2970
 			}
2971 2971
 			$modelsdb = array();
2972 2972
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) {
2973
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) {
2974
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2973
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) {
2974
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2975 2975
 						$model = trim($row[2]);
2976 2976
 						$modelsdb[$model] = trim($row[0]);
2977 2977
 					}
2978 2978
 				}
2979 2979
 			}
2980
-			$diff = array_diff($newmodelsdb,$modelsdb);
2980
+			$diff = array_diff($newmodelsdb, $modelsdb);
2981 2981
 			foreach ($diff as $key => $value) {
2982 2982
 				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
2983
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2983
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2984 2984
 				
2985 2985
 			}
2986
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2986
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2987 2987
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2988 2988
 		if ($error != '') {
2989 2989
 			return $error;
@@ -2999,32 +2999,32 @@  discard block
 block discarded – undo
2999 2999
 			return '';
3000 3000
 		}
3001 3001
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3002
-		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
3002
+		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
3003 3003
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
3004 3004
 			if ($globalDebug) echo "Check files...\n";
3005 3005
 			$newmodelsdb = array();
3006
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
3007
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
3006
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
3007
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
3008 3008
 					$model = trim($row[2]);
3009 3009
 					$newmodelsdb[$model] = trim($row[0]);
3010 3010
 				}
3011 3011
 			}
3012 3012
 			$modelsdb = array();
3013 3013
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
3014
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
3015
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
3014
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
3015
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
3016 3016
 						$model = trim($row[2]);
3017 3017
 						$modelsdb[$model] = trim($row[0]);
3018 3018
 					}
3019 3019
 				}
3020 3020
 			}
3021
-			$diff = array_diff($newmodelsdb,$modelsdb);
3021
+			$diff = array_diff($newmodelsdb, $modelsdb);
3022 3022
 			foreach ($diff as $key => $value) {
3023 3023
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3024
-				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
3024
+				update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
3025 3025
 				
3026 3026
 			}
3027
-			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
3027
+			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
3028 3028
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3029 3029
 		if ($error != '') {
3030 3030
 			return $error;
@@ -3040,32 +3040,32 @@  discard block
 block discarded – undo
3040 3040
 			return '';
3041 3041
 		}
3042 3042
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3043
-		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
3043
+		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
3044 3044
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
3045 3045
 			if ($globalDebug) echo "Check files...\n";
3046 3046
 			$newmodelsdb = array();
3047
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
3048
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
3047
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
3048
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
3049 3049
 					$model = trim($row[2]);
3050 3050
 					$newmodelsdb[$model] = trim($row[0]);
3051 3051
 				}
3052 3052
 			}
3053 3053
 			$modelsdb = array();
3054 3054
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
3055
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
3056
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
3055
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
3056
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
3057 3057
 						$model = trim($row[2]);
3058 3058
 						$modelsdb[$model] = trim($row[0]);
3059 3059
 					}
3060 3060
 				}
3061 3061
 			}
3062
-			$diff = array_diff($newmodelsdb,$modelsdb);
3062
+			$diff = array_diff($newmodelsdb, $modelsdb);
3063 3063
 			foreach ($diff as $key => $value) {
3064 3064
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3065
-				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
3065
+				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
3066 3066
 				
3067 3067
 			}
3068
-			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3068
+			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3069 3069
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3070 3070
 		if ($error != '') {
3071 3071
 			return $error;
@@ -3077,8 +3077,8 @@  discard block
 block discarded – undo
3077 3077
 		global $tmp_dir, $globalDebug;
3078 3078
 		date_default_timezone_set('UTC');
3079 3079
 		$Common = new Common();
3080
-		$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);
3081
-		$all = json_decode($data,true);
3080
+		$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);
3081
+		$all = json_decode($data, true);
3082 3082
 		$Connection = new Connection();
3083 3083
 		$querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao";
3084 3084
 		$sth = $Connection->db->prepare($querychk);
@@ -3090,8 +3090,8 @@  discard block
 block discarded – undo
3090 3090
 		foreach ($all as $model) {
3091 3091
 			$icao = $model['Designator'];
3092 3092
 			if (!isset($allicao[$icao])) {
3093
-				$aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png';
3094
-				$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']);
3093
+				$aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png';
3094
+				$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']);
3095 3095
 			} else {
3096 3096
 				$allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName'];
3097 3097
 			}
@@ -3103,9 +3103,9 @@  discard block
 block discarded – undo
3103 3103
 				if ($exist[0]['nb'] == 0) {
3104 3104
 					$sthins->execute($airdata);
3105 3105
 				} else {
3106
-					$sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao));
3106
+					$sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao));
3107 3107
 				}
3108
-			} catch(PDOException $e) {
3108
+			} catch (PDOException $e) {
3109 3109
 				return "error : ".$e->getMessage();
3110 3110
 			}
3111 3111
 		}
@@ -3137,23 +3137,23 @@  discard block
 block discarded – undo
3137 3137
 			$Connection = new Connection();
3138 3138
 			$sth = $Connection->db->prepare($query);
3139 3139
                         $sth->execute();
3140
-                } catch(PDOException $e) {
3140
+                } catch (PDOException $e) {
3141 3141
                         return "error : ".$e->getMessage();
3142 3142
                 }
3143 3143
 
3144 3144
 		$error = '';
3145 3145
 		if ($globalDebug) echo "Notam : Download...";
3146
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3146
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
3147 3147
 		if (file_exists($tmp_dir.'notam.rss')) {
3148
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
3148
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
3149 3149
 			foreach ($notams['channel']['item'] as $notam) {
3150
-				$title = explode(':',$notam['title']);
3150
+				$title = explode(':', $notam['title']);
3151 3151
 				$data['ref'] = trim($title[0]);
3152 3152
 				unset($title[0]);
3153
-				$data['title'] = trim(implode(':',$title));
3154
-				$description = strip_tags($notam['description'],'<pre>');
3155
-				preg_match(':^(.*?)<pre>:',$description,$match);
3156
-				$q = explode('/',$match[1]);
3153
+				$data['title'] = trim(implode(':', $title));
3154
+				$description = strip_tags($notam['description'], '<pre>');
3155
+				preg_match(':^(.*?)<pre>:', $description, $match);
3156
+				$q = explode('/', $match[1]);
3157 3157
 				$data['fir'] = $q[0];
3158 3158
 				$data['code'] = $q[1];
3159 3159
 				$ifrvfr = $q[2];
@@ -3169,30 +3169,30 @@  discard block
 block discarded – undo
3169 3169
 				$data['lower_limit'] = $q[5];
3170 3170
 				$data['upper_limit'] = $q[6];
3171 3171
 				$latlonrad = $q[7];
3172
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3173
-				$latitude = $Common->convertDec($las,'latitude');
3174
-				$longitude = $Common->convertDec($lns,'longitude');
3172
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
3173
+				$latitude = $Common->convertDec($las, 'latitude');
3174
+				$longitude = $Common->convertDec($lns, 'longitude');
3175 3175
 				if ($lac == 'S') $latitude = '-'.$latitude;
3176 3176
 				if ($lnc == 'W') $longitude = '-'.$longitude;
3177 3177
 				$data['center_latitude'] = $latitude;
3178 3178
 				$data['center_longitude'] = $longitude;
3179 3179
 				$data['radius'] = intval($radius);
3180 3180
 				
3181
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
3181
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
3182 3182
 				$data['text'] = $match[1];
3183
-				preg_match(':</pre>(.*?)$:',$description,$match);
3183
+				preg_match(':</pre>(.*?)$:', $description, $match);
3184 3184
 				$fromto = $match[1];
3185
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
3185
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
3186 3186
 				$fromall = trim($match[1]);
3187
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
3187
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
3188 3188
 				$from = trim($match[1]);
3189
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
3190
-				preg_match('#TO:(.*?)$#',$fromto,$match);
3189
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
3190
+				preg_match('#TO:(.*?)$#', $fromto, $match);
3191 3191
 				$toall = trim($match[1]);
3192
-				if (!preg_match(':Permanent:',$toall)) {
3193
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
3192
+				if (!preg_match(':Permanent:', $toall)) {
3193
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
3194 3194
 					$to = trim($match[1]);
3195
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3195
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
3196 3196
 					$data['permanent'] = 0;
3197 3197
 				} else {
3198 3198
 				    $data['date_end'] = NULL;
@@ -3200,7 +3200,7 @@  discard block
 block discarded – undo
3200 3200
 				}
3201 3201
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3202 3202
 				$NOTAM = new NOTAM();
3203
-				$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']);
3203
+				$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']);
3204 3204
 				unset($data);
3205 3205
 			} 
3206 3206
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -3223,16 +3223,16 @@  discard block
 block discarded – undo
3223 3223
 				$Connection = new Connection();
3224 3224
 				$sth = $Connection->db->prepare($query);
3225 3225
 				$sth->execute();
3226
-			} catch(PDOException $e) {
3226
+			} catch (PDOException $e) {
3227 3227
 				return "error : ".$e->getMessage();
3228 3228
 			}
3229 3229
 		}
3230 3230
 		$Common = new Common();
3231 3231
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3232
-		$airspace_json = json_decode($airspace_lst,true);
3232
+		$airspace_json = json_decode($airspace_lst, true);
3233 3233
 		foreach ($airspace_json['records'] as $airspace) {
3234 3234
 			if ($globalDebug) echo $airspace['name']."...\n";
3235
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3235
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
3236 3236
 			if (file_exists($tmp_dir.$airspace['name'])) {
3237 3237
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
3238 3238
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -3254,7 +3254,7 @@  discard block
 block discarded – undo
3254 3254
 				$Connection = new Connection();
3255 3255
 				$sth = $Connection->db->prepare($query);
3256 3256
 				$sth->execute(array(':new' => $new, ':old' => $old));
3257
-			} catch(PDOException $e) {
3257
+			} catch (PDOException $e) {
3258 3258
 				return "error : ".$e->getMessage();
3259 3259
 			}
3260 3260
 		}
@@ -3271,7 +3271,7 @@  discard block
 block discarded – undo
3271 3271
 			$Connection = new Connection();
3272 3272
 			$sth = $Connection->db->prepare($query);
3273 3273
                         $sth->execute();
3274
-                } catch(PDOException $e) {
3274
+                } catch (PDOException $e) {
3275 3275
                         return "error : ".$e->getMessage();
3276 3276
                 }
3277 3277
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3286,7 +3286,7 @@  discard block
 block discarded – undo
3286 3286
 			$Connection = new Connection();
3287 3287
 			$sth = $Connection->db->prepare($query);
3288 3288
                         $sth->execute();
3289
-                } catch(PDOException $e) {
3289
+                } catch (PDOException $e) {
3290 3290
                         return "error : ".$e->getMessage();
3291 3291
                 }
3292 3292
 	}
@@ -3297,7 +3297,7 @@  discard block
 block discarded – undo
3297 3297
 			$Connection = new Connection();
3298 3298
 			$sth = $Connection->db->prepare($query);
3299 3299
                         $sth->execute(array(':version' => $version));
3300
-                } catch(PDOException $e) {
3300
+                } catch (PDOException $e) {
3301 3301
                         return "error : ".$e->getMessage();
3302 3302
                 }
3303 3303
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3311,7 +3311,7 @@  discard block
 block discarded – undo
3311 3311
 			$Connection = new Connection();
3312 3312
 			$sth = $Connection->db->prepare($query);
3313 3313
                         $sth->execute(array(':version' => $version));
3314
-                } catch(PDOException $e) {
3314
+                } catch (PDOException $e) {
3315 3315
                         return "error : ".$e->getMessage();
3316 3316
                 }
3317 3317
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3325,7 +3325,7 @@  discard block
 block discarded – undo
3325 3325
 			$Connection = new Connection();
3326 3326
 			$sth = $Connection->db->prepare($query);
3327 3327
 			$sth->execute(array(':version' => $version));
3328
-		} catch(PDOException $e) {
3328
+		} catch (PDOException $e) {
3329 3329
 			return "error : ".$e->getMessage();
3330 3330
 		}
3331 3331
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3339,7 +3339,7 @@  discard block
 block discarded – undo
3339 3339
 			$Connection = new Connection();
3340 3340
 			$sth = $Connection->db->prepare($query);
3341 3341
 			$sth->execute(array(':version' => $version));
3342
-		} catch(PDOException $e) {
3342
+		} catch (PDOException $e) {
3343 3343
 			return "error : ".$e->getMessage();
3344 3344
 		}
3345 3345
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3352,7 +3352,7 @@  discard block
 block discarded – undo
3352 3352
 			$Connection = new Connection();
3353 3353
 			$sth = $Connection->db->prepare($query);
3354 3354
 			$sth->execute(array(':version' => $version));
3355
-		} catch(PDOException $e) {
3355
+		} catch (PDOException $e) {
3356 3356
 			return "error : ".$e->getMessage();
3357 3357
 		}
3358 3358
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3366,7 +3366,7 @@  discard block
 block discarded – undo
3366 3366
 			$Connection = new Connection();
3367 3367
 			$sth = $Connection->db->prepare($query);
3368 3368
 			$sth->execute(array(':version' => $version));
3369
-		} catch(PDOException $e) {
3369
+		} catch (PDOException $e) {
3370 3370
 			return "error : ".$e->getMessage();
3371 3371
 		}
3372 3372
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3380,7 +3380,7 @@  discard block
 block discarded – undo
3380 3380
 			$Connection = new Connection();
3381 3381
 			$sth = $Connection->db->prepare($query);
3382 3382
 			$sth->execute(array(':version' => $version));
3383
-		} catch(PDOException $e) {
3383
+		} catch (PDOException $e) {
3384 3384
 			return "error : ".$e->getMessage();
3385 3385
 		}
3386 3386
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3395,7 +3395,7 @@  discard block
 block discarded – undo
3395 3395
 			$Connection = new Connection();
3396 3396
 			$sth = $Connection->db->prepare($query);
3397 3397
 			$sth->execute(array(':version' => $version));
3398
-		} catch(PDOException $e) {
3398
+		} catch (PDOException $e) {
3399 3399
 			return "error : ".$e->getMessage();
3400 3400
 		}
3401 3401
 	}
@@ -3407,7 +3407,7 @@  discard block
 block discarded – undo
3407 3407
 			$Connection = new Connection();
3408 3408
 			$sth = $Connection->db->prepare($query);
3409 3409
 			$sth->execute(array(':version' => $version));
3410
-		} catch(PDOException $e) {
3410
+		} catch (PDOException $e) {
3411 3411
 			return "error : ".$e->getMessage();
3412 3412
 		}
3413 3413
 	}
@@ -3419,7 +3419,7 @@  discard block
 block discarded – undo
3419 3419
 			$Connection = new Connection();
3420 3420
 			$sth = $Connection->db->prepare($query);
3421 3421
 			$sth->execute(array(':version' => $version));
3422
-		} catch(PDOException $e) {
3422
+		} catch (PDOException $e) {
3423 3423
 			return "error : ".$e->getMessage();
3424 3424
 		}
3425 3425
 	}
@@ -3431,7 +3431,7 @@  discard block
 block discarded – undo
3431 3431
 			$Connection = new Connection();
3432 3432
 			$sth = $Connection->db->prepare($query);
3433 3433
                         $sth->execute(array(':version' => $version));
3434
-                } catch(PDOException $e) {
3434
+                } catch (PDOException $e) {
3435 3435
                         return "error : ".$e->getMessage();
3436 3436
                 }
3437 3437
 	}
@@ -3443,7 +3443,7 @@  discard block
 block discarded – undo
3443 3443
 			$Connection = new Connection();
3444 3444
 			$sth = $Connection->db->prepare($query);
3445 3445
 			$sth->execute(array(':version' => $version));
3446
-		} catch(PDOException $e) {
3446
+		} catch (PDOException $e) {
3447 3447
 			return "error : ".$e->getMessage();
3448 3448
 		}
3449 3449
 	}
@@ -3455,7 +3455,7 @@  discard block
 block discarded – undo
3455 3455
 			$Connection = new Connection();
3456 3456
 			$sth = $Connection->db->prepare($query);
3457 3457
 			$sth->execute(array(':version' => $version));
3458
-		} catch(PDOException $e) {
3458
+		} catch (PDOException $e) {
3459 3459
 			return "error : ".$e->getMessage();
3460 3460
 		}
3461 3461
 	}
@@ -3466,7 +3466,7 @@  discard block
 block discarded – undo
3466 3466
 			$Connection = new Connection();
3467 3467
 			$sth = $Connection->db->prepare($query);
3468 3468
 			$sth->execute(array(':version' => $version));
3469
-		} catch(PDOException $e) {
3469
+		} catch (PDOException $e) {
3470 3470
 			return "error : ".$e->getMessage();
3471 3471
 		}
3472 3472
 	}
@@ -3482,7 +3482,7 @@  discard block
 block discarded – undo
3482 3482
 			$Connection = new Connection();
3483 3483
 			$sth = $Connection->db->prepare($query);
3484 3484
                         $sth->execute();
3485
-                } catch(PDOException $e) {
3485
+                } catch (PDOException $e) {
3486 3486
                         return "error : ".$e->getMessage();
3487 3487
                 }
3488 3488
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3497,7 +3497,7 @@  discard block
 block discarded – undo
3497 3497
 			$Connection = new Connection();
3498 3498
 			$sth = $Connection->db->prepare($query);
3499 3499
                         $sth->execute();
3500
-                } catch(PDOException $e) {
3500
+                } catch (PDOException $e) {
3501 3501
                         return "error : ".$e->getMessage();
3502 3502
                 }
3503 3503
 	}
@@ -3513,7 +3513,7 @@  discard block
 block discarded – undo
3513 3513
 			$Connection = new Connection();
3514 3514
 			$sth = $Connection->db->prepare($query);
3515 3515
                         $sth->execute();
3516
-                } catch(PDOException $e) {
3516
+                } catch (PDOException $e) {
3517 3517
                         return "error : ".$e->getMessage();
3518 3518
                 }
3519 3519
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3528,7 +3528,7 @@  discard block
 block discarded – undo
3528 3528
 			$Connection = new Connection();
3529 3529
 			$sth = $Connection->db->prepare($query);
3530 3530
                         $sth->execute();
3531
-                } catch(PDOException $e) {
3531
+                } catch (PDOException $e) {
3532 3532
                         return "error : ".$e->getMessage();
3533 3533
                 }
3534 3534
 	}
@@ -3544,7 +3544,7 @@  discard block
 block discarded – undo
3544 3544
 			$Connection = new Connection();
3545 3545
 			$sth = $Connection->db->prepare($query);
3546 3546
                         $sth->execute();
3547
-                } catch(PDOException $e) {
3547
+                } catch (PDOException $e) {
3548 3548
                         return "error : ".$e->getMessage();
3549 3549
                 }
3550 3550
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3559,7 +3559,7 @@  discard block
 block discarded – undo
3559 3559
 			$Connection = new Connection();
3560 3560
 			$sth = $Connection->db->prepare($query);
3561 3561
                         $sth->execute();
3562
-                } catch(PDOException $e) {
3562
+                } catch (PDOException $e) {
3563 3563
                         return "error : ".$e->getMessage();
3564 3564
                 }
3565 3565
 	}
@@ -3575,7 +3575,7 @@  discard block
 block discarded – undo
3575 3575
 			$Connection = new Connection();
3576 3576
 			$sth = $Connection->db->prepare($query);
3577 3577
 			$sth->execute();
3578
-		} catch(PDOException $e) {
3578
+		} catch (PDOException $e) {
3579 3579
 			return "error : ".$e->getMessage();
3580 3580
 		}
3581 3581
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3590,7 +3590,7 @@  discard block
 block discarded – undo
3590 3590
 			$Connection = new Connection();
3591 3591
 			$sth = $Connection->db->prepare($query);
3592 3592
 			$sth->execute();
3593
-		} catch(PDOException $e) {
3593
+		} catch (PDOException $e) {
3594 3594
 			return "error : ".$e->getMessage();
3595 3595
 		}
3596 3596
 	}
@@ -3606,7 +3606,7 @@  discard block
 block discarded – undo
3606 3606
 			$Connection = new Connection();
3607 3607
 			$sth = $Connection->db->prepare($query);
3608 3608
 			$sth->execute();
3609
-		} catch(PDOException $e) {
3609
+		} catch (PDOException $e) {
3610 3610
 			return "error : ".$e->getMessage();
3611 3611
 		}
3612 3612
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3621,7 +3621,7 @@  discard block
 block discarded – undo
3621 3621
 			$Connection = new Connection();
3622 3622
 			$sth = $Connection->db->prepare($query);
3623 3623
 			$sth->execute();
3624
-		} catch(PDOException $e) {
3624
+		} catch (PDOException $e) {
3625 3625
 			return "error : ".$e->getMessage();
3626 3626
 		}
3627 3627
 	}
@@ -3637,7 +3637,7 @@  discard block
 block discarded – undo
3637 3637
 			$Connection = new Connection();
3638 3638
 			$sth = $Connection->db->prepare($query);
3639 3639
 			$sth->execute();
3640
-		} catch(PDOException $e) {
3640
+		} catch (PDOException $e) {
3641 3641
 			return "error : ".$e->getMessage();
3642 3642
 		}
3643 3643
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3652,7 +3652,7 @@  discard block
 block discarded – undo
3652 3652
 			$Connection = new Connection();
3653 3653
 			$sth = $Connection->db->prepare($query);
3654 3654
 			$sth->execute();
3655
-		} catch(PDOException $e) {
3655
+		} catch (PDOException $e) {
3656 3656
 			return "error : ".$e->getMessage();
3657 3657
 		}
3658 3658
 	}
@@ -3668,7 +3668,7 @@  discard block
 block discarded – undo
3668 3668
 			$Connection = new Connection();
3669 3669
 			$sth = $Connection->db->prepare($query);
3670 3670
                         $sth->execute();
3671
-                } catch(PDOException $e) {
3671
+                } catch (PDOException $e) {
3672 3672
                         return "error : ".$e->getMessage();
3673 3673
                 }
3674 3674
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3683,7 +3683,7 @@  discard block
 block discarded – undo
3683 3683
 			$Connection = new Connection();
3684 3684
 			$sth = $Connection->db->prepare($query);
3685 3685
 			$sth->execute();
3686
-		} catch(PDOException $e) {
3686
+		} catch (PDOException $e) {
3687 3687
 			return "error : ".$e->getMessage();
3688 3688
 		}
3689 3689
 	}
@@ -3699,7 +3699,7 @@  discard block
 block discarded – undo
3699 3699
 			$Connection = new Connection();
3700 3700
 			$sth = $Connection->db->prepare($query);
3701 3701
 			$sth->execute();
3702
-		} catch(PDOException $e) {
3702
+		} catch (PDOException $e) {
3703 3703
 			return "error : ".$e->getMessage();
3704 3704
 		}
3705 3705
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3714,7 +3714,7 @@  discard block
 block discarded – undo
3714 3714
 			$Connection = new Connection();
3715 3715
 			$sth = $Connection->db->prepare($query);
3716 3716
 			$sth->execute();
3717
-		} catch(PDOException $e) {
3717
+		} catch (PDOException $e) {
3718 3718
 			return "error : ".$e->getMessage();
3719 3719
 		}
3720 3720
 	}
@@ -3730,7 +3730,7 @@  discard block
 block discarded – undo
3730 3730
 			$Connection = new Connection();
3731 3731
 			$sth = $Connection->db->prepare($query);
3732 3732
 			$sth->execute();
3733
-		} catch(PDOException $e) {
3733
+		} catch (PDOException $e) {
3734 3734
 			return "error : ".$e->getMessage();
3735 3735
 		}
3736 3736
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3745,7 +3745,7 @@  discard block
 block discarded – undo
3745 3745
 			$Connection = new Connection();
3746 3746
 			$sth = $Connection->db->prepare($query);
3747 3747
 			$sth->execute();
3748
-		} catch(PDOException $e) {
3748
+		} catch (PDOException $e) {
3749 3749
 			return "error : ".$e->getMessage();
3750 3750
 		}
3751 3751
 	}
@@ -3761,7 +3761,7 @@  discard block
 block discarded – undo
3761 3761
 			$Connection = new Connection();
3762 3762
 			$sth = $Connection->db->prepare($query);
3763 3763
 			$sth->execute();
3764
-		} catch(PDOException $e) {
3764
+		} catch (PDOException $e) {
3765 3765
 			return "error : ".$e->getMessage();
3766 3766
 		}
3767 3767
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3776,7 +3776,7 @@  discard block
 block discarded – undo
3776 3776
 			$Connection = new Connection();
3777 3777
 			$sth = $Connection->db->prepare($query);
3778 3778
 			$sth->execute();
3779
-		} catch(PDOException $e) {
3779
+		} catch (PDOException $e) {
3780 3780
 			return "error : ".$e->getMessage();
3781 3781
 		}
3782 3782
 	}
@@ -3792,7 +3792,7 @@  discard block
 block discarded – undo
3792 3792
 			$Connection = new Connection();
3793 3793
 			$sth = $Connection->db->prepare($query);
3794 3794
 			$sth->execute();
3795
-		} catch(PDOException $e) {
3795
+		} catch (PDOException $e) {
3796 3796
 			return "error : ".$e->getMessage();
3797 3797
 		}
3798 3798
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3811,7 +3811,7 @@  discard block
 block discarded – undo
3811 3811
 			$Connection = new Connection();
3812 3812
 			$sth = $Connection->db->prepare($query);
3813 3813
 			$sth->execute();
3814
-		} catch(PDOException $e) {
3814
+		} catch (PDOException $e) {
3815 3815
 			return "error : ".$e->getMessage();
3816 3816
 		}
3817 3817
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3826,7 +3826,7 @@  discard block
 block discarded – undo
3826 3826
 			$Connection = new Connection();
3827 3827
 			$sth = $Connection->db->prepare($query);
3828 3828
 			$sth->execute();
3829
-		} catch(PDOException $e) {
3829
+		} catch (PDOException $e) {
3830 3830
 			return "error : ".$e->getMessage();
3831 3831
 		}
3832 3832
 	}
@@ -3838,7 +3838,7 @@  discard block
 block discarded – undo
3838 3838
 			$Connection = new Connection();
3839 3839
 			$sth = $Connection->db->prepare($query);
3840 3840
 			$sth->execute();
3841
-		} catch(PDOException $e) {
3841
+		} catch (PDOException $e) {
3842 3842
 			return "error : ".$e->getMessage();
3843 3843
 		}
3844 3844
 	}
@@ -3854,7 +3854,7 @@  discard block
 block discarded – undo
3854 3854
 			$Connection = new Connection();
3855 3855
 			$sth = $Connection->db->prepare($query);
3856 3856
                         $sth->execute();
3857
-                } catch(PDOException $e) {
3857
+                } catch (PDOException $e) {
3858 3858
                         return "error : ".$e->getMessage();
3859 3859
                 }
3860 3860
 	}
@@ -3869,7 +3869,7 @@  discard block
 block discarded – undo
3869 3869
 			$Connection = new Connection();
3870 3870
 			$sth = $Connection->db->prepare($query);
3871 3871
                         $sth->execute();
3872
-                } catch(PDOException $e) {
3872
+                } catch (PDOException $e) {
3873 3873
                         return "error : ".$e->getMessage();
3874 3874
                 }
3875 3875
 	}
Please login to merge, or discard this patch.