Completed
Push — master ( 939e76...90177e )
by Yannick
06:10
created
install/class.update_db.php 3 patches
Indentation   +382 added lines, -382 removed lines patch added patch discarded remove patch
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
 		try {
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78
-                        $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
78
+						$sth->execute(array(':source' => $database_file));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82 82
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
84
-    		update_db::connect_sqlite($database_file);
83
+			if ($globalDebug) echo " - Add routes to DB -";
84
+			update_db::connect_sqlite($database_file);
85 85
 		//$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 86
 		$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";
87 87
 		try {
88
-                        $sth = update_db::$db_sqlite->prepare($query);
89
-                        $sth->execute();
90
-                } catch(PDOException $e) {
91
-                        return "error : ".$e->getMessage();
92
-                }
88
+						$sth = update_db::$db_sqlite->prepare($query);
89
+						$sth->execute();
90
+				} catch(PDOException $e) {
91
+						return "error : ".$e->getMessage();
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)';
94 94
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$Connection = new Connection();
96 96
 		$sth_dest = $Connection->db->prepare($query_dest);
97 97
 		try {
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
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 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 105
 		} catch(PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109
-                return '';
109
+				return '';
110 110
 	}
111 111
 	public static function retrieve_route_oneworld($database_file) {
112 112
 		global $globalDebug, $globalTransaction;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120
-                        $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
122
-                        return "error : ".$e->getMessage();
123
-                }
120
+						$sth->execute(array(':source' => 'oneworld'));
121
+				} catch(PDOException $e) {
122
+						return "error : ".$e->getMessage();
123
+				}
124 124
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
125
+			if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128 128
 		if ($fh = fopen($database_file,"r")) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 			if ($globalTransaction) $Connection->db->commit();
148 148
 		}
149
-                return '';
149
+				return '';
150 150
 	}
151 151
 	
152 152
 	public static function retrieve_route_skyteam($database_file) {
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161
-                        $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
163
-                        return "error : ".$e->getMessage();
164
-                }
161
+						$sth->execute(array(':source' => 'skyteam'));
162
+				} catch(PDOException $e) {
163
+						return "error : ".$e->getMessage();
164
+				}
165 165
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
166
+			if ($globalDebug) echo " - Add routes to DB -";
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
191 191
 		}
192
-                return '';
192
+				return '';
193 193
 	}
194 194
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
195 195
 		global $globalTransaction;
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 		try {
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201
-                        $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
203
-                        return "error : ".$e->getMessage();
204
-                }
201
+						$sth->execute(array(':source' => $database_file));
202
+				} catch(PDOException $e) {
203
+						return "error : ".$e->getMessage();
204
+				}
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
206 206
 		try {
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209
-                        $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
211
-                        return "error : ".$e->getMessage();
212
-                }
209
+						$sth->execute(array(':source' => $database_file));
210
+				} catch(PDOException $e) {
211
+						return "error : ".$e->getMessage();
212
+				}
213 213
 
214
-    		update_db::connect_sqlite($database_file);
214
+			update_db::connect_sqlite($database_file);
215 215
 		$query = 'select * from Aircraft';
216 216
 		try {
217
-                        $sth = update_db::$db_sqlite->prepare($query);
218
-                        $sth->execute();
219
-                } catch(PDOException $e) {
220
-                        return "error : ".$e->getMessage();
221
-                }
217
+						$sth = update_db::$db_sqlite->prepare($query);
218
+						$sth->execute();
219
+				} catch(PDOException $e) {
220
+						return "error : ".$e->getMessage();
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)';
223 223
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
224 224
 		
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 230
 		try {
231 231
 			if ($globalTransaction) $Connection->db->beginTransaction();
232
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
232
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
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 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']);
240
-				    $sth_dest_owner->execute($query_dest_owner_values);
239
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+					$sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242
-            		}
242
+					}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244 244
 		} catch(PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 		try {
250 250
 			$Connection = new Connection();
251 251
 			$sth = $Connection->db->prepare($query);
252
-                        $sth->execute(array(':source' => $database_file));
253
-                } catch(PDOException $e) {
254
-                        return "error : ".$e->getMessage();
255
-                }
252
+						$sth->execute(array(':source' => $database_file));
253
+				} catch(PDOException $e) {
254
+						return "error : ".$e->getMessage();
255
+				}
256 256
 		return '';
257 257
 	}
258 258
 
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 		try {
265 265
 			$Connection = new Connection();
266 266
 			$sth = $Connection->db->prepare($query);
267
-                        $sth->execute(array(':source' => $database_file));
268
-                } catch(PDOException $e) {
269
-                        return "error : ".$e->getMessage();
270
-                }
267
+						$sth->execute(array(':source' => $database_file));
268
+				} catch(PDOException $e) {
269
+						return "error : ".$e->getMessage();
270
+				}
271 271
 		
272 272
 		if ($fh = fopen($database_file,"r")) {
273 273
 			//$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)';
@@ -277,26 +277,26 @@  discard block
 block discarded – undo
277 277
 			$sth_dest = $Connection->db->prepare($query_dest);
278 278
 			try {
279 279
 				if ($globalTransaction) $Connection->db->beginTransaction();
280
-            			while (!feof($fh)) {
281
-            				$values = array();
282
-            				$line = $Common->hex2str(fgets($fh,9999));
280
+						while (!feof($fh)) {
281
+							$values = array();
282
+							$line = $Common->hex2str(fgets($fh,9999));
283 283
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
284
-            				$values['ModeS'] = substr($line,0,6);
285
-            				$values['Registration'] = trim(substr($line,69,6));
286
-            				$aircraft_name = trim(substr($line,48,6));
287
-            				// Check if we can find ICAO, else set it to GLID
288
-            				$aircraft_name_split = explode(' ',$aircraft_name);
289
-            				$search_more = '';
290
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
291
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
292
-            				$sth_search = $Connection->db->prepare($query_search);
284
+							$values['ModeS'] = substr($line,0,6);
285
+							$values['Registration'] = trim(substr($line,69,6));
286
+							$aircraft_name = trim(substr($line,48,6));
287
+							// Check if we can find ICAO, else set it to GLID
288
+							$aircraft_name_split = explode(' ',$aircraft_name);
289
+							$search_more = '';
290
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
291
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
292
+							$sth_search = $Connection->db->prepare($query_search);
293 293
 					try {
294
-                                    		$sth_search->execute();
295
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
296
-	            				//if (count($result) > 0) {
297
-	            				if (isset($result['icao']) && $result['icao'] != '') {
298
-	            				    $values['ICAOTypeCode'] = $result['icao'];
299
-	            				} 
294
+											$sth_search->execute();
295
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
296
+								//if (count($result) > 0) {
297
+								if (isset($result['icao']) && $result['icao'] != '') {
298
+									$values['ICAOTypeCode'] = $result['icao'];
299
+								} 
300 300
 					} catch(PDOException $e) {
301 301
 						return "error : ".$e->getMessage();
302 302
 					}
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
 		try {
320 320
 			$Connection = new Connection();
321 321
 			$sth = $Connection->db->prepare($query);
322
-                        $sth->execute(array(':source' => $database_file));
323
-                } catch(PDOException $e) {
324
-                        return "error : ".$e->getMessage();
325
-                }
322
+						$sth->execute(array(':source' => $database_file));
323
+				} catch(PDOException $e) {
324
+						return "error : ".$e->getMessage();
325
+				}
326 326
 		return '';
327 327
 	}
328 328
 
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
 		try {
334 334
 			$Connection = new Connection();
335 335
 			$sth = $Connection->db->prepare($query);
336
-                        $sth->execute(array(':source' => $database_file));
337
-                } catch(PDOException $e) {
338
-                        return "error : ".$e->getMessage();
339
-                }
336
+						$sth->execute(array(':source' => $database_file));
337
+				} catch(PDOException $e) {
338
+						return "error : ".$e->getMessage();
339
+				}
340 340
 		
341 341
 		if ($fh = fopen($database_file,"r")) {
342 342
 			//$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)';
@@ -347,24 +347,24 @@  discard block
 block discarded – undo
347 347
 			try {
348 348
 				if ($globalTransaction) $Connection->db->beginTransaction();
349 349
 				$tmp = fgetcsv($fh,9999,',',"'");
350
-            			while (!feof($fh)) {
351
-            				$line = fgetcsv($fh,9999,',',"'");
350
+						while (!feof($fh)) {
351
+							$line = fgetcsv($fh,9999,',',"'");
352 352
             				
353 353
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
354 354
 					//print_r($line);
355
-            				$values['ModeS'] = $line[1];
356
-            				$values['Registration'] = $line[3];
357
-            				$aircraft_name = $line[2];
358
-            				// Check if we can find ICAO, else set it to GLID
359
-            				$aircraft_name_split = explode(' ',$aircraft_name);
360
-            				$search_more = '';
361
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
363
-            				$sth_search = $Connection->db->prepare($query_search);
355
+							$values['ModeS'] = $line[1];
356
+							$values['Registration'] = $line[3];
357
+							$aircraft_name = $line[2];
358
+							// Check if we can find ICAO, else set it to GLID
359
+							$aircraft_name_split = explode(' ',$aircraft_name);
360
+							$search_more = '';
361
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
363
+							$sth_search = $Connection->db->prepare($query_search);
364 364
 					try {
365
-                                    		$sth_search->execute();
366
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
365
+											$sth_search->execute();
366
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368 368
 					} catch(PDOException $e) {
369 369
 						return "error : ".$e->getMessage();
370 370
 					}
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
 		try {
388 388
 			$Connection = new Connection();
389 389
 			$sth = $Connection->db->prepare($query);
390
-                        $sth->execute(array(':source' => $database_file));
391
-                } catch(PDOException $e) {
392
-                        return "error : ".$e->getMessage();
393
-                }
390
+						$sth->execute(array(':source' => $database_file));
391
+				} catch(PDOException $e) {
392
+						return "error : ".$e->getMessage();
393
+				}
394 394
 		return '';
395 395
 	}
396 396
 
@@ -401,10 +401,10 @@  discard block
 block discarded – undo
401 401
 		try {
402 402
 			$Connection = new Connection();
403 403
 			$sth = $Connection->db->prepare($query);
404
-                        $sth->execute(array(':source' => $database_file));
405
-                } catch(PDOException $e) {
406
-                        return "error : ".$e->getMessage();
407
-                }
404
+						$sth->execute(array(':source' => $database_file));
405
+				} catch(PDOException $e) {
406
+						return "error : ".$e->getMessage();
407
+				}
408 408
 		
409 409
 		if ($fh = fopen($database_file,"r")) {
410 410
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -415,95 +415,95 @@  discard block
 block discarded – undo
415 415
 			try {
416 416
 				if ($globalTransaction) $Connection->db->beginTransaction();
417 417
 				$tmp = fgetcsv($fh,9999,',','"');
418
-            			while (!feof($fh)) {
419
-            				$line = fgetcsv($fh,9999,',','"');
420
-            				$values = array();
421
-            				//print_r($line);
422
-            				if ($country == 'F') {
423
-            				    $values['registration'] = $line[0];
424
-            				    $values['base'] = $line[4];
425
-            				    $values['owner'] = $line[5];
426
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
428
-					    $values['cancel'] = $line[7];
418
+						while (!feof($fh)) {
419
+							$line = fgetcsv($fh,9999,',','"');
420
+							$values = array();
421
+							//print_r($line);
422
+							if ($country == 'F') {
423
+								$values['registration'] = $line[0];
424
+								$values['base'] = $line[4];
425
+								$values['owner'] = $line[5];
426
+								if ($line[6] == '') $values['date_first_reg'] = null;
427
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
428
+						$values['cancel'] = $line[7];
429 429
 					} elseif ($country == 'EI') {
430
-					    // TODO : add modeS & reg to aircraft_modes
431
-            				    $values['registration'] = $line[0];
432
-            				    $values['base'] = $line[3];
433
-            				    $values['owner'] = $line[2];
434
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
436
-					    $values['cancel'] = '';
430
+						// TODO : add modeS & reg to aircraft_modes
431
+								$values['registration'] = $line[0];
432
+								$values['base'] = $line[3];
433
+								$values['owner'] = $line[2];
434
+								if ($line[1] == '') $values['date_first_reg'] = null;
435
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
436
+						$values['cancel'] = '';
437 437
 					} elseif ($country == 'HB') {
438
-					    // TODO : add modeS & reg to aircraft_modes
439
-            				    $values['registration'] = $line[0];
440
-            				    $values['base'] = null;
441
-            				    $values['owner'] = $line[5];
442
-            				    $values['date_first_reg'] = null;
443
-					    $values['cancel'] = '';
438
+						// TODO : add modeS & reg to aircraft_modes
439
+								$values['registration'] = $line[0];
440
+								$values['base'] = null;
441
+								$values['owner'] = $line[5];
442
+								$values['date_first_reg'] = null;
443
+						$values['cancel'] = '';
444 444
 					} elseif ($country == 'OK') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[3];
447
-            				    $values['base'] = null;
448
-            				    $values['owner'] = $line[5];
449
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
451
-					    $values['cancel'] = '';
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[3];
447
+								$values['base'] = null;
448
+								$values['owner'] = $line[5];
449
+								if ($line[18] == '') $values['date_first_reg'] = null;
450
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
451
+						$values['cancel'] = '';
452 452
 					} elseif ($country == 'VH') {
453
-					    // TODO : add modeS & reg to aircraft_modes
454
-            				    $values['registration'] = $line[0];
455
-            				    $values['base'] = null;
456
-            				    $values['owner'] = $line[12];
457
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
459
-
460
-					    $values['cancel'] = $line[39];
453
+						// TODO : add modeS & reg to aircraft_modes
454
+								$values['registration'] = $line[0];
455
+								$values['base'] = null;
456
+								$values['owner'] = $line[12];
457
+								if ($line[28] == '') $values['date_first_reg'] = null;
458
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
459
+
460
+						$values['cancel'] = $line[39];
461 461
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
462
-            				    $values['registration'] = $line[0];
463
-            				    $values['base'] = null;
464
-            				    $values['owner'] = $line[4];
465
-            				    $values['date_first_reg'] = null;
466
-					    $values['cancel'] = '';
462
+								$values['registration'] = $line[0];
463
+								$values['base'] = null;
464
+								$values['owner'] = $line[4];
465
+								$values['date_first_reg'] = null;
466
+						$values['cancel'] = '';
467 467
 					} elseif ($country == 'CC') {
468
-            				    $values['registration'] = $line[0];
469
-            				    $values['base'] = null;
470
-            				    $values['owner'] = $line[6];
471
-            				    $values['date_first_reg'] = null;
472
-					    $values['cancel'] = '';
468
+								$values['registration'] = $line[0];
469
+								$values['base'] = null;
470
+								$values['owner'] = $line[6];
471
+								$values['date_first_reg'] = null;
472
+						$values['cancel'] = '';
473 473
 					} elseif ($country == 'HJ') {
474
-            				    $values['registration'] = $line[0];
475
-            				    $values['base'] = null;
476
-            				    $values['owner'] = $line[8];
477
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
479
-					    $values['cancel'] = '';
474
+								$values['registration'] = $line[0];
475
+								$values['base'] = null;
476
+								$values['owner'] = $line[8];
477
+								if ($line[7] == '') $values['date_first_reg'] = null;
478
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
479
+						$values['cancel'] = '';
480 480
 					} elseif ($country == 'PP') {
481
-            				    $values['registration'] = $line[0];
482
-            				    $values['base'] = null;
483
-            				    $values['owner'] = $line[4];
484
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
486
-					    $values['cancel'] = $line[7];
481
+								$values['registration'] = $line[0];
482
+								$values['base'] = null;
483
+								$values['owner'] = $line[4];
484
+								if ($line[6] == '') $values['date_first_reg'] = null;
485
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
486
+						$values['cancel'] = $line[7];
487 487
 					} elseif ($country == 'E7') {
488
-            				    $values['registration'] = $line[0];
489
-            				    $values['base'] = null;
490
-            				    $values['owner'] = $line[4];
491
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
493
-					    $values['cancel'] = '';
488
+								$values['registration'] = $line[0];
489
+								$values['base'] = null;
490
+								$values['owner'] = $line[4];
491
+								if ($line[5] == '') $values['date_first_reg'] = null;
492
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
493
+						$values['cancel'] = '';
494 494
 					} elseif ($country == '8Q') {
495
-            				    $values['registration'] = $line[0];
496
-            				    $values['base'] = null;
497
-            				    $values['owner'] = $line[3];
498
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
500
-					    $values['cancel'] = '';
495
+								$values['registration'] = $line[0];
496
+								$values['base'] = null;
497
+								$values['owner'] = $line[3];
498
+								if ($line[7] == '') $values['date_first_reg'] = null;
499
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
500
+						$values['cancel'] = '';
501 501
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502
-            				    $values['registration'] = $line[0];
503
-            				    $values['base'] = null;
504
-            				    $values['owner'] = $line[3];
505
-            				    $values['date_first_reg'] = null;
506
-					    $values['cancel'] = '';
502
+								$values['registration'] = $line[0];
503
+								$values['base'] = null;
504
+								$values['owner'] = $line[3];
505
+								$values['date_first_reg'] = null;
506
+						$values['cancel'] = '';
507 507
 					}
508 508
 					if ($values['cancel'] == '' && $values['registration'] != null) {
509 509
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -625,20 +625,20 @@  discard block
 block discarded – undo
625 625
 		try {
626 626
 			$Connection = new Connection();
627 627
 			$sth = $Connection->db->prepare($query);
628
-                        $sth->execute();
629
-                } catch(PDOException $e) {
630
-                        return "error : ".$e->getMessage();
631
-                }
628
+						$sth->execute();
629
+				} catch(PDOException $e) {
630
+						return "error : ".$e->getMessage();
631
+				}
632 632
 
633 633
 
634 634
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
635 635
 		try {
636 636
 			$Connection = new Connection();
637 637
 			$sth = $Connection->db->prepare($query);
638
-                        $sth->execute();
639
-                } catch(PDOException $e) {
640
-                        return "error : ".$e->getMessage();
641
-                }
638
+						$sth->execute();
639
+				} catch(PDOException $e) {
640
+						return "error : ".$e->getMessage();
641
+				}
642 642
 
643 643
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
644 644
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 		try {
705 705
 			$Connection = new Connection();
706 706
 			$sth = $Connection->db->prepare($query);
707
-                        $sth->execute();
708
-                } catch(PDOException $e) {
709
-                        return "error : ".$e->getMessage();
710
-                }
707
+						$sth->execute();
708
+				} catch(PDOException $e) {
709
+						return "error : ".$e->getMessage();
710
+				}
711 711
 
712 712
 
713 713
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -717,10 +717,10 @@  discard block
 block discarded – undo
717 717
 		try {
718 718
 			$Connection = new Connection();
719 719
 			$sth = $Connection->db->prepare($query);
720
-                        $sth->execute($query_values);
721
-                } catch(PDOException $e) {
722
-                        return "error : ".$e->getMessage();
723
-                }
720
+						$sth->execute($query_values);
721
+				} catch(PDOException $e) {
722
+						return "error : ".$e->getMessage();
723
+				}
724 724
 		$i++;
725 725
 /*
726 726
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
 
836 836
 
837
-                return "success";
837
+				return "success";
838 838
 	}
839 839
 	
840 840
 	public static function translation() {
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
 		try {
851 851
 			$Connection = new Connection();
852 852
 			$sth = $Connection->db->prepare($query);
853
-                        $sth->execute(array(':source' => 'translation.csv'));
854
-                } catch(PDOException $e) {
855
-                        return "error : ".$e->getMessage();
856
-                }
853
+						$sth->execute(array(':source' => 'translation.csv'));
854
+				} catch(PDOException $e) {
855
+						return "error : ".$e->getMessage();
856
+				}
857 857
 
858 858
 		
859 859
 		//update_db::unzip($out_file);
@@ -872,21 +872,21 @@  discard block
 block discarded – undo
872 872
 					$data = $row;
873 873
 					$operator = $data[2];
874 874
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
875
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
876
-                                                //echo substr($operator, 0, 2)."\n";;
877
-                                                if (count($airline_array) > 0) {
875
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
876
+												//echo substr($operator, 0, 2)."\n";;
877
+												if (count($airline_array) > 0) {
878 878
 							//print_r($airline_array);
879 879
 							$operator = $airline_array[0]['icao'].substr($operator,2);
880
-                                                }
881
-                                        }
880
+												}
881
+										}
882 882
 					
883 883
 					$operator_correct = $data[3];
884 884
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
885
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
886
-                                                if (count($airline_array) > 0) {
887
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
888
-                                            	}
889
-                                        }
885
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
886
+												if (count($airline_array) > 0) {
887
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
888
+												}
889
+										}
890 890
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
891 891
 					try {
892 892
 						$sth = $Connection->db->prepare($query);
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 			//$Connection->db->commit();
901 901
 		}
902 902
 		return '';
903
-        }
903
+		}
904 904
 	
905 905
 	public static function translation_fam() {
906 906
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -910,10 +910,10 @@  discard block
 block discarded – undo
910 910
 		try {
911 911
 			$Connection = new Connection();
912 912
 			$sth = $Connection->db->prepare($query);
913
-                        $sth->execute(array(':source' => 'website_fam'));
914
-                } catch(PDOException $e) {
915
-                        return "error : ".$e->getMessage();
916
-                }
913
+						$sth->execute(array(':source' => 'website_fam'));
914
+				} catch(PDOException $e) {
915
+						return "error : ".$e->getMessage();
916
+				}
917 917
 
918 918
 		
919 919
 		//update_db::unzip($out_file);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			//$Connection->db->commit();
943 943
 		}
944 944
 		return '';
945
-        }
945
+		}
946 946
 
947 947
 	public static function modes_fam() {
948 948
 		global $tmp_dir, $globalTransaction;
@@ -950,10 +950,10 @@  discard block
 block discarded – undo
950 950
 		try {
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953
-                        $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
955
-                        return "error : ".$e->getMessage();
956
-                }
953
+						$sth->execute(array(':source' => 'website_fam'));
954
+				} catch(PDOException $e) {
955
+						return "error : ".$e->getMessage();
956
+				}
957 957
 
958 958
 		
959 959
 		//update_db::unzip($out_file);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 			if ($globalTransaction) $Connection->db->commit();
983 983
 		}
984 984
 		return '';
985
-        }
985
+		}
986 986
 
987 987
 	public static function routes_fam() {
988 988
 		global $tmp_dir, $globalTransaction;
@@ -990,10 +990,10 @@  discard block
 block discarded – undo
990 990
 		try {
991 991
 			$Connection = new Connection();
992 992
 			$sth = $Connection->db->prepare($query);
993
-                        $sth->execute(array(':source' => 'website_fam'));
994
-                } catch(PDOException $e) {
995
-                        return "error : ".$e->getMessage();
996
-                }
993
+						$sth->execute(array(':source' => 'website_fam'));
994
+				} catch(PDOException $e) {
995
+						return "error : ".$e->getMessage();
996
+				}
997 997
 
998 998
 		
999 999
 		//update_db::unzip($out_file);
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 			if ($globalTransaction) $Connection->db->commit();
1023 1023
 		}
1024 1024
 		return '';
1025
-        }
1025
+		}
1026 1026
 
1027 1027
 	public static function tle($filename,$tletype) {
1028 1028
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1033,10 +1033,10 @@  discard block
 block discarded – undo
1033 1033
 		try {
1034 1034
 			$Connection = new Connection();
1035 1035
 			$sth = $Connection->db->prepare($query);
1036
-                        $sth->execute(array(':source' => $filename));
1037
-                } catch(PDOException $e) {
1038
-                        return "error : ".$e->getMessage();
1039
-                }
1036
+						$sth->execute(array(':source' => $filename));
1037
+				} catch(PDOException $e) {
1038
+						return "error : ".$e->getMessage();
1039
+				}
1040 1040
 		
1041 1041
 		$Connection = new Connection();
1042 1042
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1071,54 +1071,54 @@  discard block
 block discarded – undo
1071 1071
 			//$Connection->db->commit();
1072 1072
 		}
1073 1073
 		return '';
1074
-        }
1074
+		}
1075 1075
 
1076 1076
 	/**
1077
-        * Convert a HTML table to an array
1078
-        * @param String $data HTML page
1079
-        * @return Array array of the tables in HTML page
1080
-        */
1081
-        private static function table2array($data) {
1082
-                $html = str_get_html($data);
1083
-                $tabledata=array();
1084
-                foreach($html->find('tr') as $element)
1085
-                {
1086
-                        $td = array();
1087
-                        foreach( $element->find('th') as $row)
1088
-                        {
1089
-                                $td [] = trim($row->plaintext);
1090
-                        }
1091
-                        $td=array_filter($td);
1092
-                        $tabledata[] = $td;
1093
-
1094
-                        $td = array();
1095
-                        $tdi = array();
1096
-                        foreach( $element->find('td') as $row)
1097
-                        {
1098
-                                $td [] = trim($row->plaintext);
1099
-                                $tdi [] = trim($row->innertext);
1100
-                        }
1101
-                        $td=array_filter($td);
1102
-                        $tdi=array_filter($tdi);
1103
-                    //    $tabledata[]=array_merge($td,$tdi);
1104
-                        $tabledata[]=$td;
1105
-                }
1106
-                return(array_filter($tabledata));
1107
-        }
1108
-
1109
-       /**
1110
-        * Get data from form result
1111
-        * @param String $url form URL
1112
-        * @return String the result
1113
-        */
1114
-        private static function getData($url) {
1115
-                $ch = curl_init();
1116
-                curl_setopt($ch, CURLOPT_URL, $url);
1117
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1118
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1119
-                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');
1120
-                return curl_exec($ch);
1121
-        }
1077
+	 * Convert a HTML table to an array
1078
+	 * @param String $data HTML page
1079
+	 * @return Array array of the tables in HTML page
1080
+	 */
1081
+		private static function table2array($data) {
1082
+				$html = str_get_html($data);
1083
+				$tabledata=array();
1084
+				foreach($html->find('tr') as $element)
1085
+				{
1086
+						$td = array();
1087
+						foreach( $element->find('th') as $row)
1088
+						{
1089
+								$td [] = trim($row->plaintext);
1090
+						}
1091
+						$td=array_filter($td);
1092
+						$tabledata[] = $td;
1093
+
1094
+						$td = array();
1095
+						$tdi = array();
1096
+						foreach( $element->find('td') as $row)
1097
+						{
1098
+								$td [] = trim($row->plaintext);
1099
+								$tdi [] = trim($row->innertext);
1100
+						}
1101
+						$td=array_filter($td);
1102
+						$tdi=array_filter($tdi);
1103
+					//    $tabledata[]=array_merge($td,$tdi);
1104
+						$tabledata[]=$td;
1105
+				}
1106
+				return(array_filter($tabledata));
1107
+		}
1108
+
1109
+	   /**
1110
+	    * Get data from form result
1111
+	    * @param String $url form URL
1112
+	    * @return String the result
1113
+	    */
1114
+		private static function getData($url) {
1115
+				$ch = curl_init();
1116
+				curl_setopt($ch, CURLOPT_URL, $url);
1117
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1118
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1119
+				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');
1120
+				return curl_exec($ch);
1121
+		}
1122 1122
 /*
1123 1123
 	public static function waypoints() {
1124 1124
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 			if ($globalTransaction) $Connection->db->commit();
1202 1202
 		}
1203 1203
 		return '';
1204
-        }
1204
+		}
1205 1205
 
1206 1206
 	public static function ivao_airlines($filename) {
1207 1207
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1211,10 +1211,10 @@  discard block
 block discarded – undo
1211 1211
 		try {
1212 1212
 			$Connection = new Connection();
1213 1213
 			$sth = $Connection->db->prepare($query);
1214
-                        $sth->execute();
1215
-                } catch(PDOException $e) {
1216
-                        return "error : ".$e->getMessage();
1217
-                }
1214
+						$sth->execute();
1215
+				} catch(PDOException $e) {
1216
+						return "error : ".$e->getMessage();
1217
+				}
1218 1218
 
1219 1219
 		$header = NULL;
1220 1220
 		$delimiter = ':';
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 			if ($globalTransaction) $Connection->db->commit();
1239 1239
 		}
1240 1240
 		return '';
1241
-        }
1241
+		}
1242 1242
 	
1243 1243
 	public static function update_airspace() {
1244 1244
 		global $tmp_dir, $globalDBdriver;
@@ -1248,11 +1248,11 @@  discard block
 block discarded – undo
1248 1248
 			$query = 'DROP TABLE airspace';
1249 1249
 			try {
1250 1250
 				$sth = $Connection->db->prepare($query);
1251
-                    		$sth->execute();
1252
-	                } catch(PDOException $e) {
1251
+							$sth->execute();
1252
+					} catch(PDOException $e) {
1253 1253
 				return "error : ".$e->getMessage();
1254
-	                }
1255
-	        }
1254
+					}
1255
+			}
1256 1256
 
1257 1257
 
1258 1258
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1307,10 +1307,10 @@  discard block
 block discarded – undo
1307 1307
 			$query = 'DROP TABLE countries';
1308 1308
 			try {
1309 1309
 				$sth = $Connection->db->prepare($query);
1310
-            	        	$sth->execute();
1311
-	                } catch(PDOException $e) {
1312
-    	                	echo "error : ".$e->getMessage();
1313
-	                }
1310
+							$sth->execute();
1311
+					} catch(PDOException $e) {
1312
+							echo "error : ".$e->getMessage();
1313
+					}
1314 1314
 		}
1315 1315
 		if ($globalDBdriver == 'mysql') {
1316 1316
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -1735,11 +1735,11 @@  discard block
 block discarded – undo
1735 1735
 						$query = 'DROP TABLE airspace';
1736 1736
 						try {
1737 1737
 							$sth = $Connection->db->prepare($query);
1738
-    	    	    					$sth->execute();
1739
-			            		} catch(PDOException $e) {
1738
+										$sth->execute();
1739
+								} catch(PDOException $e) {
1740 1740
 							return "error : ".$e->getMessage();
1741
-		            			}
1742
-		    			}
1741
+								}
1742
+						}
1743 1743
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1744 1744
 					update_db::insert_airspace_version($airspace_md5);
1745 1745
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -1859,12 +1859,12 @@  discard block
 block discarded – undo
1859 1859
 		echo $data;
1860 1860
 		*/
1861 1861
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1862
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1863
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1864
-		    $result = fread($fh,100000000);
1865
-		    //echo $result;
1866
-		    //var_dump(str_get_html($result));
1867
-		    //print_r(self::table2array($result));
1862
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1863
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
1864
+			$result = fread($fh,100000000);
1865
+			//echo $result;
1866
+			//var_dump(str_get_html($result));
1867
+			//print_r(self::table2array($result));
1868 1868
 		}
1869 1869
 
1870 1870
 	}
@@ -1878,10 +1878,10 @@  discard block
 block discarded – undo
1878 1878
 		try {
1879 1879
 			$Connection = new Connection();
1880 1880
 			$sth = $Connection->db->prepare($query);
1881
-                        $sth->execute();
1882
-                } catch(PDOException $e) {
1883
-                        return "error : ".$e->getMessage();
1884
-                }
1881
+						$sth->execute();
1882
+				} catch(PDOException $e) {
1883
+						return "error : ".$e->getMessage();
1884
+				}
1885 1885
 
