Completed
Push — master ( e3409a...79a372 )
by Yannick
05:31
created
install/class.update_db.php 2 patches
Spacing   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		fclose($fp);
25 25
 	}
26 26
 
27
-	public static function gunzip($in_file,$out_file_name = '') {
27
+	public static function gunzip($in_file, $out_file_name = '') {
28 28
 		//echo $in_file.' -> '.$out_file_name."\n";
29 29
 		$buffer_size = 4096; // read 4kb at a time
30 30
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
31 31
 		if ($in_file != '' && file_exists($in_file)) {
32 32
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
33
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
34
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
35 35
 			else {
36 36
 				echo 'gzopen not available';
37 37
 				die;
38 38
 			}
39 39
 			$out_file = fopen($out_file_name, 'wb'); 
40
-			while(!gzeof($file)) {
40
+			while (!gzeof($file)) {
41 41
 				fwrite($out_file, gzread($file, $buffer_size));
42 42
 			}  
43 43
 			fclose($out_file);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		try {
62 62
 			self::$db_sqlite = new PDO('sqlite:'.$database);
63 63
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
64
-		} catch(PDOException $e) {
64
+		} catch (PDOException $e) {
65 65
 			return "error : ".$e->getMessage();
66 66
 		}
67 67
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78 78
                         $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		try {
88 88
                         $sth = update_db::$db_sqlite->prepare($query);
89 89
                         $sth->execute();
90
-                } catch(PDOException $e) {
90
+                } catch (PDOException $e) {
91 91
                         return "error : ".$e->getMessage();
92 92
                 }
93 93
 		//$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)';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99 99
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$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);
101
-				$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);
101
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103 103
             		}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120 120
                         $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
121
+                } catch (PDOException $e) {
122 122
                         return "error : ".$e->getMessage();
123 123
                 }
124 124
 
125 125
     		if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128
-		if ($fh = fopen($database_file,"r")) {
128
+		if ($fh = fopen($database_file, "r")) {
129 129
 			$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)';
130 130
 			$Connection = new Connection();
131 131
 			$sth_dest = $Connection->db->prepare($query_dest);
132 132
 			if ($globalTransaction) $Connection->db->beginTransaction();
133 133
 			while (!feof($fh)) {
134
-				$line = fgetcsv($fh,9999,',');
134
+				$line = fgetcsv($fh, 9999, ',');
135 135
 				if ($line[0] != '') {
136 136
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
137 137
 						try {
138
-							$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');
138
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
139 139
 							$sth_dest->execute($query_dest_values);
140
-						} catch(PDOException $e) {
140
+						} catch (PDOException $e) {
141 141
 							if ($globalTransaction) $Connection->db->rollBack(); 
142 142
 							return "error : ".$e->getMessage();
143 143
 						}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161 161
                         $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error : ".$e->getMessage();
164 164
                 }
165 165
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
170
-		if ($fh = fopen($database_file,"r")) {
170
+		if ($fh = fopen($database_file, "r")) {
171 171
 			$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)';
172 172
 			$Connection = new Connection();
173 173
 			$sth_dest = $Connection->db->prepare($query_dest);
174 174
 			try {
175 175
 				if ($globalTransaction) $Connection->db->beginTransaction();
176 176
 				while (!feof($fh)) {
177
-					$line = fgetcsv($fh,9999,',');
177
+					$line = fgetcsv($fh, 9999, ',');
178 178
 					if ($line[0] != '') {
179
-						$datebe = explode('  -  ',$line[2]);
179
+						$datebe = explode('  -  ', $line[2]);
180 180
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
181
-							$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');
181
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
182 182
 							$sth_dest->execute($query_dest_values);
183 183
 						}
184 184
 					}
185 185
 				}
186 186
 				if ($globalTransaction) $Connection->db->commit();
187
-			} catch(PDOException $e) {
187
+			} catch (PDOException $e) {
188 188
 				if ($globalTransaction) $Connection->db->rollBack(); 
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201 201
                         $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
202
+                } catch (PDOException $e) {
203 203
                         return "error : ".$e->getMessage();
204 204
                 }
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209 209
                         $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
210
+                } catch (PDOException $e) {
211 211
                         return "error : ".$e->getMessage();
212 212
                 }
213 213
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		try {
217 217
                         $sth = update_db::$db_sqlite->prepare($query);
218 218
                         $sth->execute();
219
-                } catch(PDOException $e) {
219
+                } catch (PDOException $e) {
220 220
                         return "error : ".$e->getMessage();
221 221
                 }
222 222
 		//$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)';
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 			//$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']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
236
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
239
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
240 240
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242 242
             		}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244
-		} catch(PDOException $e) {
244
+		} catch (PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
246 246
 		}
247 247
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253 253
                         $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
254
+                } catch (PDOException $e) {
255 255
                         return "error : ".$e->getMessage();
256 256
                 }
257 257
 		return '';
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268 268
                         $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
269
+                } catch (PDOException $e) {
270 270
                         return "error : ".$e->getMessage();
271 271
                 }
272 272
 		
273
-		if ($fh = fopen($database_file,"r")) {
273
+		if ($fh = fopen($database_file, "r")) {
274 274
 			//$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)';
275 275
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
276 276
 		
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281 281
             			while (!feof($fh)) {
282 282
             				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
283
+            				$line = $Common->hex2str(fgets($fh, 9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
285
+            				$values['ModeS'] = substr($line, 0, 6);
286
+            				$values['Registration'] = trim(substr($line, 69, 6));
287
+            				$aircraft_name = trim(substr($line, 48, 6));
288 288
             				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
289
+            				$aircraft_name_split = explode(' ', $aircraft_name);
290 290
             				$search_more = '';
291 291
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292 292
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 	            				if (isset($result['icao']) && $result['icao'] != '') {
299 299
 	            				    $values['ICAOTypeCode'] = $result['icao'];
300 300
 	            				} 
301
-					} catch(PDOException $e) {
301
+					} catch (PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
304 304
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
305 305
 					// Add data to db
306 306
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 307
 						//$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']);
308
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
308
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
309 309
 						//print_r($query_dest_values);
310 310
 						$sth_dest->execute($query_dest_values);
311 311
 					}
312 312
 				}
313 313
 				if ($globalTransaction) $Connection->db->commit();
314
-			} catch(PDOException $e) {
314
+			} catch (PDOException $e) {
315 315
 				return "error : ".$e->getMessage();
316 316
 			}
317 317
 		}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323 323
                         $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
324
+                } catch (PDOException $e) {
325 325
                         return "error : ".$e->getMessage();
326 326
                 }
327 327
 		return '';
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337 337
                         $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
338
+                } catch (PDOException $e) {
339 339
                         return "error : ".$e->getMessage();
340 340
                 }
341 341
 		
342
-		if ($fh = fopen($database_file,"r")) {
342
+		if ($fh = fopen($database_file, "r")) {
343 343
 			//$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)';
344 344
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
345 345
 		
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 			$sth_dest = $Connection->db->prepare($query_dest);
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350
-				$tmp = fgetcsv($fh,9999,',',"'");
350
+				$tmp = fgetcsv($fh, 9999, ',', "'");
351 351
             			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
352
+            				$line = fgetcsv($fh, 9999, ',', "'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             				$values['Registration'] = $line[3];
358 358
             				$aircraft_name = $line[2];
359 359
             				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
360
+            				$aircraft_name_split = explode(' ', $aircraft_name);
361 361
             				$search_more = '';
362 362
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363 363
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
                                     		$sth_search->execute();
367 367
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368 368
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369
-					} catch(PDOException $e) {
369
+					} catch (PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
372 372
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
373 373
 					// Add data to db
374 374
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
375 375
 						//$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']);
376
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
376
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
377 377
 						//print_r($query_dest_values);
378 378
 						$sth_dest->execute($query_dest_values);
379 379
 					}
380 380
 				}
381 381
 				if ($globalTransaction) $Connection->db->commit();
382
-			} catch(PDOException $e) {
382
+			} catch (PDOException $e) {
383 383
 				return "error : ".$e->getMessage();
384 384
 			}
385 385
 		}
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391 391
                         $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
392
+                } catch (PDOException $e) {
393 393
                         return "error : ".$e->getMessage();
394 394
                 }
395 395
 		return '';
396 396
 	}
397 397
 
398
-	public static function retrieve_owner($database_file,$country = 'F') {
398
+	public static function retrieve_owner($database_file, $country = 'F') {
399 399
 		global $globalTransaction;
400 400
 		//$query = 'TRUNCATE TABLE aircraft_modes';
401 401
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405 405
                         $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
406
+                } catch (PDOException $e) {
407 407
                         return "error : ".$e->getMessage();
408 408
                 }
409 409
 		
410
-		if ($fh = fopen($database_file,"r")) {
410
+		if ($fh = fopen($database_file, "r")) {
411 411
 			//$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)';
412 412
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
413 413
 		
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
 			$sth_dest = $Connection->db->prepare($query_dest);
416 416
 			try {
417 417
 				if ($globalTransaction) $Connection->db->beginTransaction();
418
-				$tmp = fgetcsv($fh,9999,',','"');
418
+				$tmp = fgetcsv($fh, 9999, ',', '"');
419 419
             			while (!feof($fh)) {
420
-            				$line = fgetcsv($fh,9999,',','"');
420
+            				$line = fgetcsv($fh, 9999, ',', '"');
421 421
             				$values = array();
422 422
             				//print_r($line);
423 423
             				if ($country == 'F') {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
             				    $values['base'] = $line[4];
426 426
             				    $values['owner'] = $line[5];
427 427
             				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
428
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
429 429
 					    $values['cancel'] = $line[7];
430 430
 					} elseif ($country == 'EI') {
431 431
 					    // TODO : add modeS & reg to aircraft_modes
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             				    $values['base'] = $line[3];
434 434
             				    $values['owner'] = $line[2];
435 435
             				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
436
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
437 437
 					    $values['cancel'] = '';
438 438
 					} elseif ($country == 'HB') {
439 439
 					    // TODO : add modeS & reg to aircraft_modes
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
             				    $values['base'] = null;
449 449
             				    $values['owner'] = $line[5];
450 450
             				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
451
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
452 452
 					    $values['cancel'] = '';
453 453
 					} elseif ($country == 'VH') {
454 454
 					    // TODO : add modeS & reg to aircraft_modes
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             				    $values['base'] = null;
457 457
             				    $values['owner'] = $line[12];
458 458
             				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
459
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
460 460
 
461 461
 					    $values['cancel'] = $line[39];
462 462
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -476,28 +476,28 @@  discard block
 block discarded – undo
476 476
             				    $values['base'] = null;
477 477
             				    $values['owner'] = $line[8];
478 478
             				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
479
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
480 480
 					    $values['cancel'] = '';
481 481
 					} elseif ($country == 'PP') {
482 482
             				    $values['registration'] = $line[0];
483 483
             				    $values['base'] = null;
484 484
             				    $values['owner'] = $line[4];
485 485
             				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
486
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
487 487
 					    $values['cancel'] = $line[7];
488 488
 					} elseif ($country == 'E7') {
489 489
             				    $values['registration'] = $line[0];
490 490
             				    $values['base'] = null;
491 491
             				    $values['owner'] = $line[4];
492 492
             				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
493
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
494 494
 					    $values['cancel'] = '';
495 495
 					} elseif ($country == '8Q') {
496 496
             				    $values['registration'] = $line[0];
497 497
             				    $values['base'] = null;
498 498
             				    $values['owner'] = $line[3];
499 499
             				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
500
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
501 501
 					    $values['cancel'] = '';
502 502
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503 503
             				    $values['registration'] = $line[0];
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 					    $values['cancel'] = '';
508 508
 					}
509 509
 					if ($values['cancel'] == '' && $values['registration'] != null) {
510
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
510
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
511 511
 						$sth_dest->execute($query_dest_values);
512 512
 					}
513 513
 				}
514 514
 				if ($globalTransaction) $Connection->db->commit();
515
-			} catch(PDOException $e) {
515
+			} catch (PDOException $e) {
516 516
 				return "error : ".$e->getMessage();
517 517
 			}
518 518
 		}
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 			$Connection = new Connection();
628 628
 			$sth = $Connection->db->prepare($query);
629 629
                         $sth->execute();
630
-                } catch(PDOException $e) {
630
+                } catch (PDOException $e) {
631 631
                         return "error : ".$e->getMessage();
632 632
                 }
633 633
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 			$Connection = new Connection();
638 638
 			$sth = $Connection->db->prepare($query);
639 639
                         $sth->execute();
640
-                } catch(PDOException $e) {
640
+                } catch (PDOException $e) {
641 641
                         return "error : ".$e->getMessage();
642 642
                 }
643 643
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 		if ($globalTransaction) $Connection->db->beginTransaction();
649 649
   
650 650
 		$i = 0;
651
-		while($row = sparql_fetch_array($result))
651
+		while ($row = sparql_fetch_array($result))
652 652
 		{
653 653
 			if ($i >= 1) {
654 654
 			//print_r($row);
@@ -668,31 +668,31 @@  discard block
 block discarded – undo
668 668
 				$row['image'] = '';
669 669
 				$row['image_thumb'] = '';
670 670
 			} else {
671
-				$image = str_replace(' ','_',$row['image']);
671
+				$image = str_replace(' ', '_', $row['image']);
672 672
 				$digest = md5($image);
673
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
674
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
675
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
676
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
673
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
674
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
675
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
676
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
677 677
 			}
678 678
 			
679
-			$country = explode('-',$row['country']);
679
+			$country = explode('-', $row['country']);
680 680
 			$row['country'] = $country[0];
681 681
 			
682 682
 			$row['type'] = trim($row['type']);
683
-			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'])) {
683
+			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'])) {
684 684
 				$row['type'] = 'Military';
685 685
 			} 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') {
686 686
 				$row['type'] = 'small_airport';
687 687
 			}
688 688
 			
689
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
690
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $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']);
689
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
690
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $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']);
691 691
 			//print_r($query_dest_values);
692 692
 			
693 693
 			try {
694 694
 				$sth_dest->execute($query_dest_values);
695
-			} catch(PDOException $e) {
695
+			} catch (PDOException $e) {
696 696
 				return "error : ".$e->getMessage();
697 697
 			}
