Completed
Push — master ( d44f1f...2285a7 )
by Yannick
09:57
created
install/class.update_db.php 2 patches
Indentation   +405 added lines, -405 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();
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 		try {
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253
-                        $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
255
-                        return "error : ".$e->getMessage();
256
-                }
253
+						$sth->execute(array(':source' => $database_file));
254
+				} catch(PDOException $e) {
255
+						return "error : ".$e->getMessage();
256
+				}
257 257
 		return '';
258 258
 	}
259 259
 
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 		try {
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268
-                        $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
270
-                        return "error : ".$e->getMessage();
271
-                }
268
+						$sth->execute(array(':source' => $database_file));
269
+				} catch(PDOException $e) {
270
+						return "error : ".$e->getMessage();
271
+				}
272 272
 		
273 273
 		if ($fh = fopen($database_file,"r")) {
274 274
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 			$sth_dest = $Connection->db->prepare($query_dest);
279 279
 			try {
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281
-            			while (!feof($fh)) {
282
-            				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
281
+						while (!feof($fh)) {
282
+							$values = array();
283
+							$line = $Common->hex2str(fgets($fh,9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
288
-            				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
-            				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
-            				$sth_search = $Connection->db->prepare($query_search);
285
+							$values['ModeS'] = substr($line,0,6);
286
+							$values['Registration'] = trim(substr($line,69,6));
287
+							$aircraft_name = trim(substr($line,48,6));
288
+							// Check if we can find ICAO, else set it to GLID
289
+							$aircraft_name_split = explode(' ',$aircraft_name);
290
+							$search_more = '';
291
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
+							$sth_search = $Connection->db->prepare($query_search);
294 294
 					try {
295
-                                    		$sth_search->execute();
296
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
-	            				//if (count($result) > 0) {
298
-	            				if (isset($result['icao']) && $result['icao'] != '') {
299
-	            				    $values['ICAOTypeCode'] = $result['icao'];
300
-	            				} 
295
+											$sth_search->execute();
296
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
+								//if (count($result) > 0) {
298
+								if (isset($result['icao']) && $result['icao'] != '') {
299
+									$values['ICAOTypeCode'] = $result['icao'];
300
+								} 
301 301
 					} catch(PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 		try {
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323
-                        $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
325
-                        return "error : ".$e->getMessage();
326
-                }
323
+						$sth->execute(array(':source' => $database_file));
324
+				} catch(PDOException $e) {
325
+						return "error : ".$e->getMessage();
326
+				}
327 327
 		return '';
328 328
 	}
329 329
 
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 		try {
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337
-                        $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
339
-                        return "error : ".$e->getMessage();
340
-                }
337
+						$sth->execute(array(':source' => $database_file));
338
+				} catch(PDOException $e) {
339
+						return "error : ".$e->getMessage();
340
+				}
341 341
 		
342 342
 		if ($fh = fopen($database_file,"r")) {
343 343
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -348,24 +348,24 @@  discard block
 block discarded – undo
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350 350
 				$tmp = fgetcsv($fh,9999,',',"'");
351
-            			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
351
+						while (!feof($fh)) {
352
+							$line = fgetcsv($fh,9999,',',"'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
356
-            				$values['ModeS'] = $line[1];
357
-            				$values['Registration'] = $line[3];
358
-            				$aircraft_name = $line[2];
359
-            				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
361
-            				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
-            				$sth_search = $Connection->db->prepare($query_search);
356
+							$values['ModeS'] = $line[1];
357
+							$values['Registration'] = $line[3];
358
+							$aircraft_name = $line[2];
359
+							// Check if we can find ICAO, else set it to GLID
360
+							$aircraft_name_split = explode(' ',$aircraft_name);
361
+							$search_more = '';
362
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
+							$sth_search = $Connection->db->prepare($query_search);
365 365
 					try {
366
-                                    		$sth_search->execute();
367
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
366
+											$sth_search->execute();
367
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369 369
 					} catch(PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 		try {
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391
-                        $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
393
-                        return "error : ".$e->getMessage();
394
-                }
391
+						$sth->execute(array(':source' => $database_file));
392
+				} catch(PDOException $e) {
393
+						return "error : ".$e->getMessage();
394
+				}
395 395
 		return '';
396 396
 	}
397 397
 
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
 		try {
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405
-                        $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
407
-                        return "error : ".$e->getMessage();
408
-                }
405
+						$sth->execute(array(':source' => $database_file));
406
+				} catch(PDOException $e) {
407
+						return "error : ".$e->getMessage();
408
+				}
409 409
 		
410 410
 		if ($fh = fopen($database_file,"r")) {
411 411
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -416,95 +416,95 @@  discard block
 block discarded – undo
416 416
 			try {
417 417
 				if ($globalTransaction) $Connection->db->beginTransaction();
418 418
 				$tmp = fgetcsv($fh,9999,',','"');
419
-            			while (!feof($fh)) {
420
-            				$line = fgetcsv($fh,9999,',','"');
421
-            				$values = array();
422
-            				//print_r($line);
423
-            				if ($country == 'F') {
424
-            				    $values['registration'] = $line[0];
425
-            				    $values['base'] = $line[4];
426
-            				    $values['owner'] = $line[5];
427
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
429
-					    $values['cancel'] = $line[7];
419
+						while (!feof($fh)) {
420
+							$line = fgetcsv($fh,9999,',','"');
421
+							$values = array();
422
+							//print_r($line);
423
+							if ($country == 'F') {
424
+								$values['registration'] = $line[0];
425
+								$values['base'] = $line[4];
426
+								$values['owner'] = $line[5];
427
+								if ($line[6] == '') $values['date_first_reg'] = null;
428
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
429
+						$values['cancel'] = $line[7];
430 430
 					} elseif ($country == 'EI') {
431
-					    // TODO : add modeS & reg to aircraft_modes
432
-            				    $values['registration'] = $line[0];
433
-            				    $values['base'] = $line[3];
434
-            				    $values['owner'] = $line[2];
435
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
437
-					    $values['cancel'] = '';
431
+						// TODO : add modeS & reg to aircraft_modes
432
+								$values['registration'] = $line[0];
433
+								$values['base'] = $line[3];
434
+								$values['owner'] = $line[2];
435
+								if ($line[1] == '') $values['date_first_reg'] = null;
436
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
437
+						$values['cancel'] = '';
438 438
 					} elseif ($country == 'HB') {
439
-					    // TODO : add modeS & reg to aircraft_modes
440
-            				    $values['registration'] = $line[0];
441
-            				    $values['base'] = null;
442
-            				    $values['owner'] = $line[5];
443
-            				    $values['date_first_reg'] = null;
444
-					    $values['cancel'] = '';
439
+						// TODO : add modeS & reg to aircraft_modes
440
+								$values['registration'] = $line[0];
441
+								$values['base'] = null;
442
+								$values['owner'] = $line[5];
443
+								$values['date_first_reg'] = null;
444
+						$values['cancel'] = '';
445 445
 					} elseif ($country == 'OK') {
446
-					    // TODO : add modeS & reg to aircraft_modes
447
-            				    $values['registration'] = $line[3];
448
-            				    $values['base'] = null;
449
-            				    $values['owner'] = $line[5];
450
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
452
-					    $values['cancel'] = '';
446
+						// TODO : add modeS & reg to aircraft_modes
447
+								$values['registration'] = $line[3];
448
+								$values['base'] = null;
449
+								$values['owner'] = $line[5];
450
+								if ($line[18] == '') $values['date_first_reg'] = null;
451
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
452
+						$values['cancel'] = '';
453 453
 					} elseif ($country == 'VH') {
454
-					    // TODO : add modeS & reg to aircraft_modes
455
-            				    $values['registration'] = $line[0];
456
-            				    $values['base'] = null;
457
-            				    $values['owner'] = $line[12];
458
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
460
-
461
-					    $values['cancel'] = $line[39];
454
+						// TODO : add modeS & reg to aircraft_modes
455
+								$values['registration'] = $line[0];
456
+								$values['base'] = null;
457
+								$values['owner'] = $line[12];
458
+								if ($line[28] == '') $values['date_first_reg'] = null;
459
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
460
+
461
+						$values['cancel'] = $line[39];
462 462
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
463
-            				    $values['registration'] = $line[0];
464
-            				    $values['base'] = null;
465
-            				    $values['owner'] = $line[4];
466
-            				    $values['date_first_reg'] = null;
467
-					    $values['cancel'] = '';
463
+								$values['registration'] = $line[0];
464
+								$values['base'] = null;
465
+								$values['owner'] = $line[4];
466
+								$values['date_first_reg'] = null;
467
+						$values['cancel'] = '';
468 468
 					} elseif ($country == 'CC') {
469
-            				    $values['registration'] = $line[0];
470
-            				    $values['base'] = null;
471
-            				    $values['owner'] = $line[6];
472
-            				    $values['date_first_reg'] = null;
473
-					    $values['cancel'] = '';
469
+								$values['registration'] = $line[0];
470
+								$values['base'] = null;
471
+								$values['owner'] = $line[6];
472
+								$values['date_first_reg'] = null;
473
+						$values['cancel'] = '';
474 474
 					} elseif ($country == 'HJ') {
475
-            				    $values['registration'] = $line[0];
476
-            				    $values['base'] = null;
477
-            				    $values['owner'] = $line[8];
478
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
480
-					    $values['cancel'] = '';
475
+								$values['registration'] = $line[0];
476
+								$values['base'] = null;
477
+								$values['owner'] = $line[8];
478
+								if ($line[7] == '') $values['date_first_reg'] = null;
479
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
480
+						$values['cancel'] = '';
481 481
 					} elseif ($country == 'PP') {
482
-            				    $values['registration'] = $line[0];
483
-            				    $values['base'] = null;
484
-            				    $values['owner'] = $line[4];
485
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
487
-					    $values['cancel'] = $line[7];
482
+								$values['registration'] = $line[0];
483
+								$values['base'] = null;
484
+								$values['owner'] = $line[4];
485
+								if ($line[6] == '') $values['date_first_reg'] = null;
486
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
487
+						$values['cancel'] = $line[7];
488 488
 					} elseif ($country == 'E7') {
489
-            				    $values['registration'] = $line[0];
490
-            				    $values['base'] = null;
491
-            				    $values['owner'] = $line[4];
492
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
494
-					    $values['cancel'] = '';
489
+								$values['registration'] = $line[0];
490
+								$values['base'] = null;
491
+								$values['owner'] = $line[4];
492
+								if ($line[5] == '') $values['date_first_reg'] = null;
493
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
494
+						$values['cancel'] = '';
495 495
 					} elseif ($country == '8Q') {
496
-            				    $values['registration'] = $line[0];
497
-            				    $values['base'] = null;
498
-            				    $values['owner'] = $line[3];
499
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
501
-					    $values['cancel'] = '';
496
+								$values['registration'] = $line[0];
497
+								$values['base'] = null;
498
+								$values['owner'] = $line[3];
499
+								if ($line[7] == '') $values['date_first_reg'] = null;
500
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
501
+						$values['cancel'] = '';
502 502
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503
-            				    $values['registration'] = $line[0];
504
-            				    $values['base'] = null;
505
-            				    $values['owner'] = $line[3];
506
-            				    $values['date_first_reg'] = null;
507
-					    $values['cancel'] = '';
503
+								$values['registration'] = $line[0];
504
+								$values['base'] = null;
505
+								$values['owner'] = $line[3];
506
+								$values['date_first_reg'] = null;
507
+						$values['cancel'] = '';
508 508
 					}
509 509
 					if ($values['cancel'] == '' && $values['registration'] != null) {
510 510
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -626,20 +626,20 @@  discard block
 block discarded – undo
626 626
 		try {
627 627
 			$Connection = new Connection();
628 628
 			$sth = $Connection->db->prepare($query);
629
-                        $sth->execute();
630
-                } catch(PDOException $e) {
631
-                        return "error : ".$e->getMessage();
632
-                }
629
+						$sth->execute();
630
+				} catch(PDOException $e) {
631
+						return "error : ".$e->getMessage();
632
+				}
633 633
 
634 634
 
635 635
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
636 636
 		try {
637 637
 			$Connection = new Connection();
638 638
 			$sth = $Connection->db->prepare($query);
639
-                        $sth->execute();
640
-                } catch(PDOException $e) {
641
-                        return "error : ".$e->getMessage();
642
-                }
639
+						$sth->execute();
640
+				} catch(PDOException $e) {
641
+						return "error : ".$e->getMessage();
642
+				}
643 643
 
644 644
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
645 645
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -705,10 +705,10 @@  discard block
 block discarded – undo
705 705
 		try {
706 706
 			$Connection = new Connection();
707 707
 			$sth = $Connection->db->prepare($query);
708
-                        $sth->execute();
709
-                } catch(PDOException $e) {
710
-                        return "error : ".$e->getMessage();
711
-                }
708
+						$sth->execute();
709
+				} catch(PDOException $e) {
710
+						return "error : ".$e->getMessage();
711
+				}
712 712
 
713 713
 
714 714
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -718,10 +718,10 @@  discard block
 block discarded – undo
718 718
 		try {
719 719
 			$Connection = new Connection();
720 720
 			$sth = $Connection->db->prepare($query);
721
-                        $sth->execute($query_values);
722
-                } catch(PDOException $e) {
723
-                        return "error : ".$e->getMessage();
724
-                }
721
+						$sth->execute($query_values);
722
+				} catch(PDOException $e) {
723
+						return "error : ".$e->getMessage();
724
+				}
725 725
 		$i++;
726 726
 /*
727 727
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 
836 836
 
837 837
 
838
-                return "success";
838
+				return "success";
839 839
 	}
840 840
 	
841 841
 	public static function translation() {
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
 		try {
852 852
 			$Connection = new Connection();
853 853
 			$sth = $Connection->db->prepare($query);
854
-                        $sth->execute(array(':source' => 'translation.csv'));
855
-                } catch(PDOException $e) {
856
-                        return "error : ".$e->getMessage();
857
-                }
854
+						$sth->execute(array(':source' => 'translation.csv'));
855
+				} catch(PDOException $e) {
856
+						return "error : ".$e->getMessage();
857
+				}
858 858
 
859 859
 		
860 860
 		//update_db::unzip($out_file);
@@ -873,21 +873,21 @@  discard block
 block discarded – undo
873 873
 					$data = $row;
874 874
 					$operator = $data[2];
875 875
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
876
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
877
-                                                //echo substr($operator, 0, 2)."\n";;
878
-                                                if (count($airline_array) > 0) {
876
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
877
+												//echo substr($operator, 0, 2)."\n";;
878
+												if (count($airline_array) > 0) {
879 879
 							//print_r($airline_array);
880 880
 							$operator = $airline_array[0]['icao'].substr($operator,2);
881
-                                                }
882
-                                        }
881
+												}
882
+										}
883 883
 					
884 884
 					$operator_correct = $data[3];
885 885
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
886
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887
-                                                if (count($airline_array) > 0) {
888
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
889
-                                            	}
890
-                                        }
886
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887
+												if (count($airline_array) > 0) {
888
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
889
+												}
890
+										}
891 891
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
892 892
 					try {
893 893
 						$sth = $Connection->db->prepare($query);
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 			//$Connection->db->commit();
902 902
 		}
903 903
 		return '';
904
-        }
904
+		}
905 905
 	
906 906
 	public static function translation_fam() {
907 907
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -911,10 +911,10 @@  discard block
 block discarded – undo
911 911
 		try {
912 912
 			$Connection = new Connection();
913 913
 			$sth = $Connection->db->prepare($query);
914
-                        $sth->execute(array(':source' => 'website_fam'));
915
-                } catch(PDOException $e) {
916
-                        return "error : ".$e->getMessage();
917
-                }
914
+						$sth->execute(array(':source' => 'website_fam'));
915
+				} catch(PDOException $e) {
916
+						return "error : ".$e->getMessage();
917
+				}
918 918
 
919 919
 		
920 920
 		//update_db::unzip($out_file);
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 			//$Connection->db->commit();
944 944
 		}
945 945
 		return '';
946
-        }
946
+		}
947 947
 
948 948
 	/*
949 949
 	* This function use FAA public data.
@@ -955,19 +955,19 @@  discard block
 block discarded – undo
955 955
 		try {
956 956
 			$Connection = new Connection();
957 957
 			$sth = $Connection->db->prepare($query);
958
-                        $sth->execute(array(':source' => 'website_faa'));
959
-                } catch(PDOException $e) {
960
-                        return "error : ".$e->getMessage();
961
-                }
958
+						$sth->execute(array(':source' => 'website_faa'));
959
+				} catch(PDOException $e) {
960
+						return "error : ".$e->getMessage();
961
+				}
962 962
 
963 963
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
964 964
 		try {
965 965
 			$Connection = new Connection();
966 966
 			$sth = $Connection->db->prepare($query);
967
-                        $sth->execute(array(':source' => 'website_faa'));
968
-                } catch(PDOException $e) {
969
-                        return "error : ".$e->getMessage();
970
-                }
967
+						$sth->execute(array(':source' => 'website_faa'));
968
+				} catch(PDOException $e) {
969
+						return "error : ".$e->getMessage();
970
+				}
971 971
 
972 972
 		$delimiter = ",";
973 973
 		$mfr = array();
@@ -1043,17 +1043,17 @@  discard block
 block discarded – undo
1043 1043
 		}
1044 1044
 		print_r($mfr);
1045 1045
 		return '';
1046
-        }
1046
+		}
1047 1047
 	public static function modes_fam() {
1048 1048
 		global $tmp_dir, $globalTransaction;
1049 1049
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1050 1050
 		try {
1051 1051
 			$Connection = new Connection();
1052 1052
 			$sth = $Connection->db->prepare($query);
1053
-                        $sth->execute(array(':source' => 'website_fam'));
1054
-                } catch(PDOException $e) {
1055
-                        return "error : ".$e->getMessage();
1056
-                }
1053
+						$sth->execute(array(':source' => 'website_fam'));
1054
+				} catch(PDOException $e) {
1055
+						return "error : ".$e->getMessage();
1056
+				}
1057 1057
 
1058 1058
 		
1059 1059
 		//update_db::unzip($out_file);
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 			if ($globalTransaction) $Connection->db->commit();
1083 1083
 		}
1084 1084
 		return '';
1085
-        }
1085
+		}
1086 1086
         
1087 1087
 	public static function owner_fam() {
1088 1088
 		global $tmp_dir, $globalTransaction;
@@ -1090,10 +1090,10 @@  discard block
 block discarded – undo
1090 1090
 		try {
1091 1091
 			$Connection = new Connection();
1092 1092
 			$sth = $Connection->db->prepare($query);
1093
-                        $sth->execute(array(':source' => 'website_fam'));
1094
-                } catch(PDOException $e) {
1095
-                        return "error : ".$e->getMessage();
1096
-                }
1093
+						$sth->execute(array(':source' => 'website_fam'));
1094
+				} catch(PDOException $e) {
1095
+						return "error : ".$e->getMessage();
1096
+				}
1097 1097
 
1098 1098
 		$delimiter = "\t";
1099 1099
 		$Connection = new Connection();
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 			if ($globalTransaction) $Connection->db->commit();
1120 1120
 		}
1121 1121
 		return '';
1122
-        }
1122
+		}
1123 1123
 
1124 1124
 	public static function routes_fam() {
1125 1125
 		global $tmp_dir, $globalTransaction;
@@ -1127,10 +1127,10 @@  discard block
 block discarded – undo
1127 1127
 		try {
1128 1128
 			$Connection = new Connection();
1129 1129
 			$sth = $Connection->db->prepare($query);
1130
-                        $sth->execute(array(':source' => 'website_fam'));
1131
-                } catch(PDOException $e) {
1132
-                        return "error : ".$e->getMessage();
1133
-                }
1130
+						$sth->execute(array(':source' => 'website_fam'));
1131
+				} catch(PDOException $e) {
1132
+						return "error : ".$e->getMessage();
1133
+				}
1134 1134
 
1135 1135
 		
1136 1136
 		//update_db::unzip($out_file);
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 			if ($globalTransaction) $Connection->db->commit();
1160 1160
 		}
1161 1161
 		return '';
1162
-        }
1162
+		}
1163 1163
 
1164 1164
 	public static function banned_fam() {
1165 1165
 		global $tmp_dir, $globalTransaction;
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 			if ($globalTransaction) $Connection->db->commit();
1194 1194
 		}
1195 1195
 		return '';
1196
-        }
1196
+		}
1197 1197
 
1198 1198
 	public static function tle($filename,$tletype) {
1199 1199
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1204,10 +1204,10 @@  discard block
 block discarded – undo
1204 1204
 		try {
1205 1205
 			$Connection = new Connection();
1206 1206
 			$sth = $Connection->db->prepare($query);
1207
-                        $sth->execute(array(':source' => $filename));
1208
-                } catch(PDOException $e) {
1209
-                        return "error : ".$e->getMessage();
1210
-                }
1207
+						$sth->execute(array(':source' => $filename));
1208
+				} catch(PDOException $e) {
1209
+						return "error : ".$e->getMessage();
1210
+				}
1211 1211
 		
1212 1212
 		$Connection = new Connection();
1213 1213
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1242,54 +1242,54 @@  discard block
 block discarded – undo
1242 1242
 			//$Connection->db->commit();
1243 1243
 		}
1244 1244
 		return '';
1245
-        }
1245
+		}
1246 1246
 
1247 1247
 	/**
1248
-        * Convert a HTML table to an array
1249
-        * @param String $data HTML page
1250
-        * @return Array array of the tables in HTML page
1251
-        */
1252
-        private static function table2array($data) {
1253
-                $html = str_get_html($data);
1254
-                $tabledata=array();
1255
-                foreach($html->find('tr') as $element)
1256
-                {
1257
-                        $td = array();
1258
-                        foreach( $element->find('th') as $row)
1259
-                        {
1260
-                                $td [] = trim($row->plaintext);
1261
-                        }
1262
-                        $td=array_filter($td);
1263
-                        $tabledata[] = $td;
1264
-
1265
-                        $td = array();
1266
-                        $tdi = array();
1267
-                        foreach( $element->find('td') as $row)
1268
-                        {
1269
-                                $td [] = trim($row->plaintext);
1270
-                                $tdi [] = trim($row->innertext);
1271
-                        }
1272
-                        $td=array_filter($td);
1273
-                        $tdi=array_filter($tdi);
1274
-                    //    $tabledata[]=array_merge($td,$tdi);
1275
-                        $tabledata[]=$td;
1276
-                }
1277
-                return(array_filter($tabledata));
1278
-        }
1279
-
1280
-       /**
1281
-        * Get data from form result
1282
-        * @param String $url form URL
1283
-        * @return String the result
1284
-        */
1285
-        private static function getData($url) {
1286
-                $ch = curl_init();
1287
-                curl_setopt($ch, CURLOPT_URL, $url);
1288
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1289
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1290
-                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');
1291
-                return curl_exec($ch);
1292
-        }
1248
+	 * Convert a HTML table to an array
1249
+	 * @param String $data HTML page
1250
+	 * @return Array array of the tables in HTML page
1251
+	 */
1252
+		private static function table2array($data) {
1253
+				$html = str_get_html($data);
1254
+				$tabledata=array();
1255
+				foreach($html->find('tr') as $element)
1256
+				{
1257
+						$td = array();
1258
+						foreach( $element->find('th') as $row)
1259
+						{
1260
+								$td [] = trim($row->plaintext);
1261
+						}
1262
+						$td=array_filter($td);
1263
+						$tabledata[] = $td;
1264
+
1265
+						$td = array();
1266
+						$tdi = array();
1267
+						foreach( $element->find('td') as $row)
1268
+						{
1269
+								$td [] = trim($row->plaintext);
1270
+								$tdi [] = trim($row->innertext);
1271
+						}
1272
+						$td=array_filter($td);
1273
+						$tdi=array_filter($tdi);
1274
+					//    $tabledata[]=array_merge($td,$tdi);
1275
+						$tabledata[]=$td;
1276
+				}
1277
+				return(array_filter($tabledata));
1278
+		}
1279
+
1280
+	   /**
1281
+	    * Get data from form result
1282
+	    * @param String $url form URL
1283
+	    * @return String the result
1284
+	    */
1285
+		private static function getData($url) {
1286
+				$ch = curl_init();
1287
+				curl_setopt($ch, CURLOPT_URL, $url);
1288
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1289
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1290
+				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');
1291
+				return curl_exec($ch);
1292
+		}
1293 1293
 /*
1294 1294
 	public static function waypoints() {
1295 1295
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
 			if ($globalTransaction) $Connection->db->commit();
1373 1373
 		}
1374 1374
 		return '';
1375
-        }
1375
+		}
1376 1376
 
1377 1377
 	public static function ivao_airlines($filename) {
1378 1378
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1382,10 +1382,10 @@  discard block
 block discarded – undo
1382 1382
 		try {
1383 1383
 			$Connection = new Connection();
1384 1384
 			$sth = $Connection->db->prepare($query);
1385
-                        $sth->execute();
1386
-                } catch(PDOException $e) {
1387
-                        return "error : ".$e->getMessage();
1388
-                }
1385
+						$sth->execute();
1386
+				} catch(PDOException $e) {
1387
+						return "error : ".$e->getMessage();
1388
+				}
1389 1389
 
1390 1390
 		$header = NULL;
1391 1391
 		$delimiter = ':';
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 			if ($globalTransaction) $Connection->db->commit();
1410 1410
 		}
1411 1411
 		return '';
1412
-        }
1412
+		}
1413 1413
 	
1414 1414
 	public static function update_airspace() {
1415 1415
 		global $tmp_dir, $globalDBdriver;
@@ -1419,11 +1419,11 @@  discard block
 block discarded – undo
1419 1419
 			$query = 'DROP TABLE airspace';
1420 1420
 			try {
1421 1421
 				$sth = $Connection->db->prepare($query);
1422
-                    		$sth->execute();
1423
-	                } catch(PDOException $e) {
1422
+							$sth->execute();
1423
+					} catch(PDOException $e) {
1424 1424
 				return "error : ".$e->getMessage();
1425
-	                }
1426
-	        }
1425
+					}
1426
+			}
1427 1427
 
1428 1428
 
1429 1429
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1478,10 +1478,10 @@  discard block
 block discarded – undo
1478 1478
 			$query = 'DROP TABLE countries';
1479 1479
 			try {
1480 1480
 				$sth = $Connection->db->prepare($query);
1481
-            	        	$sth->execute();
1482
-	                } catch(PDOException $e) {
1483
-    	                	echo "error : ".$e->getMessage();
1484
-	                }
1481
+							$sth->execute();
1482
+					} catch(PDOException $e) {
1483
+							echo "error : ".$e->getMessage();
1484
+					}
1485 1485
 		}
1486 1486
 		if ($globalDBdriver == 'mysql') {
1487 1487
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -1956,11 +1956,11 @@  discard block
 block discarded – undo
1956 1956
 						$query = 'DROP TABLE airspace';
1957 1957
 						try {
1958 1958
 							$sth = $Connection->db->prepare($query);
1959
-    	    	    					$sth->execute();
1960
-			            		} catch(PDOException $e) {
1959
+										$sth->execute();
1960
+								} catch(PDOException $e) {
1961 1961
 							return "error : ".$e->getMessage();
1962
-		            			}
1963
-		    			}
1962
+								}
1963
+						}
1964 1964
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1965 1965
 					update_db::insert_airspace_version($airspace_md5);
1966 1966
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2080,12 +2080,12 @@  discard block
 block discarded – undo
2080 2080
 		echo $data;
2081 2081
 		*/
2082 2082
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2083
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2084
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2085
-		    $result = fread($fh,100000000);
2086
-		    //echo $result;
2087
-		    //var_dump(str_get_html($result));
2088
-		    //print_r(self::table2array($result));
2083
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2084
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2085
+			$result = fread($fh,100000000);
2086
+			//echo $result;
2087
+			//var_dump(str_get_html($result));
2088
+			//print_r(self::table2array($result));
2089 2089
 		}
2090 2090
 
2091 2091
 	}
@@ -2099,10 +2099,10 @@  discard block
 block discarded – undo
2099 2099
 		try {
2100 2100
 			$Connection = new Connection();
2101 2101
 			$sth = $Connection->db->prepare($query);
2102
-                        $sth->execute();
2103
-                } catch(PDOException $e) {
2104
-                        return "error : ".$e->getMessage();
2105
-                }
2102
+						$sth->execute();
2103
+				} catch(PDOException $e) {
2104
+						return "error : ".$e->getMessage();
2105
+				}
2106 2106
 
2107 2107
 		$error = '';
2108 2108
 		if ($globalDebug) echo "Notam : Download...";
@@ -2158,8 +2158,8 @@  discard block
 block discarded – undo
2158 2158
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2159 2159
 					$data['permanent'] = 0;
2160 2160
 				} else {
2161
-				    $data['date_end'] = NULL;
2162
-				    $data['permanent'] = 1;
2161
+					$data['date_end'] = NULL;
2162
+					$data['permanent'] = 1;
2163 2163
 				}
2164 2164
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2165 2165
 				$NOTAM = new NOTAM();
@@ -2218,13 +2218,13 @@  discard block
 block discarded – undo
2218 2218
 		try {
2219 2219
 			$Connection = new Connection();
2220 2220
 			$sth = $Connection->db->prepare($query);
2221
-                        $sth->execute();
2222
-                } catch(PDOException $e) {
2223
-                        return "error : ".$e->getMessage();
2224
-                }
2225
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2226
-                if ($row['nb'] > 0) return false;
2227
-                else return true;
2221
+						$sth->execute();
2222
+				} catch(PDOException $e) {
2223
+						return "error : ".$e->getMessage();
2224
+				}
2225
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2226
+				if ($row['nb'] > 0) return false;
2227
+				else return true;
2228 2228
 	}
2229 2229
 
2230 2230
 	public static function insert_last_update() {
@@ -2233,10 +2233,10 @@  discard block
 block discarded – undo
2233 2233
 		try {
2234 2234
 			$Connection = new Connection();
2235 2235
 			$sth = $Connection->db->prepare($query);
2236
-                        $sth->execute();
2237
-                } catch(PDOException $e) {
2238
-                        return "error : ".$e->getMessage();
2239
-                }
2236
+						$sth->execute();
2237
+				} catch(PDOException $e) {
2238
+						return "error : ".$e->getMessage();
2239
+				}
2240 2240
 	}