1886 1886
 		$error = '';
1887 1887
 		if ($globalDebug) echo "Notam : Download...";
@@ -1937,8 +1937,8 @@  discard block
 block discarded – undo
1937 1937
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1938 1938
 					$data['permanent'] = 0;
1939 1939
 				} else {
1940
-				    $data['date_end'] = NULL;
1941
-				    $data['permanent'] = 1;
1940
+					$data['date_end'] = NULL;
1941
+					$data['permanent'] = 1;
1942 1942
 				}
1943 1943
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1944 1944
 				$NOTAM = new NOTAM();
@@ -1997,13 +1997,13 @@  discard block
 block discarded – undo
1997 1997
 		try {
1998 1998
 			$Connection = new Connection();
1999 1999
 			$sth = $Connection->db->prepare($query);
2000
-                        $sth->execute();
2001
-                } catch(PDOException $e) {
2002
-                        return "error : ".$e->getMessage();
2003
-                }
2004
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2005
-                if ($row['nb'] > 0) return false;
2006
-                else return true;
2000
+						$sth->execute();
2001
+				} catch(PDOException $e) {
2002
+						return "error : ".$e->getMessage();
2003
+				}
2004
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2005
+				if ($row['nb'] > 0) return false;
2006
+				else return true;
2007 2007
 	}
2008 2008
 
2009 2009
 	public static function insert_last_update() {
@@ -2012,10 +2012,10 @@  discard block
 block discarded – undo
2012 2012
 		try {
2013 2013
 			$Connection = new Connection();
2014 2014
 			$sth = $Connection->db->prepare($query);
2015
-                        $sth->execute();
2016
-                } catch(PDOException $e) {
2017
-                        return "error : ".$e->getMessage();
2018
-                }
2015
+						$sth->execute();
2016
+				} catch(PDOException $e) {
2017
+						return "error : ".$e->getMessage();
2018
+				}
2019 2019
 	}
2020 2020
 
2021 2021
 	public static function check_airspace_version($version) {
@@ -2023,13 +2023,13 @@  discard block
 block discarded – undo
2023 2023
 		try {
2024 2024
 			$Connection = new Connection();
2025 2025
 			$sth = $Connection->db->prepare($query);
2026
-                        $sth->execute(array(':version' => $version));
2027
-                } catch(PDOException $e) {
2028
-                        return "error : ".$e->getMessage();
2029
-                }
2030
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2031
-                if ($row['nb'] > 0) return true;
2032
-                else return false;
2026
+						$sth->execute(array(':version' => $version));
2027
+				} catch(PDOException $e) {
2028
+						return "error : ".$e->getMessage();
2029
+				}
2030
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2031
+				if ($row['nb'] > 0) return true;
2032
+				else return false;
2033 2033
 	}
2034 2034
 
2035 2035
 
@@ -2039,10 +2039,10 @@  discard block
 block discarded – undo
2039 2039
 		try {
2040 2040
 			$Connection = new Connection();
2041 2041
 			$sth = $Connection->db->prepare($query);
2042
-                        $sth->execute(array(':version' => $version));
2043
-                } catch(PDOException $e) {
2044
-                        return "error : ".$e->getMessage();
2045
-                }
2042
+						$sth->execute(array(':version' => $version));
2043
+				} catch(PDOException $e) {
2044
+						return "error : ".$e->getMessage();
2045
+				}
2046 2046
 	}
2047 2047
 
2048 2048
 	public static function check_last_notam_update() {
@@ -2055,13 +2055,13 @@  discard block
 block discarded – undo
2055 2055
 		try {
2056 2056
 			$Connection = new Connection();
2057 2057
 			$sth = $Connection->db->prepare($query);
2058
-                        $sth->execute();
2059
-                } catch(PDOException $e) {
2060
-                        return "error : ".$e->getMessage();
2061
-                }
2062
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2063
-                if ($row['nb'] > 0) return false;
2064
-                else return true;
2058
+						$sth->execute();
2059
+				} catch(PDOException $e) {
2060
+						return "error : ".$e->getMessage();
2061
+				}
2062
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2063
+				if ($row['nb'] > 0) return false;
2064
+				else return true;
2065 2065
 	}
2066 2066
 
2067 2067
 	public static function insert_last_notam_update() {
@@ -2070,10 +2070,10 @@  discard block
 block discarded – undo
2070 2070
 		try {
2071 2071
 			$Connection = new Connection();
2072 2072
 			$sth = $Connection->db->prepare($query);
2073
-                        $sth->execute();
2074
-                } catch(PDOException $e) {
2075
-                        return "error : ".$e->getMessage();
2076
-                }
2073
+						$sth->execute();
2074
+				} catch(PDOException $e) {
2075
+						return "error : ".$e->getMessage();
2076
+				}
2077 2077
 	}
2078 2078
 	public static function check_last_airspace_update() {
2079 2079
 		global $globalDBdriver;
@@ -2085,13 +2085,13 @@  discard block
 block discarded – undo
2085 2085
 		try {
2086 2086
 			$Connection = new Connection();
2087 2087
 			$sth = $Connection->db->prepare($query);
2088
-                        $sth->execute();
2089
-                } catch(PDOException $e) {
2090
-                        return "error : ".$e->getMessage();
2091
-                }
2092
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2093
-                if ($row['nb'] > 0) return false;
2094
-                else return true;
2088
+						$sth->execute();
2089
+				} catch(PDOException $e) {
2090
+						return "error : ".$e->getMessage();
2091
+				}
2092
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2093
+				if ($row['nb'] > 0) return false;
2094
+				else return true;
2095 2095
 	}