698 698
 			}
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 			$Connection = new Connection();
707 707
 			$sth = $Connection->db->prepare($query);
708 708
                         $sth->execute();
709
-                } catch(PDOException $e) {
709
+                } catch (PDOException $e) {
710 710
                         return "error : ".$e->getMessage();
711 711
                 }
712 712
 
@@ -714,12 +714,12 @@  discard block
 block discarded – undo
714 714
 		if ($globalDebug) echo "Insert Not available Airport...\n";
715 715
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
716 716
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
717
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
717
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
718 718
 		try {
719 719
 			$Connection = new Connection();
720 720
 			$sth = $Connection->db->prepare($query);
721 721
                         $sth->execute($query_values);
722
-                } catch(PDOException $e) {
722
+                } catch (PDOException $e) {
723 723
                         return "error : ".$e->getMessage();
724 724
                 }
725 725
 		$i++;
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		echo "Download data from ourairports.com...\n";
738 738
 		$delimiter = ',';
739 739
 		$out_file = $tmp_dir.'airports.csv';
740
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
740
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
741 741
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
742 742
 		echo "Add data from ourairports.com...\n";
743 743
 
@@ -748,32 +748,32 @@  discard block
 block discarded – undo
748 748
 			//$Connection->db->beginTransaction();
749 749
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
750 750
 			{
751
-				if(!$header) $header = $row;
751
+				if (!$header) $header = $row;
752 752
 				else {
753 753
 					$data = array();
754 754
 					$data = array_combine($header, $row);
755 755
 					try {
756 756
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
757 757
 						$sth->execute(array(':icao' => $data['gps_code']));
758
-					} catch(PDOException $e) {
758
+					} catch (PDOException $e) {
759 759
 						return "error : ".$e->getMessage();
760 760
 					}
761 761
 					if ($sth->fetchColumn() > 0) {
762 762
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
763 763
 						try {
764 764
 							$sth = $Connection->db->prepare($query);
765
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
766
-						} catch(PDOException $e) {
765
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
766
+						} catch (PDOException $e) {
767 767
 							return "error : ".$e->getMessage();
768 768
 						}
769 769
 					} else {
770 770
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
771 771
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
772
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
772
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
773 773
 						try {
774 774
 							$sth = $Connection->db->prepare($query);
775 775
 							$sth->execute($query_values);
776
-						} catch(PDOException $e) {
776
+						} catch (PDOException $e) {
777 777
 							return "error : ".$e->getMessage();
778 778
 						}
779 779
 						$i++;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
 		echo "Download data from another free database...\n";
788 788
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
789
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
789
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
790 790
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
791 791
 		update_db::unzip($out_file);
792 792
 		$header = NULL;
@@ -798,15 +798,15 @@  discard block
 block discarded – undo
798 798
 			//$Connection->db->beginTransaction();
799 799
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
800 800
 			{
801
-				if(!$header) $header = $row;
801
+				if (!$header) $header = $row;
802 802
 				else {
803 803
 					$data = $row;
804 804
 
805 805
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
806 806
 					try {
807 807
 						$sth = $Connection->db->prepare($query);
808
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
809
-					} catch(PDOException $e) {
808
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
809
+					} catch (PDOException $e) {
810 810
 						return "error : ".$e->getMessage();
811 811
 					}
812 812
 				}
@@ -820,15 +820,15 @@  discard block
 block discarded – undo
820 820
 		try {
821 821
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
822 822
 			$sth->execute();
823
-		} catch(PDOException $e) {
823
+		} catch (PDOException $e) {
824 824
 			return "error : ".$e->getMessage();
825 825
 		}
826 826
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
827 827
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
828 828
 			try {
829 829
 				$sth2 = $Connection->db->prepare($query2);
830
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
831
-			} catch(PDOException $e) {
830
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
831
+			} catch (PDOException $e) {
832 832
 				return "error : ".$e->getMessage();
833 833
 			}
834 834
 		}
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 			$Connection = new Connection();
853 853
 			$sth = $Connection->db->prepare($query);
854 854
                         $sth->execute(array(':source' => 'translation.csv'));
855
-                } catch(PDOException $e) {
855
+                } catch (PDOException $e) {
856 856
                         return "error : ".$e->getMessage();
857 857
                 }
858 858
 
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 870
 			{
871 871
 				$i++;
872
-				if($i > 12) {
872
+				if ($i > 12) {
873 873
 					$data = $row;
874 874
 					$operator = $data[2];
875 875
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
                                                 //echo substr($operator, 0, 2)."\n";;
878 878
                                                 if (count($airline_array) > 0) {
879 879
 							//print_r($airline_array);
880
-							$operator = $airline_array[0]['icao'].substr($operator,2);
880
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
881 881
                                                 }
882 882
                                         }
883 883
 					
@@ -885,14 +885,14 @@  discard block
 block discarded – undo
885 885
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
886 886
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887 887
                                                 if (count($airline_array) > 0) {
888
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
888
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
889 889
                                             	}
890 890
                                         }
891 891
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
892 892
 					try {
893 893
 						$sth = $Connection->db->prepare($query);
894
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
895
-					} catch(PDOException $e) {
894
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
895
+					} catch (PDOException $e) {
896 896
 						return "error : ".$e->getMessage();
897 897
 					}
898 898
 				}
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 			$Connection = new Connection();
913 913
 			$sth = $Connection->db->prepare($query);
914 914
                         $sth->execute(array(':source' => 'website_fam'));
915
-                } catch(PDOException $e) {
915
+                } catch (PDOException $e) {
916 916
                         return "error : ".$e->getMessage();
917 917
                 }
918 918
 
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
933 933
 					try {
934 934
 						$sth = $Connection->db->prepare($query);
935
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
936
-					} catch(PDOException $e) {
935
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
936
+					} catch (PDOException $e) {
937 937
 						return "error : ".$e->getMessage();
938 938
 					}
939 939
 				}
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 			$Connection = new Connection();
953 953
 			$sth = $Connection->db->prepare($query);
954 954
                         $sth->execute(array(':source' => 'website_faa'));
955
-                } catch(PDOException $e) {
955
+                } catch (PDOException $e) {
956 956
                         return "error : ".$e->getMessage();
957 957
                 }
958 958
 
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 			$Connection = new Connection();
962 962
 			$sth = $Connection->db->prepare($query);
963 963
                         $sth->execute(array(':source' => 'website_faa'));
964
-                } catch(PDOException $e) {
964
+                } catch (PDOException $e) {
965 965
                         return "error : ".$e->getMessage();
966 966
                 }
967 967
 
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
990 990
 						try {
991 991
 							$sth = $Connection->db->prepare($query);
992
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => $data[6],':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
993
-						} catch(PDOException $e) {
992
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => $data[6], ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
993
+						} catch (PDOException $e) {
994 994
 							return "error : ".$e->getMessage();
995 995
 						}
996 996
 					}
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 			$Connection = new Connection();
1010 1010
 			$sth = $Connection->db->prepare($query);
1011 1011
                         $sth->execute(array(':source' => 'website_fam'));
1012
-                } catch(PDOException $e) {
1012
+                } catch (PDOException $e) {
1013 1013
                         return "error : ".$e->getMessage();
1014 1014
                 }
1015 1015
 
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1030 1030
 					try {
1031 1031
 						$sth = $Connection->db->prepare($query);
1032
-						$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'));
1033
-					} catch(PDOException $e) {
1032
+						$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'));
1033
+					} catch (PDOException $e) {
1034 1034
 						return "error : ".$e->getMessage();
1035 1035
 					}
1036 1036
 				}
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 			$Connection = new Connection();
1050 1050
 			$sth = $Connection->db->prepare($query);
1051 1051
                         $sth->execute(array(':source' => 'website_fam'));
1052
-                } catch(PDOException $e) {
1052
+                } catch (PDOException $e) {
1053 1053
                         return "error : ".$e->getMessage();
1054 1054
                 }
1055 1055
 
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1066 1066
 					try {
1067 1067
 						$sth = $Connection->db->prepare($query);
1068
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1069
-					} catch(PDOException $e) {
1068
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1069
+					} catch (PDOException $e) {
1070 1070
 						print_r($data);
1071 1071
 						return "error : ".$e->getMessage();
1072 1072
 					}
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 			$Connection = new Connection();
1087 1087
 			$sth = $Connection->db->prepare($query);
1088 1088
                         $sth->execute(array(':source' => 'website_fam'));
1089
-                } catch(PDOException $e) {
1089
+                } catch (PDOException $e) {
1090 1090
                         return "error : ".$e->getMessage();
1091 1091
                 }
1092 1092
 
@@ -1106,8 +1106,8 @@  discard block
 block discarded – undo
1106 1106
 					$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)';
1107 1107
 					try {
1108 1108
 						$sth = $Connection->db->prepare($query);
1109
-						$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'));
1110
-					} catch(PDOException $e) {
1109
+						$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'));
1110
+					} catch (PDOException $e) {
1111 1111
 						return "error : ".$e->getMessage();
1112 1112
 					}
1113 1113
 				}
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 		return '';
1120 1120
         }
1121 1121
 
1122
-	public static function tle($filename,$tletype) {
1122
+	public static function tle($filename, $tletype) {
1123 1123
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1124 1124
 		global $tmp_dir, $globalTransaction;
1125 1125
 		//$Spotter = new Spotter();
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 			$Connection = new Connection();
1130 1130
 			$sth = $Connection->db->prepare($query);
1131 1131
                         $sth->execute(array(':source' => $filename));
1132
-                } catch(PDOException $e) {
1132
+                } catch (PDOException $e) {
1133 1133
                         return "error : ".$e->getMessage();
1134 1134
                 }
1135 1135
 		
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1155 1155
 					try {
1156 1156
 						$sth = $Connection->db->prepare($query);
1157
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1158
-					} catch(PDOException $e) {
1157
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1158
+					} catch (PDOException $e) {
1159 1159
 						return "error : ".$e->getMessage();
1160 1160
 					}
1161 1161
 
@@ -1175,28 +1175,28 @@  discard block
 block discarded – undo
1175 1175
         */
1176 1176
         private static function table2array($data) {
1177 1177
                 $html = str_get_html($data);
1178
-                $tabledata=array();
1179
-                foreach($html->find('tr') as $element)
1178
+                $tabledata = array();
1179
+                foreach ($html->find('tr') as $element)
1180 1180
                 {
1181 1181
                         $td = array();
1182
-                        foreach( $element->find('th') as $row)
1182
+                        foreach ($element->find('th') as $row)
1183 1183
                         {
1184 1184
                                 $td [] = trim($row->plaintext);
1185 1185
                         }
1186
-                        $td=array_filter($td);
1186
+                        $td = array_filter($td);
1187 1187
                         $tabledata[] = $td;
1188 1188
 
1189 1189
                         $td = array();
1190 1190
                         $tdi = array();
1191
-                        foreach( $element->find('td') as $row)
1191
+                        foreach ($element->find('td') as $row)
1192 1192
                         {
1193 1193
                                 $td [] = trim($row->plaintext);
1194 1194
                                 $tdi [] = trim($row->innertext);
1195 1195
                         }
1196
-                        $td=array_filter($td);
1197
-                        $tdi=array_filter($tdi);
1196
+                        $td = array_filter($td);
1197
+                        $tdi = array_filter($tdi);
1198 1198
                     //    $tabledata[]=array_merge($td,$tdi);
1199
-                        $tabledata[]=$td;
1199
+                        $tabledata[] = $td;
1200 1200
                 }
1201 1201
                 return(array_filter($tabledata));
1202 1202
         }
@@ -1269,13 +1269,13 @@  discard block
 block discarded – undo
1269 1269
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1270 1270
 			{
1271 1271
 				$i++;
1272
-				if($i > 3 && count($row) > 2) {
1272
+				if ($i > 3 && count($row) > 2) {
1273 1273
 					$data = array_values(array_filter($row));
1274 1274
 					$cntdata = count($data);
1275 1275
 					if ($cntdata > 10) {
1276 1276
 						$value = $data[9];
1277 1277
 						
1278
-						for ($i =10;$i < $cntdata;$i++) {
1278
+						for ($i = 10; $i < $cntdata; $i++) {
1279 1279
 							$value .= ' '.$data[$i];
1280 1280
 						}
1281 1281
 						$data[9] = $value;
@@ -1285,8 +1285,8 @@  discard block
 block discarded – undo
1285 1285
 						$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)';
1286 1286
 						try {
1287 1287
 							$sth = $Connection->db->prepare($query);
1288
-							$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]));
1289
-						} catch(PDOException $e) {
1288
+							$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]));
1289
+						} catch (PDOException $e) {
1290 1290
 							return "error : ".$e->getMessage();
1291 1291
 						}
1292 1292
 					}
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
 			$Connection = new Connection();
1308 1308
 			$sth = $Connection->db->prepare($query);
1309 1309
                         $sth->execute();
1310
-                } catch(PDOException $e) {
1310
+                } catch (PDOException $e) {
1311 1311
                         return "error : ".$e->getMessage();
1312 1312
                 }
1313 1313
 
@@ -1319,12 +1319,12 @@  discard block
 block discarded – undo
1319 1319
 			if ($globalTransaction) $Connection->db->beginTransaction();
1320 1320
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1321 1321
 			{
1322
-				if(count($row) > 1) {
1322
+				if (count($row) > 1) {
1323 1323
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1324 1324
 					try {
1325 1325
 						$sth = $Connection->db->prepare($query);
1326
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1327
-					} catch(PDOException $e) {
1326
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1327
+					} catch (PDOException $e) {
1328 1328
 						return "error : ".$e->getMessage();
1329 1329
 					}
1330 1330
 				}
@@ -1344,21 +1344,21 @@  discard block
 block discarded – undo
1344 1344
 			try {
1345 1345
 				$sth = $Connection->db->prepare($query);
1346 1346
                     		$sth->execute();
1347
-	                } catch(PDOException $e) {
1347
+	                } catch (PDOException $e) {
1348 1348
 				return "error : ".$e->getMessage();
1349 1349
 	                }
1350 1350
 	        }
1351 1351
 
1352 1352
 
1353
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1353
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1354 1354
 		else {
1355
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1355
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1356 1356
 			$query = "CREATE EXTENSION postgis";
1357
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1357
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1358 1358
 			try {
1359 1359
 				$sth = $Connection->db->prepare($query);
1360 1360
 				$sth->execute();
1361
-			} catch(PDOException $e) {
1361
+			} catch (PDOException $e) {
1362 1362
 				return "error : ".$e->getMessage();
1363 1363
 			}
1364 1364
 		}
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
 		include_once('class.create_db.php');
1372 1372
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1373 1373
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1374
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1374
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1375 1375
 		$error = '';
1376 1376
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1377 1377
 			if ($globalDebug) echo "Gunzip...";
@@ -1403,14 +1403,14 @@  discard block
 block discarded – undo
1403 1403
 			try {
1404 1404
 				$sth = $Connection->db->prepare($query);
1405 1405
             	        	$sth->execute();
1406
-	                } catch(PDOException $e) {
1406
+	                } catch (PDOException $e) {
1407 1407
     	                	echo "error : ".$e->getMessage();
1408 1408
 	                }
1409 1409
 		}