2241 2241
 
2242 2242
 	public static function check_airspace_version($version) {
@@ -2244,13 +2244,13 @@  discard block
 block discarded – undo
2244 2244
 		try {
2245 2245
 			$Connection = new Connection();
2246 2246
 			$sth = $Connection->db->prepare($query);
2247
-                        $sth->execute(array(':version' => $version));
2248
-                } catch(PDOException $e) {
2249
-                        return "error : ".$e->getMessage();
2250
-                }
2251
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2252
-                if ($row['nb'] > 0) return true;
2253
-                else return false;
2247
+						$sth->execute(array(':version' => $version));
2248
+				} catch(PDOException $e) {
2249
+						return "error : ".$e->getMessage();
2250
+				}
2251
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2252
+				if ($row['nb'] > 0) return true;
2253
+				else return false;
2254 2254
 	}
2255 2255
 
2256 2256
 
@@ -2260,10 +2260,10 @@  discard block
 block discarded – undo
2260 2260
 		try {
2261 2261
 			$Connection = new Connection();
2262 2262
 			$sth = $Connection->db->prepare($query);
2263
-                        $sth->execute(array(':version' => $version));
2264
-                } catch(PDOException $e) {
2265
-                        return "error : ".$e->getMessage();
2266
-                }
2263
+						$sth->execute(array(':version' => $version));
2264
+				} catch(PDOException $e) {
2265
+						return "error : ".$e->getMessage();
2266
+				}
2267 2267
 	}