2096 2096
 
2097 2097
 	public static function insert_last_airspace_update() {
@@ -2100,10 +2100,10 @@  discard block
 block discarded – undo
2100 2100
 		try {
2101 2101
 			$Connection = new Connection();
2102 2102
 			$sth = $Connection->db->prepare($query);
2103
-                        $sth->execute();
2104
-                } catch(PDOException $e) {
2105
-                        return "error : ".$e->getMessage();
2106
-                }
2103
+						$sth->execute();
2104
+				} catch(PDOException $e) {
2105
+						return "error : ".$e->getMessage();
2106
+				}
2107 2107
 	}
2108 2108
 
2109 2109
 	public static function check_last_owner_update() {
@@ -2116,13 +2116,13 @@  discard block
 block discarded – undo
2116 2116
 		try {
2117 2117
 			$Connection = new Connection();
2118 2118
 			$sth = $Connection->db->prepare($query);
2119
-                        $sth->execute();
2120
-                } catch(PDOException $e) {
2121
-                        return "error : ".$e->getMessage();
2122
-                }
2123
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2124
-                if ($row['nb'] > 0) return false;
2125
-                else return true;
2119
+						$sth->execute();
2120
+				} catch(PDOException $e) {
2121
+						return "error : ".$e->getMessage();
2122
+				}
2123
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2124
+				if ($row['nb'] > 0) return false;
2125
+				else return true;
2126 2126
 	}
2127 2127
 
2128 2128
 	public static function insert_last_owner_update() {
@@ -2131,10 +2131,10 @@  discard block
 block discarded – undo
2131 2131
 		try {
2132 2132
 			$Connection = new Connection();
2133 2133
 			$sth = $Connection->db->prepare($query);
2134
-                        $sth->execute();
2135
-                } catch(PDOException $e) {
2136
-                        return "error : ".$e->getMessage();
2137
-                }
2134
+						$sth->execute();
2135
+				} catch(PDOException $e) {
2136
+						return "error : ".$e->getMessage();
2137
+				}
2138 2138
 	}
2139 2139
 	public static function check_last_schedules_update() {
2140 2140
 		global $globalDBdriver;
@@ -2146,13 +2146,13 @@  discard block
 block discarded – undo
2146 2146
 		try {
2147 2147
 			$Connection = new Connection();
2148 2148
 			$sth = $Connection->db->prepare($query);
2149
-                        $sth->execute();
2150
-                } catch(PDOException $e) {
2151
-                        return "error : ".$e->getMessage();
2152
-                }
2153
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2154
-                if ($row['nb'] > 0) return false;
2155
-                else return true;
2149
+						$sth->execute();
2150
+				} catch(PDOException $e) {
2151
+						return "error : ".$e->getMessage();
2152
+				}
2153
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2154
+				if ($row['nb'] > 0) return false;
2155
+				else return true;
2156 2156
 	}
2157 2157
 
2158 2158
 	public static function insert_last_schedules_update() {
@@ -2161,10 +2161,10 @@  discard block
 block discarded – undo
2161 2161
 		try {
2162 2162
 			$Connection = new Connection();
2163 2163
 			$sth = $Connection->db->prepare($query);
2164
-                        $sth->execute();
2165
-                } catch(PDOException $e) {
2166
-                        return "error : ".$e->getMessage();
2167
-                }
2164
+						$sth->execute();
2165
+				} catch(PDOException $e) {
2166
+						return "error : ".$e->getMessage();
2167
+				}
2168 2168
 	}
2169 2169
 	public static function check_last_tle_update() {
2170 2170
 		global $globalDBdriver;
@@ -2176,13 +2176,13 @@  discard block
 block discarded – undo
2176 2176
 		try {
2177 2177
 			$Connection = new Connection();
2178 2178
 			$sth = $Connection->db->prepare($query);
2179
-                        $sth->execute();
2180
-                } catch(PDOException $e) {
2181
-                        return "error : ".$e->getMessage();
2182
-                }
2183
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2184
-                if ($row['nb'] > 0) return false;
2185
-                else return true;
2179
+						$sth->execute();
2180
+				} catch(PDOException $e) {
2181
+						return "error : ".$e->getMessage();
2182
+				}
2183
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2184
+				if ($row['nb'] > 0) return false;
2185
+				else return true;
2186 2186
 	}
2187 2187
 
2188 2188
 	public static function insert_last_tle_update() {
@@ -2191,10 +2191,10 @@  discard block
 block discarded – undo
2191 2191
 		try {
2192 2192
 			$Connection = new Connection();
2193 2193
 			$sth = $Connection->db->prepare($query);
2194
-                        $sth->execute();
2195
-                } catch(PDOException $e) {
2196
-                        return "error : ".$e->getMessage();
2197
-                }
2194
+						$sth->execute();
2195
+				} catch(PDOException $e) {
2196
+						return "error : ".$e->getMessage();
2197
+				}
2198 2198
 	}
2199 2199
 	
2200 2200
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +253 added lines, -253 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
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			$Connection = new Connection();
251 251
 			$sth = $Connection->db->prepare($query);
252 252
                         $sth->execute(array(':source' => $database_file));
253
-                } catch(PDOException $e) {
253
+                } catch (PDOException $e) {
254 254
                         return "error : ".$e->getMessage();
255 255
                 }
256 256
 		return '';
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 			$Connection = new Connection();
266 266
 			$sth = $Connection->db->prepare($query);
267 267
                         $sth->execute(array(':source' => $database_file));
268
-                } catch(PDOException $e) {
268
+                } catch (PDOException $e) {
269 269
                         return "error : ".$e->getMessage();
270 270
                 }
271 271
 		
272
-		if ($fh = fopen($database_file,"r")) {
272
+		if ($fh = fopen($database_file, "r")) {
273 273
 			//$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)';
274 274
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
275 275
 		
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 				if ($globalTransaction) $Connection->db->beginTransaction();
280 280
             			while (!feof($fh)) {
281 281
             				$values = array();
282
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+            				$line = $Common->hex2str(fgets($fh, 9999));
283 283
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
284
-            				$values['ModeS'] = substr($line,0,6);
285
-            				$values['Registration'] = trim(substr($line,69,6));
286
-            				$aircraft_name = trim(substr($line,48,6));
284
+            				$values['ModeS'] = substr($line, 0, 6);
285
+            				$values['Registration'] = trim(substr($line, 69, 6));
286
+            				$aircraft_name = trim(substr($line, 48, 6));
287 287
             				// Check if we can find ICAO, else set it to GLID
288
-            				$aircraft_name_split = explode(' ',$aircraft_name);
288
+            				$aircraft_name_split = explode(' ', $aircraft_name);
289 289
             				$search_more = '';
290 290
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
291 291
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
 	            				if (isset($result['icao']) && $result['icao'] != '') {
298 298
 	            				    $values['ICAOTypeCode'] = $result['icao'];
299 299
 	            				} 
300
-					} catch(PDOException $e) {
300
+					} catch (PDOException $e) {
301 301
 						return "error : ".$e->getMessage();
302 302
 					}
303 303
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
304 304
 					// Add data to db
305 305
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') {
306 306
 						//$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']);
307
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
307
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
308 308
 						//print_r($query_dest_values);
309 309
 						$sth_dest->execute($query_dest_values);
310 310
 					}
311 311
 				}
312 312
 				if ($globalTransaction) $Connection->db->commit();
313
-			} catch(PDOException $e) {
313
+			} catch (PDOException $e) {
314 314
 				return "error : ".$e->getMessage();
315 315
 			}
316 316
 		}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			$Connection = new Connection();
321 321
 			$sth = $Connection->db->prepare($query);
322 322
                         $sth->execute(array(':source' => $database_file));
323
-                } catch(PDOException $e) {
323
+                } catch (PDOException $e) {
324 324
                         return "error : ".$e->getMessage();
325 325
                 }
326 326
 		return '';
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
 			$Connection = new Connection();
335 335
 			$sth = $Connection->db->prepare($query);
336 336
                         $sth->execute(array(':source' => $database_file));
337
-                } catch(PDOException $e) {
337
+                } catch (PDOException $e) {
338 338
                         return "error : ".$e->getMessage();
339 339
                 }
340 340
 		
341
-		if ($fh = fopen($database_file,"r")) {
341
+		if ($fh = fopen($database_file, "r")) {
342 342
 			//$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)';
343 343
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
344 344
 		
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 			$sth_dest = $Connection->db->prepare($query_dest);
347 347
 			try {
348 348
 				if ($globalTransaction) $Connection->db->beginTransaction();
349
-				$tmp = fgetcsv($fh,9999,',',"'");
349
+				$tmp = fgetcsv($fh, 9999, ',', "'");
350 350
             			while (!feof($fh)) {
351
-            				$line = fgetcsv($fh,9999,',',"'");
351
+            				$line = fgetcsv($fh, 9999, ',', "'");
352 352
             				
353 353
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
354 354
 					//print_r($line);
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             				$values['Registration'] = $line[3];
357 357
             				$aircraft_name = $line[2];
358 358
             				// Check if we can find ICAO, else set it to GLID
359
-            				$aircraft_name_split = explode(' ',$aircraft_name);
359
+            				$aircraft_name_split = explode(' ', $aircraft_name);
360 360
             				$search_more = '';
361 361
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
362 362
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -365,20 +365,20 @@  discard block
 block discarded – undo
365 365
                                     		$sth_search->execute();
366 366
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367 367
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
-					} catch(PDOException $e) {
368
+					} catch (PDOException $e) {
369 369
 						return "error : ".$e->getMessage();
370 370
 					}
371 371
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
372 372
 					// Add data to db
373 373
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
374 374
 						//$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']);
375
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
375
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
376 376
 						//print_r($query_dest_values);
377 377
 						$sth_dest->execute($query_dest_values);
378 378
 					}
379 379
 				}
380 380
 				if ($globalTransaction) $Connection->db->commit();
381
-			} catch(PDOException $e) {
381
+			} catch (PDOException $e) {
382 382
 				return "error : ".$e->getMessage();
383 383
 			}
384 384
 		}
@@ -388,13 +388,13 @@  discard block
 block discarded – undo
388 388
 			$Connection = new Connection();
389 389
 			$sth = $Connection->db->prepare($query);
390 390
                         $sth->execute(array(':source' => $database_file));
391
-                } catch(PDOException $e) {
391
+                } catch (PDOException $e) {
392 392
                         return "error : ".$e->getMessage();
393 393
                 }
394 394
 		return '';
395 395
 	}
396 396
 
397
-	public static function retrieve_owner($database_file,$country = 'F') {
397
+	public static function retrieve_owner($database_file, $country = 'F') {
398 398
 		global $globalTransaction;
399 399
 		//$query = 'TRUNCATE TABLE aircraft_modes';
400 400
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 			$Connection = new Connection();
403 403
 			$sth = $Connection->db->prepare($query);
404 404
                         $sth->execute(array(':source' => $database_file));
405
-                } catch(PDOException $e) {
405
+                } catch (PDOException $e) {
406 406
                         return "error : ".$e->getMessage();
407 407
                 }
408 408
 		
409
-		if ($fh = fopen($database_file,"r")) {
409
+		if ($fh = fopen($database_file, "r")) {
410 410
 			//$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)';
411 411
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
412 412
 		
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 			$sth_dest = $Connection->db->prepare($query_dest);
415 415
 			try {
416 416
 				if ($globalTransaction) $Connection->db->beginTransaction();
417
-				$tmp = fgetcsv($fh,9999,',','"');
417
+				$tmp = fgetcsv($fh, 9999, ',', '"');
418 418
             			while (!feof($fh)) {
419
-            				$line = fgetcsv($fh,9999,',','"');
419
+            				$line = fgetcsv($fh, 9999, ',', '"');
420 420
             				$values = array();
421 421
             				//print_r($line);
422 422
             				if ($country == 'F') {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
             				    $values['base'] = $line[4];
425 425
             				    $values['owner'] = $line[5];
426 426
             				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
427
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
428 428
 					    $values['cancel'] = $line[7];
429 429
 					} elseif ($country == 'EI') {
430 430
 					    // TODO : add modeS & reg to aircraft_modes
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
             				    $values['base'] = $line[3];
433 433
             				    $values['owner'] = $line[2];
434 434
             				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
435
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
436 436
 					    $values['cancel'] = '';
437 437
 					} elseif ($country == 'HB') {
438 438
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             				    $values['base'] = null;
448 448
             				    $values['owner'] = $line[5];
449 449
             				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
450
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
451 451
 					    $values['cancel'] = '';
452 452
 					} elseif ($country == 'VH') {
453 453
 					    // TODO : add modeS & reg to aircraft_modes
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
             				    $values['base'] = null;
456 456
             				    $values['owner'] = $line[12];
457 457
             				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
458
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
459 459
 
460 460
 					    $values['cancel'] = $line[39];
461 461
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -475,28 +475,28 @@  discard block
 block discarded – undo
475 475
             				    $values['base'] = null;
476 476
             				    $values['owner'] = $line[8];
477 477
             				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
478
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
479 479
 					    $values['cancel'] = '';
480 480
 					} elseif ($country == 'PP') {
481 481
             				    $values['registration'] = $line[0];
482 482
             				    $values['base'] = null;
483 483
             				    $values['owner'] = $line[4];
484 484
             				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
485
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
486 486
 					    $values['cancel'] = $line[7];
487 487
 					} elseif ($country == 'E7') {
488 488
             				    $values['registration'] = $line[0];
489 489
             				    $values['base'] = null;
490 490
             				    $values['owner'] = $line[4];
491 491
             				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
492
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
493 493
 					    $values['cancel'] = '';
494 494
 					} elseif ($country == '8Q') {
495 495
             				    $values['registration'] = $line[0];
496 496
             				    $values['base'] = null;
497 497
             				    $values['owner'] = $line[3];
498 498
             				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
500 500
 					    $values['cancel'] = '';
501 501
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502 502
             				    $values['registration'] = $line[0];
@@ -506,12 +506,12 @@  discard block
 block discarded – undo
506 506
 					    $values['cancel'] = '';
507 507
 					}
508 508
 					if ($values['cancel'] == '' && $values['registration'] != null) {
509
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
509
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
510 510
 						$sth_dest->execute($query_dest_values);
511 511
 					}
512 512
 				}
513 513
 				if ($globalTransaction) $Connection->db->commit();
514
-			} catch(PDOException $e) {
514
+			} catch (PDOException $e) {
515 515
 				return "error : ".$e->getMessage();
516 516
 			}
517 517
 		}
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 			$Connection = new Connection();
627 627
 			$sth = $Connection->db->prepare($query);
628 628
                         $sth->execute();
629
-                } catch(PDOException $e) {
629
+                } catch (PDOException $e) {
630 630
                         return "error : ".$e->getMessage();
631 631
                 }
632 632
 
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 			$Connection = new Connection();
637 637
 			$sth = $Connection->db->prepare($query);
638 638
                         $sth->execute();
639
-                } catch(PDOException $e) {
639
+                } catch (PDOException $e) {
640 640
                         return "error : ".$e->getMessage();
641 641
                 }
642 642
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		if ($globalTransaction) $Connection->db->beginTransaction();
648 648
   
649 649
 		$i = 0;
650
-		while($row = sparql_fetch_array($result))
650
+		while ($row = sparql_fetch_array($result))
651 651
 		{
652 652
 			if ($i >= 1) {
653 653
 			//print_r($row);
@@ -667,31 +667,31 @@  discard block
 block discarded – undo
667 667
 				$row['image'] = '';
668 668
 				$row['image_thumb'] = '';
669 669
 			} else {
670
-				$image = str_replace(' ','_',$row['image']);
670
+				$image = str_replace(' ', '_', $row['image']);
671 671
 				$digest = md5($image);
672
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
673
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
674
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
675
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
672
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
673
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
674
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
675
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
676 676
 			}
677 677
 			
678
-			$country = explode('-',$row['country']);
678
+			$country = explode('-', $row['country']);
679 679
 			$row['country'] = $country[0];
680 680
 			
681 681
 			$row['type'] = trim($row['type']);
682
-			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'])) {
682
+			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 683
 				$row['type'] = 'Military';
684 684
 			} 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') {
685 685
 				$row['type'] = 'small_airport';
686 686
 			}
687 687
 			
688
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
689
-			$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']);
688
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
689
+			$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']);
690 690
 			//print_r($query_dest_values);
691 691
 			
692 692
 			try {
693 693
 				$sth_dest->execute($query_dest_values);
694
-			} catch(PDOException $e) {
694
+			} catch (PDOException $e) {
695 695
 				return "error : ".$e->getMessage();
696 696
 			}
697 697
 			}
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			$Connection = new Connection();
706 706
 			$sth = $Connection->db->prepare($query);
707 707
                         $sth->execute();
708
-                } catch(PDOException $e) {
708
+                } catch (PDOException $e) {
709 709
                         return "error : ".$e->getMessage();
710 710
                 }
711 711
 
@@ -713,12 +713,12 @@  discard block
 block discarded – undo
713 713
 		if ($globalDebug) echo "Insert Not available Airport...\n";
714 714
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
715 715
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
716
-		$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' => '');
716
+		$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 717
 		try {
718 718
 			$Connection = new Connection();
719 719
 			$sth = $Connection->db->prepare($query);
720 720
                         $sth->execute($query_values);
721
-                } catch(PDOException $e) {
721
+                } catch (PDOException $e) {
722 722
                         return "error : ".$e->getMessage();
723 723
                 }
724 724
 		$i++;
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		echo "Download data from ourairports.com...\n";
737 737
 		$delimiter = ',';
738 738
 		$out_file = $tmp_dir.'airports.csv';
739
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
739
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
740 740
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
741 741
 		echo "Add data from ourairports.com...\n";
742 742
 
@@ -747,32 +747,32 @@  discard block
 block discarded – undo
747 747
 			//$Connection->db->beginTransaction();