1410 1410
 		if ($globalDBdriver == 'mysql') {
1411
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1411
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1412 1412
 		} else {
1413
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1413
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1414 1414
 		}
1415 1415
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1416 1416
 		return $error;
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1424 1424
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1425 1425
 //		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');
1426
-		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');
1426
+		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');
1427 1427
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1428 1428
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1429 1429
 		return $error;
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1444 1444
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1445 1445
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1446
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1446
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1447 1447
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1448 1448
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1449 1449
 		if ($error != '') {
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 		global $tmp_dir, $globalDebug;
1457 1457
 		$error = '';
1458 1458
 		if ($globalDebug) echo "Routes : Download...";
1459
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1459
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1460 1460
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1461 1461
 			if ($globalDebug) echo "Gunzip...";
1462 1462
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
 		global $tmp_dir, $globalDebug;
1473 1473
 		$error = '';
1474 1474
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1475
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1475
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1476 1476
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1477 1477
 			if ($globalDebug) echo "Gunzip...";
1478 1478
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1488,7 +1488,7 @@  discard block
 block discarded – undo
1488 1488
 		global $tmp_dir, $globalDebug;
1489 1489
 		$error = '';
1490 1490
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1491
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1491
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1492 1492
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1493 1493
 			if ($globalDebug) echo "Gunzip...";
1494 1494
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 */
1517 1517
 		if ($globalDebug) echo "Modes : Download...";
1518 1518
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1519
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1519
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1520 1520
 
1521 1521
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1522 1522
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
 	public static function update_ModeS_faa() {
1537 1537
 		global $tmp_dir, $globalDebug;
1538 1538
 		if ($globalDebug) echo "Modes FAA: Download...";
1539
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1539
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1540 1540
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1541 1541
 			if ($globalDebug) echo "Unzip...";
1542 1542
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1552,7 +1552,7 @@  discard block
 block discarded – undo
1552 1552
 	public static function update_ModeS_flarm() {
1553 1553
 		global $tmp_dir, $globalDebug;
1554 1554
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1555
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1555
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1556 1556
 		if (file_exists($tmp_dir.'data.fln')) {
1557 1557
 			if ($globalDebug) echo "Add to DB...";
1558 1558
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
 	public static function update_ModeS_ogn() {
1567 1567
 		global $tmp_dir, $globalDebug;
1568 1568
 		if ($globalDebug) echo "Modes OGN: Download...";
1569
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1569
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1570 1570
 		if (file_exists($tmp_dir.'ogn.csv')) {
1571 1571
 			if ($globalDebug) echo "Add to DB...";
1572 1572
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1581,173 +1581,173 @@  discard block
 block discarded – undo
1581 1581
 		global $tmp_dir, $globalDebug;
1582 1582
 		
1583 1583
 		if ($globalDebug) echo "Owner France: Download...";
1584
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1584
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1585 1585
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1586 1586
 			if ($globalDebug) echo "Add to DB...";
1587
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1587
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1588 1588
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1589 1589
 		if ($error != '') {
1590 1590
 			return $error;
1591 1591
 		} elseif ($globalDebug) echo "Done\n";
1592 1592
 		
1593 1593
 		if ($globalDebug) echo "Owner Ireland: Download...";
1594
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1594
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1595 1595
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1596 1596
 			if ($globalDebug) echo "Add to DB...";
1597
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1597
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1598 1598
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1599 1599
 		if ($error != '') {
1600 1600
 			return $error;
1601 1601
 		} elseif ($globalDebug) echo "Done\n";
1602 1602
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1603
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1603
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1604 1604
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1605 1605
 			if ($globalDebug) echo "Add to DB...";
1606
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1606
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1607 1607
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1608 1608
 		if ($error != '') {
1609 1609
 			return $error;
1610 1610
 		} elseif ($globalDebug) echo "Done\n";
1611 1611
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1612
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1612
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1613 1613
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1614 1614
 			if ($globalDebug) echo "Add to DB...";
1615
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1615
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1616 1616
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1617 1617
 		if ($error != '') {
1618 1618
 			return $error;
1619 1619
 		} elseif ($globalDebug) echo "Done\n";
1620 1620
 		if ($globalDebug) echo "Owner Australia: Download...";
1621
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1621
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1622 1622
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1623 1623
 			if ($globalDebug) echo "Add to DB...";
1624
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1624
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1625 1625
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1626 1626
 		if ($error != '') {
1627 1627
 			return $error;
1628 1628
 		} elseif ($globalDebug) echo "Done\n";
1629 1629
 		if ($globalDebug) echo "Owner Austria: Download...";
1630
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1630
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1631 1631
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1632 1632
 			if ($globalDebug) echo "Add to DB...";
1633
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1633
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1634 1634
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1635 1635
 		if ($error != '') {
1636 1636
 			return $error;
1637 1637
 		} elseif ($globalDebug) echo "Done\n";
1638 1638
 		if ($globalDebug) echo "Owner Chile: Download...";
1639
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1639
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1640 1640
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1641 1641
 			if ($globalDebug) echo "Add to DB...";
1642
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1642
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1643 1643
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1644 1644
 		if ($error != '') {
1645 1645
 			return $error;
1646 1646
 		} elseif ($globalDebug) echo "Done\n";
1647 1647
 		if ($globalDebug) echo "Owner Colombia: Download...";
1648
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1648
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1649 1649
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1650 1650
 			if ($globalDebug) echo "Add to DB...";
1651
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1651
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1652 1652
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1653 1653
 		if ($error != '') {
1654 1654
 			return $error;
1655 1655
 		} elseif ($globalDebug) echo "Done\n";
1656 1656
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1657
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1657
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1658 1658
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1659 1659
 			if ($globalDebug) echo "Add to DB...";
1660
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1660
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1661 1661
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1662 1662
 		if ($error != '') {
1663 1663
 			return $error;
1664 1664
 		} elseif ($globalDebug) echo "Done\n";
1665 1665
 		if ($globalDebug) echo "Owner Brazil: Download...";
1666
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1666
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1667 1667
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1668 1668
 			if ($globalDebug) echo "Add to DB...";
1669
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1669
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1670 1670
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1671 1671
 		if ($error != '') {
1672 1672
 			return $error;
1673 1673
 		} elseif ($globalDebug) echo "Done\n";
1674 1674
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1675
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1675
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1676 1676
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1677 1677
 			if ($globalDebug) echo "Add to DB...";
1678
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1678
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1679 1679
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1680 1680
 		if ($error != '') {
1681 1681
 			return $error;
1682 1682
 		} elseif ($globalDebug) echo "Done\n";
1683 1683
 		if ($globalDebug) echo "Owner Croatia: Download...";
1684
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1684
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1685 1685
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1686 1686
 			if ($globalDebug) echo "Add to DB...";
1687
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1687
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1688 1688
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1689 1689
 		if ($error != '') {
1690 1690
 			return $error;
1691 1691
 		} elseif ($globalDebug) echo "Done\n";
1692 1692
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1693
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1693
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1694 1694
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1695 1695
 			if ($globalDebug) echo "Add to DB...";
1696
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1696
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1697 1697
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1698 1698
 		if ($error != '') {
1699 1699
 			return $error;
1700 1700
 		} elseif ($globalDebug) echo "Done\n";
1701 1701
 		if ($globalDebug) echo "Owner Maldives: Download...";
1702
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1702
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1703 1703
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1704 1704
 			if ($globalDebug) echo "Add to DB...";
1705
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1705
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1706 1706
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1707 1707
 		if ($error != '') {
1708 1708
 			return $error;
1709 1709
 		} elseif ($globalDebug) echo "Done\n";
1710 1710
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1711
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1711
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1712 1712
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1713 1713
 			if ($globalDebug) echo "Add to DB...";
1714
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1714
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1715 1715
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1716 1716
 		if ($error != '') {
1717 1717
 			return $error;
1718 1718
 		} elseif ($globalDebug) echo "Done\n";
1719 1719
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1720
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1720
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1721 1721
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1722 1722
 			if ($globalDebug) echo "Add to DB...";
1723
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1723
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1724 1724
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1725 1725
 		if ($error != '') {
1726 1726
 			return $error;
1727 1727
 		} elseif ($globalDebug) echo "Done\n";
1728 1728
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1729
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1729
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1730 1730
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1731 1731
 			if ($globalDebug) echo "Add to DB...";
1732
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1732
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1733 1733
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1734 1734
 		if ($error != '') {
1735 1735
 			return $error;
1736 1736
 		} elseif ($globalDebug) echo "Done\n";
1737 1737
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1738
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1738
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1739 1739
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1740 1740
 			if ($globalDebug) echo "Add to DB...";
1741
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1741
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1742 1742
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1743 1743
 		if ($error != '') {
1744 1744
 			return $error;
1745 1745
 		} elseif ($globalDebug) echo "Done\n";
1746 1746
 		if ($globalDebug) echo "Owner Iceland: Download...";
1747
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1747
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1748 1748
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1749 1749
 			if ($globalDebug) echo "Add to DB...";
1750
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1750
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1751 1751
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1752 1752
 		if ($error != '') {
1753 1753
 			return $error;
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
 		global $tmp_dir, $globalDebug;
1760 1760
 		$error = '';
1761 1761
 		if ($globalDebug) echo "Translation : Download...";
1762
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1762
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1763 1763
 		if (file_exists($tmp_dir.'translation.zip')) {
1764 1764
 			if ($globalDebug) echo "Unzip...";
1765 1765
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 	public static function update_translation_fam() {
1776 1776
 		global $tmp_dir, $globalDebug;
1777 1777
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1778
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1778
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1779 1779
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1780 1780
 			if ($globalDebug) echo "Gunzip...";
1781 1781
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
 	public static function update_ModeS_fam() {
1791 1791
 		global $tmp_dir, $globalDebug;
1792 1792
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1793
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1793
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1794 1794
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1795 1795
 			if ($globalDebug) echo "Gunzip...";
1796 1796
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1806,9 +1806,9 @@  discard block
 block discarded – undo
1806 1806
 		global $tmp_dir, $globalDebug, $globalOwner;
1807 1807
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1808 1808
 		if ($globalOwner === TRUE) {
1809
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1809
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1810 1810
 		} else {
1811
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1811
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
1812 1812
 		}
1813 1813
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1814 1814
 			if ($globalDebug) echo "Gunzip...";
@@ -1824,7 +1824,7 @@  discard block
 block discarded – undo
1824 1824
 	public static function update_routes_fam() {
1825 1825
 		global $tmp_dir, $globalDebug;
1826 1826
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
1827
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1827
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
1828 1828
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1829 1829
 			if ($globalDebug) echo "Gunzip...";
1830 1830
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -1843,18 +1843,18 @@  discard block
 block discarded – undo
1843 1843
 		$error = '';
1844 1844
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
1845 1845
 		if ($globalDBdriver == 'mysql') {
1846
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1846
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1847 1847
 		} else {
1848
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1848
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1849 1849
 		}
1850 1850
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
1851
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1851
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1852 1852
 			$airspace_md5 = $airspace_md5_file[0];
1853 1853
 			if (!update_db::check_airspace_version($airspace_md5)) {
1854 1854
 				if ($globalDBdriver == 'mysql') {
1855
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
1855
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
1856 1856
 				} else {
1857
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1857
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
1858 1858
 				}
1859 1859
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1860 1860
 					if ($globalDebug) echo "Gunzip...";
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
 						try {
1867 1867
 							$sth = $Connection->db->prepare($query);
1868 1868
     	    	    					$sth->execute();
1869
-			            		} catch(PDOException $e) {
1869
+			            		} catch (PDOException $e) {
1870 1870
 							return "error : ".$e->getMessage();
1871 1871
 		            			}
1872 1872
 		    			}
@@ -1884,15 +1884,15 @@  discard block
 block discarded – undo
1884 1884
 	public static function update_tle() {
1885 1885
 		global $tmp_dir, $globalDebug;
1886 1886
 		if ($globalDebug) echo "Download TLE : Download...";
1887
-		$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',
1888
-		'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',
1889
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1887
+		$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',
1888
+		'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',
1889
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
1890 1890
 		foreach ($alltle as $filename) {
1891 1891
 			if ($globalDebug) echo "downloading ".$filename.'...';
1892
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1892
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
1893 1893
 			if (file_exists($tmp_dir.$filename)) {
1894 1894
 				if ($globalDebug) echo "Add to DB ".$filename."...";
1895
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1895
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
1896 1896
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1897 1897
 			if ($error != '') {
1898 1898
 				echo $error."\n";
@@ -1905,32 +1905,32 @@  discard block
 block discarded – undo
1905 1905
 		global $tmp_dir, $globalDebug;
1906 1906
 		$error = '';
1907 1907
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
1908
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1908
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
1909 1909
 		if (file_exists($tmp_dir.'models.md5sum')) {
1910 1910
 			if ($globalDebug) echo "Check files...\n";
1911 1911
 			$newmodelsdb = array();
1912
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1913
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1912
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
1913
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1914 1914
 					$model = trim($row[2]);
1915 1915
 					$newmodelsdb[$model] = trim($row[0]);
1916 1916
 				}
1917 1917
 			}
1918 1918
 			$modelsdb = array();
1919 1919
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
1920
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
1921
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1920
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
1921
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1922 1922
 						$model = trim($row[2]);
1923 1923
 						$modelsdb[$model] = trim($row[0]);
1924 1924
 					}
1925 1925
 				}
1926 1926
 			}
1927
-			$diff = array_diff($newmodelsdb,$modelsdb);
1927
+			$diff = array_diff($newmodelsdb, $modelsdb);
1928 1928
 			foreach ($diff as $key => $value) {
1929 1929
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
1930
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1930
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
1931 1931
 				
1932 1932
 			}
1933
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1933
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
1934 1934
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1935 1935
 		if ($error != '') {
1936 1936
 			return $error;
@@ -1942,32 +1942,32 @@  discard block
 block discarded – undo
1942 1942
 		global $tmp_dir, $globalDebug;
1943 1943
 		$error = '';
1944 1944
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
1945
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1945
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
1946 1946
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1947 1947
 			if ($globalDebug) echo "Check files...\n";
1948 1948
 			$newmodelsdb = array();
1949
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1950
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1949
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
1950
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1951 1951
 					$model = trim($row[2]);
1952 1952
 					$newmodelsdb[$model] = trim($row[0]);
1953 1953
 				}
1954 1954
 			}
1955 1955
 			$modelsdb = array();
1956 1956
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
1957
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
1958
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1957
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
1958
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1959 1959
 						$model = trim($row[2]);
1960 1960
 						$modelsdb[$model] = trim($row[0]);
1961 1961
 					}
1962 1962
 				}
1963 1963
 			}
1964
-			$diff = array_diff($newmodelsdb,$modelsdb);
1964
+			$diff = array_diff($newmodelsdb, $modelsdb);
1965 1965
 			foreach ($diff as $key => $value) {
1966 1966
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
1967
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1967
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
1968 1968
 				
1969 1969
 			}
1970
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1970
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
1971 1971
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1972 1972
 		if ($error != '') {
1973 1973
 			return $error;
@@ -1990,8 +1990,8 @@  discard block
 block discarded – undo
1990 1990
 		*/
1991 1991
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1992 1992
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1993
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1994
-		    $result = fread($fh,100000000);
1993
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
1994
+		    $result = fread($fh, 100000000);
1995 1995
 		    //echo $result;
1996 1996
 		    //var_dump(str_get_html($result));
1997 1997
 		    //print_r(self::table2array($result));
@@ -2009,23 +2009,23 @@  discard block
 block discarded – undo
2009 2009
 			$Connection = new Connection();
2010 2010
 			$sth = $Connection->db->prepare($query);
2011 2011
                         $sth->execute();
2012
-                } catch(PDOException $e) {
2012
+                } catch (PDOException $e) {
2013 2013
                         return "error : ".$e->getMessage();
2014 2014
                 }
2015 2015
 
2016 2016
 		$error = '';
2017 2017
 		if ($globalDebug) echo "Notam : Download...";
2018
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2018
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2019 2019
 		if (file_exists($tmp_dir.'notam.rss')) {
2020
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2020
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2021 2021
 			foreach ($notams['channel']['item'] as $notam) {
2022
-				$title = explode(':',$notam['title']);
2022
+				$title = explode(':', $notam['title']);
2023 2023
 				$data['ref'] = trim($title[0]);
2024 2024
 				unset($title[0]);
2025
-				$data['title'] = trim(implode(':',$title));
2026
-				$description = strip_tags($notam['description'],'<pre>');
2027
-				preg_match(':^(.*?)<pre>:',$description,$match);
2028
-				$q = explode('/',$match[1]);
2025
+				$data['title'] = trim(implode(':', $title));
2026
+				$description = strip_tags($notam['description'], '<pre>');
2027
+				preg_match(':^(.*?)<pre>:', $description, $match);
2028
+				$q = explode('/', $match[1]);
2029 2029
 				$data['fir'] = $q[0];
2030 2030
 				$data['code'] = $q[1];
2031 2031
 				$ifrvfr = $q[2];
@@ -2041,30 +2041,30 @@  discard block
 block discarded – undo
2041 2041
 				$data['lower_limit'] = $q[5];
2042 2042
 				$data['upper_limit'] = $q[6];
2043 2043
 				$latlonrad = $q[7];
2044
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2045
-				$latitude = $Common->convertDec($las,'latitude');
2046
-				$longitude = $Common->convertDec($lns,'longitude');
2044
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2045
+				$latitude = $Common->convertDec($las, 'latitude');
2046
+				$longitude = $Common->convertDec($lns, 'longitude');
2047 2047
 				if ($lac == 'S') $latitude = '-'.$latitude;
2048 2048
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2049 2049
 				$data['center_latitude'] = $latitude;
2050 2050
 				$data['center_longitude'] = $longitude;
2051 2051
 				$data['radius'] = intval($radius);
2052 2052
 				
2053
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2053
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2054 2054
 				$data['text'] = $match[1];
2055
-				preg_match(':</pre>(.*?)$:',$description,$match);
2055
+				preg_match(':</pre>(.*?)$:', $description, $match);
2056 2056
 				$fromto = $match[1];
2057
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2057
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2058 2058
 				$fromall = trim($match[1]);
2059
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2059
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2060 2060
 				$from = trim($match[1]);
2061
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2062
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2061
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2062
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2063 2063
 				$toall = trim($match[1]);
2064
-				if (!preg_match(':Permanent:',$toall)) {
2065
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2064
+				if (!preg_match(':Permanent:', $toall)) {
2065
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2066 2066
 					$to = trim($match[1]);
2067
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2067
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2068 2068
 					$data['permanent'] = 0;
2069 2069
 				} else {
2070 2070
 				    $data['date_end'] = NULL;
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
 				}
2073 2073
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2074 2074
 				$NOTAM = new NOTAM();
2075
-				$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']);
2075
+				$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']);
2076 2076
 				unset($data);
2077 2077
 			} 
2078 2078
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2095,16 +2095,16 @@  discard block
 block discarded – undo
2095 2095
 				$Connection = new Connection();
2096 2096
 				$sth = $Connection->db->prepare($query);
2097 2097
 				$sth->execute();
2098
-			} catch(PDOException $e) {
2098
+			} catch (PDOException $e) {
2099 2099
 				return "error : ".$e->getMessage();
2100 2100
 			}
2101 2101
 		}
2102 2102
 		$Common = new Common();
2103 2103
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2104
-		$airspace_json = json_decode($airspace_lst,true);
2104
+		$airspace_json = json_decode($airspace_lst, true);
2105 2105
 		foreach ($airspace_json['records'] as $airspace) {
2106 2106
 			if ($globalDebug) echo $airspace['name']."...\n";
2107
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2107
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2108 2108
 			if (file_exists($tmp_dir.$airspace['name'])) {
2109 2109
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2110 2110
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2128,7 +2128,7 @@  discard block
 block discarded – undo
2128 2128
 			$Connection = new Connection();
2129 2129
 			$sth = $Connection->db->prepare($query);
2130 2130
                         $sth->execute();
2131
-                } catch(PDOException $e) {
2131
+                } catch (PDOException $e) {
2132 2132
                         return "error : ".$e->getMessage();
2133 2133
                 }
2134 2134
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2143,7 +2143,7 @@  discard block
 block discarded – undo
2143 2143
 			$Connection = new Connection();
2144 2144
 			$sth = $Connection->db->prepare($query);
2145 2145
                         $sth->execute();
2146
-                } catch(PDOException $e) {
2146
+                } catch (PDOException $e) {
2147 2147
                         return "error : ".$e->getMessage();
2148 2148
                 }
2149 2149
 	}
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
 			$Connection = new Connection();
2155 2155
 			$sth = $Connection->db->prepare($query);
2156 2156
                         $sth->execute(array(':version' => $version));
2157
-                } catch(PDOException $e) {
2157
+                } catch (PDOException $e) {
2158 2158
                         return "error : ".$e->getMessage();
2159 2159
                 }
2160 2160
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2170,7 +2170,7 @@  discard block
 block discarded – undo
2170 2170
 			$Connection = new Connection();
2171 2171
 			$sth = $Connection->db->prepare($query);
2172 2172
                         $sth->execute(array(':version' => $version));
2173
-                } catch(PDOException $e) {
2173
+                } catch (PDOException $e) {
2174 2174
                         return "error : ".$e->getMessage();
2175 2175
                 }
2176 2176
 	}
@@ -2186,7 +2186,7 @@  discard block
 block discarded – undo
2186 2186
 			$Connection = new Connection();
2187 2187
 			$sth = $Connection->db->prepare($query);
2188 2188
                         $sth->execute();
2189
-                } catch(PDOException $e) {
2189
+                } catch (PDOException $e) {
2190 2190
                         return "error : ".$e->getMessage();
2191 2191
                 }
2192 2192
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2201,7 +2201,7 @@  discard block
 block discarded – undo
2201 2201
 			$Connection = new Connection();
2202 2202
 			$sth = $Connection->db->prepare($query);
2203 2203
                         $sth->execute();
2204
-                } catch(PDOException $e) {
2204
+                } catch (PDOException $e) {
2205 2205
                         return "error : ".$e->getMessage();
2206 2206
                 }
2207 2207
 	}
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 			$Connection = new Connection();
2217 2217
 			$sth = $Connection->db->prepare($query);