2268 2268
 
2269 2269
 	public static function check_last_notam_update() {
@@ -2276,13 +2276,13 @@  discard block
 block discarded – undo
2276 2276
 		try {
2277 2277
 			$Connection = new Connection();
2278 2278
 			$sth = $Connection->db->prepare($query);
2279
-                        $sth->execute();
2280
-                } catch(PDOException $e) {
2281
-                        return "error : ".$e->getMessage();
2282
-                }
2283
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2284
-                if ($row['nb'] > 0) return false;
2285
-                else return true;
2279
+						$sth->execute();
2280
+				} catch(PDOException $e) {
2281
+						return "error : ".$e->getMessage();
2282
+				}
2283
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2284
+				if ($row['nb'] > 0) return false;
2285
+				else return true;
2286 2286
 	}
2287 2287
 
2288 2288
 	public static function insert_last_notam_update() {
@@ -2291,10 +2291,10 @@  discard block
 block discarded – undo
2291 2291
 		try {
2292 2292
 			$Connection = new Connection();
2293 2293
 			$sth = $Connection->db->prepare($query);
2294
-                        $sth->execute();
2295
-                } catch(PDOException $e) {
2296
-                        return "error : ".$e->getMessage();
2297
-                }
2294
+						$sth->execute();
2295
+				} catch(PDOException $e) {
2296
+						return "error : ".$e->getMessage();
2297
+				}
2298 2298
 	}
2299 2299
 	public static function check_last_airspace_update() {
2300 2300
 		global $globalDBdriver;
@@ -2306,13 +2306,13 @@  discard block
 block discarded – undo
2306 2306
 		try {
2307 2307
 			$Connection = new Connection();
2308 2308
 			$sth = $Connection->db->prepare($query);
2309
-                        $sth->execute();
2310
-                } catch(PDOException $e) {
2311
-                        return "error : ".$e->getMessage();
2312
-                }
2313
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2314
-                if ($row['nb'] > 0) return false;
2315
-                else return true;
2309
+						$sth->execute();
2310
+				} catch(PDOException $e) {
2311
+						return "error : ".$e->getMessage();
2312
+				}
2313
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2314
+				if ($row['nb'] > 0) return false;
2315
+				else return true;
2316 2316
 	}
2317 2317
 
2318 2318
 	public static function insert_last_airspace_update() {
@@ -2321,10 +2321,10 @@  discard block
 block discarded – undo
2321 2321
 		try {
2322 2322
 			$Connection = new Connection();
2323 2323
 			$sth = $Connection->db->prepare($query);
2324
-                        $sth->execute();
2325
-                } catch(PDOException $e) {
2326
-                        return "error : ".$e->getMessage();
2327
-                }
2324
+						$sth->execute();
2325
+				} catch(PDOException $e) {
2326
+						return "error : ".$e->getMessage();
2327
+				}
2328 2328
 	}
2329 2329
 
2330 2330
 	public static function check_last_owner_update() {
@@ -2337,13 +2337,13 @@  discard block
 block discarded – undo
2337 2337
 		try {
2338 2338
 			$Connection = new Connection();
2339 2339
 			$sth = $Connection->db->prepare($query);
2340
-                        $sth->execute();
2341
-                } catch(PDOException $e) {
2342
-                        return "error : ".$e->getMessage();
2343
-                }
2344
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2345
-                if ($row['nb'] > 0) return false;
2346
-                else return true;
2340
+						$sth->execute();
2341
+				} catch(PDOException $e) {
2342
+						return "error : ".$e->getMessage();
2343
+				}
2344
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2345
+				if ($row['nb'] > 0) return false;
2346
+				else return true;
2347 2347
 	}
2348 2348
 
2349 2349
 	public static function insert_last_owner_update() {
@@ -2352,10 +2352,10 @@  discard block
 block discarded – undo
2352 2352
 		try {
2353 2353
 			$Connection = new Connection();
2354 2354
 			$sth = $Connection->db->prepare($query);
2355
-                        $sth->execute();
2356
-                } catch(PDOException $e) {
2357
-                        return "error : ".$e->getMessage();
2358
-                }
2355
+						$sth->execute();
2356
+				} catch(PDOException $e) {
2357
+						return "error : ".$e->getMessage();
2358
+				}
2359 2359
 	}
2360 2360
 	public static function check_last_schedules_update() {
2361 2361
 		global $globalDBdriver;
@@ -2367,13 +2367,13 @@  discard block
 block discarded – undo
2367 2367
 		try {
2368 2368
 			$Connection = new Connection();
2369 2369
 			$sth = $Connection->db->prepare($query);
2370
-                        $sth->execute();
2371
-                } catch(PDOException $e) {
2372
-                        return "error : ".$e->getMessage();
2373
-                }
2374
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2375
-                if ($row['nb'] > 0) return false;
2376
-                else return true;
2370
+						$sth->execute();
2371
+				} catch(PDOException $e) {
2372
+						return "error : ".$e->getMessage();
2373
+				}
2374
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2375
+				if ($row['nb'] > 0) return false;
2376
+				else return true;
2377 2377
 	}
2378 2378
 
2379 2379
 	public static function insert_last_schedules_update() {
@@ -2382,10 +2382,10 @@  discard block
 block discarded – undo
2382 2382
 		try {
2383 2383
 			$Connection = new Connection();
2384 2384
 			$sth = $Connection->db->prepare($query);
2385
-                        $sth->execute();
2386
-                } catch(PDOException $e) {
2387
-                        return "error : ".$e->getMessage();
2388
-                }
2385
+						$sth->execute();
2386
+				} catch(PDOException $e) {
2387
+						return "error : ".$e->getMessage();
2388
+				}
2389 2389
 	}
2390 2390
 	public static function check_last_tle_update() {
2391 2391
 		global $globalDBdriver;
@@ -2397,13 +2397,13 @@  discard block
 block discarded – undo
2397 2397
 		try {
2398 2398
 			$Connection = new Connection();
2399 2399
 			$sth = $Connection->db->prepare($query);
2400
-                        $sth->execute();
2401
-                } catch(PDOException $e) {
2402
-                        return "error : ".$e->getMessage();
2403
-                }
2404
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2405
-                if ($row['nb'] > 0) return false;
2406
-                else return true;
2400
+						$sth->execute();
2401
+				} catch(PDOException $e) {
2402
+						return "error : ".$e->getMessage();
2403
+				}
2404
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2405
+				if ($row['nb'] > 0) return false;
2406
+				else return true;
2407 2407
 	}