748 748
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
749 749
 			{
750
-				if(!$header) $header = $row;
750
+				if (!$header) $header = $row;
751 751
 				else {
752 752
 					$data = array();
753 753
 					$data = array_combine($header, $row);
754 754
 					try {
755 755
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
756 756
 						$sth->execute(array(':icao' => $data['gps_code']));
757
-					} catch(PDOException $e) {
757
+					} catch (PDOException $e) {
758 758
 						return "error : ".$e->getMessage();
759 759
 					}
760 760
 					if ($sth->fetchColumn() > 0) {
761 761
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
762 762
 						try {
763 763
 							$sth = $Connection->db->prepare($query);
764
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
765
-						} catch(PDOException $e) {
764
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
765
+						} catch (PDOException $e) {
766 766
 							return "error : ".$e->getMessage();
767 767
 						}
768 768
 					} else {
769 769
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
770 770
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
771
-						$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']);
771
+						$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 772
 						try {
773 773
 							$sth = $Connection->db->prepare($query);
774 774
 							$sth->execute($query_values);
775
-						} catch(PDOException $e) {
775
+						} catch (PDOException $e) {
776 776
 							return "error : ".$e->getMessage();
777 777
 						}
778 778
 						$i++;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 
786 786
 		echo "Download data from another free database...\n";
787 787
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
788
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
788
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
789 789
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
790 790
 		update_db::unzip($out_file);
791 791
 		$header = NULL;
@@ -797,15 +797,15 @@  discard block
 block discarded – undo
797 797
 			//$Connection->db->beginTransaction();
798 798
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
799 799
 			{
800
-				if(!$header) $header = $row;
800
+				if (!$header) $header = $row;
801 801
 				else {
802 802
 					$data = $row;
803 803
 
804 804
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
805 805
 					try {
806 806
 						$sth = $Connection->db->prepare($query);
807
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
808
-					} catch(PDOException $e) {
807
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
808
+					} catch (PDOException $e) {
809 809
 						return "error : ".$e->getMessage();
810 810
 					}
811 811
 				}
@@ -819,15 +819,15 @@  discard block
 block discarded – undo
819 819
 		try {
820 820
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
821 821
 			$sth->execute();
822
-		} catch(PDOException $e) {
822
+		} catch (PDOException $e) {
823 823
 			return "error : ".$e->getMessage();
824 824
 		}
825 825
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
826 826
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
827 827
 			try {
828 828
 				$sth2 = $Connection->db->prepare($query2);
829
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
830
-			} catch(PDOException $e) {
829
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
830
+			} catch (PDOException $e) {
831 831
 				return "error : ".$e->getMessage();
832 832
 			}
833 833
 		}
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 			$Connection = new Connection();
852 852
 			$sth = $Connection->db->prepare($query);
853 853
                         $sth->execute(array(':source' => 'translation.csv'));
854
-                } catch(PDOException $e) {
854
+                } catch (PDOException $e) {
855 855
                         return "error : ".$e->getMessage();
856 856
                 }
857 857
 
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
869 869
 			{
870 870
 				$i++;
871
-				if($i > 12) {
871
+				if ($i > 12) {
872 872
 					$data = $row;
873 873
 					$operator = $data[2];
874 874
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
                                                 //echo substr($operator, 0, 2)."\n";;
877 877
                                                 if (count($airline_array) > 0) {
878 878
 							//print_r($airline_array);
879
-							$operator = $airline_array[0]['icao'].substr($operator,2);
879
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
880 880
                                                 }
881 881
                                         }
882 882
 					
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
885 885
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
886 886
                                                 if (count($airline_array) > 0) {
887
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
887
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
888 888
                                             	}
889 889
                                         }
890 890
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
891 891
 					try {
892 892
 						$sth = $Connection->db->prepare($query);
893
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
894
-					} catch(PDOException $e) {
893
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
894
+					} catch (PDOException $e) {
895 895
 						return "error : ".$e->getMessage();
896 896
 					}
897 897
 				}
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 			$Connection = new Connection();
912 912
 			$sth = $Connection->db->prepare($query);
913 913
                         $sth->execute(array(':source' => 'website_fam'));
914
-                } catch(PDOException $e) {
914
+                } catch (PDOException $e) {
915 915
                         return "error : ".$e->getMessage();
916 916
                 }
917 917
 
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
932 932
 					try {
933 933
 						$sth = $Connection->db->prepare($query);
934
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
935
-					} catch(PDOException $e) {
934
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
935
+					} catch (PDOException $e) {
936 936
 						return "error : ".$e->getMessage();
937 937
 					}
938 938
 				}
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953 953
                         $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
954
+                } catch (PDOException $e) {
955 955
                         return "error : ".$e->getMessage();
956 956
                 }
957 957
 
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
972 972
 					try {
973 973
 						$sth = $Connection->db->prepare($query);
974
-						$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'));
975
-					} catch(PDOException $e) {
974
+						$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'));
975
+					} catch (PDOException $e) {
976 976
 						return "error : ".$e->getMessage();
977 977
 					}
978 978
 				}
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 			$Connection = new Connection();
992 992
 			$sth = $Connection->db->prepare($query);
993 993
                         $sth->execute(array(':source' => 'website_fam'));
994
-                } catch(PDOException $e) {
994
+                } catch (PDOException $e) {
995 995
                         return "error : ".$e->getMessage();
996 996
                 }
997 997
 
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 					$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)';
1012 1012
 					try {
1013 1013
 						$sth = $Connection->db->prepare($query);
1014
-						$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'));
1015
-					} catch(PDOException $e) {
1014
+						$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'));
1015
+					} catch (PDOException $e) {
1016 1016
 						return "error : ".$e->getMessage();
1017 1017
 					}
1018 1018
 				}
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 		return '';
1025 1025
         }
1026 1026
 
1027
-	public static function tle($filename,$tletype) {
1027
+	public static function tle($filename, $tletype) {
1028 1028
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1029 1029
 		global $tmp_dir, $globalTransaction;
1030 1030
 		//$Spotter = new Spotter();
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 			$Connection = new Connection();
1035 1035
 			$sth = $Connection->db->prepare($query);
1036 1036
                         $sth->execute(array(':source' => $filename));
1037
-                } catch(PDOException $e) {
1037
+                } catch (PDOException $e) {
1038 1038
                         return "error : ".$e->getMessage();
1039 1039
                 }
1040 1040
 		
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1060 1060
 					try {
1061 1061
 						$sth = $Connection->db->prepare($query);
1062
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1063
-					} catch(PDOException $e) {
1062
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1063
+					} catch (PDOException $e) {
1064 1064
 						return "error : ".$e->getMessage();
1065 1065
 					}
1066 1066
 
@@ -1080,28 +1080,28 @@  discard block
 block discarded – undo
1080 1080
         */
1081 1081
         private static function table2array($data) {
1082 1082
                 $html = str_get_html($data);
1083
-                $tabledata=array();
1084
-                foreach($html->find('tr') as $element)
1083
+                $tabledata = array();
1084
+                foreach ($html->find('tr') as $element)
1085 1085
                 {
1086 1086
                         $td = array();
1087
-                        foreach( $element->find('th') as $row)
1087
+                        foreach ($element->find('th') as $row)
1088 1088
                         {
1089 1089
                                 $td [] = trim($row->plaintext);
1090 1090
                         }
1091
-                        $td=array_filter($td);
1091
+                        $td = array_filter($td);
1092 1092
                         $tabledata[] = $td;
1093 1093
 
1094 1094
                         $td = array();
1095 1095
                         $tdi = array();
1096
-                        foreach( $element->find('td') as $row)
1096
+                        foreach ($element->find('td') as $row)
1097 1097
                         {
1098 1098
                                 $td [] = trim($row->plaintext);
1099 1099
                                 $tdi [] = trim($row->innertext);
1100 1100
                         }
1101
-                        $td=array_filter($td);
1102
-                        $tdi=array_filter($tdi);
1101
+                        $td = array_filter($td);
1102
+                        $tdi = array_filter($tdi);
1103 1103
                     //    $tabledata[]=array_merge($td,$tdi);
1104
-                        $tabledata[]=$td;
1104
+                        $tabledata[] = $td;
1105 1105
                 }
1106 1106
                 return(array_filter($tabledata));
1107 1107
         }
@@ -1174,13 +1174,13 @@  discard block
 block discarded – undo
1174 1174
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1175 1175
 			{
1176 1176
 				$i++;
1177
-				if($i > 3 && count($row) > 2) {
1177
+				if ($i > 3 && count($row) > 2) {
1178 1178
 					$data = array_values(array_filter($row));
1179 1179
 					$cntdata = count($data);
1180 1180
 					if ($cntdata > 10) {
1181 1181
 						$value = $data[9];
1182 1182
 						
1183
-						for ($i =10;$i < $cntdata;$i++) {
1183
+						for ($i = 10; $i < $cntdata; $i++) {
1184 1184
 							$value .= ' '.$data[$i];
1185 1185
 						}
1186 1186
 						$data[9] = $value;
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 						$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)';
1191 1191
 						try {
1192 1192
 							$sth = $Connection->db->prepare($query);
1193
-							$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]));
1194
-						} catch(PDOException $e) {
1193
+							$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]));
1194
+						} catch (PDOException $e) {
1195 1195
 							return "error : ".$e->getMessage();
1196 1196
 						}
1197 1197
 					}
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 			$Connection = new Connection();
1213 1213
 			$sth = $Connection->db->prepare($query);
1214 1214
                         $sth->execute();
1215
-                } catch(PDOException $e) {
1215
+                } catch (PDOException $e) {
1216 1216
                         return "error : ".$e->getMessage();
1217 1217
                 }
1218 1218
 
@@ -1224,12 +1224,12 @@  discard block
 block discarded – undo
1224 1224
 			if ($globalTransaction) $Connection->db->beginTransaction();
1225 1225
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1226 1226
 			{
1227
-				if(count($row) > 1) {
1227
+				if (count($row) > 1) {
1228 1228
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1229 1229
 					try {
1230 1230
 						$sth = $Connection->db->prepare($query);
1231
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1232
-					} catch(PDOException $e) {
1231
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1232
+					} catch (PDOException $e) {
1233 1233
 						return "error : ".$e->getMessage();
1234 1234
 					}
1235 1235
 				}
@@ -1249,21 +1249,21 @@  discard block
 block discarded – undo
1249 1249
 			try {
1250 1250
 				$sth = $Connection->db->prepare($query);
1251 1251
                     		$sth->execute();
1252
-	                } catch(PDOException $e) {
1252
+	                } catch (PDOException $e) {
1253 1253
 				return "error : ".$e->getMessage();
1254 1254
 	                }
1255 1255
 	        }
1256 1256
 
1257 1257
 
1258
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1258
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1259 1259
 		else {
1260
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1260
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1261 1261
 			$query = "CREATE EXTENSION postgis";
1262
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1262
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1263 1263
 			try {
1264 1264
 				$sth = $Connection->db->prepare($query);
1265 1265
 				$sth->execute();
1266
-			} catch(PDOException $e) {
1266
+			} catch (PDOException $e) {
1267 1267
 				return "error : ".$e->getMessage();
1268 1268
 			}
1269 1269
 		}
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		include_once('class.create_db.php');
1277 1277
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1278 1278
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1279
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1279
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1280 1280
 		$error = '';
1281 1281
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1282 1282
 			if ($globalDebug) echo "Gunzip...";
@@ -1308,14 +1308,14 @@  discard block
 block discarded – undo
1308 1308
 			try {
1309 1309
 				$sth = $Connection->db->prepare($query);
1310 1310
             	        	$sth->execute();
1311
-	                } catch(PDOException $e) {
1311
+	                } catch (PDOException $e) {
1312 1312
     	                	echo "error : ".$e->getMessage();
1313 1313
 	                }
1314 1314
 		}
1315 1315
 		if ($globalDBdriver == 'mysql') {
1316
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1316
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1317 1317
 		} else {
1318
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1318
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1319 1319
 		}
1320 1320
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1321 1321
 		return $error;
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1329 1329
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1330 1330
 //		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');