2218 2218
                         $sth->execute();
2219
-                } catch(PDOException $e) {
2219
+                } catch (PDOException $e) {
2220 2220
                         return "error : ".$e->getMessage();
2221 2221
                 }
2222 2222
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 			$Connection = new Connection();
2232 2232
 			$sth = $Connection->db->prepare($query);
2233 2233
                         $sth->execute();
2234
-                } catch(PDOException $e) {
2234
+                } catch (PDOException $e) {
2235 2235
                         return "error : ".$e->getMessage();
2236 2236
                 }
2237 2237
 	}
@@ -2247,7 +2247,7 @@  discard block
 block discarded – undo
2247 2247
 			$Connection = new Connection();
2248 2248
 			$sth = $Connection->db->prepare($query);
2249 2249
                         $sth->execute();
2250
-                } catch(PDOException $e) {
2250
+                } catch (PDOException $e) {
2251 2251
                         return "error : ".$e->getMessage();
2252 2252
                 }
2253 2253
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
 			$Connection = new Connection();
2263 2263
 			$sth = $Connection->db->prepare($query);
2264 2264
                         $sth->execute();
2265
-                } catch(PDOException $e) {
2265
+                } catch (PDOException $e) {
2266 2266
                         return "error : ".$e->getMessage();
2267 2267
                 }
2268 2268
 	}
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
 			$Connection = new Connection();
2278 2278
 			$sth = $Connection->db->prepare($query);
2279 2279
                         $sth->execute();
2280
-                } catch(PDOException $e) {
2280
+                } catch (PDOException $e) {
2281 2281
                         return "error : ".$e->getMessage();
2282 2282
                 }
2283 2283
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2292,7 +2292,7 @@  discard block
 block discarded – undo
2292 2292
 			$Connection = new Connection();
2293 2293
 			$sth = $Connection->db->prepare($query);
2294 2294
                         $sth->execute();
2295
-                } catch(PDOException $e) {
2295
+                } catch (PDOException $e) {
2296 2296
                         return "error : ".$e->getMessage();
2297 2297
                 }
2298 2298
 	}
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
 			$Connection = new Connection();
2308 2308
 			$sth = $Connection->db->prepare($query);
2309 2309
                         $sth->execute();
2310
-                } catch(PDOException $e) {
2310
+                } catch (PDOException $e) {
2311 2311
                         return "error : ".$e->getMessage();
2312 2312
                 }
2313 2313
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2322,7 +2322,7 @@  discard block
 block discarded – undo
2322 2322
 			$Connection = new Connection();
2323 2323
 			$sth = $Connection->db->prepare($query);
2324 2324
                         $sth->execute();
2325
-                } catch(PDOException $e) {
2325
+                } catch (PDOException $e) {
2326 2326
                         return "error : ".$e->getMessage();
2327 2327
                 }
2328 2328
 	}
@@ -2337,7 +2337,7 @@  discard block
 block discarded – undo
2337 2337
 			$Connection = new Connection();
2338 2338
 			$sth = $Connection->db->prepare($query);
2339 2339
                         $sth->execute();
2340
-                } catch(PDOException $e) {
2340
+                } catch (PDOException $e) {
2341 2341
                         return "error : ".$e->getMessage();
2342 2342
                 }
2343 2343
 	}
@@ -2352,7 +2352,7 @@  discard block
 block discarded – undo
2352 2352
 			$Connection = new Connection();
2353 2353
 			$sth = $Connection->db->prepare($query);
2354 2354
                         $sth->execute();
2355
-                } catch(PDOException $e) {
2355
+                } catch (PDOException $e) {
2356 2356
                         return "error : ".$e->getMessage();
2357 2357
                 }
2358 2358
 	}
Please login to merge, or discard this patch.
Braces   +810 added lines, -281 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 100
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$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);
101 117
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$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)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$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']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -277,7 +324,9 @@  discard block
 block discarded – undo
277 324
 			$Connection = new Connection();
278 325
 			$sth_dest = $Connection->db->prepare($query_dest);
279 326
 			try {
280
-				if ($globalTransaction) $Connection->db->beginTransaction();
327
+				if ($globalTransaction) {
328
+					$Connection->db->beginTransaction();
329
+				}
281 330
             			while (!feof($fh)) {
282 331
             				$values = array();
283 332
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -288,7 +337,9 @@  discard block
 block discarded – undo
288 337
             				// Check if we can find ICAO, else set it to GLID
289 338
             				$aircraft_name_split = explode(' ',$aircraft_name);
290 339
             				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
340
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
341
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
342
+            				}
292 343
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293 344
             				$sth_search = $Connection->db->prepare($query_search);
294 345
 					try {
@@ -301,7 +352,9 @@  discard block
 block discarded – undo
301 352
 					} catch(PDOException $e) {
302 353
 						return "error : ".$e->getMessage();
303 354
 					}
304
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
355
+					if (!isset($values['ICAOTypeCode'])) {
356
+						$values['ICAOTypeCode'] = 'GLID';
357
+					}
305 358
 					// Add data to db
306 359
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 360
 						//$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']);
@@ -310,7 +363,9 @@  discard block
 block discarded – undo
310 363
 						$sth_dest->execute($query_dest_values);
311 364
 					}