2408 2408
 
2409 2409
 	public static function insert_last_tle_update() {
@@ -2412,10 +2412,10 @@  discard block
 block discarded – undo
2412 2412
 		try {
2413 2413
 			$Connection = new Connection();
2414 2414
 			$sth = $Connection->db->prepare($query);
2415
-                        $sth->execute();
2416
-                } catch(PDOException $e) {
2417
-                        return "error : ".$e->getMessage();
2418
-                }
2415
+						$sth->execute();
2416
+				} catch(PDOException $e) {
2417
+						return "error : ".$e->getMessage();
2418
+				}
2419 2419
 	}
2420 2420
 	public static function delete_duplicatemodes() {
2421 2421
 		global $globalDBdriver;
@@ -2427,10 +2427,10 @@  discard block
 block discarded – undo
2427 2427
 		try {
2428 2428
 			$Connection = new Connection();
2429 2429
 			$sth = $Connection->db->prepare($query);
2430
-                        $sth->execute();
2431
-                } catch(PDOException $e) {
2432
-                        return "error : ".$e->getMessage();
2433
-                }
2430
+						$sth->execute();
2431
+				} catch(PDOException $e) {
2432
+						return "error : ".$e->getMessage();
2433
+				}
2434 2434
 	}
2435 2435
 	public static function delete_duplicateowner() {
2436 2436
 		global $globalDBdriver;
@@ -2442,10 +2442,10 @@  discard block
 block discarded – undo
2442 2442
 		try {
2443 2443
 			$Connection = new Connection();
2444 2444
 			$sth = $Connection->db->prepare($query);
2445
-                        $sth->execute();
2446
-                } catch(PDOException $e) {
2447
-                        return "error : ".$e->getMessage();
2448
-                }
2445
+						$sth->execute();
2446
+				} catch(PDOException $e) {
2447
+						return "error : ".$e->getMessage();
2448
+				}
2449 2449
 	}
2450 2450
 	
2451 2451
 	public static function update_all() {
Please login to merge, or discard this patch.
Braces   +846 added lines, -293 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 100
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 117
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -277,7 +324,9 @@  discard block
 block discarded – undo
277 324
 			$Connection = new Connection();
278 325
 			$sth_dest = $Connection->db->prepare($query_dest);
279 326
 			try {
280
-				if ($globalTransaction) $Connection->db->beginTransaction();
327
+				if ($globalTransaction) {
328
+					$Connection->db->beginTransaction();
329
+				}
281 330
             			while (!feof($fh)) {
282 331
             				$values = array();
283 332
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -288,7 +337,9 @@  discard block
 block discarded – undo
288 337
             				// Check if we can find ICAO, else set it to GLID
289 338
             				$aircraft_name_split = explode(' ',$aircraft_name);
290 339
             				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
340
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
341
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
342
+            				}
292 343
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293 344
             				$sth_search = $Connection->db->prepare($query_search);
294 345
 					try {
@@ -301,7 +352,9 @@  discard block
 block discarded – undo
301 352
 					} catch(PDOException $e) {
302 353
 						return "error : ".$e->getMessage();
303 354
 					}
304
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
355
+					if (!isset($values['ICAOTypeCode'])) {
356
+						$values['ICAOTypeCode'] = 'GLID';
357
+					}
305 358
 					// Add data to db
306 359
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 360
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -310,7 +363,9 @@  discard block
 block discarded – undo
310 363
 						$sth_dest->execute($query_dest_values);
311 364
 					}
312 365
 				}
313
-				if ($globalTransaction) $Connection->db->commit();
366
+				if ($globalTransaction) {
367
+					$Connection->db->commit();
368
+				}
314 369
 			} catch(PDOException $e) {
315 370
 				return "error : ".$e->getMessage();
316 371
 			}
@@ -346,7 +401,9 @@  discard block
 block discarded – undo
346 401
 			$Connection = new Connection();
347 402
 			$sth_dest = $Connection->db->prepare($query_dest);
348 403
 			try {
349
-				if ($globalTransaction) $Connection->db->beginTransaction();
404
+				if ($globalTransaction) {
405
+					$Connection->db->beginTransaction();
406
+				}
350 407
 				$tmp = fgetcsv($fh,9999,',',"'");
351 408
             			while (!feof($fh)) {
352 409
             				$line = fgetcsv($fh,9999,',',"'");
@@ -359,13 +416,17 @@  discard block
 block discarded – undo
359 416
             				// Check if we can find ICAO, else set it to GLID
360 417
             				$aircraft_name_split = explode(' ',$aircraft_name);
361 418
             				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
419
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
420
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				}
363 422
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364 423
             				$sth_search = $Connection->db->prepare($query_search);
365 424
 					try {
366 425
                                     		$sth_search->execute();
367 426
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
427
+	            				if (isset($result['icao']) && $result['icao'] != '') {
428
+	            					$values['ICAOTypeCode'] = $result['icao'];
429
+	            				}
369 430
 					} catch(PDOException $e) {
370 431
 						return "error : ".$e->getMessage();
371 432
 					}
@@ -378,7 +439,9 @@  discard block
 block discarded – undo
378 439
 						$sth_dest->execute($query_dest_values);
379 440
 					}
380 441
 				}
381
-				if ($globalTransaction) $Connection->db->commit();
442
+				if ($globalTransaction) {
443
+					$Connection->db->commit();
444
+				}
382 445
 			} catch(PDOException $e) {
383 446
 				return "error : ".$e->getMessage();
384 447
 			}
@@ -414,7 +477,9 @@  discard block
 block discarded – undo
414 477
 			$Connection = new Connection();
415 478
 			$sth_dest = $Connection->db->prepare($query_dest);
416 479
 			try {
417
-				if ($globalTransaction) $Connection->db->beginTransaction();
480
+				if ($globalTransaction) {
481
+					$Connection->db->beginTransaction();
482
+				}
418 483
 				$tmp = fgetcsv($fh,9999,',','"');
419 484
             			while (!feof($fh)) {
420 485
             				$line = fgetcsv($fh,9999,',','"');
@@ -424,16 +489,22 @@  discard block
 block discarded – undo
424 489
             				    $values['registration'] = $line[0];
425 490
             				    $values['base'] = $line[4];
426 491
             				    $values['owner'] = $line[5];
427
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
492
+            				    if ($line[6] == '') {
493
+            				    	$values['date_first_reg'] = null;
494
+            				    } else {
495
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    }
429 497
 					    $values['cancel'] = $line[7];
430 498
 					} elseif ($country == 'EI') {
431 499
 					    // TODO : add modeS & reg to aircraft_modes
432 500
             				    $values['registration'] = $line[0];
433 501
             				    $values['base'] = $line[3];
434 502
             				    $values['owner'] = $line[2];
435
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
503
+            				    if ($line[1] == '') {
504
+            				    	$values['date_first_reg'] = null;
505
+            				    } else {
506
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
507
+					    }
437 508
 					    $values['cancel'] = '';
438 509
 					} elseif ($country == 'HB') {
439 510
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,16 +518,22 @@  discard block
 block discarded – undo
447 518
             				    $values['registration'] = $line[3];
448 519
             				    $values['base'] = null;
449 520
             				    $values['owner'] = $line[5];
450
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
521
+            				    if ($line[18] == '') {
522
+            				    	$values['date_first_reg'] = null;
523
+            				    } else {
524
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
525
+					    }
452 526
 					    $values['cancel'] = '';
453 527
 					} elseif ($country == 'VH') {
454 528
 					    // TODO : add modeS & reg to aircraft_modes
455 529
             				    $values['registration'] = $line[0];
456 530
             				    $values['base'] = null;
457 531
             				    $values['owner'] = $line[12];
458
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
532
+            				    if ($line[28] == '') {
533
+            				    	$values['date_first_reg'] = null;
534
+            				    } else {
535
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
536
+					    }
460 537
 
461 538
 					    $values['cancel'] = $line[39];
462 539
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -475,29 +552,41 @@  discard block
 block discarded – undo
475 552
             				    $values['registration'] = $line[0];
476 553
             				    $values['base'] = null;
477 554
             				    $values['owner'] = $line[8];
478
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
555
+            				    if ($line[7] == '') {
556
+            				    	$values['date_first_reg'] = null;
557
+            				    } else {
558
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
559
+					    }
480 560
 					    $values['cancel'] = '';
481 561
 					} elseif ($country == 'PP') {
482 562
             				    $values['registration'] = $line[0];
483 563
             				    $values['base'] = null;
484 564
             				    $values['owner'] = $line[4];
485
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
565
+            				    if ($line[6] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
569
+					    }
487 570
 					    $values['cancel'] = $line[7];
488 571
 					} elseif ($country == 'E7') {
489 572
             				    $values['registration'] = $line[0];
490 573
             				    $values['base'] = null;
491 574
             				    $values['owner'] = $line[4];
492
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
575
+            				    if ($line[5] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
579
+					    }
494 580
 					    $values['cancel'] = '';
495 581
 					} elseif ($country == '8Q') {
496 582
             				    $values['registration'] = $line[0];
497 583
             				    $values['base'] = null;
498 584
             				    $values['owner'] = $line[3];
499
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
585
+            				    if ($line[7] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
589
+					    }
501 590
 					    $values['cancel'] = '';
502 591
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503 592
             				    $values['registration'] = $line[0];
@@ -511,7 +600,9 @@  discard block
 block discarded – undo
511 600
 						$sth_dest->execute($query_dest_values);
512 601
 					}
513 602
 				}
514
-				if ($globalTransaction) $Connection->db->commit();
603
+				if ($globalTransaction) {
604
+					$Connection->db->commit();
605
+				}
515 606
 			} catch(PDOException $e) {
516 607
 				return "error : ".$e->getMessage();
517 608
 			}
@@ -645,25 +736,45 @@  discard block
 block discarded – undo
645 736
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
646 737
 		$Connection = new Connection();
647 738
 		$sth_dest = $Connection->db->prepare($query_dest);
648
-		if ($globalTransaction) $Connection->db->beginTransaction();
739
+		if ($globalTransaction) {
740
+			$Connection->db->beginTransaction();
741
+		}
649 742
   
650 743
 		$i = 0;
651 744
 		while($row = sparql_fetch_array($result))