1331
-		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');
1331
+		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');
1332 1332
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1333 1333
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1334 1334
 		return $error;
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1349 1349
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1350 1350
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1351
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1351
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1352 1352
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1353 1353
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1354 1354
 		if ($error != '') {
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 		global $tmp_dir, $globalDebug;
1362 1362
 		$error = '';
1363 1363
 		if ($globalDebug) echo "Routes : Download...";
1364
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1364
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1365 1365
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1366 1366
 			if ($globalDebug) echo "Gunzip...";
1367 1367
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		global $tmp_dir, $globalDebug;
1378 1378
 		$error = '';
1379 1379
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1380
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1380
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1381 1381
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1382 1382
 			if ($globalDebug) echo "Gunzip...";
1383 1383
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
 		global $tmp_dir, $globalDebug;
1394 1394
 		$error = '';
1395 1395
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1396
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1396
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1397 1397
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1398 1398
 			if ($globalDebug) echo "Gunzip...";
1399 1399
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 */
1422 1422
 		if ($globalDebug) echo "Modes : Download...";
1423 1423
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1424
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1424
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1425 1425
 
1426 1426
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1427 1427
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 	public static function update_ModeS_flarm() {
1442 1442
 		global $tmp_dir, $globalDebug;
1443 1443
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1444
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1444
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1445 1445
 		if (file_exists($tmp_dir.'data.fln')) {
1446 1446
 			if ($globalDebug) echo "Add to DB...";
1447 1447
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	public static function update_ModeS_ogn() {
1456 1456
 		global $tmp_dir, $globalDebug;
1457 1457
 		if ($globalDebug) echo "Modes OGN: Download...";
1458
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1458
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1459 1459
 		if (file_exists($tmp_dir.'ogn.csv')) {
1460 1460
 			if ($globalDebug) echo "Add to DB...";
1461 1461
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1470,173 +1470,173 @@  discard block
 block discarded – undo
1470 1470
 		global $tmp_dir, $globalDebug;
1471 1471
 		
1472 1472
 		if ($globalDebug) echo "Owner France: Download...";
1473
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1473
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1474 1474
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1475 1475
 			if ($globalDebug) echo "Add to DB...";
1476
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1476
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1477 1477
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1478 1478
 		if ($error != '') {
1479 1479
 			return $error;
1480 1480
 		} elseif ($globalDebug) echo "Done\n";
1481 1481
 		
1482 1482
 		if ($globalDebug) echo "Owner Ireland: Download...";
1483
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1483
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1484 1484
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1485 1485
 			if ($globalDebug) echo "Add to DB...";
1486
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1486
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1487 1487
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1488 1488
 		if ($error != '') {
1489 1489
 			return $error;
1490 1490
 		} elseif ($globalDebug) echo "Done\n";
1491 1491
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1492
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1492
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1493 1493
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1494 1494
 			if ($globalDebug) echo "Add to DB...";
1495
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1495
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1496 1496
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1497 1497
 		if ($error != '') {
1498 1498
 			return $error;
1499 1499
 		} elseif ($globalDebug) echo "Done\n";
1500 1500
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1501
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1501
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1502 1502
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1503 1503
 			if ($globalDebug) echo "Add to DB...";
1504
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1504
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1505 1505
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1506 1506
 		if ($error != '') {
1507 1507
 			return $error;
1508 1508
 		} elseif ($globalDebug) echo "Done\n";
1509 1509
 		if ($globalDebug) echo "Owner Australia: Download...";
1510
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1510
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1511 1511
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1512 1512
 			if ($globalDebug) echo "Add to DB...";
1513
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1513
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1514 1514
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1515 1515
 		if ($error != '') {
1516 1516
 			return $error;
1517 1517
 		} elseif ($globalDebug) echo "Done\n";
1518 1518
 		if ($globalDebug) echo "Owner Austria: Download...";
1519
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1519
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1520 1520
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1521 1521
 			if ($globalDebug) echo "Add to DB...";
1522
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1522
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1523 1523
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1524 1524
 		if ($error != '') {
1525 1525
 			return $error;
1526 1526
 		} elseif ($globalDebug) echo "Done\n";
1527 1527
 		if ($globalDebug) echo "Owner Chile: Download...";
1528
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1528
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1529 1529
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1530 1530
 			if ($globalDebug) echo "Add to DB...";
1531
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1531
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1532 1532
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1533 1533
 		if ($error != '') {
1534 1534
 			return $error;
1535 1535
 		} elseif ($globalDebug) echo "Done\n";
1536 1536
 		if ($globalDebug) echo "Owner Colombia: Download...";
1537
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1537
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1538 1538
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1539 1539
 			if ($globalDebug) echo "Add to DB...";
1540
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1540
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1541 1541
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1542 1542
 		if ($error != '') {
1543 1543
 			return $error;
1544 1544
 		} elseif ($globalDebug) echo "Done\n";
1545 1545
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1546
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1546
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1547 1547
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1548 1548
 			if ($globalDebug) echo "Add to DB...";
1549
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1549
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1550 1550
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1551 1551
 		if ($error != '') {
1552 1552
 			return $error;
1553 1553
 		} elseif ($globalDebug) echo "Done\n";
1554 1554
 		if ($globalDebug) echo "Owner Brazil: Download...";
1555
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1555
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1556 1556
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1557 1557
 			if ($globalDebug) echo "Add to DB...";
1558
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1558
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1559 1559
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1560 1560
 		if ($error != '') {
1561 1561
 			return $error;
1562 1562
 		} elseif ($globalDebug) echo "Done\n";
1563 1563
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1564
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1564
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1565 1565
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1566 1566
 			if ($globalDebug) echo "Add to DB...";
1567
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1567
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1568 1568
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1569 1569
 		if ($error != '') {
1570 1570
 			return $error;
1571 1571
 		} elseif ($globalDebug) echo "Done\n";
1572 1572
 		if ($globalDebug) echo "Owner Croatia: Download...";
1573
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1573
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1574 1574
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1575 1575
 			if ($globalDebug) echo "Add to DB...";
1576
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1576
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1577 1577
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1578 1578
 		if ($error != '') {
1579 1579
 			return $error;
1580 1580
 		} elseif ($globalDebug) echo "Done\n";
1581 1581
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1582
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1582
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1583 1583
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1584 1584
 			if ($globalDebug) echo "Add to DB...";
1585
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1585
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1586 1586
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1587 1587
 		if ($error != '') {
1588 1588
 			return $error;
1589 1589
 		} elseif ($globalDebug) echo "Done\n";
1590 1590
 		if ($globalDebug) echo "Owner Maldives: Download...";
1591
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1591
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1592 1592
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1593 1593
 			if ($globalDebug) echo "Add to DB...";
1594
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1594
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1595 1595
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1596 1596
 		if ($error != '') {
1597 1597
 			return $error;
1598 1598
 		} elseif ($globalDebug) echo "Done\n";
1599 1599
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1600
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1600
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1601 1601
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1602 1602
 			if ($globalDebug) echo "Add to DB...";
1603
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1603
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1604 1604
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1605 1605
 		if ($error != '') {
1606 1606
 			return $error;
1607 1607
 		} elseif ($globalDebug) echo "Done\n";
1608 1608
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1609
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1609
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1610 1610
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1611 1611
 			if ($globalDebug) echo "Add to DB...";
1612
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1612
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1613 1613
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1614 1614
 		if ($error != '') {
1615 1615
 			return $error;
1616 1616
 		} elseif ($globalDebug) echo "Done\n";
1617 1617
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1618
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1618
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1619 1619
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1620 1620
 			if ($globalDebug) echo "Add to DB...";
1621
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1621
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1622 1622
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1623 1623
 		if ($error != '') {
1624 1624
 			return $error;
1625 1625
 		} elseif ($globalDebug) echo "Done\n";
1626 1626
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1627
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1627
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1628 1628
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1629 1629
 			if ($globalDebug) echo "Add to DB...";
1630
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1630
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1631 1631
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1632 1632
 		if ($error != '') {
1633 1633
 			return $error;
1634 1634
 		} elseif ($globalDebug) echo "Done\n";
1635 1635
 		if ($globalDebug) echo "Owner Iceland: Download...";
1636
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1636
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1637 1637
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1638 1638
 			if ($globalDebug) echo "Add to DB...";
1639
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1639
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1640 1640
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1641 1641
 		if ($error != '') {
1642 1642
 			return $error;
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 		global $tmp_dir, $globalDebug;
1649 1649
 		$error = '';
1650 1650
 		if ($globalDebug) echo "Translation : Download...";
1651
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1651
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1652 1652
 		if (file_exists($tmp_dir.'translation.zip')) {
1653 1653
 			if ($globalDebug) echo "Unzip...";
1654 1654
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
 	public static function update_translation_fam() {
1665 1665
 		global $tmp_dir, $globalDebug;
1666 1666
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1667
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1667
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1668 1668
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1669 1669
 			if ($globalDebug) echo "Gunzip...";
1670 1670
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 	public static function update_ModeS_fam() {
1680 1680
 		global $tmp_dir, $globalDebug;
1681 1681
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1682
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1682
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1683 1683
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1684 1684
 			if ($globalDebug) echo "Gunzip...";
1685 1685
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
 	public static function update_routes_fam() {
1695 1695
 		global $tmp_dir, $globalDebug;
1696 1696
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
1697
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1697
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
1698 1698
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1699 1699
 			if ($globalDebug) echo "Gunzip...";
1700 1700
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -1713,18 +1713,18 @@  discard block
 block discarded – undo
1713 1713
 		$error = '';
1714 1714
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
1715 1715
 		if ($globalDBdriver == 'mysql') {
1716
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1716
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1717 1717
 		} else {
1718
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1718
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1719 1719
 		}
1720 1720
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
1721
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1721
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1722 1722
 			$airspace_md5 = $airspace_md5_file[0];
1723 1723
 			if (!update_db::check_airspace_version($airspace_md5)) {
1724 1724
 				if ($globalDBdriver == 'mysql') {
1725
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
1725
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
1726 1726
 				} else {
1727
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1727
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
1728 1728
 				}
1729 1729
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1730 1730
 					if ($globalDebug) echo "Gunzip...";
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
 						try {
1737 1737
 							$sth = $Connection->db->prepare($query);
1738 1738
     	    	    					$sth->execute();
1739
-			            		} catch(PDOException $e) {
1739
+			            		} catch (PDOException $e) {
1740 1740
 							return "error : ".$e->getMessage();
1741 1741
 		            			}
1742 1742
 		    			}
@@ -1754,15 +1754,15 @@  discard block
 block discarded – undo
1754 1754
 	public static function update_tle() {
1755 1755
 		global $tmp_dir, $globalDebug;
1756 1756
 		if ($globalDebug) echo "Download TLE : Download...";
1757
-		$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',
1758
-		'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',
1759
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1757
+		$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',
1758
+		'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',
1759
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
1760 1760
 		foreach ($alltle as $filename) {
1761 1761
 			if ($globalDebug) echo "downloading ".$filename.'...';
1762
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1762
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
1763 1763
 			if (file_exists($tmp_dir.$filename)) {
1764 1764
 				if ($globalDebug) echo "Add to DB ".$filename."...";
1765
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1765
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
1766 1766
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1767 1767
 			if ($error != '') {
1768 1768
 				echo $error."\n";
@@ -1775,32 +1775,32 @@  discard block
 block discarded – undo
1775 1775
 		global $tmp_dir, $globalDebug;
1776 1776
 		$error = '';
1777 1777
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
1778
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1778
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
1779 1779
 		if (file_exists($tmp_dir.'models.md5sum')) {
1780 1780
 			if ($globalDebug) echo "Check files...\n";
1781 1781
 			$newmodelsdb = array();
1782
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1783
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1782
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
1783
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1784 1784
 					$model = trim($row[2]);
1785 1785
 					$newmodelsdb[$model] = trim($row[0]);
1786 1786
 				}
1787 1787
 			}
1788 1788
 			$modelsdb = array();
1789 1789
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
1790
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
1791
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1790
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
1791
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1792 1792
 						$model = trim($row[2]);
1793 1793
 						$modelsdb[$model] = trim($row[0]);
1794 1794
 					}
1795 1795
 				}
1796 1796
 			}
1797
-			$diff = array_diff($newmodelsdb,$modelsdb);
1797
+			$diff = array_diff($newmodelsdb, $modelsdb);
1798 1798
 			foreach ($diff as $key => $value) {
1799 1799
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
1800
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1800
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
1801 1801
 				
1802 1802
 			}
1803
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1803
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
1804 1804
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1805 1805
 		if ($error != '') {
1806 1806
 			return $error;
@@ -1812,32 +1812,32 @@  discard block
 block discarded – undo
1812 1812
 		global $tmp_dir, $globalDebug;
1813 1813
 		$error = '';
1814 1814
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
1815
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1815
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
1816 1816
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1817 1817
 			if ($globalDebug) echo "Check files...\n";
1818 1818
 			$newmodelsdb = array();
1819
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1820
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1819
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
1820
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1821 1821
 					$model = trim($row[2]);
1822 1822
 					$newmodelsdb[$model] = trim($row[0]);
1823 1823
 				}
1824 1824
 			}
1825 1825
 			$modelsdb = array();
1826 1826
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
1827
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
1828
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
1827
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
1828
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
1829 1829
 						$model = trim($row[2]);
1830 1830
 						$modelsdb[$model] = trim($row[0]);
1831 1831
 					}
1832 1832
 				}
1833 1833
 			}
1834
-			$diff = array_diff($newmodelsdb,$modelsdb);
1834
+			$diff = array_diff($newmodelsdb, $modelsdb);
1835 1835
 			foreach ($diff as $key => $value) {
1836 1836
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
1837
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1837
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
1838 1838
 				
1839 1839
 			}
1840
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1840
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
1841 1841
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
1842 1842
 		if ($error != '') {
1843 1843
 			return $error;
@@ -1860,8 +1860,8 @@  discard block
 block discarded – undo
1860 1860
 		*/
1861 1861
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1862 1862
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1863
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1864
-		    $result = fread($fh,100000000);
1863
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
1864
+		    $result = fread($fh, 100000000);
1865 1865
 		    //echo $result;
1866 1866
 		    //var_dump(str_get_html($result));
1867 1867
 		    //print_r(self::table2array($result));
@@ -1879,23 +1879,23 @@  discard block
 block discarded – undo
1879 1879
 			$Connection = new Connection();
1880 1880
 			$sth = $Connection->db->prepare($query);
1881 1881
                         $sth->execute();
1882
-                } catch(PDOException $e) {
1882
+                } catch (PDOException $e) {
1883 1883
                         return "error : ".$e->getMessage();
1884 1884
                 }
1885 1885
 
1886 1886
 		$error = '';
1887 1887
 		if ($globalDebug) echo "Notam : Download...";
1888
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1888
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
1889 1889
 		if (file_exists($tmp_dir.'notam.rss')) {
1890
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
1890
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
1891 1891
 			foreach ($notams['channel']['item'] as $notam) {
1892
-				$title = explode(':',$notam['title']);
1892
+				$title = explode(':', $notam['title']);
1893 1893
 				$data['ref'] = trim($title[0]);
1894 1894
 				unset($title[0]);
1895
-				$data['title'] = trim(implode(':',$title));
1896
-				$description = strip_tags($notam['description'],'<pre>');
1897
-				preg_match(':^(.*?)<pre>:',$description,$match);
1898
-				$q = explode('/',$match[1]);
1895
+				$data['title'] = trim(implode(':', $title));
1896
+				$description = strip_tags($notam['description'], '<pre>');
1897
+				preg_match(':^(.*?)<pre>:', $description, $match);
1898
+				$q = explode('/', $match[1]);
1899 1899
 				$data['fir'] = $q[0];
1900 1900
 				$data['code'] = $q[1];
1901 1901
 				$ifrvfr = $q[2];
@@ -1911,30 +1911,30 @@  discard block
 block discarded – undo
1911 1911
 				$data['lower_limit'] = $q[5];
1912 1912
 				$data['upper_limit'] = $q[6];
1913 1913
 				$latlonrad = $q[7];
1914
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1915
-				$latitude = $Common->convertDec($las,'latitude');
1916
-				$longitude = $Common->convertDec($lns,'longitude');
1914
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
1915
+				$latitude = $Common->convertDec($las, 'latitude');
1916
+				$longitude = $Common->convertDec($lns, 'longitude');
1917 1917
 				if ($lac == 'S') $latitude = '-'.$latitude;
1918 1918
 				if ($lnc == 'W') $longitude = '-'.$longitude;
1919 1919
 				$data['center_latitude'] = $latitude;
1920 1920
 				$data['center_longitude'] = $longitude;
1921 1921
 				$data['radius'] = intval($radius);
1922 1922
 				
1923
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
1923
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
1924 1924
 				$data['text'] = $match[1];
1925
-				preg_match(':</pre>(.*?)$:',$description,$match);
1925
+				preg_match(':</pre>(.*?)$:', $description, $match);
1926 1926
 				$fromto = $match[1];
1927
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
1927
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
1928 1928
 				$fromall = trim($match[1]);
1929
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
1929
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
1930 1930
 				$from = trim($match[1]);
1931
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
1932
-				preg_match('#TO:(.*?)$#',$fromto,$match);
1931
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
1932
+				preg_match('#TO:(.*?)$#', $fromto, $match);
1933 1933
 				$toall = trim($match[1]);
1934
-				if (!preg_match(':Permanent:',$toall)) {
1935
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
1934
+				if (!preg_match(':Permanent:', $toall)) {
1935
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
1936 1936
 					$to = trim($match[1]);
1937
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1937
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
1938 1938
 					$data['permanent'] = 0;
1939 1939
 				} else {
1940 1940
 				    $data['date_end'] = NULL;
@@ -1942,7 +1942,7 @@  discard block
 block discarded – undo
1942 1942
 				}
1943 1943
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1944 1944
 				$NOTAM = new NOTAM();
1945
-				$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']);
1945
+				$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']);
1946 1946
 				unset($data);
1947 1947
 			} 
1948 1948
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -1965,16 +1965,16 @@  discard block
 block discarded – undo
1965 1965
 				$Connection = new Connection();
1966 1966
 				$sth = $Connection->db->prepare($query);
1967 1967
 				$sth->execute();
1968
-			} catch(PDOException $e) {
1968
+			} catch (PDOException $e) {
1969 1969
 				return "error : ".$e->getMessage();
1970 1970
 			}
1971 1971
 		}
1972 1972
 		$Common = new Common();
1973 1973
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
1974
-		$airspace_json = json_decode($airspace_lst,true);
1974
+		$airspace_json = json_decode($airspace_lst, true);
1975 1975
 		foreach ($airspace_json['records'] as $airspace) {
1976 1976
 			if ($globalDebug) echo $airspace['name']."...\n";
1977
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
1977
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
1978 1978
 			if (file_exists($tmp_dir.$airspace['name'])) {
1979 1979
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
1980 1980
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 			$Connection = new Connection();
1999 1999
 			$sth = $Connection->db->prepare($query);
2000 2000
                         $sth->execute();
2001
-                } catch(PDOException $e) {
2001
+                } catch (PDOException $e) {
2002 2002
                         return "error : ".$e->getMessage();
2003 2003
                 }
2004 2004
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
 			$Connection = new Connection();
2014 2014
 			$sth = $Connection->db->prepare($query);
2015 2015
                         $sth->execute();
2016
-                } catch(PDOException $e) {
2016
+                } catch (PDOException $e) {
2017 2017
                         return "error : ".$e->getMessage();
2018 2018
                 }
2019 2019
 	}
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
 			$Connection = new Connection();
2025 2025
 			$sth = $Connection->db->prepare($query);
2026 2026
                         $sth->execute(array(':version' => $version));
2027
-                } catch(PDOException $e) {
2027
+                } catch (PDOException $e) {
2028 2028
                         return "error : ".$e->getMessage();
2029 2029
                 }
2030 2030
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 			$Connection = new Connection();
2041 2041
 			$sth = $Connection->db->prepare($query);
2042 2042
                         $sth->execute(array(':version' => $version));
2043
-                } catch(PDOException $e) {
2043
+                } catch (PDOException $e) {
2044 2044
                         return "error : ".$e->getMessage();
2045 2045
                 }
2046 2046
 	}
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
 			$Connection = new Connection();
2057 2057
 			$sth = $Connection->db->prepare($query);
2058 2058
                         $sth->execute();
2059
-                } catch(PDOException $e) {
2059
+                } catch (PDOException $e) {
2060 2060
                         return "error : ".$e->getMessage();
2061 2061
                 }
2062 2062
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2071,7 +2071,7 @@  discard block
 block discarded – undo
2071 2071
 			$Connection = new Connection();
2072 2072
 			$sth = $Connection->db->prepare($query);
2073 2073
                         $sth->execute();
2074
-                } catch(PDOException $e) {
2074
+                } catch (PDOException $e) {
2075 2075
                         return "error : ".$e->getMessage();
2076 2076
                 }
2077 2077
 	}
@@ -2086,7 +2086,7 @@  discard block
 block discarded – undo
2086 2086
 			$Connection = new Connection();
2087 2087
 			$sth = $Connection->db->prepare($query);
2088 2088
                         $sth->execute();
2089
-                } catch(PDOException $e) {
2089
+                } catch (PDOException $e) {
2090 2090
                         return "error : ".$e->getMessage();
2091 2091
                 }
2092 2092
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2101,7 +2101,7 @@  discard block
 block discarded – undo
2101 2101
 			$Connection = new Connection();
2102 2102
 			$sth = $Connection->db->prepare($query);
2103 2103
                         $sth->execute();
2104
-                } catch(PDOException $e) {
2104
+                } catch (PDOException $e) {
2105 2105
                         return "error : ".$e->getMessage();
2106 2106
                 }
2107 2107
 	}
@@ -2117,7 +2117,7 @@  discard block
 block discarded – undo
2117 2117
 			$Connection = new Connection();
2118 2118
 			$sth = $Connection->db->prepare($query);
2119 2119
                         $sth->execute();
2120
-                } catch(PDOException $e) {
2120
+                } catch (PDOException $e) {
2121 2121
                         return "error : ".$e->getMessage();
2122 2122
                 }
2123 2123
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2132,7 +2132,7 @@  discard block
 block discarded – undo
2132 2132
 			$Connection = new Connection();
2133 2133
 			$sth = $Connection->db->prepare($query);
2134 2134
                         $sth->execute();
2135
-                } catch(PDOException $e) {
2135
+                } catch (PDOException $e) {
2136 2136
                         return "error : ".$e->getMessage();
2137 2137
                 }
2138 2138
 	}
@@ -2147,7 +2147,7 @@  discard block
 block discarded – undo
2147 2147
 			$Connection = new Connection();
2148 2148
 			$sth = $Connection->db->prepare($query);
2149 2149
                         $sth->execute();
2150
-                } catch(PDOException $e) {
2150
+                } catch (PDOException $e) {
2151 2151
                         return "error : ".$e->getMessage();
2152 2152
                 }
2153 2153
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2162,7 +2162,7 @@  discard block
 block discarded – undo
2162 2162
 			$Connection = new Connection();
2163 2163
 			$sth = $Connection->db->prepare($query);
2164 2164
                         $sth->execute();
2165
-                } catch(PDOException $e) {
2165
+                } catch (PDOException $e) {
2166 2166
                         return "error : ".$e->getMessage();
2167 2167
                 }
2168 2168
 	}
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
 			$Connection = new Connection();
2178 2178
 			$sth = $Connection->db->prepare($query);
2179 2179
                         $sth->execute();
2180
-                } catch(PDOException $e) {
2180
+                } catch (PDOException $e) {
2181 2181
                         return "error : ".$e->getMessage();
2182 2182
                 }
2183 2183
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
 			$Connection = new Connection();
2193 2193
 			$sth = $Connection->db->prepare($query);
2194 2194
                         $sth->execute();
2195
-                } catch(PDOException $e) {
2195
+                } catch (PDOException $e) {
2196 2196
                         return "error : ".$e->getMessage();
2197 2197
                 }
2198 2198
 	}
Please login to merge, or discard this patch.
Braces   +768 added lines, -267 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
 		}
@@ -276,7 +323,9 @@  discard block
 block discarded – undo
276 323
 			$Connection = new Connection();
277 324
 			$sth_dest = $Connection->db->prepare($query_dest);