312 365
 				}
313
-				if ($globalTransaction) $Connection->db->commit();
366
+				if ($globalTransaction) {
367
+					$Connection->db->commit();
368
+				}
314 369
 			} catch(PDOException $e) {
315 370
 				return "error : ".$e->getMessage();
316 371
 			}
@@ -346,7 +401,9 @@  discard block
 block discarded – undo
346 401
 			$Connection = new Connection();
347 402
 			$sth_dest = $Connection->db->prepare($query_dest);
348 403
 			try {
349
-				if ($globalTransaction) $Connection->db->beginTransaction();
404
+				if ($globalTransaction) {
405
+					$Connection->db->beginTransaction();
406
+				}
350 407
 				$tmp = fgetcsv($fh,9999,',',"'");
351 408
             			while (!feof($fh)) {
352 409
             				$line = fgetcsv($fh,9999,',',"'");
@@ -359,13 +416,17 @@  discard block
 block discarded – undo
359 416
             				// Check if we can find ICAO, else set it to GLID
360 417
             				$aircraft_name_split = explode(' ',$aircraft_name);
361 418
             				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
419
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
420
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				}
363 422
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364 423
             				$sth_search = $Connection->db->prepare($query_search);
365 424
 					try {
366 425
                                     		$sth_search->execute();
367 426
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
427
+	            				if (isset($result['icao']) && $result['icao'] != '') {
428
+	            					$values['ICAOTypeCode'] = $result['icao'];
429
+	            				}
369 430
 					} catch(PDOException $e) {
370 431
 						return "error : ".$e->getMessage();
371 432
 					}
@@ -378,7 +439,9 @@  discard block
 block discarded – undo
378 439
 						$sth_dest->execute($query_dest_values);
379 440
 					}
380 441
 				}
381
-				if ($globalTransaction) $Connection->db->commit();
442
+				if ($globalTransaction) {
443
+					$Connection->db->commit();
444
+				}
382 445
 			} catch(PDOException $e) {
383 446
 				return "error : ".$e->getMessage();
384 447
 			}
@@ -414,7 +477,9 @@  discard block
 block discarded – undo
414 477
 			$Connection = new Connection();
415 478
 			$sth_dest = $Connection->db->prepare($query_dest);
416 479
 			try {
417
-				if ($globalTransaction) $Connection->db->beginTransaction();
480
+				if ($globalTransaction) {
481
+					$Connection->db->beginTransaction();
482
+				}
418 483
 				$tmp = fgetcsv($fh,9999,',','"');
419 484
             			while (!feof($fh)) {
420 485
             				$line = fgetcsv($fh,9999,',','"');
@@ -424,16 +489,22 @@  discard block
 block discarded – undo
424 489
             				    $values['registration'] = $line[0];
425 490
             				    $values['base'] = $line[4];
426 491
             				    $values['owner'] = $line[5];
427
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
492
+            				    if ($line[6] == '') {
493
+            				    	$values['date_first_reg'] = null;
494
+            				    } else {
495
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    }
429 497
 					    $values['cancel'] = $line[7];
430 498
 					} elseif ($country == 'EI') {
431 499
 					    // TODO : add modeS & reg to aircraft_modes
432 500
             				    $values['registration'] = $line[0];
433 501
             				    $values['base'] = $line[3];
434 502
             				    $values['owner'] = $line[2];
435
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
503
+            				    if ($line[1] == '') {
504
+            				    	$values['date_first_reg'] = null;
505
+            				    } else {
506
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
507
+					    }
437 508
 					    $values['cancel'] = '';
438 509
 					} elseif ($country == 'HB') {
439 510
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,16 +518,22 @@  discard block
 block discarded – undo
447 518
             				    $values['registration'] = $line[3];
448 519
             				    $values['base'] = null;
449 520
             				    $values['owner'] = $line[5];
450
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
521
+            				    if ($line[18] == '') {
522
+            				    	$values['date_first_reg'] = null;
523
+            				    } else {
524
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
525
+					    }
452 526
 					    $values['cancel'] = '';
453 527
 					} elseif ($country == 'VH') {
454 528
 					    // TODO : add modeS & reg to aircraft_modes
455 529
             				    $values['registration'] = $line[0];
456 530
             				    $values['base'] = null;
457 531
             				    $values['owner'] = $line[12];
458
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
532
+            				    if ($line[28] == '') {
533
+            				    	$values['date_first_reg'] = null;
534
+            				    } else {
535
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
536
+					    }
460 537
 
461 538
 					    $values['cancel'] = $line[39];
462 539
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -475,29 +552,41 @@  discard block
 block discarded – undo
475 552
             				    $values['registration'] = $line[0];
476 553
             				    $values['base'] = null;
477 554
             				    $values['owner'] = $line[8];
478
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
555
+            				    if ($line[7] == '') {
556
+            				    	$values['date_first_reg'] = null;
557
+            				    } else {
558
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
559
+					    }
480 560
 					    $values['cancel'] = '';
481 561
 					} elseif ($country == 'PP') {
482 562
             				    $values['registration'] = $line[0];
483 563
             				    $values['base'] = null;
484 564
             				    $values['owner'] = $line[4];
485
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
565
+            				    if ($line[6] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
569
+					    }
487 570
 					    $values['cancel'] = $line[7];
488 571
 					} elseif ($country == 'E7') {
489 572
             				    $values['registration'] = $line[0];
490 573
             				    $values['base'] = null;
491 574
             				    $values['owner'] = $line[4];
492
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
575
+            				    if ($line[5] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
579
+					    }
494 580
 					    $values['cancel'] = '';
495 581
 					} elseif ($country == '8Q') {
496 582
             				    $values['registration'] = $line[0];
497 583
             				    $values['base'] = null;
498 584
             				    $values['owner'] = $line[3];
499
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
585
+            				    if ($line[7] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
589
+					    }
501 590
 					    $values['cancel'] = '';
502 591
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503 592
             				    $values['registration'] = $line[0];
@@ -511,7 +600,9 @@  discard block
 block discarded – undo
511 600
 						$sth_dest->execute($query_dest_values);
512 601
 					}
513 602
 				}
514
-				if ($globalTransaction) $Connection->db->commit();
603
+				if ($globalTransaction) {
604
+					$Connection->db->commit();
605
+				}
515 606
 			} catch(PDOException $e) {
516 607
 				return "error : ".$e->getMessage();
517 608
 			}
@@ -645,25 +736,45 @@  discard block
 block discarded – undo
645 736
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
646 737
 		$Connection = new Connection();
647 738
 		$sth_dest = $Connection->db->prepare($query_dest);
648
-		if ($globalTransaction) $Connection->db->beginTransaction();
739
+		if ($globalTransaction) {
740
+			$Connection->db->beginTransaction();
741
+		}
649 742
   
650 743
 		$i = 0;
651 744
 		while($row = sparql_fetch_array($result))
652 745
 		{
653 746
 			if ($i >= 1) {
654 747
 			//print_r($row);
655
-			if (!isset($row['iata'])) $row['iata'] = '';
656
-			if (!isset($row['icao'])) $row['icao'] = '';
657
-			if (!isset($row['type'])) $row['type'] = '';
658
-			if (!isset($row['altitude'])) $row['altitude'] = '';
748
+			if (!isset($row['iata'])) {
749
+				$row['iata'] = '';
750
+			}
751
+			if (!isset($row['icao'])) {
752
+				$row['icao'] = '';
753
+			}
754
+			if (!isset($row['type'])) {
755
+				$row['type'] = '';
756
+			}
757
+			if (!isset($row['altitude'])) {
758
+				$row['altitude'] = '';
759
+			}
659 760
 			if (isset($row['city_bis'])) {
660 761
 				$row['city'] = $row['city_bis'];
661 762
 			}
662
-			if (!isset($row['city'])) $row['city'] = '';
663
-			if (!isset($row['country'])) $row['country'] = '';
664
-			if (!isset($row['homepage'])) $row['homepage'] = '';
665
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
666
-			if (!isset($row['name'])) continue;
763
+			if (!isset($row['city'])) {
764
+				$row['city'] = '';
765
+			}
766
+			if (!isset($row['country'])) {
767
+				$row['country'] = '';
768
+			}
769
+			if (!isset($row['homepage'])) {
770
+				$row['homepage'] = '';
771
+			}
772
+			if (!isset($row['wikipedia_page'])) {
773
+				$row['wikipedia_page'] = '';
774
+			}
775
+			if (!isset($row['name'])) {
776
+				continue;
777
+			}
667 778
 			if (!isset($row['image'])) {
668 779
 				$row['image'] = '';
669 780
 				$row['image_thumb'] = '';
@@ -699,7 +810,9 @@  discard block
 block discarded – undo
699 810
 
700 811
 			$i++;
701 812
 		}
702
-		if ($globalTransaction) $Connection->db->commit();
813
+		if ($globalTransaction) {
814
+			$Connection->db->commit();
815
+		}
703 816
 		echo "Delete duplicate rows...\n";
704 817
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
705 818
 		try {
@@ -711,7 +824,9 @@  discard block
 block discarded – undo
711 824
                 }
712 825
 
713 826
 
714
-		if ($globalDebug) echo "Insert Not available Airport...\n";
827
+		if ($globalDebug) {
828
+			echo "Insert Not available Airport...\n";
829
+		}
715 830
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
716 831
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
717 832
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -738,7 +853,9 @@  discard block
 block discarded – undo
738 853
 		$delimiter = ',';
739 854
 		$out_file = $tmp_dir.'airports.csv';
740 855
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
741
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
856
+		if (!file_exists($out_file) || !is_readable($out_file)) {
857
+			return FALSE;
858
+		}
742 859
 		echo "Add data from ourairports.com...\n";
743 860
 
744 861
 		$header = NULL;
@@ -748,8 +865,9 @@  discard block
 block discarded – undo
748 865
 			//$Connection->db->beginTransaction();
749 866
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
750 867
 			{
751
-				if(!$header) $header = $row;
752
-				else {
868
+				if(!$header) {
869
+					$header = $row;
870
+				} else {
753 871
 					$data = array();
754 872
 					$data = array_combine($header, $row);
755 873
 					try {
@@ -787,7 +905,9 @@  discard block
 block discarded – undo
787 905
 		echo "Download data from another free database...\n";
788 906
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
789 907
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
790
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
908
+		if (!file_exists($out_file) || !is_readable($out_file)) {
909
+			return FALSE;
910
+		}
791 911
 		update_db::unzip($out_file);
792 912
 		$header = NULL;
793 913
 		echo "Add data from another free database...\n";
@@ -798,8 +918,9 @@  discard block
 block discarded – undo
798 918
 			//$Connection->db->beginTransaction();
799 919
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
800 920
 			{
801
-				if(!$header) $header = $row;
802
-				else {
921
+				if(!$header) {
922
+					$header = $row;
923
+				} else {
803 924
 					$data = $row;
804 925
 
805 926
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -972,7 +1093,9 @@  discard block
 block discarded – undo
972 1093
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
973 1094
 		{
974 1095
 			$i = 0;
975
-			if ($globalTransaction) $Connection->db->beginTransaction();
1096
+			if ($globalTransaction) {
1097
+				$Connection->db->beginTransaction();
1098
+			}
976 1099
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
977 1100
 			{
978 1101
 				if ($i > 0) {
@@ -998,7 +1121,9 @@  discard block
 block discarded – undo
998 1121
 				$i++;
999 1122
 			}
1000 1123
 			fclose($handle);
1001
-			if ($globalTransaction) $Connection->db->commit();
1124
+			if ($globalTransaction) {
1125
+				$Connection->db->commit();
1126
+			}
1002 1127
 		}
1003 1128
 		return '';
1004 1129
         }
@@ -1022,7 +1147,9 @@  discard block
 block discarded – undo
1022 1147
 			$i = 0;
1023 1148
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1024 1149
 			//$Connection->db->beginTransaction();
1025
-			if ($globalTransaction) $Connection->db->beginTransaction();
1150
+			if ($globalTransaction) {
1151
+				$Connection->db->beginTransaction();
1152
+			}
1026 1153
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1027 1154
 			{
1028 1155
 				if ($i > 0) {
@@ -1037,7 +1164,9 @@  discard block
 block discarded – undo
1037 1164
 				$i++;
1038 1165
 			}
1039 1166
 			fclose($handle);
1040
-			if ($globalTransaction) $Connection->db->commit();
1167
+			if ($globalTransaction) {
1168
+				$Connection->db->commit();
1169
+			}
1041 1170
 		}
1042 1171
 		return '';
1043 1172
         }
@@ -1058,7 +1187,9 @@  discard block
 block discarded – undo
1058 1187
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1059 1188
 		{
1060 1189
 			$i = 0;
1061
-			if ($globalTransaction) $Connection->db->beginTransaction();
1190
+			if ($globalTransaction) {
1191
+				$Connection->db->beginTransaction();
1192
+			}
1062 1193
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1063 1194
 			{
1064 1195
 				if ($i > 0) {
@@ -1074,7 +1205,9 @@  discard block
 block discarded – undo
1074 1205
 				$i++;
1075 1206
 			}
1076 1207
 			fclose($handle);
1077
-			if ($globalTransaction) $Connection->db->commit();
1208
+			if ($globalTransaction) {
1209
+				$Connection->db->commit();
1210
+			}
1078 1211
 		}
1079 1212
 		return '';
1080 1213
         }
@@ -1099,7 +1232,9 @@  discard block
 block discarded – undo
1099 1232
 			$i = 0;
1100 1233
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1101 1234
 			//$Connection->db->beginTransaction();
1102
-			if ($globalTransaction) $Connection->db->beginTransaction();
1235
+			if ($globalTransaction) {
1236
+				$Connection->db->beginTransaction();
1237
+			}
1103 1238
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1104 1239
 			{
1105 1240
 				if ($i > 0) {
@@ -1114,7 +1249,9 @@  discard block
 block discarded – undo
1114 1249
 				$i++;
1115 1250
 			}
1116 1251
 			fclose($handle);
1117
-			if ($globalTransaction) $Connection->db->commit();
1252
+			if ($globalTransaction) {
1253
+				$Connection->db->commit();
1254
+			}
1118 1255
 		}
1119 1256
 		return '';
1120 1257
         }
@@ -1265,7 +1402,9 @@  discard block
 block discarded – undo
1265 1402
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1266 1403
 		{
1267 1404
 			$i = 0;
1268
-			if ($globalTransaction) $Connection->db->beginTransaction();
1405
+			if ($globalTransaction) {
1406
+				$Connection->db->beginTransaction();
1407
+			}
1269 1408
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1270 1409
 			{
1271 1410
 				$i++;
@@ -1293,7 +1432,9 @@  discard block
 block discarded – undo
1293 1432
 				}
1294 1433
 			}
1295 1434
 			fclose($handle);
1296
-			if ($globalTransaction) $Connection->db->commit();
1435
+			if ($globalTransaction) {
1436
+				$Connection->db->commit();
1437
+			}
1297 1438
 		}
1298 1439
 		return '';
1299 1440
         }
@@ -1316,7 +1457,9 @@  discard block
 block discarded – undo
1316 1457
 		$Connection = new Connection();
1317 1458
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1318 1459
 		{
1319
-			if ($globalTransaction) $Connection->db->beginTransaction();
1460
+			if ($globalTransaction) {
1461
+				$Connection->db->beginTransaction();
1462
+			}
1320 1463
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1321 1464
 			{
1322 1465
 				if(count($row) > 1) {
@@ -1330,7 +1473,9 @@  discard block
 block discarded – undo
1330 1473
 				}
1331 1474
 			}
1332 1475
 			fclose($handle);
1333
-			if ($globalTransaction) $Connection->db->commit();
1476
+			if ($globalTransaction) {
1477
+				$Connection->db->commit();
1478
+			}
1334 1479
 		}
1335 1480
 		return '';
1336 1481
         }
@@ -1350,8 +1495,9 @@  discard block
 block discarded – undo
1350 1495
 	        }
1351 1496
 
1352 1497
 
1353
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1354
-		else {
1498
+		if ($globalDBdriver == 'mysql') {
1499
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1500
+		} else {
1355 1501
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1356 1502
 			$query = "CREATE EXTENSION postgis";
1357 1503
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1370,20 +1516,30 @@  discard block
 block discarded – undo
1370 1516
 		global $tmp_dir, $globalDebug;
1371 1517
 		include_once('class.create_db.php');
1372 1518
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1373
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1519
+		if ($globalDebug) {
1520
+			echo "NOTAM from FlightAirMap website : Download...";
1521
+		}
1374 1522
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1375 1523
 		$error = '';
1376 1524
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1377
-			if ($globalDebug) echo "Gunzip...";
1525
+			if ($globalDebug) {
1526
+				echo "Gunzip...";
1527
+			}
1378 1528
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1379
-			if ($globalDebug) echo "Add to DB...";
1529
+			if ($globalDebug) {
1530
+				echo "Add to DB...";
1531
+			}
1380 1532
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1381 1533
 			$NOTAM = new NOTAM();
1382 1534
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1383
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1535
+		} else {
1536
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1537
+		}
1384 1538
 		if ($error != '') {
1385 1539
 			return $error;
1386
-		} elseif ($globalDebug) echo "Done\n";
1540
+		} elseif ($globalDebug) {
1541
+			echo "Done\n";
1542
+		}
1387 1543
 		return '';
1388 1544
 	}
1389 1545
 
@@ -1437,67 +1593,111 @@  discard block
 block discarded – undo
1437 1593
 		//if ($globalDebug) echo "IVAO : Download...";
1438 1594
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1439 1595
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1440
-			if ($globalDebug) echo "Unzip...";
1596
+			if ($globalDebug) {
1597
+				echo "Unzip...";
1598
+			}
1441 1599
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1442
-			if ($globalDebug) echo "Add to DB...";
1600
+			if ($globalDebug) {
1601
+				echo "Add to DB...";
1602
+			}
1443 1603
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1444
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1604
+			if ($globalDebug) {
1605
+				echo "Copy airlines logos to airlines images directory...";
1606
+			}
1445 1607
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1446
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1447
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1448
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1608
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1609
+					$error = "Failed to copy airlines logo.";
1610
+				}
1611
+			} else {
1612
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1613
+			}
1614
+		} else {
1615
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1616
+		}
1449 1617
 		if ($error != '') {
1450 1618
 			return $error;
1451
-		} elseif ($globalDebug) echo "Done\n";
1619
+		} elseif ($globalDebug) {
1620
+			echo "Done\n";
1621
+		}
1452 1622
 		return '';