652 745
 		{
653 746
 			if ($i >= 1) {
654 747
 			//print_r($row);
655
-			if (!isset($row['iata'])) $row['iata'] = '';
656
-			if (!isset($row['icao'])) $row['icao'] = '';
657
-			if (!isset($row['type'])) $row['type'] = '';
658
-			if (!isset($row['altitude'])) $row['altitude'] = '';
748
+			if (!isset($row['iata'])) {
749
+				$row['iata'] = '';
750
+			}
751
+			if (!isset($row['icao'])) {
752
+				$row['icao'] = '';
753
+			}
754
+			if (!isset($row['type'])) {
755
+				$row['type'] = '';
756
+			}
757
+			if (!isset($row['altitude'])) {
758
+				$row['altitude'] = '';
759
+			}
659 760
 			if (isset($row['city_bis'])) {
660 761
 				$row['city'] = $row['city_bis'];
661 762
 			}
662
-			if (!isset($row['city'])) $row['city'] = '';
663
-			if (!isset($row['country'])) $row['country'] = '';
664
-			if (!isset($row['homepage'])) $row['homepage'] = '';
665
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
666
-			if (!isset($row['name'])) continue;
763
+			if (!isset($row['city'])) {
764
+				$row['city'] = '';
765
+			}
766
+			if (!isset($row['country'])) {
767
+				$row['country'] = '';
768
+			}
769
+			if (!isset($row['homepage'])) {
770
+				$row['homepage'] = '';
771
+			}
772
+			if (!isset($row['wikipedia_page'])) {
773
+				$row['wikipedia_page'] = '';
774
+			}
775
+			if (!isset($row['name'])) {
776
+				continue;
777
+			}
667 778
 			if (!isset($row['image'])) {
668 779
 				$row['image'] = '';
669 780
 				$row['image_thumb'] = '';
@@ -699,7 +810,9 @@  discard block
 block discarded – undo
699 810
 
700 811
 			$i++;
701 812
 		}
702
-		if ($globalTransaction) $Connection->db->commit();
813
+		if ($globalTransaction) {
814
+			$Connection->db->commit();
815
+		}
703 816
 		echo "Delete duplicate rows...\n";
704 817
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
705 818
 		try {
@@ -711,7 +824,9 @@  discard block
 block discarded – undo
711 824
                 }
712 825
 
713 826
 
714
-		if ($globalDebug) echo "Insert Not available Airport...\n";
827
+		if ($globalDebug) {
828
+			echo "Insert Not available Airport...\n";
829
+		}
715 830
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
716 831
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
717 832
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -738,7 +853,9 @@  discard block
 block discarded – undo
738 853
 		$delimiter = ',';
739 854
 		$out_file = $tmp_dir.'airports.csv';
740 855
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
741
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
856
+		if (!file_exists($out_file) || !is_readable($out_file)) {
857
+			return FALSE;
858
+		}
742 859
 		echo "Add data from ourairports.com...\n";
743 860
 
744 861
 		$header = NULL;
@@ -748,8 +865,9 @@  discard block
 block discarded – undo
748 865
 			//$Connection->db->beginTransaction();
749 866
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
750 867
 			{
751
-				if(!$header) $header = $row;
752
-				else {
868
+				if(!$header) {
869
+					$header = $row;
870
+				} else {
753 871
 					$data = array();
754 872
 					$data = array_combine($header, $row);
755 873
 					try {
@@ -787,7 +905,9 @@  discard block
 block discarded – undo
787 905
 		echo "Download data from another free database...\n";
788 906
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
789 907
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
790
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
908
+		if (!file_exists($out_file) || !is_readable($out_file)) {
909
+			return FALSE;
910
+		}
791 911
 		update_db::unzip($out_file);
792 912
 		$header = NULL;
793 913
 		echo "Add data from another free database...\n";
@@ -798,8 +918,9 @@  discard block
 block discarded – undo
798 918
 			//$Connection->db->beginTransaction();
799 919
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
800 920
 			{
801
-				if(!$header) $header = $row;
802
-				else {
921
+				if(!$header) {
922
+					$header = $row;
923
+				} else {
803 924
 					$data = $row;
804 925
 
805 926
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -975,7 +1096,9 @@  discard block
 block discarded – undo
975 1096
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
976 1097
 		{
977 1098
 			$i = 0;
978
-			if ($globalTransaction) $Connection->db->beginTransaction();
1099
+			if ($globalTransaction) {
1100
+				$Connection->db->beginTransaction();
1101
+			}
979 1102
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
980 1103
 			{
981 1104
 				if ($i > 0) {
@@ -988,7 +1111,9 @@  discard block
 block discarded – undo
988 1111
 					}
989 1112
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
990 1113
 					if (!empty($result_search)) {
991
-						if ($globalDebug) echo '.';
1114
+						if ($globalDebug) {
1115
+							echo '.';
1116
+						}
992 1117
 							//if ($globalDBdriver == 'mysql') {
993 1118
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
994 1119
 							//} else {
@@ -1010,8 +1135,12 @@  discard block
 block discarded – undo
1010 1135
 						}
1011 1136
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1012 1137
 						if (!empty($result_search_mfr)) {
1013
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1014
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1138
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1139
+								$data[16] = $data[23];
1140
+							}
1141
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1142
+								$data[16] = $data[15];
1143
+							}
1015 1144
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1016 1145
 							try {
1017 1146
 								$sthf = $Connection->db->prepare($queryf);
@@ -1022,7 +1151,9 @@  discard block
 block discarded – undo
1022 1151
 						}
1023 1152
 					}
1024 1153
 					if (strtotime($data[29]) > time()) {
1025
-						if ($globalDebug) echo 'i';
1154
+						if ($globalDebug) {
1155
+							echo 'i';
1156
+						}
1026 1157
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1027 1158
 						try {
1028 1159
 							$sth = $Connection->db->prepare($query);
@@ -1033,13 +1164,19 @@  discard block
 block discarded – undo
1033 1164
 					}
1034 1165
 				}
1035 1166
 				if ($i % 90 == 0) {
1036
-					if ($globalTransaction) $Connection->db->commit();
1037
-					if ($globalTransaction) $Connection->db->beginTransaction();
1167
+					if ($globalTransaction) {
1168
+						$Connection->db->commit();
1169
+					}
1170
+					if ($globalTransaction) {
1171
+						$Connection->db->beginTransaction();
1172
+					}
1038 1173
 				}
1039 1174
 				$i++;
1040 1175
 			}
1041 1176
 			fclose($handle);
1042
-			if ($globalTransaction) $Connection->db->commit();
1177
+			if ($globalTransaction) {
1178
+				$Connection->db->commit();
1179
+			}
1043 1180
 		}
1044 1181
 		print_r($mfr);
1045 1182
 		return '';
@@ -1064,7 +1201,9 @@  discard block
 block discarded – undo
1064 1201
 			$i = 0;
1065 1202
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1066 1203
 			//$Connection->db->beginTransaction();
1067
-			if ($globalTransaction) $Connection->db->beginTransaction();
1204
+			if ($globalTransaction) {
1205
+				$Connection->db->beginTransaction();
1206
+			}
1068 1207
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1069 1208
 			{
1070 1209
 				if ($i > 0) {
@@ -1079,7 +1218,9 @@  discard block
 block discarded – undo
1079 1218
 				$i++;
1080 1219
 			}
1081 1220
 			fclose($handle);
1082
-			if ($globalTransaction) $Connection->db->commit();
1221
+			if ($globalTransaction) {
1222
+				$Connection->db->commit();
1223
+			}
1083 1224
 		}
1084 1225
 		return '';
1085 1226
         }
@@ -1100,7 +1241,9 @@  discard block
 block discarded – undo
1100 1241
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1101 1242
 		{
1102 1243
 			$i = 0;
1103
-			if ($globalTransaction) $Connection->db->beginTransaction();
1244
+			if ($globalTransaction) {
1245
+				$Connection->db->beginTransaction();
1246
+			}
1104 1247
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1105 1248
 			{
1106 1249
 				if ($i > 0) {
@@ -1116,7 +1259,9 @@  discard block
 block discarded – undo
1116 1259
 				$i++;
1117 1260
 			}
1118 1261
 			fclose($handle);
1119
-			if ($globalTransaction) $Connection->db->commit();
1262
+			if ($globalTransaction) {
1263
+				$Connection->db->commit();
1264
+			}
1120 1265
 		}
1121 1266
 		return '';
1122 1267
         }
@@ -1141,7 +1286,9 @@  discard block
 block discarded – undo
1141 1286
 			$i = 0;
1142 1287
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1143 1288
 			//$Connection->db->beginTransaction();
1144
-			if ($globalTransaction) $Connection->db->beginTransaction();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->beginTransaction();
1291
+			}
1145 1292
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1146 1293
 			{
1147 1294
 				if ($i > 0) {
@@ -1156,7 +1303,9 @@  discard block
 block discarded – undo
1156 1303
 				$i++;
1157 1304
 			}
1158 1305
 			fclose($handle);
1159
-			if ($globalTransaction) $Connection->db->commit();
1306
+			if ($globalTransaction) {
1307
+				$Connection->db->commit();
1308
+			}
1160 1309
 		}
1161 1310
 		return '';
1162 1311
         }
@@ -1175,7 +1324,9 @@  discard block
 block discarded – undo
1175 1324
 		$Connection = new Connection();
1176 1325
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1177 1326
 		{
1178
-			if ($globalTransaction) $Connection->db->beginTransaction();
1327
+			if ($globalTransaction) {
1328
+				$Connection->db->beginTransaction();
1329
+			}
1179 1330
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1180 1331
 			{
1181 1332
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1190,7 +1341,9 @@  discard block
 block discarded – undo
1190 1341
 				}
1191 1342
 			}
1192 1343
 			fclose($handle);
1193
-			if ($globalTransaction) $Connection->db->commit();
1344
+			if ($globalTransaction) {
1345
+				$Connection->db->commit();
1346
+			}
1194 1347
 		}
1195 1348
 		return '';
1196 1349
         }
@@ -1341,7 +1494,9 @@  discard block
 block discarded – undo
1341 1494
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1342 1495
 		{
1343 1496
 			$i = 0;
1344
-			if ($globalTransaction) $Connection->db->beginTransaction();
1497
+			if ($globalTransaction) {
1498
+				$Connection->db->beginTransaction();
1499
+			}
1345 1500
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1346 1501
 			{
1347 1502
 				$i++;
@@ -1369,7 +1524,9 @@  discard block
 block discarded – undo
1369 1524
 				}
1370 1525
 			}
1371 1526
 			fclose($handle);
1372
-			if ($globalTransaction) $Connection->db->commit();
1527
+			if ($globalTransaction) {
1528
+				$Connection->db->commit();
1529
+			}
1373 1530
 		}
1374 1531
 		return '';
1375 1532
         }
@@ -1392,7 +1549,9 @@  discard block
 block discarded – undo
1392 1549
 		$Connection = new Connection();
1393 1550
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1394 1551
 		{
1395
-			if ($globalTransaction) $Connection->db->beginTransaction();
1552
+			if ($globalTransaction) {
1553
+				$Connection->db->beginTransaction();
1554
+			}
1396 1555
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1397 1556
 			{
1398 1557
 				if(count($row) > 1) {
@@ -1406,7 +1565,9 @@  discard block
 block discarded – undo
1406 1565
 				}
1407 1566
 			}
1408 1567
 			fclose($handle);
1409
-			if ($globalTransaction) $Connection->db->commit();
1568
+			if ($globalTransaction) {
1569
+				$Connection->db->commit();
1570
+			}
1410 1571
 		}
1411 1572
 		return '';
1412 1573
         }
@@ -1426,8 +1587,9 @@  discard block
 block discarded – undo
1426 1587
 	        }
1427 1588
 
1428 1589
 
1429
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1430
-		else {
1590
+		if ($globalDBdriver == 'mysql') {
1591
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1592
+		} else {
1431 1593
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1432 1594
 			$query = "CREATE EXTENSION postgis";
1433 1595
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1446,20 +1608,30 @@  discard block
 block discarded – undo
1446 1608
 		global $tmp_dir, $globalDebug;
1447 1609
 		include_once('class.create_db.php');
1448 1610
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1449
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1611
+		if ($globalDebug) {
1612
+			echo "NOTAM from FlightAirMap website : Download...";
1613
+		}
1450 1614
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1451 1615
 		$error = '';
1452 1616
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1453
-			if ($globalDebug) echo "Gunzip...";
1617
+			if ($globalDebug) {
1618
+				echo "Gunzip...";
1619
+			}
1454 1620
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1455
-			if ($globalDebug) echo "Add to DB...";
1621
+			if ($globalDebug) {
1622
+				echo "Add to DB...";
1623
+			}
1456 1624
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1457 1625
 			$NOTAM = new NOTAM();
1458 1626
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1459
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1627
+		} else {
1628
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1629
+		}
1460 1630
 		if ($error != '') {
1461 1631
 			return $error;
1462
-		} elseif ($globalDebug) echo "Done\n";
1632
+		} elseif ($globalDebug) {
1633
+			echo "Done\n";
1634
+		}
1463 1635
 		return '';
1464 1636
 	}
1465 1637
 
@@ -1513,67 +1685,111 @@  discard block
 block discarded – undo
1513 1685
 		//if ($globalDebug) echo "IVAO : Download...";
1514 1686
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1515 1687
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1516
-			if ($globalDebug) echo "Unzip...";
1688
+			if ($globalDebug) {
1689
+				echo "Unzip...";
1690
+			}
1517 1691
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1518
-			if ($globalDebug) echo "Add to DB...";
1692
+			if ($globalDebug) {
1693
+				echo "Add to DB...";
1694
+			}
1519 1695
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1520
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1696
+			if ($globalDebug) {
1697
+				echo "Copy airlines logos to airlines images directory...";
1698
+			}
1521 1699
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1522
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1523
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1524
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1700
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1701
+					$error = "Failed to copy airlines logo.";
1702
+				}
1703
+			} else {
1704
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1705
+			}
1706
+		} else {
1707
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1708
+		}
1525 1709
 		if ($error != '') {
1526 1710
 			return $error;
1527
-		} elseif ($globalDebug) echo "Done\n";
1711
+		} elseif ($globalDebug) {
1712
+			echo "Done\n";
1713
+		}
1528 1714
 		return '';
1529 1715
 	}
1530 1716
 
1531 1717
 	public static function update_routes() {
1532 1718
 		global $tmp_dir, $globalDebug;
1533 1719
 		$error = '';
1534
-		if ($globalDebug) echo "Routes : Download...";
1720
+		if ($globalDebug) {
1721
+			echo "Routes : Download...";
1722
+		}
1535 1723
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1536 1724
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1537
-			if ($globalDebug) echo "Gunzip...";
1725
+			if ($globalDebug) {
1726
+				echo "Gunzip...";
1727
+			}
1538 1728
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1539
-			if ($globalDebug) echo "Add to DB...";
1729
+			if ($globalDebug) {
1730
+				echo "Add to DB...";
1731
+			}
1540 1732
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1541
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1733
+		} else {
1734
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1735
+		}
1542 1736
 		if ($error != '') {
1543 1737
 			return $error;
1544
-		} elseif ($globalDebug) echo "Done\n";
1738
+		} elseif ($globalDebug) {
1739
+			echo "Done\n";
1740
+		}
1545 1741
 		return '';