278 325
 			try {
279
-				if ($globalTransaction) $Connection->db->beginTransaction();
326
+				if ($globalTransaction) {
327
+					$Connection->db->beginTransaction();
328
+				}
280 329
             			while (!feof($fh)) {
281 330
             				$values = array();
282 331
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -287,7 +336,9 @@  discard block
 block discarded – undo
287 336
             				// Check if we can find ICAO, else set it to GLID
288 337
             				$aircraft_name_split = explode(' ',$aircraft_name);
289 338
             				$search_more = '';
290
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
339
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
340
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				}
291 342
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
292 343
             				$sth_search = $Connection->db->prepare($query_search);
293 344
 					try {
@@ -300,7 +351,9 @@  discard block
 block discarded – undo
300 351
 					} catch(PDOException $e) {
301 352
 						return "error : ".$e->getMessage();
302 353
 					}
303
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
354
+					if (!isset($values['ICAOTypeCode'])) {
355
+						$values['ICAOTypeCode'] = 'GLID';
356
+					}
304 357
 					// Add data to db
305 358
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') {
306 359
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -309,7 +362,9 @@  discard block
 block discarded – undo
309 362
 						$sth_dest->execute($query_dest_values);
310 363
 					}
311 364
 				}
312
-				if ($globalTransaction) $Connection->db->commit();
365
+				if ($globalTransaction) {
366
+					$Connection->db->commit();
367
+				}
313 368
 			} catch(PDOException $e) {
314 369
 				return "error : ".$e->getMessage();
315 370
 			}
@@ -345,7 +400,9 @@  discard block
 block discarded – undo
345 400
 			$Connection = new Connection();
346 401
 			$sth_dest = $Connection->db->prepare($query_dest);
347 402
 			try {
348
-				if ($globalTransaction) $Connection->db->beginTransaction();
403
+				if ($globalTransaction) {
404
+					$Connection->db->beginTransaction();
405
+				}
349 406
 				$tmp = fgetcsv($fh,9999,',',"'");
350 407
             			while (!feof($fh)) {
351 408
             				$line = fgetcsv($fh,9999,',',"'");
@@ -358,13 +415,17 @@  discard block
 block discarded – undo
358 415
             				// Check if we can find ICAO, else set it to GLID
359 416
             				$aircraft_name_split = explode(' ',$aircraft_name);
360 417
             				$search_more = '';
361
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
418
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
419
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
420
+            				}
362 421
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
363 422
             				$sth_search = $Connection->db->prepare($query_search);
364 423
 					try {
365 424
                                     		$sth_search->execute();
366 425
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
426
+	            				if (isset($result['icao']) && $result['icao'] != '') {
427
+	            					$values['ICAOTypeCode'] = $result['icao'];
428
+	            				}
368 429
 					} catch(PDOException $e) {
369 430
 						return "error : ".$e->getMessage();
370 431
 					}
@@ -377,7 +438,9 @@  discard block
 block discarded – undo
377 438
 						$sth_dest->execute($query_dest_values);
378 439
 					}
379 440
 				}
380
-				if ($globalTransaction) $Connection->db->commit();
441
+				if ($globalTransaction) {
442
+					$Connection->db->commit();
443
+				}
381 444
 			} catch(PDOException $e) {
382 445
 				return "error : ".$e->getMessage();
383 446
 			}
@@ -413,7 +476,9 @@  discard block
 block discarded – undo
413 476
 			$Connection = new Connection();
414 477
 			$sth_dest = $Connection->db->prepare($query_dest);
415 478
 			try {
416
-				if ($globalTransaction) $Connection->db->beginTransaction();
479
+				if ($globalTransaction) {
480
+					$Connection->db->beginTransaction();
481
+				}
417 482
 				$tmp = fgetcsv($fh,9999,',','"');
418 483
             			while (!feof($fh)) {
419 484
             				$line = fgetcsv($fh,9999,',','"');
@@ -423,16 +488,22 @@  discard block
 block discarded – undo
423 488
             				    $values['registration'] = $line[0];
424 489
             				    $values['base'] = $line[4];
425 490
             				    $values['owner'] = $line[5];
426
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
491
+            				    if ($line[6] == '') {
492
+            				    	$values['date_first_reg'] = null;
493
+            				    } else {
494
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+					    }
428 496
 					    $values['cancel'] = $line[7];
429 497
 					} elseif ($country == 'EI') {
430 498
 					    // TODO : add modeS & reg to aircraft_modes
431 499
             				    $values['registration'] = $line[0];
432 500
             				    $values['base'] = $line[3];
433 501
             				    $values['owner'] = $line[2];
434
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
502
+            				    if ($line[1] == '') {
503
+            				    	$values['date_first_reg'] = null;
504
+            				    } else {
505
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
506
+					    }
436 507
 					    $values['cancel'] = '';
437 508
 					} elseif ($country == 'HB') {
438 509
 					    // TODO : add modeS & reg to aircraft_modes
@@ -446,16 +517,22 @@  discard block
 block discarded – undo
446 517
             				    $values['registration'] = $line[3];
447 518
             				    $values['base'] = null;
448 519
             				    $values['owner'] = $line[5];
449
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
520
+            				    if ($line[18] == '') {
521
+            				    	$values['date_first_reg'] = null;
522
+            				    } else {
523
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
524
+					    }
451 525
 					    $values['cancel'] = '';
452 526
 					} elseif ($country == 'VH') {
453 527
 					    // TODO : add modeS & reg to aircraft_modes
454 528
             				    $values['registration'] = $line[0];
455 529
             				    $values['base'] = null;
456 530
             				    $values['owner'] = $line[12];
457
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
531
+            				    if ($line[28] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
535
+					    }
459 536
 
460 537
 					    $values['cancel'] = $line[39];
461 538
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -474,29 +551,41 @@  discard block
 block discarded – undo
474 551
             				    $values['registration'] = $line[0];
475 552
             				    $values['base'] = null;
476 553
             				    $values['owner'] = $line[8];
477
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
554
+            				    if ($line[7] == '') {
555
+            				    	$values['date_first_reg'] = null;
556
+            				    } else {
557
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
558
+					    }
479 559
 					    $values['cancel'] = '';
480 560
 					} elseif ($country == 'PP') {
481 561
             				    $values['registration'] = $line[0];
482 562
             				    $values['base'] = null;
483 563
             				    $values['owner'] = $line[4];
484
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
564
+            				    if ($line[6] == '') {
565
+            				    	$values['date_first_reg'] = null;
566
+            				    } else {
567
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
568
+					    }
486 569
 					    $values['cancel'] = $line[7];
487 570
 					} elseif ($country == 'E7') {
488 571
             				    $values['registration'] = $line[0];
489 572
             				    $values['base'] = null;
490 573
             				    $values['owner'] = $line[4];
491
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
574
+            				    if ($line[5] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
578
+					    }
493 579
 					    $values['cancel'] = '';
494 580
 					} elseif ($country == '8Q') {
495 581
             				    $values['registration'] = $line[0];
496 582
             				    $values['base'] = null;
497 583
             				    $values['owner'] = $line[3];
498
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
584
+            				    if ($line[7] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
588
+					    }
500 589
 					    $values['cancel'] = '';
501 590
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502 591
             				    $values['registration'] = $line[0];
@@ -510,7 +599,9 @@  discard block
 block discarded – undo
510 599
 						$sth_dest->execute($query_dest_values);
511 600
 					}
512 601
 				}
513
-				if ($globalTransaction) $Connection->db->commit();
602
+				if ($globalTransaction) {
603
+					$Connection->db->commit();
604
+				}
514 605
 			} catch(PDOException $e) {
515 606
 				return "error : ".$e->getMessage();
516 607
 			}
@@ -644,25 +735,45 @@  discard block
 block discarded – undo
644 735
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
645 736
 		$Connection = new Connection();
646 737
 		$sth_dest = $Connection->db->prepare($query_dest);
647
-		if ($globalTransaction) $Connection->db->beginTransaction();
738
+		if ($globalTransaction) {
739
+			$Connection->db->beginTransaction();
740
+		}
648 741
   
649 742
 		$i = 0;
650 743
 		while($row = sparql_fetch_array($result))
651 744
 		{
652 745
 			if ($i >= 1) {
653 746
 			//print_r($row);
654
-			if (!isset($row['iata'])) $row['iata'] = '';
655
-			if (!isset($row['icao'])) $row['icao'] = '';
656
-			if (!isset($row['type'])) $row['type'] = '';
657
-			if (!isset($row['altitude'])) $row['altitude'] = '';
747
+			if (!isset($row['iata'])) {
748
+				$row['iata'] = '';
749
+			}
750
+			if (!isset($row['icao'])) {
751
+				$row['icao'] = '';
752
+			}
753
+			if (!isset($row['type'])) {
754
+				$row['type'] = '';
755
+			}
756
+			if (!isset($row['altitude'])) {
757
+				$row['altitude'] = '';
758
+			}
658 759
 			if (isset($row['city_bis'])) {
659 760
 				$row['city'] = $row['city_bis'];
660 761
 			}
661
-			if (!isset($row['city'])) $row['city'] = '';
662
-			if (!isset($row['country'])) $row['country'] = '';
663
-			if (!isset($row['homepage'])) $row['homepage'] = '';
664
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
665
-			if (!isset($row['name'])) continue;
762
+			if (!isset($row['city'])) {
763
+				$row['city'] = '';
764
+			}
765
+			if (!isset($row['country'])) {
766
+				$row['country'] = '';
767
+			}
768
+			if (!isset($row['homepage'])) {
769
+				$row['homepage'] = '';
770
+			}
771
+			if (!isset($row['wikipedia_page'])) {
772
+				$row['wikipedia_page'] = '';
773
+			}
774
+			if (!isset($row['name'])) {
775
+				continue;
776
+			}
666 777
 			if (!isset($row['image'])) {
667 778
 				$row['image'] = '';
668 779
 				$row['image_thumb'] = '';
@@ -698,7 +809,9 @@  discard block
 block discarded – undo
698 809
 
699 810
 			$i++;
700 811
 		}
701
-		if ($globalTransaction) $Connection->db->commit();
812
+		if ($globalTransaction) {
813
+			$Connection->db->commit();
814
+		}
702 815
 		echo "Delete duplicate rows...\n";
703 816
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
704 817
 		try {
@@ -710,7 +823,9 @@  discard block
 block discarded – undo
710 823
                 }
711 824
 
712 825
 
713
-		if ($globalDebug) echo "Insert Not available Airport...\n";
826
+		if ($globalDebug) {
827
+			echo "Insert Not available Airport...\n";
828
+		}
714 829
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
715 830
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
716 831
 		$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' => '');
@@ -737,7 +852,9 @@  discard block
 block discarded – undo
737 852
 		$delimiter = ',';
738 853
 		$out_file = $tmp_dir.'airports.csv';
739 854
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
740
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
855
+		if (!file_exists($out_file) || !is_readable($out_file)) {
856
+			return FALSE;
857
+		}
741 858
 		echo "Add data from ourairports.com...\n";
742 859
 
743 860
 		$header = NULL;
@@ -747,8 +864,9 @@  discard block
 block discarded – undo
747 864
 			//$Connection->db->beginTransaction();
748 865
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
749 866
 			{
750
-				if(!$header) $header = $row;
751
-				else {
867
+				if(!$header) {
868
+					$header = $row;
869
+				} else {
752 870
 					$data = array();
753 871
 					$data = array_combine($header, $row);
754 872
 					try {
@@ -786,7 +904,9 @@  discard block
 block discarded – undo
786 904
 		echo "Download data from another free database...\n";
787 905
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
788 906
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
789
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
907
+		if (!file_exists($out_file) || !is_readable($out_file)) {
908
+			return FALSE;
909
+		}
790 910
 		update_db::unzip($out_file);
791 911
 		$header = NULL;
792 912
 		echo "Add data from another free database...\n";
@@ -797,8 +917,9 @@  discard block
 block discarded – undo
797 917
 			//$Connection->db->beginTransaction();
798 918
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
799 919
 			{
800
-				if(!$header) $header = $row;
801
-				else {
920
+				if(!$header) {
921
+					$header = $row;
922
+				} else {
802 923
 					$data = $row;
803 924
 
804 925
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -964,7 +1085,9 @@  discard block
 block discarded – undo
964 1085
 			$i = 0;
965 1086
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
966 1087
 			//$Connection->db->beginTransaction();
967
-			if ($globalTransaction) $Connection->db->beginTransaction();
1088
+			if ($globalTransaction) {
1089
+				$Connection->db->beginTransaction();
1090
+			}
968 1091
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
969 1092
 			{
970 1093
 				if ($i > 0) {
@@ -979,7 +1102,9 @@  discard block
 block discarded – undo
979 1102
 				$i++;
980 1103
 			}
981 1104
 			fclose($handle);
982
-			if ($globalTransaction) $Connection->db->commit();
1105
+			if ($globalTransaction) {
1106
+				$Connection->db->commit();
1107
+			}
983 1108
 		}
984 1109
 		return '';
985 1110
         }
@@ -1004,7 +1129,9 @@  discard block
 block discarded – undo
1004 1129
 			$i = 0;
1005 1130
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1006 1131
 			//$Connection->db->beginTransaction();
1007
-			if ($globalTransaction) $Connection->db->beginTransaction();
1132
+			if ($globalTransaction) {
1133
+				$Connection->db->beginTransaction();
1134
+			}
1008 1135
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1009 1136
 			{
1010 1137
 				if ($i > 0) {
@@ -1019,7 +1146,9 @@  discard block
 block discarded – undo
1019 1146
 				$i++;
1020 1147
 			}
1021 1148
 			fclose($handle);
1022
-			if ($globalTransaction) $Connection->db->commit();
1149
+			if ($globalTransaction) {
1150
+				$Connection->db->commit();
1151
+			}
1023 1152
 		}
1024 1153
 		return '';
1025 1154
         }
@@ -1170,7 +1299,9 @@  discard block
 block discarded – undo
1170 1299
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1171 1300
 		{
1172 1301
 			$i = 0;
1173
-			if ($globalTransaction) $Connection->db->beginTransaction();
1302
+			if ($globalTransaction) {
1303
+				$Connection->db->beginTransaction();
1304
+			}
1174 1305
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1175 1306
 			{
1176 1307
 				$i++;
@@ -1198,7 +1329,9 @@  discard block
 block discarded – undo
1198 1329
 				}
1199 1330
 			}
1200 1331
 			fclose($handle);
1201
-			if ($globalTransaction) $Connection->db->commit();
1332
+			if ($globalTransaction) {
1333
+				$Connection->db->commit();
1334
+			}
1202 1335
 		}
1203 1336
 		return '';
1204 1337
         }
@@ -1221,7 +1354,9 @@  discard block
 block discarded – undo
1221 1354
 		$Connection = new Connection();
1222 1355
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1223 1356
 		{
1224
-			if ($globalTransaction) $Connection->db->beginTransaction();
1357
+			if ($globalTransaction) {
1358
+				$Connection->db->beginTransaction();
1359
+			}
1225 1360
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1226 1361
 			{
1227 1362
 				if(count($row) > 1) {
@@ -1235,7 +1370,9 @@  discard block
 block discarded – undo
1235 1370
 				}
1236 1371
 			}
1237 1372
 			fclose($handle);
1238
-			if ($globalTransaction) $Connection->db->commit();
1373
+			if ($globalTransaction) {
1374
+				$Connection->db->commit();
1375
+			}
1239 1376
 		}
1240 1377
 		return '';
1241 1378
         }
@@ -1255,8 +1392,9 @@  discard block
 block discarded – undo
1255 1392
 	        }
1256 1393
 
1257 1394
 
1258
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1259
-		else {
1395
+		if ($globalDBdriver == 'mysql') {
1396
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1397
+		} else {
1260 1398
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1261 1399
 			$query = "CREATE EXTENSION postgis";
1262 1400
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1275,20 +1413,30 @@  discard block
 block discarded – undo
1275 1413
 		global $tmp_dir, $globalDebug;
1276 1414
 		include_once('class.create_db.php');
1277 1415
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1278
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1416
+		if ($globalDebug) {
1417
+			echo "NOTAM from FlightAirMap website : Download...";
1418
+		}
1279 1419
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1280 1420
 		$error = '';
1281 1421
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1282
-			if ($globalDebug) echo "Gunzip...";
1422
+			if ($globalDebug) {
1423
+				echo "Gunzip...";
1424
+			}
1283 1425
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1284
-			if ($globalDebug) echo "Add to DB...";
1426
+			if ($globalDebug) {
1427
+				echo "Add to DB...";
1428
+			}
1285 1429
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1286 1430
 			$NOTAM = new NOTAM();
1287 1431
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1288
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1432
+		} else {
1433
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1434
+		}
1289 1435
 		if ($error != '') {
1290 1436
 			return $error;
1291
-		} elseif ($globalDebug) echo "Done\n";
1437
+		} elseif ($globalDebug) {
1438
+			echo "Done\n";
1439
+		}
1292 1440
 		return '';
1293 1441
 	}
1294 1442
 
@@ -1342,67 +1490,111 @@  discard block
 block discarded – undo
1342 1490
 		//if ($globalDebug) echo "IVAO : Download...";
1343 1491
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1344 1492
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1345
-			if ($globalDebug) echo "Unzip...";
1493
+			if ($globalDebug) {
1494
+				echo "Unzip...";
1495
+			}
1346 1496
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1347
-			if ($globalDebug) echo "Add to DB...";
1497
+			if ($globalDebug) {
1498
+				echo "Add to DB...";
1499
+			}
1348 1500
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1349
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1501
+			if ($globalDebug) {
1502
+				echo "Copy airlines logos to airlines images directory...";
1503
+			}
1350 1504
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1351
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1352
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1353
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1505
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1506
+					$error = "Failed to copy airlines logo.";
1507
+				}
1508
+			} else {
1509
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1510
+			}
1511
+		} else {
1512
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1513
+		}
1354 1514
 		if ($error != '') {
1355 1515
 			return $error;
1356
-		} elseif ($globalDebug) echo "Done\n";
1516
+		} elseif ($globalDebug) {
1517
+			echo "Done\n";
1518
+		}
1357 1519
 		return '';
1358 1520
 	}
1359 1521
 
1360 1522
 	public static function update_routes() {
1361 1523
 		global $tmp_dir, $globalDebug;
1362 1524
 		$error = '';
1363
-		if ($globalDebug) echo "Routes : Download...";
1525
+		if ($globalDebug) {
1526
+			echo "Routes : Download...";
1527
+		}
1364 1528
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1365 1529
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1366
-			if ($globalDebug) echo "Gunzip...";
1530
+			if ($globalDebug) {
1531
+				echo "Gunzip...";
1532
+			}
1367 1533
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1368
-			if ($globalDebug) echo "Add to DB...";
1534
+			if ($globalDebug) {
1535
+				echo "Add to DB...";
1536
+			}
1369 1537
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1370
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1538
+		} else {
1539
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1540
+		}
1371 1541
 		if ($error != '') {
1372 1542
 			return $error;
1373
-		} elseif ($globalDebug) echo "Done\n";
1543
+		} elseif ($globalDebug) {
1544
+			echo "Done\n";
1545
+		}
1374 1546
 		return '';