1453 1623
 	}
1454 1624
 
1455 1625
 	public static function update_routes() {
1456 1626
 		global $tmp_dir, $globalDebug;
1457 1627
 		$error = '';
1458
-		if ($globalDebug) echo "Routes : Download...";
1628
+		if ($globalDebug) {
1629
+			echo "Routes : Download...";
1630
+		}
1459 1631
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1460 1632
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1461
-			if ($globalDebug) echo "Gunzip...";
1633
+			if ($globalDebug) {
1634
+				echo "Gunzip...";
1635
+			}
1462 1636
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1463
-			if ($globalDebug) echo "Add to DB...";
1637
+			if ($globalDebug) {
1638
+				echo "Add to DB...";
1639
+			}
1464 1640
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1465
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1641
+		} else {
1642
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1643
+		}
1466 1644
 		if ($error != '') {
1467 1645
 			return $error;
1468
-		} elseif ($globalDebug) echo "Done\n";
1646
+		} elseif ($globalDebug) {
1647
+			echo "Done\n";
1648
+		}
1469 1649
 		return '';
1470 1650
 	}
1471 1651
 	public static function update_oneworld() {
1472 1652
 		global $tmp_dir, $globalDebug;
1473 1653
 		$error = '';
1474
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1654
+		if ($globalDebug) {
1655
+			echo "Schedules Oneworld : Download...";
1656
+		}
1475 1657
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1476 1658
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1477
-			if ($globalDebug) echo "Gunzip...";
1659
+			if ($globalDebug) {
1660
+				echo "Gunzip...";
1661
+			}
1478 1662
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1479
-			if ($globalDebug) echo "Add to DB...";
1663
+			if ($globalDebug) {
1664
+				echo "Add to DB...";
1665
+			}
1480 1666
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1481
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1667
+		} else {
1668
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1669
+		}
1482 1670
 		if ($error != '') {
1483 1671
 			return $error;
1484
-		} elseif ($globalDebug) echo "Done\n";
1672
+		} elseif ($globalDebug) {
1673
+			echo "Done\n";
1674
+		}
1485 1675
 		return '';
1486 1676
 	}
1487 1677
 	public static function update_skyteam() {
1488 1678
 		global $tmp_dir, $globalDebug;
1489 1679
 		$error = '';
1490
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1680
+		if ($globalDebug) {
1681
+			echo "Schedules Skyteam : Download...";
1682
+		}
1491 1683
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1492 1684
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1493
-			if ($globalDebug) echo "Gunzip...";
1685
+			if ($globalDebug) {
1686
+				echo "Gunzip...";
1687
+			}
1494 1688
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1495
-			if ($globalDebug) echo "Add to DB...";
1689
+			if ($globalDebug) {
1690
+				echo "Add to DB...";
1691
+			}
1496 1692
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1497
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1693
+		} else {
1694
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1695
+		}
1498 1696
 		if ($error != '') {
1499 1697
 			return $error;
1500
-		} elseif ($globalDebug) echo "Done\n";
1698
+		} elseif ($globalDebug) {
1699
+			echo "Done\n";
1700
+		}
1501 1701
 		return '';
1502 1702
 	}
1503 1703
 	public static function update_ModeS() {
@@ -1514,326 +1714,564 @@  discard block
 block discarded – undo
1514 1714
 			exit;
1515 1715
 		} elseif ($globalDebug) echo "Done\n";
1516 1716
 */
1517
-		if ($globalDebug) echo "Modes : Download...";
1518
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1717
+		if ($globalDebug) {
1718
+			echo "Modes : Download...";
1719
+		}
1720
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1519 1721
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1520 1722
 
1521 1723
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1522 1724
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1523
-			if ($globalDebug) echo "Unzip...";
1524
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1725
+			if ($globalDebug) {
1726
+				echo "Unzip...";
1727
+			}
1728
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1525 1729
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1526
-			if ($globalDebug) echo "Add to DB...";
1730
+			if ($globalDebug) {
1731
+				echo "Add to DB...";
1732
+			}
1527 1733
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1528 1734
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1529
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1735
+		} else {
1736
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1737
+		}
1530 1738
 		if ($error != '') {
1531 1739
 			return $error;
1532
-		} elseif ($globalDebug) echo "Done\n";
1740
+		} elseif ($globalDebug) {
1741
+			echo "Done\n";
1742
+		}
1533 1743
 		return '';
1534 1744
 	}
1535 1745
 
1536 1746
 	public static function update_ModeS_faa() {
1537 1747
 		global $tmp_dir, $globalDebug;
1538
-		if ($globalDebug) echo "Modes FAA: Download...";
1748
+		if ($globalDebug) {
1749
+			echo "Modes FAA: Download...";
1750
+		}
1539 1751
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1540 1752
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1541
-			if ($globalDebug) echo "Unzip...";
1753
+			if ($globalDebug) {
1754
+				echo "Unzip...";
1755
+			}
1542 1756
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1543
-			if ($globalDebug) echo "Add to DB...";
1757
+			if ($globalDebug) {
1758
+				echo "Add to DB...";
1759
+			}
1544 1760
 			$error = update_db::modes_faa($tmp_dir.'ReleasableAircraft.zip');
1545
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1761
+		} else {
1762
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1763
+		}
1546 1764
 		if ($error != '') {
1547 1765
 			return $error;
1548
-		} elseif ($globalDebug) echo "Done\n";
1766
+		} elseif ($globalDebug) {
1767
+			echo "Done\n";
1768
+		}
1549 1769
 		return '';
1550 1770
 	}
1551 1771
 
1552 1772
 	public static function update_ModeS_flarm() {
1553 1773
 		global $tmp_dir, $globalDebug;
1554
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1774
+		if ($globalDebug) {
1775
+			echo "Modes Flarmnet: Download...";
1776
+		}
1555 1777
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1556 1778
 		if (file_exists($tmp_dir.'data.fln')) {
1557
-			if ($globalDebug) echo "Add to DB...";
1779
+			if ($globalDebug) {
1780
+				echo "Add to DB...";
1781
+			}
1558 1782
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1559
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1783
+		} else {
1784
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1785
+		}
1560 1786
 		if ($error != '') {
1561 1787
 			return $error;
1562
-		} elseif ($globalDebug) echo "Done\n";
1788
+		} elseif ($globalDebug) {
1789
+			echo "Done\n";
1790
+		}
1563 1791
 		return '';
1564 1792
 	}
1565 1793
 
1566 1794
 	public static function update_ModeS_ogn() {
1567 1795
 		global $tmp_dir, $globalDebug;
1568
-		if ($globalDebug) echo "Modes OGN: Download...";
1796
+		if ($globalDebug) {
1797
+			echo "Modes OGN: Download...";
1798
+		}
1569 1799
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1570 1800
 		if (file_exists($tmp_dir.'ogn.csv')) {
1571
-			if ($globalDebug) echo "Add to DB...";
1801
+			if ($globalDebug) {
1802
+				echo "Add to DB...";
1803
+			}
1572 1804
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1573
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1805
+		} else {
1806
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1807
+		}
1574 1808
 		if ($error != '') {
1575 1809
 			return $error;
1576
-		} elseif ($globalDebug) echo "Done\n";
1810
+		} elseif ($globalDebug) {
1811
+			echo "Done\n";
1812
+		}
1577 1813
 		return '';
1578 1814
 	}
1579 1815
 
1580 1816
 	public static function update_owner() {
1581 1817
 		global $tmp_dir, $globalDebug;
1582 1818
 		
1583
-		if ($globalDebug) echo "Owner France: Download...";
1819
+		if ($globalDebug) {
1820
+			echo "Owner France: Download...";
1821
+		}
1584 1822
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1585 1823
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1586
-			if ($globalDebug) echo "Add to DB...";
1824
+			if ($globalDebug) {
1825
+				echo "Add to DB...";
1826
+			}
1587 1827
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1588
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1828
+		} else {
1829
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1830
+		}
1589 1831
 		if ($error != '') {
1590 1832
 			return $error;
1591
-		} elseif ($globalDebug) echo "Done\n";
1833
+		} elseif ($globalDebug) {
1834
+			echo "Done\n";
1835
+		}
1592 1836
 		