1546 1742
 	}
1547 1743
 	public static function update_oneworld() {
1548 1744
 		global $tmp_dir, $globalDebug;
1549 1745
 		$error = '';
1550
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1746
+		if ($globalDebug) {
1747
+			echo "Schedules Oneworld : Download...";
1748
+		}
1551 1749
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1552 1750
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1553
-			if ($globalDebug) echo "Gunzip...";
1751
+			if ($globalDebug) {
1752
+				echo "Gunzip...";
1753
+			}
1554 1754
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1555
-			if ($globalDebug) echo "Add to DB...";
1755
+			if ($globalDebug) {
1756
+				echo "Add to DB...";
1757
+			}
1556 1758
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1557
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1759
+		} else {
1760
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1761
+		}
1558 1762
 		if ($error != '') {
1559 1763
 			return $error;
1560
-		} elseif ($globalDebug) echo "Done\n";
1764
+		} elseif ($globalDebug) {
1765
+			echo "Done\n";
1766
+		}
1561 1767
 		return '';
1562 1768
 	}
1563 1769
 	public static function update_skyteam() {
1564 1770
 		global $tmp_dir, $globalDebug;
1565 1771
 		$error = '';
1566
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1772
+		if ($globalDebug) {
1773
+			echo "Schedules Skyteam : Download...";
1774
+		}
1567 1775
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1568 1776
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1569
-			if ($globalDebug) echo "Gunzip...";
1777
+			if ($globalDebug) {
1778
+				echo "Gunzip...";
1779
+			}
1570 1780
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1571
-			if ($globalDebug) echo "Add to DB...";
1781
+			if ($globalDebug) {
1782
+				echo "Add to DB...";
1783
+			}
1572 1784
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1573
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1785
+		} else {
1786
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1787
+		}
1574 1788
 		if ($error != '') {
1575 1789
 			return $error;
1576
-		} elseif ($globalDebug) echo "Done\n";
1790
+		} elseif ($globalDebug) {
1791
+			echo "Done\n";
1792
+		}
1577 1793
 		return '';
1578 1794
 	}
1579 1795
 	public static function update_ModeS() {
@@ -1590,341 +1806,587 @@  discard block
 block discarded – undo
1590 1806
 			exit;
1591 1807
 		} elseif ($globalDebug) echo "Done\n";
1592 1808
 */
1593
-		if ($globalDebug) echo "Modes : Download...";
1594
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1809
+		if ($globalDebug) {
1810
+			echo "Modes : Download...";
1811
+		}
1812
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1595 1813
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1596 1814
 
1597 1815
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1598 1816
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1599
-			if ($globalDebug) echo "Unzip...";
1600
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1817
+			if ($globalDebug) {
1818
+				echo "Unzip...";
1819
+			}
1820
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1601 1821
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1602
-			if ($globalDebug) echo "Add to DB...";
1822
+			if ($globalDebug) {
1823
+				echo "Add to DB...";
1824
+			}
1603 1825
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1604 1826
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1605
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1827
+		} else {
1828
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1829
+		}
1606 1830
 		if ($error != '') {
1607 1831
 			return $error;
1608
-		} elseif ($globalDebug) echo "Done\n";
1832
+		} elseif ($globalDebug) {
1833
+			echo "Done\n";
1834
+		}
1609 1835
 		return '';
1610 1836
 	}
1611 1837
 
1612 1838
 	public static function update_ModeS_faa() {
1613 1839
 		global $tmp_dir, $globalDebug;
1614
-		if ($globalDebug) echo "Modes FAA: Download...";
1840
+		if ($globalDebug) {
1841
+			echo "Modes FAA: Download...";
1842
+		}
1615 1843
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1616 1844
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1617
-			if ($globalDebug) echo "Unzip...";
1845
+			if ($globalDebug) {
1846
+				echo "Unzip...";
1847
+			}
1618 1848
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1619
-			if ($globalDebug) echo "Add to DB...";
1849
+			if ($globalDebug) {
1850
+				echo "Add to DB...";
1851
+			}
1620 1852
 			$error = update_db::modes_faa();
1621
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1853
+		} else {
1854
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1855
+		}
1622 1856
 		if ($error != '') {
1623 1857
 			return $error;
1624
-		} elseif ($globalDebug) echo "Done\n";
1858
+		} elseif ($globalDebug) {
1859
+			echo "Done\n";
1860
+		}
1625 1861
 		return '';
1626 1862
 	}
1627 1863
 
1628 1864
 	public static function update_ModeS_flarm() {
1629 1865
 		global $tmp_dir, $globalDebug;
1630
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1866
+		if ($globalDebug) {
1867
+			echo "Modes Flarmnet: Download...";
1868
+		}
1631 1869
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1632 1870
 		if (file_exists($tmp_dir.'data.fln')) {
1633
-			if ($globalDebug) echo "Add to DB...";
1871
+			if ($globalDebug) {
1872
+				echo "Add to DB...";
1873
+			}
1634 1874
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1635
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1875
+		} else {
1876
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1877
+		}
1636 1878
 		if ($error != '') {
1637 1879
 			return $error;
1638
-		} elseif ($globalDebug) echo "Done\n";
1880
+		} elseif ($globalDebug) {
1881
+			echo "Done\n";
1882
+		}
1639 1883
 		return '';
1640 1884
 	}
1641 1885
 
1642 1886
 	public static function update_ModeS_ogn() {
1643 1887
 		global $tmp_dir, $globalDebug;
1644
-		if ($globalDebug) echo "Modes OGN: Download...";
1888
+		if ($globalDebug) {
1889
+			echo "Modes OGN: Download...";
1890
+		}
1645 1891
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1646 1892
 		if (file_exists($tmp_dir.'ogn.csv')) {
1647
-			if ($globalDebug) echo "Add to DB...";
1893
+			if ($globalDebug) {
1894
+				echo "Add to DB...";
1895
+			}
1648 1896
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1649
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1897
+		} else {
1898
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1899
+		}
1650 1900
 		if ($error != '') {
1651 1901
 			return $error;
1652
-		} elseif ($globalDebug) echo "Done\n";
1902
+		} elseif ($globalDebug) {
1903
+			echo "Done\n";
1904
+		}
1653 1905
 		return '';
1654 1906
 	}
1655 1907
 
1656 1908
 	public static function update_owner() {
1657 1909
 		global $tmp_dir, $globalDebug;
1658 1910
 		
1659
-		if ($globalDebug) echo "Owner France: Download...";
1911
+		if ($globalDebug) {
1912
+			echo "Owner France: Download...";
1913
+		}
1660 1914
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1661 1915
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1662
-			if ($globalDebug) echo "Add to DB...";
1916
+			if ($globalDebug) {
1917
+				echo "Add to DB...";
1918
+			}
1663 1919
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1664
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1920
+		} else {
1921
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1922
+		}
1665 1923
 		if ($error != '') {
1666 1924
 			return $error;
1667
-		} elseif ($globalDebug) echo "Done\n";
1925
+		} elseif ($globalDebug) {
1926
+			echo "Done\n";
1927
+		}
1668 1928
 		