1375 1547
 	}
1376 1548
 	public static function update_oneworld() {
1377 1549
 		global $tmp_dir, $globalDebug;
1378 1550
 		$error = '';
1379
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1551
+		if ($globalDebug) {
1552
+			echo "Schedules Oneworld : Download...";
1553
+		}
1380 1554
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1381 1555
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1382
-			if ($globalDebug) echo "Gunzip...";
1556
+			if ($globalDebug) {
1557
+				echo "Gunzip...";
1558
+			}
1383 1559
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1384
-			if ($globalDebug) echo "Add to DB...";
1560
+			if ($globalDebug) {
1561
+				echo "Add to DB...";
1562
+			}
1385 1563
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1386
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1564
+		} else {
1565
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1566
+		}
1387 1567
 		if ($error != '') {
1388 1568
 			return $error;
1389
-		} elseif ($globalDebug) echo "Done\n";
1569
+		} elseif ($globalDebug) {
1570
+			echo "Done\n";
1571
+		}
1390 1572
 		return '';
1391 1573
 	}
1392 1574
 	public static function update_skyteam() {
1393 1575
 		global $tmp_dir, $globalDebug;
1394 1576
 		$error = '';
1395
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1577
+		if ($globalDebug) {
1578
+			echo "Schedules Skyteam : Download...";
1579
+		}
1396 1580
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1397 1581
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1398
-			if ($globalDebug) echo "Gunzip...";
1582
+			if ($globalDebug) {
1583
+				echo "Gunzip...";
1584
+			}
1399 1585
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1400
-			if ($globalDebug) echo "Add to DB...";
1586
+			if ($globalDebug) {
1587
+				echo "Add to DB...";
1588
+			}
1401 1589
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1402
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1590
+		} else {
1591
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1592
+		}
1403 1593
 		if ($error != '') {
1404 1594
 			return $error;
1405
-		} elseif ($globalDebug) echo "Done\n";
1595
+		} elseif ($globalDebug) {
1596
+			echo "Done\n";
1597
+		}
1406 1598
 		return '';
1407 1599
 	}
1408 1600
 	public static function update_ModeS() {
@@ -1419,291 +1611,509 @@  discard block
 block discarded – undo
1419 1611
 			exit;
1420 1612
 		} elseif ($globalDebug) echo "Done\n";
1421 1613
 */
1422
-		if ($globalDebug) echo "Modes : Download...";
1423
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1614
+		if ($globalDebug) {
1615
+			echo "Modes : Download...";
1616
+		}
1617
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1424 1618
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1425 1619
 
1426 1620
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1427 1621
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1428
-			if ($globalDebug) echo "Unzip...";
1429
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1622
+			if ($globalDebug) {
1623
+				echo "Unzip...";
1624
+			}
1625
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1430 1626
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1431
-			if ($globalDebug) echo "Add to DB...";
1627
+			if ($globalDebug) {
1628
+				echo "Add to DB...";
1629
+			}
1432 1630
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1433 1631
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1434
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1632
+		} else {
1633
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1634
+		}
1435 1635
 		if ($error != '') {
1436 1636
 			return $error;
1437
-		} elseif ($globalDebug) echo "Done\n";
1637
+		} elseif ($globalDebug) {
1638
+			echo "Done\n";
1639
+		}
1438 1640
 		return '';
1439 1641
 	}
1440 1642
 
1441 1643
 	public static function update_ModeS_flarm() {
1442 1644
 		global $tmp_dir, $globalDebug;
1443
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1645
+		if ($globalDebug) {
1646
+			echo "Modes Flarmnet: Download...";
1647
+		}
1444 1648
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1445 1649
 		if (file_exists($tmp_dir.'data.fln')) {
1446
-			if ($globalDebug) echo "Add to DB...";
1650
+			if ($globalDebug) {
1651
+				echo "Add to DB...";
1652
+			}
1447 1653
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1448
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1654
+		} else {
1655
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1656
+		}
1449 1657
 		if ($error != '') {
1450 1658
 			return $error;
1451
-		} elseif ($globalDebug) echo "Done\n";
1659
+		} elseif ($globalDebug) {
1660
+			echo "Done\n";
1661
+		}
1452 1662
 		return '';
1453 1663
 	}
1454 1664
 
1455 1665
 	public static function update_ModeS_ogn() {
1456 1666
 		global $tmp_dir, $globalDebug;
1457
-		if ($globalDebug) echo "Modes OGN: Download...";
1667
+		if ($globalDebug) {
1668
+			echo "Modes OGN: Download...";
1669
+		}
1458 1670
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1459 1671
 		if (file_exists($tmp_dir.'ogn.csv')) {
1460
-			if ($globalDebug) echo "Add to DB...";
1672
+			if ($globalDebug) {
1673
+				echo "Add to DB...";
1674
+			}
1461 1675
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1462
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1676
+		} else {
1677
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1678
+		}
1463 1679
 		if ($error != '') {
1464 1680
 			return $error;
1465
-		} elseif ($globalDebug) echo "Done\n";
1681
+		} elseif ($globalDebug) {
1682
+			echo "Done\n";
1683
+		}
1466 1684
 		return '';
1467 1685
 	}
1468 1686
 
1469 1687
 	public static function update_owner() {
1470 1688
 		global $tmp_dir, $globalDebug;
1471 1689
 		
1472
-		if ($globalDebug) echo "Owner France: Download...";
1690
+		if ($globalDebug) {
1691
+			echo "Owner France: Download...";
1692
+		}
1473 1693
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1474 1694
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1475
-			if ($globalDebug) echo "Add to DB...";
1695
+			if ($globalDebug) {
1696
+				echo "Add to DB...";
1697
+			}
1476 1698
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1477
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1699
+		} else {
1700
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1701
+		}
1478 1702
 		if ($error != '') {
1479 1703
 			return $error;
1480
-		} elseif ($globalDebug) echo "Done\n";
1704
+		} elseif ($globalDebug) {
1705
+			echo "Done\n";
1706
+		}
1481 1707
 		
1482
-		if ($globalDebug) echo "Owner Ireland: Download...";
1708
+		if ($globalDebug) {
1709
+			echo "Owner Ireland: Download...";
1710
+		}
1483 1711
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1484 1712
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1485
-			if ($globalDebug) echo "Add to DB...";
1713
+			if ($globalDebug) {
1714
+				echo "Add to DB...";
1715
+			}
1486 1716
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1487
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1717
+		} else {
1718
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1719
+		}
1488 1720
 		if ($error != '') {
1489 1721
 			return $error;
1490
-		} elseif ($globalDebug) echo "Done\n";
1491
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1722
+		} elseif ($globalDebug) {
1723
+			echo "Done\n";
1724
+		}
1725
+		if ($globalDebug) {
1726
+			echo "Owner Switzerland: Download...";
1727
+		}
1492 1728
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1493 1729
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1494
-			if ($globalDebug) echo "Add to DB...";
1730
+			if ($globalDebug) {
1731
+				echo "Add to DB...";
1732
+			}
1495 1733
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1496
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1734
+		} else {
1735
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1736
+		}
1497 1737
 		if ($error != '') {
1498 1738
 			return $error;
1499
-		} elseif ($globalDebug) echo "Done\n";
1500
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1739
+		} elseif ($globalDebug) {
1740
+			echo "Done\n";
1741
+		}
1742
+		if ($globalDebug) {
1743
+			echo "Owner Czech Republic: Download...";
1744
+		}
1501 1745
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1502 1746
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1503
-			if ($globalDebug) echo "Add to DB...";
1747
+			if ($globalDebug) {
1748
+				echo "Add to DB...";
1749
+			}
1504 1750
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1505
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1751
+		} else {
1752
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1753
+		}
1506 1754
 		if ($error != '') {
1507 1755
 			return $error;
1508
-		} elseif ($globalDebug) echo "Done\n";
1509
-		if ($globalDebug) echo "Owner Australia: Download...";
1756
+		} elseif ($globalDebug) {
1757
+			echo "Done\n";
1758
+		}
1759
+		if ($globalDebug) {
1760
+			echo "Owner Australia: Download...";
1761
+		}
1510 1762
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1511 1763
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1512
-			if ($globalDebug) echo "Add to DB...";
1764
+			if ($globalDebug) {
1765
+				echo "Add to DB...";
1766
+			}
1513 1767
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1514
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1768
+		} else {
1769
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1770
+		}
1515 1771
 		if ($error != '') {
1516 1772
 			return $error;
1517
-		} elseif ($globalDebug) echo "Done\n";
1518
-		if ($globalDebug) echo "Owner Austria: Download...";
1773
+		} elseif ($globalDebug) {
1774
+			echo "Done\n";
1775
+		}
1776
+		if ($globalDebug) {
1777
+			echo "Owner Austria: Download...";
1778
+		}
1519 1779
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1520 1780
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1521
-			if ($globalDebug) echo "Add to DB...";
1781
+			if ($globalDebug) {
1782
+				echo "Add to DB...";
1783
+			}
1522 1784
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1523
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1785
+		} else {
1786
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1787
+		}
1524 1788
 		if ($error != '') {
1525 1789
 			return $error;
1526
-		} elseif ($globalDebug) echo "Done\n";
1527
-		if ($globalDebug) echo "Owner Chile: Download...";
1790
+		} elseif ($globalDebug) {
1791
+			echo "Done\n";
1792
+		}
1793
+		if ($globalDebug) {
1794
+			echo "Owner Chile: Download...";
1795
+		}
1528 1796
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1529 1797
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1530
-			if ($globalDebug) echo "Add to DB...";
1798
+			if ($globalDebug) {
1799
+				echo "Add to DB...";
1800
+			}
1531 1801
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1532
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1802
+		} else {
1803
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1804
+		}
1533 1805
 		if ($error != '') {
1534 1806
 			return $error;
1535
-		} elseif ($globalDebug) echo "Done\n";
1536
-		if ($globalDebug) echo "Owner Colombia: Download...";
1807
+		} elseif ($globalDebug) {
1808
+			echo "Done\n";
1809
+		}
1810
+		if ($globalDebug) {
1811
+			echo "Owner Colombia: Download...";
1812
+		}
1537 1813
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1538 1814
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1539
-			if ($globalDebug) echo "Add to DB...";
1815
+			if ($globalDebug) {
1816
+				echo "Add to DB...";
1817
+			}
1540 1818
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1541
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1819
+		} else {
1820
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1821
+		}
1542 1822
 		if ($error != '') {
1543 1823
 			return $error;
1544
-		} elseif ($globalDebug) echo "Done\n";
1545
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1824
+		} elseif ($globalDebug) {
1825
+			echo "Done\n";
1826
+		}
1827
+		if ($globalDebug) {
1828
+			echo "Owner Bosnia Herzegobina: Download...";
1829
+		}
1546 1830
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1547 1831
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1548
-			if ($globalDebug) echo "Add to DB...";
1832
+			if ($globalDebug) {
1833
+				echo "Add to DB...";
1834
+			}
1549 1835
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1550
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1836
+		} else {
1837
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1838
+		}
1551 1839
 		if ($error != '') {
1552 1840
 			return $error;
1553
-		} elseif ($globalDebug) echo "Done\n";
1554
-		if ($globalDebug) echo "Owner Brazil: Download...";
1841
+		} elseif ($globalDebug) {
1842
+			echo "Done\n";
1843
+		}
1844
+		if ($globalDebug) {
1845
+			echo "Owner Brazil: Download...";
1846
+		}
1555 1847
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1556 1848
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1557
-			if ($globalDebug) echo "Add to DB...";
1849
+			if ($globalDebug) {
1850
+				echo "Add to DB...";
1851
+			}
1558 1852
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1559
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1853
+		} else {
1854
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1855
+		}
1560 1856
 		if ($error != '') {
1561 1857
 			return $error;
1562
-		} elseif ($globalDebug) echo "Done\n";
1563
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1858
+		} elseif ($globalDebug) {
1859
+			echo "Done\n";
1860
+		}
1861
+		if ($globalDebug) {
1862
+			echo "Owner Cayman Islands: Download...";
1863
+		}
1564 1864
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1565 1865
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1566
-			if ($globalDebug) echo "Add to DB...";
1866
+			if ($globalDebug) {
1867
+				echo "Add to DB...";
1868
+			}
1567 1869
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1568
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1870
+		} else {
1871
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1872
+		}
1569 1873
 		if ($error != '') {
1570 1874
 			return $error;
1571
-		} elseif ($globalDebug) echo "Done\n";
1572
-		if ($globalDebug) echo "Owner Croatia: Download...";
1875
+		} elseif ($globalDebug) {
1876
+			echo "Done\n";
1877
+		}
1878
+		if ($globalDebug) {
1879
+			echo "Owner Croatia: Download...";
1880
+		}
1573 1881
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1574 1882
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1575
-			if ($globalDebug) echo "Add to DB...";
1883
+			if ($globalDebug) {
1884
+				echo "Add to DB...";
1885
+			}
1576 1886
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1577
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1887
+		} else {
1888
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1889
+		}
1578 1890
 		if ($error != '') {
1579 1891
 			return $error;
1580
-		} elseif ($globalDebug) echo "Done\n";
1581
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
1892
+		} elseif ($globalDebug) {
1893
+			echo "Done\n";
1894
+		}
1895
+		if ($globalDebug) {
1896
+			echo "Owner Luxembourg: Download...";
1897
+		}
1582 1898
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1583 1899
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1584
-			if ($globalDebug) echo "Add to DB...";
1900
+			if ($globalDebug) {
1901
+				echo "Add to DB...";
1902
+			}
1585 1903
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1586
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1904
+		} else {
1905
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1906
+		}
1587 1907
 		if ($error != '') {
1588 1908
 			return $error;
1589
-		} elseif ($globalDebug) echo "Done\n";
1590
-		if ($globalDebug) echo "Owner Maldives: Download...";
1909
+		} elseif ($globalDebug) {
1910
+			echo "Done\n";
1911
+		}
1912
+		if ($globalDebug) {
1913
+			echo "Owner Maldives: Download...";
1914
+		}
1591 1915
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1592 1916
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1593
-			if ($globalDebug) echo "Add to DB...";
1917
+			if ($globalDebug) {
1918
+				echo "Add to DB...";
1919
+			}
1594 1920
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1595
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1921
+		} else {
1922
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1923
+		}
1596 1924
 		if ($error != '') {
1597 1925
 			return $error;
1598
-		} elseif ($globalDebug) echo "Done\n";
1599
-		if ($globalDebug) echo "Owner New Zealand: Download...";
1926
+		} elseif ($globalDebug) {
1927
+			echo "Done\n";
1928
+		}
1929
+		if ($globalDebug) {
1930
+			echo "Owner New Zealand: Download...";
1931
+		}
1600 1932
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1601 1933
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1602
-			if ($globalDebug) echo "Add to DB...";
1934
+			if ($globalDebug) {
1935
+				echo "Add to DB...";
1936
+			}
1603 1937
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1604
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1938
+		} else {
1939
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1940
+		}
1605 1941
 		if ($error != '') {
1606 1942
 			return $error;
1607
-		} elseif ($globalDebug) echo "Done\n";
1608
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1943
+		} elseif ($globalDebug) {
1944
+			echo "Done\n";
1945
+		}
1946
+		if ($globalDebug) {
1947
+			echo "Owner Papua New Guinea: Download...";
1948
+		}
1609 1949
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1610 1950
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1611
-			if ($globalDebug) echo "Add to DB...";
1951
+			if ($globalDebug) {
1952
+				echo "Add to DB...";
1953
+			}
1612 1954
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1613
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1955
+		} else {
1956
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1957
+		}
1614 1958
 		if ($error != '') {
1615 1959
 			return $error;
1616
-		} elseif ($globalDebug) echo "Done\n";
1617
-		if ($globalDebug) echo "Owner Slovakia: Download...";
1960
+		} elseif ($globalDebug) {
1961
+			echo "Done\n";
1962
+		}
1963
+		if ($globalDebug) {
1964
+			echo "Owner Slovakia: Download...";
1965
+		}
1618 1966
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1619 1967
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1620
-			if ($globalDebug) echo "Add to DB...";
1968
+			if ($globalDebug) {
1969
+				echo "Add to DB...";
1970
+			}
1621 1971
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1622
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1972
+		} else {
1973
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1974
+		}
1623 1975
 		if ($error != '') {
1624 1976
 			return $error;
1625
-		} elseif ($globalDebug) echo "Done\n";
1626
-		if ($globalDebug) echo "Owner Ecuador: Download...";
1977
+		} elseif ($globalDebug) {
1978
+			echo "Done\n";
1979
+		}
1980
+		if ($globalDebug) {
1981
+			echo "Owner Ecuador: Download...";
1982
+		}
1627 1983
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1628 1984
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1629
-			if ($globalDebug) echo "Add to DB...";
1985
+			if ($globalDebug) {
1986
+				echo "Add to DB...";
1987
+			}
1630 1988
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1631
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1989
+		} else {
1990
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1991
+		}
1632 1992
 		if ($error != '') {
1633 1993
 			return $error;
1634
-		} elseif ($globalDebug) echo "Done\n";
1635
-		if ($globalDebug) echo "Owner Iceland: Download...";
1994
+		} elseif ($globalDebug) {
1995
+			echo "Done\n";
1996
+		}
1997
+		if ($globalDebug) {
1998
+			echo "Owner Iceland: Download...";
1999
+		}
1636 2000
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1637 2001
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1638
-			if ($globalDebug) echo "Add to DB...";
2002
+			if ($globalDebug) {
2003
+				echo "Add to DB...";
2004
+			}
1639 2005
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1640
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2006
+		} else {
2007
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2008
+		}
1641 2009
 		if ($error != '') {
1642 2010
 			return $error;
1643
-		} elseif ($globalDebug) echo "Done\n";
2011
+		} elseif ($globalDebug) {
2012
+			echo "Done\n";
2013
+		}
1644 2014
 		return '';
1645 2015
 	}
1646 2016
 