1593
-		if ($globalDebug) echo "Owner Ireland: Download...";
1837
+		if ($globalDebug) {
1838
+			echo "Owner Ireland: Download...";
1839
+		}
1594 1840
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1595 1841
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1596
-			if ($globalDebug) echo "Add to DB...";
1842
+			if ($globalDebug) {
1843
+				echo "Add to DB...";
1844
+			}
1597 1845
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1598
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1846
+		} else {
1847
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1848
+		}
1599 1849
 		if ($error != '') {
1600 1850
 			return $error;
1601
-		} elseif ($globalDebug) echo "Done\n";
1602
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1851
+		} elseif ($globalDebug) {
1852
+			echo "Done\n";
1853
+		}
1854
+		if ($globalDebug) {
1855
+			echo "Owner Switzerland: Download...";
1856
+		}
1603 1857
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1604 1858
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1605
-			if ($globalDebug) echo "Add to DB...";
1859
+			if ($globalDebug) {
1860
+				echo "Add to DB...";
1861
+			}
1606 1862
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1607
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1863
+		} else {
1864
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1865
+		}
1608 1866
 		if ($error != '') {
1609 1867
 			return $error;
1610
-		} elseif ($globalDebug) echo "Done\n";
1611
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1868
+		} elseif ($globalDebug) {
1869
+			echo "Done\n";
1870
+		}
1871
+		if ($globalDebug) {
1872
+			echo "Owner Czech Republic: Download...";
1873
+		}
1612 1874
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1613 1875
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1614
-			if ($globalDebug) echo "Add to DB...";
1876
+			if ($globalDebug) {
1877
+				echo "Add to DB...";
1878
+			}
1615 1879
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1616
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1880
+		} else {
1881
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1882
+		}
1617 1883
 		if ($error != '') {
1618 1884
 			return $error;
1619
-		} elseif ($globalDebug) echo "Done\n";
1620
-		if ($globalDebug) echo "Owner Australia: Download...";
1885
+		} elseif ($globalDebug) {
1886
+			echo "Done\n";
1887
+		}
1888
+		if ($globalDebug) {
1889
+			echo "Owner Australia: Download...";
1890
+		}
1621 1891
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1622 1892
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1623
-			if ($globalDebug) echo "Add to DB...";
1893
+			if ($globalDebug) {
1894
+				echo "Add to DB...";
1895
+			}
1624 1896
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1625
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1897
+		} else {
1898
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1899
+		}
1626 1900
 		if ($error != '') {
1627 1901
 			return $error;
1628
-		} elseif ($globalDebug) echo "Done\n";
1629
-		if ($globalDebug) echo "Owner Austria: Download...";
1902
+		} elseif ($globalDebug) {
1903
+			echo "Done\n";
1904
+		}
1905
+		if ($globalDebug) {
1906
+			echo "Owner Austria: Download...";
1907
+		}
1630 1908
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1631 1909
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1632
-			if ($globalDebug) echo "Add to DB...";
1910
+			if ($globalDebug) {
1911
+				echo "Add to DB...";
1912
+			}
1633 1913
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1634
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1914
+		} else {
1915
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1916
+		}
1635 1917
 		if ($error != '') {
1636 1918
 			return $error;
1637
-		} elseif ($globalDebug) echo "Done\n";
1638
-		if ($globalDebug) echo "Owner Chile: Download...";
1919
+		} elseif ($globalDebug) {
1920
+			echo "Done\n";
1921
+		}
1922
+		if ($globalDebug) {
1923
+			echo "Owner Chile: Download...";
1924
+		}
1639 1925
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1640 1926
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1641
-			if ($globalDebug) echo "Add to DB...";
1927
+			if ($globalDebug) {
1928
+				echo "Add to DB...";
1929
+			}
1642 1930
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1643
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1931
+		} else {
1932
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1933
+		}
1644 1934
 		if ($error != '') {
1645 1935
 			return $error;
1646
-		} elseif ($globalDebug) echo "Done\n";
1647
-		if ($globalDebug) echo "Owner Colombia: Download...";
1936
+		} elseif ($globalDebug) {
1937
+			echo "Done\n";
1938
+		}
1939
+		if ($globalDebug) {
1940
+			echo "Owner Colombia: Download...";
1941
+		}
1648 1942
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1649 1943
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1650
-			if ($globalDebug) echo "Add to DB...";
1944
+			if ($globalDebug) {
1945
+				echo "Add to DB...";
1946
+			}
1651 1947
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1652
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1948
+		} else {
1949
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1950
+		}
1653 1951
 		if ($error != '') {
1654 1952
 			return $error;
1655
-		} elseif ($globalDebug) echo "Done\n";
1656
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1953
+		} elseif ($globalDebug) {
1954
+			echo "Done\n";
1955
+		}
1956
+		if ($globalDebug) {
1957
+			echo "Owner Bosnia Herzegobina: Download...";
1958
+		}
1657 1959
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1658 1960
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1659
-			if ($globalDebug) echo "Add to DB...";
1961
+			if ($globalDebug) {
1962
+				echo "Add to DB...";
1963
+			}
1660 1964
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1661
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1965
+		} else {
1966
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1967
+		}
1662 1968
 		if ($error != '') {
1663 1969
 			return $error;
1664
-		} elseif ($globalDebug) echo "Done\n";
1665
-		if ($globalDebug) echo "Owner Brazil: Download...";
1970
+		} elseif ($globalDebug) {
1971
+			echo "Done\n";
1972
+		}
1973
+		if ($globalDebug) {
1974
+			echo "Owner Brazil: Download...";
1975
+		}
1666 1976
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1667 1977
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1668
-			if ($globalDebug) echo "Add to DB...";
1978
+			if ($globalDebug) {
1979
+				echo "Add to DB...";
1980
+			}
1669 1981
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1670
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1982
+		} else {
1983
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1984
+		}
1671 1985
 		if ($error != '') {
1672 1986
 			return $error;
1673
-		} elseif ($globalDebug) echo "Done\n";
1674
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1987
+		} elseif ($globalDebug) {
1988
+			echo "Done\n";
1989
+		}
1990
+		if ($globalDebug) {
1991
+			echo "Owner Cayman Islands: Download...";
1992
+		}
1675 1993
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1676 1994
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1677
-			if ($globalDebug) echo "Add to DB...";
1995
+			if ($globalDebug) {
1996
+				echo "Add to DB...";
1997
+			}
1678 1998
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1679
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1999
+		} else {
2000
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2001
+		}
1680 2002
 		if ($error != '') {
1681 2003
 			return $error;
1682
-		} elseif ($globalDebug) echo "Done\n";
1683
-		if ($globalDebug) echo "Owner Croatia: Download...";
2004
+		} elseif ($globalDebug) {
2005
+			echo "Done\n";
2006
+		}
2007
+		if ($globalDebug) {
2008
+			echo "Owner Croatia: Download...";
2009
+		}
1684 2010
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1685 2011
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1686
-			if ($globalDebug) echo "Add to DB...";
2012
+			if ($globalDebug) {
2013
+				echo "Add to DB...";
2014
+			}
1687 2015
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1688
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2016
+		} else {
2017
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2018
+		}
1689 2019
 		if ($error != '') {
1690 2020
 			return $error;
1691
-		} elseif ($globalDebug) echo "Done\n";
1692
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2021
+		} elseif ($globalDebug) {
2022
+			echo "Done\n";
2023
+		}
2024
+		if ($globalDebug) {
2025
+			echo "Owner Luxembourg: Download...";
2026
+		}
1693 2027
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1694 2028
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1695
-			if ($globalDebug) echo "Add to DB...";
2029
+			if ($globalDebug) {
2030
+				echo "Add to DB...";
2031
+			}
1696 2032
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1697
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2033
+		} else {
2034
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2035
+		}
1698 2036
 		if ($error != '') {
1699 2037
 			return $error;
1700
-		} elseif ($globalDebug) echo "Done\n";
1701
-		if ($globalDebug) echo "Owner Maldives: Download...";
2038
+		} elseif ($globalDebug) {
2039
+			echo "Done\n";
2040
+		}
2041
+		if ($globalDebug) {
2042
+			echo "Owner Maldives: Download...";
2043
+		}
1702 2044
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1703 2045
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1704
-			if ($globalDebug) echo "Add to DB...";
2046
+			if ($globalDebug) {
2047
+				echo "Add to DB...";
2048
+			}
1705 2049
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1706
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2050
+		} else {
2051
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2052
+		}
1707 2053
 		if ($error != '') {
1708 2054
 			return $error;
1709
-		} elseif ($globalDebug) echo "Done\n";
1710
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2055
+		} elseif ($globalDebug) {
2056
+			echo "Done\n";
2057
+		}
2058
+		if ($globalDebug) {
2059
+			echo "Owner New Zealand: Download...";
2060
+		}
1711 2061
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1712 2062
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1713
-			if ($globalDebug) echo "Add to DB...";
2063
+			if ($globalDebug) {
2064
+				echo "Add to DB...";
2065
+			}
1714 2066
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1715
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2067
+		} else {
2068
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2069
+		}
1716 2070
 		if ($error != '') {
1717 2071
 			return $error;
1718
-		} elseif ($globalDebug) echo "Done\n";
1719
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2072
+		} elseif ($globalDebug) {
2073
+			echo "Done\n";
2074
+		}
2075
+		if ($globalDebug) {
2076
+			echo "Owner Papua New Guinea: Download...";
2077
+		}
1720 2078
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1721 2079
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1722
-			if ($globalDebug) echo "Add to DB...";
2080
+			if ($globalDebug) {
2081
+				echo "Add to DB...";
2082
+			}
1723 2083
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1724
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2084
+		} else {
2085
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2086
+		}
1725 2087
 		if ($error != '') {
1726 2088
 			return $error;
1727
-		} elseif ($globalDebug) echo "Done\n";
1728
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2089
+		} elseif ($globalDebug) {
2090
+			echo "Done\n";
2091
+		}
2092
+		if ($globalDebug) {
2093
+			echo "Owner Slovakia: Download...";
2094
+		}
1729 2095
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1730 2096
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1731
-			if ($globalDebug) echo "Add to DB...";
2097
+			if ($globalDebug) {
2098
+				echo "Add to DB...";
2099
+			}
1732 2100
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1733
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2101
+		} else {
2102
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2103
+		}
1734 2104
 		if ($error != '') {
1735 2105
 			return $error;
1736
-		} elseif ($globalDebug) echo "Done\n";
1737
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2106
+		} elseif ($globalDebug) {
2107
+			echo "Done\n";
2108
+		}
2109
+		if ($globalDebug) {
2110
+			echo "Owner Ecuador: Download...";
2111
+		}
1738 2112
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1739 2113
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1740
-			if ($globalDebug) echo "Add to DB...";
2114
+			if ($globalDebug) {
2115
+				echo "Add to DB...";
2116
+			}
1741 2117
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1742
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2118
+		} else {
2119
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2120
+		}
1743 2121
 		if ($error != '') {
1744 2122
 			return $error;
1745
-		} elseif ($globalDebug) echo "Done\n";
1746
-		if ($globalDebug) echo "Owner Iceland: Download...";
2123
+		} elseif ($globalDebug) {
2124
+			echo "Done\n";
2125
+		}
2126
+		if ($globalDebug) {
2127
+			echo "Owner Iceland: Download...";
2128
+		}
1747 2129
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1748 2130
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1749
-			if ($globalDebug) echo "Add to DB...";
2131
+			if ($globalDebug) {
2132
+				echo "Add to DB...";
2133
+			}
1750 2134
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1751
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2135
+		} else {
2136
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2137
+		}
1752 2138
 		if ($error != '') {
1753 2139
 			return $error;
1754
-		} elseif ($globalDebug) echo "Done\n";
2140
+		} elseif ($globalDebug) {
2141
+			echo "Done\n";
2142
+		}
1755 2143
 		return '';
1756 2144
 	}
1757 2145
 
1758 2146
 	public static function update_translation() {
1759 2147
 		global $tmp_dir, $globalDebug;
1760 2148
 		$error = '';
1761
-		if ($globalDebug) echo "Translation : Download...";
2149
+		if ($globalDebug) {
2150
+			echo "Translation : Download...";
2151
+		}
1762 2152
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1763 2153
 		if (file_exists($tmp_dir.'translation.zip')) {
1764
-			if ($globalDebug) echo "Unzip...";
2154
+			if ($globalDebug) {
2155
+				echo "Unzip...";
2156
+			}
1765 2157
 			update_db::unzip($tmp_dir.'translation.zip');
1766
-			if ($globalDebug) echo "Add to DB...";
2158
+			if ($globalDebug) {
2159
+				echo "Add to DB...";
2160
+			}
1767 2161
 			$error = update_db::translation();
1768
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2162
+		} else {
2163
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2164
+		}
1769 2165
 		if ($error != '') {
1770 2166
 			return $error;
1771
-		} elseif ($globalDebug) echo "Done\n";
2167
+		} elseif ($globalDebug) {
2168
+			echo "Done\n";
2169
+		}
1772 2170
 		return '';
1773 2171
 	}
1774 2172
 
1775 2173
 	public static function update_translation_fam() {
1776 2174
 		global $tmp_dir, $globalDebug;
1777
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2175
+		if ($globalDebug) {
2176
+			echo "Translation from FlightAirMap website : Download...";
2177
+		}
1778 2178
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1779 2179
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1780
-			if ($globalDebug) echo "Gunzip...";
2180
+			if ($globalDebug) {
2181
+				echo "Gunzip...";
2182
+			}
1781 2183
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1782
-			if ($globalDebug) echo "Add to DB...";
2184
+			if ($globalDebug) {
2185
+				echo "Add to DB...";
2186
+			}
1783 2187
 			$error = update_db::translation_fam();
1784
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2188
+		} else {
2189
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2190
+		}
1785 2191
 		if ($error != '') {
1786 2192
 			return $error;
1787
-		} elseif ($globalDebug) echo "Done\n";
2193
+		} elseif ($globalDebug) {
2194
+			echo "Done\n";
2195
+		}
1788 2196
 		return '';
1789 2197
 	}
1790 2198
 	public static function update_ModeS_fam() {
1791 2199
 		global $tmp_dir, $globalDebug;
1792
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2200
+		if ($globalDebug) {
2201
+			echo "ModeS from FlightAirMap website : Download...";
2202
+		}
1793 2203
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1794 2204
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1795
-			if ($globalDebug) echo "Gunzip...";
2205
+			if ($globalDebug) {
2206
+				echo "Gunzip...";
2207
+			}
1796 2208
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1797
-			if ($globalDebug) echo "Add to DB...";
2209
+			if ($globalDebug) {
2210
+				echo "Add to DB...";
2211
+			}
1798 2212
 			$error = update_db::modes_fam();
1799
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2213
+		} else {
2214
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2215
+		}
1800 2216
 		if ($error != '') {
1801 2217
 			return $error;
1802
-		} elseif ($globalDebug) echo "Done\n";
2218
+		} elseif ($globalDebug) {
2219
+			echo "Done\n";
2220
+		}
1803 2221
 		return '';
1804 2222
 	}
1805 2223
 	public static function update_owner_fam() {
1806 2224
 		global $tmp_dir, $globalDebug, $globalOwner;
1807
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2225
+		if ($globalDebug) {
2226
+			echo "owner from FlightAirMap website : Download...";
2227
+		}
1808 2228
 		if ($globalOwner === TRUE) {
1809 2229
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1810 2230
 		} else {
1811 2231
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1812 2232
 		}
1813 2233
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1814
-			if ($globalDebug) echo "Gunzip...";
2234
+			if ($globalDebug) {
2235
+				echo "Gunzip...";
2236
+			}
1815 2237
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
1816
-			if ($globalDebug) echo "Add to DB...";
2238
+			if ($globalDebug) {
2239
+				echo "Add to DB...";
2240
+			}
1817 2241
 			$error = update_db::owner_fam();
1818
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2242
+		} else {
2243
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2244
+		}
1819 2245
 		if ($error != '') {
1820 2246
 			return $error;
1821
-		} elseif ($globalDebug) echo "Done\n";
2247
+		} elseif ($globalDebug) {
2248
+			echo "Done\n";
2249
+		}
1822 2250
 		return '';