1669
-		if ($globalDebug) echo "Owner Ireland: Download...";
1929
+		if ($globalDebug) {
1930
+			echo "Owner Ireland: Download...";
1931
+		}
1670 1932
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1671 1933
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1672
-			if ($globalDebug) echo "Add to DB...";
1934
+			if ($globalDebug) {
1935
+				echo "Add to DB...";
1936
+			}
1673 1937
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1674
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1938
+		} else {
1939
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1940
+		}
1675 1941
 		if ($error != '') {
1676 1942
 			return $error;
1677
-		} elseif ($globalDebug) echo "Done\n";
1678
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1943
+		} elseif ($globalDebug) {
1944
+			echo "Done\n";
1945
+		}
1946
+		if ($globalDebug) {
1947
+			echo "Owner Switzerland: Download...";
1948
+		}
1679 1949
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1680 1950
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1681
-			if ($globalDebug) echo "Add to DB...";
1951
+			if ($globalDebug) {
1952
+				echo "Add to DB...";
1953
+			}
1682 1954
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1683
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1955
+		} else {
1956
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1957
+		}
1684 1958
 		if ($error != '') {
1685 1959
 			return $error;
1686
-		} elseif ($globalDebug) echo "Done\n";
1687
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1960
+		} elseif ($globalDebug) {
1961
+			echo "Done\n";
1962
+		}
1963
+		if ($globalDebug) {
1964
+			echo "Owner Czech Republic: Download...";
1965
+		}
1688 1966
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1689 1967
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1690
-			if ($globalDebug) echo "Add to DB...";
1968
+			if ($globalDebug) {
1969
+				echo "Add to DB...";
1970
+			}
1691 1971
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1692
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1972
+		} else {
1973
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1974
+		}
1693 1975
 		if ($error != '') {
1694 1976
 			return $error;
1695
-		} elseif ($globalDebug) echo "Done\n";
1696
-		if ($globalDebug) echo "Owner Australia: Download...";
1977
+		} elseif ($globalDebug) {
1978
+			echo "Done\n";
1979
+		}
1980
+		if ($globalDebug) {
1981
+			echo "Owner Australia: Download...";
1982
+		}
1697 1983
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1698 1984
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1699
-			if ($globalDebug) echo "Add to DB...";
1985
+			if ($globalDebug) {
1986
+				echo "Add to DB...";
1987
+			}
1700 1988
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1701
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1989
+		} else {
1990
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1991
+		}
1702 1992
 		if ($error != '') {
1703 1993
 			return $error;
1704
-		} elseif ($globalDebug) echo "Done\n";
1705
-		if ($globalDebug) echo "Owner Austria: Download...";
1994
+		} elseif ($globalDebug) {
1995
+			echo "Done\n";
1996
+		}
1997
+		if ($globalDebug) {
1998
+			echo "Owner Austria: Download...";
1999
+		}
1706 2000
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1707 2001
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1708
-			if ($globalDebug) echo "Add to DB...";
2002
+			if ($globalDebug) {
2003
+				echo "Add to DB...";
2004
+			}
1709 2005
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1710
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2006
+		} else {
2007
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2008
+		}
1711 2009
 		if ($error != '') {
1712 2010
 			return $error;
1713
-		} elseif ($globalDebug) echo "Done\n";
1714
-		if ($globalDebug) echo "Owner Chile: Download...";
2011
+		} elseif ($globalDebug) {
2012
+			echo "Done\n";
2013
+		}
2014
+		if ($globalDebug) {
2015
+			echo "Owner Chile: Download...";
2016
+		}
1715 2017
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1716 2018
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1717
-			if ($globalDebug) echo "Add to DB...";
2019
+			if ($globalDebug) {
2020
+				echo "Add to DB...";
2021
+			}
1718 2022
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1719
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2023
+		} else {
2024
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2025
+		}
1720 2026
 		if ($error != '') {
1721 2027
 			return $error;
1722
-		} elseif ($globalDebug) echo "Done\n";
1723
-		if ($globalDebug) echo "Owner Colombia: Download...";
2028
+		} elseif ($globalDebug) {
2029
+			echo "Done\n";
2030
+		}
2031
+		if ($globalDebug) {
2032
+			echo "Owner Colombia: Download...";
2033
+		}
1724 2034
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1725 2035
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1726
-			if ($globalDebug) echo "Add to DB...";
2036
+			if ($globalDebug) {
2037
+				echo "Add to DB...";
2038
+			}
1727 2039
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1728
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2040
+		} else {
2041
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2042
+		}
1729 2043
 		if ($error != '') {
1730 2044
 			return $error;
1731
-		} elseif ($globalDebug) echo "Done\n";
1732
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2045
+		} elseif ($globalDebug) {
2046
+			echo "Done\n";
2047
+		}
2048
+		if ($globalDebug) {
2049
+			echo "Owner Bosnia Herzegobina: Download...";
2050
+		}
1733 2051
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1734 2052
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1735
-			if ($globalDebug) echo "Add to DB...";
2053
+			if ($globalDebug) {
2054
+				echo "Add to DB...";
2055
+			}
1736 2056
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1737
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2057
+		} else {
2058
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2059
+		}
1738 2060
 		if ($error != '') {
1739 2061
 			return $error;
1740
-		} elseif ($globalDebug) echo "Done\n";
1741
-		if ($globalDebug) echo "Owner Brazil: Download...";
2062
+		} elseif ($globalDebug) {
2063
+			echo "Done\n";
2064
+		}
2065
+		if ($globalDebug) {
2066
+			echo "Owner Brazil: Download...";
2067
+		}
1742 2068
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1743 2069
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1744
-			if ($globalDebug) echo "Add to DB...";
2070
+			if ($globalDebug) {
2071
+				echo "Add to DB...";
2072
+			}
1745 2073
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1746
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2074
+		} else {
2075
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2076
+		}
1747 2077
 		if ($error != '') {
1748 2078
 			return $error;
1749
-		} elseif ($globalDebug) echo "Done\n";
1750
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2079
+		} elseif ($globalDebug) {
2080
+			echo "Done\n";
2081
+		}
2082
+		if ($globalDebug) {
2083
+			echo "Owner Cayman Islands: Download...";
2084
+		}
1751 2085
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1752 2086
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1753
-			if ($globalDebug) echo "Add to DB...";
2087
+			if ($globalDebug) {
2088
+				echo "Add to DB...";
2089
+			}
1754 2090
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1755
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2091
+		} else {
2092
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2093
+		}
1756 2094
 		if ($error != '') {
1757 2095
 			return $error;
1758
-		} elseif ($globalDebug) echo "Done\n";
1759
-		if ($globalDebug) echo "Owner Croatia: Download...";
2096
+		} elseif ($globalDebug) {
2097
+			echo "Done\n";
2098
+		}
2099
+		if ($globalDebug) {
2100
+			echo "Owner Croatia: Download...";
2101
+		}
1760 2102
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1761 2103
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1762
-			if ($globalDebug) echo "Add to DB...";
2104
+			if ($globalDebug) {
2105
+				echo "Add to DB...";
2106
+			}
1763 2107
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1764
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2108
+		} else {
2109
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2110
+		}
1765 2111
 		if ($error != '') {
1766 2112
 			return $error;
1767
-		} elseif ($globalDebug) echo "Done\n";
1768
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2113
+		} elseif ($globalDebug) {
2114
+			echo "Done\n";
2115
+		}
2116
+		if ($globalDebug) {
2117
+			echo "Owner Luxembourg: Download...";
2118
+		}
1769 2119
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1770 2120
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1771
-			if ($globalDebug) echo "Add to DB...";
2121
+			if ($globalDebug) {
2122
+				echo "Add to DB...";
2123
+			}
1772 2124
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1773
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2125
+		} else {
2126
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2127
+		}
1774 2128
 		if ($error != '') {
1775 2129
 			return $error;
1776
-		} elseif ($globalDebug) echo "Done\n";
1777
-		if ($globalDebug) echo "Owner Maldives: Download...";
2130
+		} elseif ($globalDebug) {
2131
+			echo "Done\n";
2132
+		}
2133
+		if ($globalDebug) {
2134
+			echo "Owner Maldives: Download...";
2135
+		}
1778 2136
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1779 2137
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1780
-			if ($globalDebug) echo "Add to DB...";
2138
+			if ($globalDebug) {
2139
+				echo "Add to DB...";
2140
+			}
1781 2141
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1782
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2142
+		} else {
2143
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2144
+		}
1783 2145
 		if ($error != '') {
1784 2146
 			return $error;
1785
-		} elseif ($globalDebug) echo "Done\n";
1786
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2147
+		} elseif ($globalDebug) {
2148
+			echo "Done\n";
2149
+		}
2150
+		if ($globalDebug) {
2151
+			echo "Owner New Zealand: Download...";
2152
+		}
1787 2153
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1788 2154
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1789
-			if ($globalDebug) echo "Add to DB...";
2155
+			if ($globalDebug) {
2156
+				echo "Add to DB...";
2157
+			}
1790 2158
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1791
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2159
+		} else {
2160
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2161
+		}
1792 2162
 		if ($error != '') {
1793 2163
 			return $error;
1794
-		} elseif ($globalDebug) echo "Done\n";
1795
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2164
+		} elseif ($globalDebug) {
2165
+			echo "Done\n";
2166
+		}
2167
+		if ($globalDebug) {
2168
+			echo "Owner Papua New Guinea: Download...";
2169
+		}
1796 2170
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1797 2171
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1798
-			if ($globalDebug) echo "Add to DB...";
2172
+			if ($globalDebug) {
2173
+				echo "Add to DB...";
2174
+			}
1799 2175
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1800
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2176
+		} else {
2177
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2178
+		}
1801 2179
 		if ($error != '') {
1802 2180
 			return $error;
1803
-		} elseif ($globalDebug) echo "Done\n";
1804
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2181
+		} elseif ($globalDebug) {
2182
+			echo "Done\n";
2183
+		}
2184
+		if ($globalDebug) {
2185
+			echo "Owner Slovakia: Download...";
2186
+		}
1805 2187
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1806 2188
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1807
-			if ($globalDebug) echo "Add to DB...";
2189
+			if ($globalDebug) {
2190
+				echo "Add to DB...";
2191
+			}
1808 2192
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1809
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2193
+		} else {
2194
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2195
+		}
1810 2196
 		if ($error != '') {
1811 2197
 			return $error;
1812
-		} elseif ($globalDebug) echo "Done\n";
1813
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2198
+		} elseif ($globalDebug) {
2199
+			echo "Done\n";
2200
+		}
2201
+		if ($globalDebug) {
2202
+			echo "Owner Ecuador: Download...";
2203
+		}
1814 2204
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1815 2205
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1816
-			if ($globalDebug) echo "Add to DB...";
2206
+			if ($globalDebug) {
2207
+				echo "Add to DB...";
2208
+			}
1817 2209
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1818
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2210
+		} else {
2211
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2212
+		}
1819 2213
 		if ($error != '') {
1820 2214
 			return $error;
1821
-		} elseif ($globalDebug) echo "Done\n";
1822
-		if ($globalDebug) echo "Owner Iceland: Download...";
2215
+		} elseif ($globalDebug) {
2216
+			echo "Done\n";
2217
+		}
2218
+		if ($globalDebug) {
2219
+			echo "Owner Iceland: Download...";
2220
+		}
1823 2221
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1824 2222
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1825
-			if ($globalDebug) echo "Add to DB...";
2223
+			if ($globalDebug) {
2224
+				echo "Add to DB...";
2225
+			}
1826 2226
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1827
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2227
+		} else {
2228
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2229
+		}
1828 2230
 		if ($error != '') {
1829 2231
 			return $error;
1830
-		} elseif ($globalDebug) echo "Done\n";
2232
+		} elseif ($globalDebug) {
2233
+			echo "Done\n";
2234
+		}
1831 2235
 		return '';
1832 2236
 	}
1833 2237
 
1834 2238
 	public static function update_translation() {
1835 2239
 		global $tmp_dir, $globalDebug;
1836 2240
 		$error = '';
1837
-		if ($globalDebug) echo "Translation : Download...";
2241
+		if ($globalDebug) {
2242
+			echo "Translation : Download...";
2243
+		}
1838 2244
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1839 2245
 		if (file_exists($tmp_dir.'translation.zip')) {
1840
-			if ($globalDebug) echo "Unzip...";
2246
+			if ($globalDebug) {
2247
+				echo "Unzip...";
2248
+			}
1841 2249
 			update_db::unzip($tmp_dir.'translation.zip');
1842
-			if ($globalDebug) echo "Add to DB...";
2250
+			if ($globalDebug) {
2251
+				echo "Add to DB...";
2252
+			}
1843 2253
 			$error = update_db::translation();
1844
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2254
+		} else {
2255
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2256
+		}
1845 2257
 		if ($error != '') {
1846 2258
 			return $error;
1847
-		} elseif ($globalDebug) echo "Done\n";
2259
+		} elseif ($globalDebug) {
2260
+			echo "Done\n";
2261
+		}
1848 2262
 		return '';
1849 2263
 	}
1850 2264
 
1851 2265
 	public static function update_translation_fam() {
1852 2266
 		global $tmp_dir, $globalDebug;
1853
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2267
+		if ($globalDebug) {
2268
+			echo "Translation from FlightAirMap website : Download...";
2269
+		}
1854 2270
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1855 2271
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1856
-			if ($globalDebug) echo "Gunzip...";
2272
+			if ($globalDebug) {
2273
+				echo "Gunzip...";
2274
+			}
1857 2275
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1858
-			if ($globalDebug) echo "Add to DB...";
2276
+			if ($globalDebug) {
2277
+				echo "Add to DB...";
2278
+			}
1859 2279
 			$error = update_db::translation_fam();
1860
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2280
+		} else {
2281
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2282
+		}
1861 2283
 		if ($error != '') {
1862 2284
 			return $error;
1863
-		} elseif ($globalDebug) echo "Done\n";
2285
+		} elseif ($globalDebug) {
2286
+			echo "Done\n";
2287
+		}
1864 2288
 		return '';
1865 2289
 	}
1866 2290
 	public static function update_ModeS_fam() {
1867 2291
 		global $tmp_dir, $globalDebug;
1868
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2292
+		if ($globalDebug) {
2293
+			echo "ModeS from FlightAirMap website : Download...";
2294
+		}
1869 2295
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1870 2296
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1871
-			if ($globalDebug) echo "Gunzip...";
2297
+			if ($globalDebug) {
2298
+				echo "Gunzip...";
2299
+			}
1872 2300
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1873
-			if ($globalDebug) echo "Add to DB...";
2301
+			if ($globalDebug) {
2302
+				echo "Add to DB...";
2303
+			}
1874 2304
 			$error = update_db::modes_fam();
1875
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2305
+		} else {
2306
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2307
+		}
1876 2308
 		if ($error != '') {
1877 2309
 			return $error;
1878
-		} elseif ($globalDebug) echo "Done\n";
2310
+		} elseif ($globalDebug) {
2311
+			echo "Done\n";
2312
+		}
1879 2313
 		return '';
1880 2314
 	}
1881 2315
 	public static function update_owner_fam() {
1882 2316
 		global $tmp_dir, $globalDebug, $globalOwner;
1883
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2317
+		if ($globalDebug) {
2318
+			echo "owner from FlightAirMap website : Download...";
2319
+		}
1884 2320
 		if ($globalOwner === TRUE) {
1885 2321
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1886 2322
 		} else {
1887 2323
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1888 2324
 		}
1889 2325
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1890
-			if ($globalDebug) echo "Gunzip...";
2326
+			if ($globalDebug) {
2327
+				echo "Gunzip...";
2328
+			}
1891 2329
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
1892
-			if ($globalDebug) echo "Add to DB...";
2330
+			if ($globalDebug) {
2331
+				echo "Add to DB...";
2332
+			}
1893 2333
 			$error = update_db::owner_fam();
1894
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2334
+		} else {
2335
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2336
+		}
1895 2337
 		if ($error != '') {
1896 2338
 			return $error;
1897
-		} elseif ($globalDebug) echo "Done\n";
2339
+		} elseif ($globalDebug) {
2340
+			echo "Done\n";
2341
+		}
1898 2342
 		return '';
1899 2343
 	}
1900 2344
 	public static function update_routes_fam() {
1901 2345
 		global $tmp_dir, $globalDebug;
1902
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2346
+		if ($globalDebug) {
2347
+			echo "Routes from FlightAirMap website : Download...";
2348
+		}
1903 2349
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1904 2350
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1905
-			if ($globalDebug) echo "Gunzip...";
2351
+			if ($globalDebug) {
2352
+				echo "Gunzip...";
2353
+			}
1906 2354
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1907
-			if ($globalDebug) echo "Add to DB...";
2355
+			if ($globalDebug) {
2356
+				echo "Add to DB...";
2357
+			}
1908 2358
 			$error = update_db::routes_fam();
1909
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2359
+		} else {
2360
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2361
+		}
1910 2362
 		if ($error != '') {
1911 2363
 			return $error;
1912
-		} elseif ($globalDebug) echo "Done\n";
2364
+		} elseif ($globalDebug) {
2365
+			echo "Done\n";
2366
+		}
1913 2367
 		return '';
1914 2368
 	}
1915 2369
 	public static function update_banned_fam() {
1916 2370
 		global $tmp_dir, $globalDebug;
1917
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2371
+		if ($globalDebug) {
2372
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2373
+		}
1918 2374
 		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
1919 2375
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
1920 2376
 			//if ($globalDebug) echo "Gunzip...";
1921 2377
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
1922
-			if ($globalDebug) echo "Add to DB...";
2378
+			if ($globalDebug) {
2379
+				echo "Add to DB...";
2380
+			}
1923 2381
 			$error = update_db::banned_fam();
1924
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2382
+		} else {
2383
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2384
+		}
1925 2385
 		if ($error != '') {
1926 2386
 			return $error;
1927
-		} elseif ($globalDebug) echo "Done\n";
2387
+		} elseif ($globalDebug) {
2388
+			echo "Done\n";
2389
+		}
1928 2390
 		return '';
1929 2391
 	}
1930 2392
 
@@ -1932,7 +2394,9 @@  discard block
 block discarded – undo