1647 2017
 	public static function update_translation() {
1648 2018
 		global $tmp_dir, $globalDebug;
1649 2019
 		$error = '';
1650
-		if ($globalDebug) echo "Translation : Download...";
2020
+		if ($globalDebug) {
2021
+			echo "Translation : Download...";
2022
+		}
1651 2023
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1652 2024
 		if (file_exists($tmp_dir.'translation.zip')) {
1653
-			if ($globalDebug) echo "Unzip...";
2025
+			if ($globalDebug) {
2026
+				echo "Unzip...";
2027
+			}
1654 2028
 			update_db::unzip($tmp_dir.'translation.zip');
1655
-			if ($globalDebug) echo "Add to DB...";
2029
+			if ($globalDebug) {
2030
+				echo "Add to DB...";
2031
+			}
1656 2032
 			$error = update_db::translation();
1657
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2033
+		} else {
2034
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2035
+		}
1658 2036
 		if ($error != '') {
1659 2037
 			return $error;
1660
-		} elseif ($globalDebug) echo "Done\n";
2038
+		} elseif ($globalDebug) {
2039
+			echo "Done\n";
2040
+		}
1661 2041
 		return '';
1662 2042
 	}
1663 2043
 
1664 2044
 	public static function update_translation_fam() {
1665 2045
 		global $tmp_dir, $globalDebug;
1666
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2046
+		if ($globalDebug) {
2047
+			echo "Translation from FlightAirMap website : Download...";
2048
+		}
1667 2049
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1668 2050
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1669
-			if ($globalDebug) echo "Gunzip...";
2051
+			if ($globalDebug) {
2052
+				echo "Gunzip...";
2053
+			}
1670 2054
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1671
-			if ($globalDebug) echo "Add to DB...";
2055
+			if ($globalDebug) {
2056
+				echo "Add to DB...";
2057
+			}
1672 2058
 			$error = update_db::translation_fam();
1673
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2059
+		} else {
2060
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2061
+		}
1674 2062
 		if ($error != '') {
1675 2063
 			return $error;
1676
-		} elseif ($globalDebug) echo "Done\n";
2064
+		} elseif ($globalDebug) {
2065
+			echo "Done\n";
2066
+		}
1677 2067
 		return '';
1678 2068
 	}
1679 2069
 	public static function update_ModeS_fam() {
1680 2070
 		global $tmp_dir, $globalDebug;
1681
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2071
+		if ($globalDebug) {
2072
+			echo "ModeS from FlightAirMap website : Download...";
2073
+		}
1682 2074
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1683 2075
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1684
-			if ($globalDebug) echo "Gunzip...";
2076
+			if ($globalDebug) {
2077
+				echo "Gunzip...";
2078
+			}
1685 2079
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1686
-			if ($globalDebug) echo "Add to DB...";
2080
+			if ($globalDebug) {
2081
+				echo "Add to DB...";
2082
+			}
1687 2083
 			$error = update_db::modes_fam();
1688
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2084
+		} else {
2085
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2086
+		}
1689 2087
 		if ($error != '') {
1690 2088
 			return $error;
1691
-		} elseif ($globalDebug) echo "Done\n";
2089
+		} elseif ($globalDebug) {
2090
+			echo "Done\n";
2091
+		}
1692 2092
 		return '';
1693 2093
 	}
1694 2094
 	public static function update_routes_fam() {
1695 2095
 		global $tmp_dir, $globalDebug;
1696
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2096
+		if ($globalDebug) {
2097
+			echo "Routes from FlightAirMap website : Download...";
2098
+		}
1697 2099
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1698 2100
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1699
-			if ($globalDebug) echo "Gunzip...";
2101
+			if ($globalDebug) {
2102
+				echo "Gunzip...";
2103
+			}
1700 2104
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1701
-			if ($globalDebug) echo "Add to DB...";
2105
+			if ($globalDebug) {
2106
+				echo "Add to DB...";
2107
+			}
1702 2108
 			$error = update_db::routes_fam();
1703
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2109
+		} else {
2110
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2111
+		}
1704 2112
 		if ($error != '') {
1705 2113
 			return $error;
1706
-		} elseif ($globalDebug) echo "Done\n";
2114
+		} elseif ($globalDebug) {
2115
+			echo "Done\n";
2116
+		}
1707 2117
 		return '';
1708 2118
 	}
1709 2119
 
@@ -1711,7 +2121,9 @@  discard block
 block discarded – undo
1711 2121
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1712 2122
 		include_once('class.create_db.php');
1713 2123
 		$error = '';
1714
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2124
+		if ($globalDebug) {
2125
+			echo "Airspace from FlightAirMap website : Download...";
2126
+		}
1715 2127
 		if ($globalDBdriver == 'mysql') {
1716 2128
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1717 2129
 		} else {
@@ -1727,9 +2139,13 @@  discard block
 block discarded – undo
1727 2139
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1728 2140
 				}
1729 2141
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1730
-					if ($globalDebug) echo "Gunzip...";
2142
+					if ($globalDebug) {
2143
+						echo "Gunzip...";
2144
+					}
1731 2145
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1732
-					if ($globalDebug) echo "Add to DB...";
2146
+					if ($globalDebug) {
2147
+						echo "Add to DB...";
2148
+					}
1733 2149
 					$Connection = new Connection();
1734 2150
 					if ($Connection->tableExists('airspace')) {
1735 2151
 						$query = 'DROP TABLE airspace';
@@ -1742,31 +2158,47 @@  discard block
 block discarded – undo
1742 2158
 		    			}
1743 2159
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1744 2160
 					update_db::insert_airspace_version($airspace_md5);
1745
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2161
+				} else {
2162
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2163
+				}
1746 2164
 			}
1747
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2165
+		} else {
2166
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2167
+		}
1748 2168
 		if ($error != '') {
1749 2169
 			return $error;
1750
-		} elseif ($globalDebug) echo "Done\n";
2170
+		} elseif ($globalDebug) {
2171
+			echo "Done\n";
2172
+		}
1751 2173
 		return '';
1752 2174
 	}
1753 2175
 
1754 2176
 	public static function update_tle() {
1755 2177
 		global $tmp_dir, $globalDebug;
1756
-		if ($globalDebug) echo "Download TLE : Download...";
2178
+		if ($globalDebug) {
2179
+			echo "Download TLE : Download...";
2180
+		}
1757 2181
 		$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',
1758 2182
 		'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',
1759 2183
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1760 2184
 		foreach ($alltle as $filename) {
1761
-			if ($globalDebug) echo "downloading ".$filename.'...';
2185
+			if ($globalDebug) {
2186
+				echo "downloading ".$filename.'...';
2187
+			}
1762 2188
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1763 2189
 			if (file_exists($tmp_dir.$filename)) {
1764
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2190
+				if ($globalDebug) {
2191
+					echo "Add to DB ".$filename."...";
2192
+				}
1765 2193
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1766
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2194
+			} else {
2195
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2196
+			}
1767 2197
 			if ($error != '') {
1768 2198
 				echo $error."\n";
1769
-			} elseif ($globalDebug) echo "Done\n";
2199
+			} elseif ($globalDebug) {
2200
+				echo "Done\n";
2201
+			}
1770 2202
 		}
1771 2203
 		return '';
1772 2204
 	}
@@ -1774,10 +2206,14 @@  discard block
 block discarded – undo
1774 2206
 	public static function update_models() {
1775 2207
 		global $tmp_dir, $globalDebug;
1776 2208
 		$error = '';
1777
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2209
+		if ($globalDebug) {
2210
+			echo "Models from FlightAirMap website : Download...";
2211
+		}
1778 2212
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1779 2213
 		if (file_exists($tmp_dir.'models.md5sum')) {
1780
-			if ($globalDebug) echo "Check files...\n";
2214
+			if ($globalDebug) {
2215
+				echo "Check files...\n";
2216
+			}
1781 2217
 			$newmodelsdb = array();
1782 2218
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1783 2219
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1796,25 +2232,35 @@  discard block
 block discarded – undo
1796 2232
 			}
1797 2233
 			$diff = array_diff($newmodelsdb,$modelsdb);
1798 2234
 			foreach ($diff as $key => $value) {
1799
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2235
+				if ($globalDebug) {
2236
+					echo 'Downloading model '.$key.' ...'."\n";
2237
+				}
1800 2238
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1801 2239
 				
1802 2240
 			}
1803 2241
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1804
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2242
+		} else {
2243
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2244
+		}
1805 2245
 		if ($error != '') {
1806 2246
 			return $error;
1807
-		} elseif ($globalDebug) echo "Done\n";
2247
+		} elseif ($globalDebug) {
2248
+			echo "Done\n";
2249
+		}
1808 2250
 		return '';
1809 2251
 	}
1810 2252
 
1811 2253
 	public static function update_space_models() {
1812 2254
 		global $tmp_dir, $globalDebug;
1813 2255
 		$error = '';
1814
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2256
+		if ($globalDebug) {
2257
+			echo "Space models from FlightAirMap website : Download...";
2258
+		}
1815 2259
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1816 2260
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1817
-			if ($globalDebug) echo "Check files...\n";
2261
+			if ($globalDebug) {
2262
+				echo "Check files...\n";
2263
+			}
1818 2264
 			$newmodelsdb = array();
1819 2265
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1820 2266
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1833,15 +2279,21 @@  discard block
 block discarded – undo
1833 2279
 			}
1834 2280
 			$diff = array_diff($newmodelsdb,$modelsdb);
1835 2281
 			foreach ($diff as $key => $value) {
1836
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2282
+				if ($globalDebug) {
2283
+					echo 'Downloading space model '.$key.' ...'."\n";
2284
+				}
1837 2285
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1838 2286
 				
1839 2287
 			}
1840 2288
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1841
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2289
+		} else {
2290
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2291
+		}
1842 2292
 		if ($error != '') {
1843 2293
 			return $error;
1844
-		} elseif ($globalDebug) echo "Done\n";
2294
+		} elseif ($globalDebug) {
2295
+			echo "Done\n";
2296
+		}
1845 2297
 		return '';
1846 2298
 	}
1847 2299
 
@@ -1884,7 +2336,9 @@  discard block
 block discarded – undo
1884 2336
                 }
1885 2337
 
1886 2338
 		$error = '';
1887
-		if ($globalDebug) echo "Notam : Download...";
2339
+		if ($globalDebug) {
2340
+			echo "Notam : Download...";
2341
+		}
1888 2342
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1889 2343
 		if (file_exists($tmp_dir.'notam.rss')) {
1890 2344
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -1899,14 +2353,30 @@  discard block
 block discarded – undo
1899 2353
 				$data['fir'] = $q[0];
1900 2354
 				$data['code'] = $q[1];
1901 2355
 				$ifrvfr = $q[2];
1902
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
1903
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
1904
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
1905
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
1906
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
1907
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
1908
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
1909
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2356
+				if ($ifrvfr == 'IV') {
2357
+					$data['rules'] = 'IFR/VFR';
2358
+				}
2359
+				if ($ifrvfr == 'I') {
2360
+					$data['rules'] = 'IFR';
2361
+				}
2362
+				if ($ifrvfr == 'V') {
2363
+					$data['rules'] = 'VFR';
2364
+				}
2365
+				if ($q[4] == 'A') {
2366
+					$data['scope'] = 'Airport warning';
2367
+				}
2368
+				if ($q[4] == 'E') {
2369
+					$data['scope'] = 'Enroute warning';
2370
+				}
2371
+				if ($q[4] == 'W') {
2372
+					$data['scope'] = 'Navigation warning';
2373
+				}
2374
+				if ($q[4] == 'AE') {
2375
+					$data['scope'] = 'Airport/Enroute warning';
2376
+				}
2377
+				if ($q[4] == 'AW') {
2378
+					$data['scope'] = 'Airport/Navigation warning';
2379
+				}
1910 2380
 				//$data['scope'] = $q[4];
1911 2381
 				$data['lower_limit'] = $q[5];
1912 2382
 				$data['upper_limit'] = $q[6];
@@ -1914,8 +2384,12 @@  discard block
 block discarded – undo
1914 2384
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1915 2385
 				$latitude = $Common->convertDec($las,'latitude');
1916 2386
 				$longitude = $Common->convertDec($lns,'longitude');
1917
-				if ($lac == 'S') $latitude = '-'.$latitude;
1918
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2387
+				if ($lac == 'S') {
2388
+					$latitude = '-'.$latitude;
2389
+				}
2390
+				if ($lnc == 'W') {
2391
+					$longitude = '-'.$longitude;
2392
+				}
1919 2393
 				$data['center_latitude'] = $latitude;
1920 2394
 				$data['center_longitude'] = $longitude;
1921 2395
 				$data['radius'] = intval($radius);
@@ -1945,10 +2419,14 @@  discard block
 block discarded – undo
1945 2419
 				$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']);
1946 2420
 				unset($data);
1947 2421
 			} 
1948
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2422
+		} else {
2423
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2424
+		}
1949 2425
 		if ($error != '') {
1950 2426
 			return $error;
1951
-		} elseif ($globalDebug) echo "Done\n";
2427
+		} elseif ($globalDebug) {
2428
+			echo "Done\n";
2429
+		}
1952 2430
 		return '';
1953 2431
 	}
1954 2432
 	
@@ -1973,7 +2451,9 @@  discard block
 block discarded – undo
1973 2451
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
1974 2452
 		$airspace_json = json_decode($airspace_lst,true);
1975 2453
 		foreach ($airspace_json['records'] as $airspace) {
1976
-			if ($globalDebug) echo $airspace['name']."...\n";
2454
+			if ($globalDebug) {
2455
+				echo $airspace['name']."...\n";
2456
+			}
1977 2457
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
1978 2458
 			if (file_exists($tmp_dir.$airspace['name'])) {
1979 2459
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2002,8 +2482,11 @@  discard block
 block discarded – undo
2002 2482
                         return "error : ".$e->getMessage();
2003 2483
                 }
2004 2484
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2005
-                if ($row['nb'] > 0) return false;
2006
-                else return true;
2485
+                if ($row['nb'] > 0) {
2486
+                	return false;
2487
+                } else {
2488
+                	return true;
2489
+                }
2007 2490
 	}
2008 2491
 
2009 2492
 	public static function insert_last_update() {
@@ -2028,8 +2511,11 @@  discard block
 block discarded – undo
2028 2511
                         return "error : ".$e->getMessage();
2029 2512
                 }
2030 2513
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2031
-                if ($row['nb'] > 0) return true;
2032
-                else return false;
2514
+                if ($row['nb'] > 0) {
2515
+                	return true;
2516
+                } else {
2517
+                	return false;
2518
+                }
2033 2519
 	}
2034 2520
 
2035 2521
 
@@ -2060,8 +2546,11 @@  discard block
 block discarded – undo
2060 2546
                         return "error : ".$e->getMessage();
2061 2547
                 }
2062 2548
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2063
-                if ($row['nb'] > 0) return false;
2064
-                else return true;
2549
+                if ($row['nb'] > 0) {
2550
+                	return false;
2551
+                } else {
2552
+                	return true;
2553
+                }
2065 2554
 	}
2066 2555
 
2067 2556
 	public static function insert_last_notam_update() {
@@ -2090,8 +2579,11 @@  discard block
 block discarded – undo
2090 2579
                         return "error : ".$e->getMessage();
2091 2580
                 }
2092 2581
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2093
-                if ($row['nb'] > 0) return false;
2094
-                else return true;
2582
+                if ($row['nb'] > 0) {
2583
+                	return false;
2584
+                } else {
2585
+                	return true;
2586
+                }
2095 2587
 	}
2096 2588
 
2097 2589
 	public static function insert_last_airspace_update() {
@@ -2121,8 +2613,11 @@  discard block
 block discarded – undo
2121 2613
                         return "error : ".$e->getMessage();
2122 2614
                 }
2123 2615
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2124
-                if ($row['nb'] > 0) return false;
2125
-                else return true;
2616
+                if ($row['nb'] > 0) {
2617
+                	return false;
2618
+                } else {
2619
+                	return true;
2620
+                }
2126 2621
 	}
2127 2622
 
2128 2623
 	public static function insert_last_owner_update() {
@@ -2151,8 +2646,11 @@  discard block
 block discarded – undo
2151 2646
                         return "error : ".$e->getMessage();
2152 2647
                 }
2153 2648
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2154
-                if ($row['nb'] > 0) return false;
2155
-                else return true;
2649
+                if ($row['nb'] > 0) {
2650
+                	return false;
2651
+                } else {
2652
+                	return true;
2653
+                }
2156 2654
 	}
2157 2655
 
2158 2656
 	public static function insert_last_schedules_update() {
@@ -2181,8 +2679,11 @@  discard block
 block discarded – undo
2181 2679
                         return "error : ".$e->getMessage();
2182 2680
                 }
2183 2681
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2184
-                if ($row['nb'] > 0) return false;
2185
-                else return true;
2682
+                if ($row['nb'] > 0) {
2683
+                	return false;
2684
+                } else {
2685
+                	return true;
2686
+                }
2186 2687
 	}
2187 2688
 
2188 2689
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,15 +31,19 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
40
-}
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
46
+	}
41 47
 if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
42 48
 	echo "Check if new airspace version exist...";
43 49
 	echo $update_db->update_airspace_fam();
@@ -52,22 +58,28 @@  discard block
 block discarded – undo
52 58
 	if ($METAR->check_last_update()) {
53 59
 		$METAR->addMETARCycle();
54 60
 		$METAR->insert_last_update();
55
-	} else echo "METAR are only updated every 30 minutes.\n";
56
-}
61
+	} else {
62
+		echo "METAR are only updated every 30 minutes.\n";
63
+	}
64
+	}
57 65
 
58 66
 
59 67
 if (isset($globalOwner) && $globalOwner && $update_db->check_last_owner_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
60 68
 	echo "Updating private aircraft's owners...\n";
61 69
 	$update_db->update_owner();
62 70
 	$update_db->insert_last_owner_update();
63
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
71
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
72
+	echo "Owner are only updated every 15 days.\n";
73
+}
64 74
 
65 75
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
66 76
 	echo "Updating schedules...";
67 77
 	//$update_db->update_oneworld();
68 78
 	$update_db->update_skyteam();
69 79
 	$update_db->insert_last_schedules_update();
70
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
80
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
81
+	echo "Schedules are only updated every 15 days.\n";
82
+}
71 83
 
72 84
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
73 85
 	echo "Updating statistics and archive old data...";
Please login to merge, or discard this patch.