1823 2251
 	}
1824 2252
 	public static function update_routes_fam() {
1825 2253
 		global $tmp_dir, $globalDebug;
1826
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2254
+		if ($globalDebug) {
2255
+			echo "Routes from FlightAirMap website : Download...";
2256
+		}
1827 2257
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1828 2258
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1829
-			if ($globalDebug) echo "Gunzip...";
2259
+			if ($globalDebug) {
2260
+				echo "Gunzip...";
2261
+			}
1830 2262
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1831
-			if ($globalDebug) echo "Add to DB...";
2263
+			if ($globalDebug) {
2264
+				echo "Add to DB...";
2265
+			}
1832 2266
 			$error = update_db::routes_fam();
1833
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2267
+		} else {
2268
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2269
+		}
1834 2270
 		if ($error != '') {
1835 2271
 			return $error;
1836
-		} elseif ($globalDebug) echo "Done\n";
2272
+		} elseif ($globalDebug) {
2273
+			echo "Done\n";
2274
+		}
1837 2275
 		return '';
1838 2276
 	}
1839 2277
 
@@ -1841,7 +2279,9 @@  discard block
 block discarded – undo
1841 2279
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1842 2280
 		include_once('class.create_db.php');
1843 2281
 		$error = '';
1844
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2282
+		if ($globalDebug) {
2283
+			echo "Airspace from FlightAirMap website : Download...";
2284
+		}
1845 2285
 		if ($globalDBdriver == 'mysql') {
1846 2286
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1847 2287
 		} else {
@@ -1857,9 +2297,13 @@  discard block
 block discarded – undo
1857 2297
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1858 2298
 				}
1859 2299
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1860
-					if ($globalDebug) echo "Gunzip...";
2300
+					if ($globalDebug) {
2301
+						echo "Gunzip...";
2302
+					}
1861 2303
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1862
-					if ($globalDebug) echo "Add to DB...";
2304
+					if ($globalDebug) {
2305
+						echo "Add to DB...";
2306
+					}
1863 2307
 					$Connection = new Connection();
1864 2308
 					if ($Connection->tableExists('airspace')) {
1865 2309
 						$query = 'DROP TABLE airspace';
@@ -1872,31 +2316,47 @@  discard block
 block discarded – undo
1872 2316
 		    			}
1873 2317
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1874 2318
 					update_db::insert_airspace_version($airspace_md5);
1875
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2319
+				} else {
2320
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2321
+				}
1876 2322
 			}
1877
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2323
+		} else {
2324
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2325
+		}
1878 2326
 		if ($error != '') {
1879 2327
 			return $error;
1880
-		} elseif ($globalDebug) echo "Done\n";
2328
+		} elseif ($globalDebug) {
2329
+			echo "Done\n";
2330
+		}
1881 2331
 		return '';
1882 2332
 	}
1883 2333
 
1884 2334
 	public static function update_tle() {
1885 2335
 		global $tmp_dir, $globalDebug;
1886
-		if ($globalDebug) echo "Download TLE : Download...";
2336
+		if ($globalDebug) {
2337
+			echo "Download TLE : Download...";
2338
+		}
1887 2339
 		$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',
1888 2340
 		'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',
1889 2341
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1890 2342
 		foreach ($alltle as $filename) {
1891
-			if ($globalDebug) echo "downloading ".$filename.'...';
2343
+			if ($globalDebug) {
2344
+				echo "downloading ".$filename.'...';
2345
+			}
1892 2346
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1893 2347
 			if (file_exists($tmp_dir.$filename)) {
1894
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2348
+				if ($globalDebug) {
2349
+					echo "Add to DB ".$filename."...";
2350
+				}
1895 2351
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1896
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2352
+			} else {
2353
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2354
+			}
1897 2355
 			if ($error != '') {
1898 2356
 				echo $error."\n";
1899
-			} elseif ($globalDebug) echo "Done\n";
2357
+			} elseif ($globalDebug) {
2358
+				echo "Done\n";
2359
+			}
1900 2360
 		}
1901 2361
 		return '';
1902 2362
 	}
@@ -1904,10 +2364,14 @@  discard block
 block discarded – undo
1904 2364
 	public static function update_models() {
1905 2365
 		global $tmp_dir, $globalDebug;
1906 2366
 		$error = '';
1907
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2367
+		if ($globalDebug) {
2368
+			echo "Models from FlightAirMap website : Download...";
2369
+		}
1908 2370
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1909 2371
 		if (file_exists($tmp_dir.'models.md5sum')) {
1910
-			if ($globalDebug) echo "Check files...\n";
2372
+			if ($globalDebug) {
2373
+				echo "Check files...\n";
2374
+			}
1911 2375
 			$newmodelsdb = array();
1912 2376
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1913 2377
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1926,25 +2390,35 @@  discard block
 block discarded – undo
1926 2390
 			}
1927 2391
 			$diff = array_diff($newmodelsdb,$modelsdb);
1928 2392
 			foreach ($diff as $key => $value) {
1929
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2393
+				if ($globalDebug) {
2394
+					echo 'Downloading model '.$key.' ...'."\n";
2395
+				}
1930 2396
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1931 2397
 				
1932 2398
 			}
1933 2399
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1934
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2400
+		} else {
2401
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2402
+		}
1935 2403
 		if ($error != '') {
1936 2404
 			return $error;
1937
-		} elseif ($globalDebug) echo "Done\n";
2405
+		} elseif ($globalDebug) {
2406
+			echo "Done\n";
2407
+		}
1938 2408
 		return '';
1939 2409
 	}
1940 2410
 
1941 2411
 	public static function update_space_models() {
1942 2412
 		global $tmp_dir, $globalDebug;
1943 2413
 		$error = '';
1944
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2414
+		if ($globalDebug) {
2415
+			echo "Space models from FlightAirMap website : Download...";
2416
+		}
1945 2417
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1946 2418
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1947
-			if ($globalDebug) echo "Check files...\n";
2419
+			if ($globalDebug) {
2420
+				echo "Check files...\n";
2421
+			}
1948 2422
 			$newmodelsdb = array();
1949 2423
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1950 2424
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1963,15 +2437,21 @@  discard block
 block discarded – undo
1963 2437
 			}
1964 2438
 			$diff = array_diff($newmodelsdb,$modelsdb);
1965 2439
 			foreach ($diff as $key => $value) {
1966
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2440
+				if ($globalDebug) {
2441
+					echo 'Downloading space model '.$key.' ...'."\n";
2442
+				}
1967 2443
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1968 2444
 				
1969 2445
 			}
1970 2446
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1971
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2447
+		} else {
2448
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2449
+		}
1972 2450
 		if ($error != '') {
1973 2451
 			return $error;
1974
-		} elseif ($globalDebug) echo "Done\n";
2452
+		} elseif ($globalDebug) {
2453
+			echo "Done\n";
2454
+		}
1975 2455
 		return '';
1976 2456
 	}
1977 2457
 
@@ -2014,7 +2494,9 @@  discard block
 block discarded – undo
2014 2494
                 }
2015 2495
 
2016 2496
 		$error = '';
2017
-		if ($globalDebug) echo "Notam : Download...";
2497
+		if ($globalDebug) {
2498
+			echo "Notam : Download...";
2499
+		}
2018 2500
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2019 2501
 		if (file_exists($tmp_dir.'notam.rss')) {
2020 2502
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2029,14 +2511,30 @@  discard block
 block discarded – undo
2029 2511
 				$data['fir'] = $q[0];
2030 2512
 				$data['code'] = $q[1];
2031 2513
 				$ifrvfr = $q[2];
2032
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2033
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2034
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2035
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2036
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2037
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2038
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2039
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2514
+				if ($ifrvfr == 'IV') {
2515
+					$data['rules'] = 'IFR/VFR';
2516
+				}
2517
+				if ($ifrvfr == 'I') {
2518
+					$data['rules'] = 'IFR';
2519
+				}
2520
+				if ($ifrvfr == 'V') {
2521
+					$data['rules'] = 'VFR';
2522
+				}
2523
+				if ($q[4] == 'A') {
2524
+					$data['scope'] = 'Airport warning';
2525
+				}
2526
+				if ($q[4] == 'E') {
2527
+					$data['scope'] = 'Enroute warning';
2528
+				}
2529
+				if ($q[4] == 'W') {
2530
+					$data['scope'] = 'Navigation warning';
2531
+				}
2532
+				if ($q[4] == 'AE') {
2533
+					$data['scope'] = 'Airport/Enroute warning';
2534
+				}
2535
+				if ($q[4] == 'AW') {
2536
+					$data['scope'] = 'Airport/Navigation warning';
2537
+				}
2040 2538
 				//$data['scope'] = $q[4];
2041 2539
 				$data['lower_limit'] = $q[5];
2042 2540
 				$data['upper_limit'] = $q[6];
@@ -2044,8 +2542,12 @@  discard block
 block discarded – undo
2044 2542
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2045 2543
 				$latitude = $Common->convertDec($las,'latitude');
2046 2544
 				$longitude = $Common->convertDec($lns,'longitude');
2047
-				if ($lac == 'S') $latitude = '-'.$latitude;
2048
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2545
+				if ($lac == 'S') {
2546
+					$latitude = '-'.$latitude;
2547
+				}
2548
+				if ($lnc == 'W') {
2549
+					$longitude = '-'.$longitude;
2550
+				}
2049 2551
 				$data['center_latitude'] = $latitude;
2050 2552
 				$data['center_longitude'] = $longitude;
2051 2553
 				$data['radius'] = intval($radius);
@@ -2075,10 +2577,14 @@  discard block
 block discarded – undo
2075 2577
 				$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']);
2076 2578
 				unset($data);
2077 2579
 			} 
2078
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2580
+		} else {
2581
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2582
+		}
2079 2583
 		if ($error != '') {
2080 2584
 			return $error;
2081
-		} elseif ($globalDebug) echo "Done\n";
2585
+		} elseif ($globalDebug) {
2586
+			echo "Done\n";
2587
+		}
2082 2588
 		return '';
2083 2589
 	}
2084 2590
 	
@@ -2103,7 +2609,9 @@  discard block
 block discarded – undo
2103 2609
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2104 2610
 		$airspace_json = json_decode($airspace_lst,true);
2105 2611
 		foreach ($airspace_json['records'] as $airspace) {
2106
-			if ($globalDebug) echo $airspace['name']."...\n";
2612
+			if ($globalDebug) {
2613
+				echo $airspace['name']."...\n";
2614
+			}
2107 2615
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2108 2616
 			if (file_exists($tmp_dir.$airspace['name'])) {
2109 2617
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2132,8 +2640,11 @@  discard block
 block discarded – undo
2132 2640
                         return "error : ".$e->getMessage();
2133 2641
                 }
2134 2642
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2135
-                if ($row['nb'] > 0) return false;
2136
-                else return true;
2643
+                if ($row['nb'] > 0) {
2644
+                	return false;
2645
+                } else {
2646
+                	return true;
2647
+                }
2137 2648
 	}
2138 2649
 
2139 2650
 	public static function insert_last_update() {
@@ -2158,8 +2669,11 @@  discard block
 block discarded – undo
2158 2669
                         return "error : ".$e->getMessage();
2159 2670
                 }
2160 2671
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2161
-                if ($row['nb'] > 0) return true;
2162
-                else return false;
2672
+                if ($row['nb'] > 0) {
2673
+                	return true;
2674
+                } else {
2675
+                	return false;
2676
+                }
2163 2677
 	}
2164 2678
 
2165 2679
 
@@ -2190,8 +2704,11 @@  discard block
 block discarded – undo
2190 2704
                         return "error : ".$e->getMessage();
2191 2705
                 }
2192 2706
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2193
-                if ($row['nb'] > 0) return false;
2194
-                else return true;
2707
+                if ($row['nb'] > 0) {
2708
+                	return false;
2709
+                } else {
2710
+                	return true;
2711
+                }
2195 2712
 	}
2196 2713
 
2197 2714
 	public static function insert_last_notam_update() {
@@ -2220,8 +2737,11 @@  discard block
 block discarded – undo
2220 2737
                         return "error : ".$e->getMessage();
2221 2738
                 }
2222 2739
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2223
-                if ($row['nb'] > 0) return false;
2224
-                else return true;
2740
+                if ($row['nb'] > 0) {
2741
+                	return false;
2742
+                } else {
2743
+                	return true;
2744
+                }
2225 2745
 	}
2226 2746
 
2227 2747
 	public static function insert_last_airspace_update() {
@@ -2251,8 +2771,11 @@  discard block
 block discarded – undo
2251 2771
                         return "error : ".$e->getMessage();
2252 2772
                 }
2253 2773
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2254
-                if ($row['nb'] > 0) return false;
2255
-                else return true;
2774
+                if ($row['nb'] > 0) {
2775
+                	return false;
2776
+                } else {
2777
+                	return true;
2778
+                }
2256 2779
 	}
2257 2780
 
2258 2781
 	public static function insert_last_owner_update() {
@@ -2281,8 +2804,11 @@  discard block
 block discarded – undo
2281 2804
                         return "error : ".$e->getMessage();
2282 2805
                 }
2283 2806
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2284
-                if ($row['nb'] > 0) return false;
2285
-                else return true;
2807
+                if ($row['nb'] > 0) {
2808
+                	return false;
2809
+                } else {
2810
+                	return true;
2811
+                }
2286 2812
 	}
2287 2813
 
2288 2814
 	public static function insert_last_schedules_update() {
@@ -2311,8 +2837,11 @@  discard block
 block discarded – undo
2311 2837
                         return "error : ".$e->getMessage();
2312 2838
                 }
2313 2839
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2314
-                if ($row['nb'] > 0) return false;
2315
-                else return true;
2840
+                if ($row['nb'] > 0) {
2841
+                	return false;
2842
+                } else {
2843
+                	return true;
2844
+                }
2316 2845
 	}
2317 2846
 
2318 2847
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.