1932 2394
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1933 2395
 		include_once('class.create_db.php');
1934 2396
 		$error = '';
1935
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2397
+		if ($globalDebug) {
2398
+			echo "Airspace from FlightAirMap website : Download...";
2399
+		}
1936 2400
 		if ($globalDBdriver == 'mysql') {
1937 2401
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1938 2402
 		} else {
@@ -1948,9 +2412,13 @@  discard block
 block discarded – undo
1948 2412
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1949 2413
 				}
1950 2414
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1951
-					if ($globalDebug) echo "Gunzip...";
2415
+					if ($globalDebug) {
2416
+						echo "Gunzip...";
2417
+					}
1952 2418
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1953
-					if ($globalDebug) echo "Add to DB...";
2419
+					if ($globalDebug) {
2420
+						echo "Add to DB...";
2421
+					}
1954 2422
 					$Connection = new Connection();
1955 2423
 					if ($Connection->tableExists('airspace')) {
1956 2424
 						$query = 'DROP TABLE airspace';
@@ -1963,31 +2431,47 @@  discard block
 block discarded – undo
1963 2431
 		    			}
1964 2432
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1965 2433
 					update_db::insert_airspace_version($airspace_md5);
1966
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2434
+				} else {
2435
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2436
+				}
1967 2437
 			}
1968
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2438
+		} else {
2439
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2440
+		}
1969 2441
 		if ($error != '') {
1970 2442
 			return $error;
1971
-		} elseif ($globalDebug) echo "Done\n";
2443
+		} elseif ($globalDebug) {
2444
+			echo "Done\n";
2445
+		}
1972 2446
 		return '';
1973 2447
 	}
1974 2448
 
1975 2449
 	public static function update_tle() {
1976 2450
 		global $tmp_dir, $globalDebug;
1977
-		if ($globalDebug) echo "Download TLE : Download...";
2451
+		if ($globalDebug) {
2452
+			echo "Download TLE : Download...";
2453
+		}
1978 2454
 		$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',
1979 2455
 		'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',
1980 2456
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1981 2457
 		foreach ($alltle as $filename) {
1982
-			if ($globalDebug) echo "downloading ".$filename.'...';
2458
+			if ($globalDebug) {
2459
+				echo "downloading ".$filename.'...';
2460
+			}
1983 2461
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1984 2462
 			if (file_exists($tmp_dir.$filename)) {
1985
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2463
+				if ($globalDebug) {
2464
+					echo "Add to DB ".$filename."...";
2465
+				}
1986 2466
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1987
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2467
+			} else {
2468
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2469
+			}
1988 2470
 			if ($error != '') {
1989 2471
 				echo $error."\n";
1990
-			} elseif ($globalDebug) echo "Done\n";
2472
+			} elseif ($globalDebug) {
2473
+				echo "Done\n";
2474
+			}
1991 2475
 		}
1992 2476
 		return '';
1993 2477
 	}
@@ -1995,10 +2479,14 @@  discard block
 block discarded – undo
1995 2479
 	public static function update_models() {
1996 2480
 		global $tmp_dir, $globalDebug;
1997 2481
 		$error = '';
1998
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2482
+		if ($globalDebug) {
2483
+			echo "Models from FlightAirMap website : Download...";
2484
+		}
1999 2485
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2000 2486
 		if (file_exists($tmp_dir.'models.md5sum')) {
2001
-			if ($globalDebug) echo "Check files...\n";
2487
+			if ($globalDebug) {
2488
+				echo "Check files...\n";
2489
+			}
2002 2490
 			$newmodelsdb = array();
2003 2491
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2004 2492
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2017,25 +2505,35 @@  discard block
 block discarded – undo
2017 2505
 			}
2018 2506
 			$diff = array_diff($newmodelsdb,$modelsdb);
2019 2507
 			foreach ($diff as $key => $value) {
2020
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2508
+				if ($globalDebug) {
2509
+					echo 'Downloading model '.$key.' ...'."\n";
2510
+				}
2021 2511
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2022 2512
 				
2023 2513
 			}
2024 2514
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2025
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2515
+		} else {
2516
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2517
+		}
2026 2518
 		if ($error != '') {
2027 2519
 			return $error;
2028
-		} elseif ($globalDebug) echo "Done\n";
2520
+		} elseif ($globalDebug) {
2521
+			echo "Done\n";
2522
+		}
2029 2523
 		return '';
2030 2524
 	}
2031 2525
 
2032 2526
 	public static function update_space_models() {
2033 2527
 		global $tmp_dir, $globalDebug;
2034 2528
 		$error = '';
2035
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2529
+		if ($globalDebug) {
2530
+			echo "Space models from FlightAirMap website : Download...";
2531
+		}
2036 2532
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2037 2533
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2038
-			if ($globalDebug) echo "Check files...\n";
2534
+			if ($globalDebug) {
2535
+				echo "Check files...\n";
2536
+			}
2039 2537
 			$newmodelsdb = array();
2040 2538
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2041 2539
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2054,15 +2552,21 @@  discard block
 block discarded – undo
2054 2552
 			}
2055 2553
 			$diff = array_diff($newmodelsdb,$modelsdb);
2056 2554
 			foreach ($diff as $key => $value) {
2057
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2555
+				if ($globalDebug) {
2556
+					echo 'Downloading space model '.$key.' ...'."\n";
2557
+				}
2058 2558
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2059 2559
 				
2060 2560
 			}
2061 2561
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2062
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2562
+		} else {
2563
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2564
+		}
2063 2565
 		if ($error != '') {
2064 2566
 			return $error;
2065
-		} elseif ($globalDebug) echo "Done\n";
2567
+		} elseif ($globalDebug) {
2568
+			echo "Done\n";
2569
+		}
2066 2570
 		return '';
2067 2571
 	}
2068 2572
 
@@ -2105,7 +2609,9 @@  discard block
 block discarded – undo
2105 2609
                 }
2106 2610
 
2107 2611
 		$error = '';
2108
-		if ($globalDebug) echo "Notam : Download...";
2612
+		if ($globalDebug) {
2613
+			echo "Notam : Download...";
2614
+		}
2109 2615
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2110 2616
 		if (file_exists($tmp_dir.'notam.rss')) {
2111 2617
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2120,14 +2626,30 @@  discard block
 block discarded – undo
2120 2626
 				$data['fir'] = $q[0];
2121 2627
 				$data['code'] = $q[1];
2122 2628
 				$ifrvfr = $q[2];
2123
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2124
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2125
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2126
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2127
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2128
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2129
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2130
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2629
+				if ($ifrvfr == 'IV') {
2630
+					$data['rules'] = 'IFR/VFR';
2631
+				}
2632
+				if ($ifrvfr == 'I') {
2633
+					$data['rules'] = 'IFR';
2634
+				}
2635
+				if ($ifrvfr == 'V') {
2636
+					$data['rules'] = 'VFR';
2637
+				}
2638
+				if ($q[4] == 'A') {
2639
+					$data['scope'] = 'Airport warning';
2640
+				}
2641
+				if ($q[4] == 'E') {
2642
+					$data['scope'] = 'Enroute warning';
2643
+				}
2644
+				if ($q[4] == 'W') {
2645
+					$data['scope'] = 'Navigation warning';
2646
+				}
2647
+				if ($q[4] == 'AE') {
2648
+					$data['scope'] = 'Airport/Enroute warning';
2649
+				}
2650
+				if ($q[4] == 'AW') {
2651
+					$data['scope'] = 'Airport/Navigation warning';
2652
+				}
2131 2653
 				//$data['scope'] = $q[4];
2132 2654
 				$data['lower_limit'] = $q[5];
2133 2655
 				$data['upper_limit'] = $q[6];
@@ -2135,8 +2657,12 @@  discard block
 block discarded – undo
2135 2657
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2136 2658
 				$latitude = $Common->convertDec($las,'latitude');
2137 2659
 				$longitude = $Common->convertDec($lns,'longitude');
2138
-				if ($lac == 'S') $latitude = '-'.$latitude;
2139
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2660
+				if ($lac == 'S') {
2661
+					$latitude = '-'.$latitude;
2662
+				}
2663
+				if ($lnc == 'W') {
2664
+					$longitude = '-'.$longitude;
2665
+				}
2140 2666
 				$data['center_latitude'] = $latitude;
2141 2667
 				$data['center_longitude'] = $longitude;
2142 2668
 				$data['radius'] = intval($radius);
@@ -2166,10 +2692,14 @@  discard block
 block discarded – undo
2166 2692
 				$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']);
2167 2693
 				unset($data);
2168 2694
 			} 
2169
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2695
+		} else {
2696
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2697
+		}
2170 2698
 		if ($error != '') {
2171 2699
 			return $error;
2172
-		} elseif ($globalDebug) echo "Done\n";
2700
+		} elseif ($globalDebug) {
2701
+			echo "Done\n";
2702
+		}
2173 2703
 		return '';
2174 2704
 	}
2175 2705
 	
@@ -2194,7 +2724,9 @@  discard block
 block discarded – undo
2194 2724
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2195 2725
 		$airspace_json = json_decode($airspace_lst,true);
2196 2726
 		foreach ($airspace_json['records'] as $airspace) {
2197
-			if ($globalDebug) echo $airspace['name']."...\n";
2727
+			if ($globalDebug) {
2728
+				echo $airspace['name']."...\n";
2729
+			}
2198 2730
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2199 2731
 			if (file_exists($tmp_dir.$airspace['name'])) {
2200 2732
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2223,8 +2755,11 @@  discard block
 block discarded – undo
2223 2755
                         return "error : ".$e->getMessage();
2224 2756
                 }
2225 2757
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2226
-                if ($row['nb'] > 0) return false;
2227
-                else return true;
2758
+                if ($row['nb'] > 0) {
2759
+                	return false;
2760
+                } else {
2761
+                	return true;
2762
+                }
2228 2763
 	}
2229 2764
 
2230 2765
 	public static function insert_last_update() {
@@ -2249,8 +2784,11 @@  discard block
 block discarded – undo
2249 2784
                         return "error : ".$e->getMessage();
2250 2785
                 }
2251 2786
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2252
-                if ($row['nb'] > 0) return true;
2253
-                else return false;
2787
+                if ($row['nb'] > 0) {
2788
+                	return true;
2789
+                } else {
2790
+                	return false;
2791
+                }
2254 2792
 	}
2255 2793
 
2256 2794
 
@@ -2281,8 +2819,11 @@  discard block
 block discarded – undo
2281 2819
                         return "error : ".$e->getMessage();
2282 2820
                 }
2283 2821
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2284
-                if ($row['nb'] > 0) return false;
2285
-                else return true;
2822
+                if ($row['nb'] > 0) {
2823
+                	return false;
2824
+                } else {
2825
+                	return true;
2826
+                }
2286 2827
 	}
2287 2828
 
2288 2829
 	public static function insert_last_notam_update() {
@@ -2311,8 +2852,11 @@  discard block
 block discarded – undo
2311 2852
                         return "error : ".$e->getMessage();
2312 2853
                 }
2313 2854
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2314
-                if ($row['nb'] > 0) return false;
2315
-                else return true;
2855
+                if ($row['nb'] > 0) {
2856
+                	return false;
2857
+                } else {
2858
+                	return true;
2859
+                }
2316 2860
 	}
2317 2861
 
2318 2862
 	public static function insert_last_airspace_update() {
@@ -2342,8 +2886,11 @@  discard block
 block discarded – undo
2342 2886
                         return "error : ".$e->getMessage();
2343 2887
                 }
2344 2888
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2345
-                if ($row['nb'] > 0) return false;
2346
-                else return true;
2889
+                if ($row['nb'] > 0) {
2890
+                	return false;
2891
+                } else {
2892
+                	return true;
2893
+                }
2347 2894
 	}
2348 2895
 
2349 2896
 	public static function insert_last_owner_update() {
@@ -2372,8 +2919,11 @@  discard block
 block discarded – undo
2372 2919
                         return "error : ".$e->getMessage();
2373 2920
                 }
2374 2921
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2375
-                if ($row['nb'] > 0) return false;
2376
-                else return true;
2922
+                if ($row['nb'] > 0) {
2923
+                	return false;
2924
+                } else {
2925
+                	return true;
2926
+                }
2377 2927
 	}
2378 2928
 
2379 2929
 	public static function insert_last_schedules_update() {
@@ -2402,8 +2952,11 @@  discard block
 block discarded – undo
2402 2952
                         return "error : ".$e->getMessage();
2403 2953
                 }
2404 2954
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2405
-                if ($row['nb'] > 0) return false;
2406
-                else return true;
2955
+                if ($row['nb'] > 0) {
2956
+                	return false;
2957
+                } else {
2958
+                	return true;
2959
+                }
2407 2960
 	}
2408 2961
 
2409 2962
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.