Completed
Push — master ( 4b9f50...005bcb )
by Yannick
28:37
created
install/class.update_db.php 4 patches
Doc Comments   +48 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@  discard block
 block discarded – undo
10 10
 class update_db {
11 11
 	public static $db_sqlite;
12 12
 
13
+	/**
14
+	 * @param string $file
15
+	 */
13 16
 	public static function download($url, $file, $referer = '') {
14 17
 		//$file = str_replace('/',DIRECTORY_SEPARATOR,$file);
15 18
 		$fp = fopen($file, 'w+');
@@ -25,6 +28,9 @@  discard block
 block discarded – undo
25 28
 		fclose($fp);
26 29
 	}
27 30
 
31
+	/**
32
+	 * @param string $in_file
33
+	 */
28 34
 	public static function gunzip($in_file,$out_file_name = '') {
29 35
 		//echo $in_file.' -> '.$out_file_name."\n";
30 36
 		$buffer_size = 4096; // read 4kb at a time
@@ -46,6 +52,9 @@  discard block
 block discarded – undo
46 52
 		}
47 53
 	}
48 54
 
55
+	/**
56
+	 * @param string $in_file
57
+	 */
49 58
 	public static function unzip($in_file) {
50 59
 		if ($in_file != '' && file_exists($in_file)) {
51 60
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -67,6 +76,9 @@  discard block
 block discarded – undo
67 76
 		}
68 77
 	}
69 78
 	
79
+	/**
80
+	 * @param string $database_file
81
+	 */
70 82
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 83
 		global $globalDebug, $globalTransaction;
72 84
 		//$query = 'TRUNCATE TABLE routes';
@@ -109,6 +121,10 @@  discard block
 block discarded – undo
109 121
 		}
110 122
                 return '';
111 123
 	}
124
+
125
+	/**
126
+	 * @param string $database_file
127
+	 */
112 128
 	public static function retrieve_route_oneworld($database_file) {
113 129
 		global $globalDebug, $globalTransaction;
114 130
 		//$query = 'TRUNCATE TABLE routes';
@@ -150,6 +166,9 @@  discard block
 block discarded – undo
150 166
                 return '';
151 167
 	}
152 168
 	
169
+	/**
170
+	 * @param string $database_file
171
+	 */
153 172
 	public static function retrieve_route_skyteam($database_file) {
154 173
 		global $globalDebug, $globalTransaction;
155 174
 		//$query = 'TRUNCATE TABLE routes';
@@ -192,6 +211,10 @@  discard block
 block discarded – undo
192 211
 		}
193 212
                 return '';
194 213
 	}
214
+
215
+	/**
216
+	 * @param string $database_file
217
+	 */
195 218
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 219
 		global $globalTransaction;
197 220
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -258,6 +281,9 @@  discard block
 block discarded – undo
258 281
 		return '';
259 282
 	}
260 283
 
284
+	/**
285
+	 * @param string $database_file
286
+	 */
261 287
 	public static function retrieve_modes_flarmnet($database_file) {
262 288
 		global $globalTransaction;
263 289
 		$Common = new Common();
@@ -328,6 +354,9 @@  discard block
 block discarded – undo
328 354
 		return '';
329 355
 	}
330 356
 
357
+	/**
358
+	 * @param string $database_file
359
+	 */
331 360
 	public static function retrieve_modes_ogn($database_file) {
332 361
 		global $globalTransaction;
333 362
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -397,6 +426,9 @@  discard block
 block discarded – undo
397 426
 		return '';
398 427
 	}
399 428
 
429
+	/**
430
+	 * @param string $database_file
431
+	 */
400 432
 	public static function retrieve_owner($database_file,$country = 'F') {
401 433
 		global $globalTransaction, $globalMasterSource;
402 434
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -1332,6 +1364,10 @@  discard block
 block discarded – undo
1332 1364
 		return '';
1333 1365
         }
1334 1366
 
1367
+	/**
1368
+	 * @param string $filename
1369
+	 * @param string $tletype
1370
+	 */
1335 1371
 	public static function tle($filename,$tletype) {
1336 1372
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1337 1373
 		global $tmp_dir, $globalTransaction;
@@ -1381,6 +1417,9 @@  discard block
 block discarded – undo
1381 1417
 		return '';
1382 1418
         }
1383 1419
 
1420
+	/**
1421
+	 * @param string $filename
1422
+	 */
1384 1423
 	public static function satellite_ucsdb($filename) {
1385 1424
 		global $tmp_dir, $globalTransaction;
1386 1425
 		$query = "DELETE FROM satellite";
@@ -1428,6 +1467,9 @@  discard block
 block discarded – undo
1428 1467
 		return '';
1429 1468
 	}
1430 1469
 
1470
+	/**
1471
+	 * @param string $filename
1472
+	 */
1431 1473
 	public static function satellite_celestrak($filename) {
1432 1474
 		global $tmp_dir, $globalTransaction;
1433 1475
 		$satcat_sources = array(
@@ -1743,6 +1785,9 @@  discard block
 block discarded – undo
1743 1785
 
1744 1786
 	}
1745 1787
 */
1788
+	/**
1789
+	 * @param string $filename
1790
+	 */
1746 1791
 	public static function waypoints($filename) {
1747 1792
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1748 1793
 		global $tmp_dir, $globalTransaction;
@@ -1790,6 +1835,9 @@  discard block
 block discarded – undo
1790 1835
 		return '';
1791 1836
         }
1792 1837
 
1838
+	/**
1839
+	 * @param string $filename
1840
+	 */
1793 1841
 	public static function ivao_airlines($filename) {
1794 1842
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1795 1843
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Indentation   +387 added lines, -387 removed lines patch added patch discarded remove patch
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
 		try {
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79
-                        $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
81
-                        return "error : ".$e->getMessage();
82
-                }
79
+						$sth->execute(array(':source' => $database_file));
80
+				} catch(PDOException $e) {
81
+						return "error : ".$e->getMessage();
82
+				}
83 83
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
85
-    		update_db::connect_sqlite($database_file);
84
+			if ($globalDebug) echo " - Add routes to DB -";
85
+			update_db::connect_sqlite($database_file);
86 86
 		//$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';
87 87
 		$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";
88 88
 		try {
89
-                        $sth = update_db::$db_sqlite->prepare($query);
90
-                        $sth->execute();
91
-                } catch(PDOException $e) {
92
-                        return "error : ".$e->getMessage();
93
-                }
89
+						$sth = update_db::$db_sqlite->prepare($query);
90
+						$sth->execute();
91
+				} catch(PDOException $e) {
92
+						return "error : ".$e->getMessage();
93
+				}
94 94
 		//$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)';
95 95
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
96 96
 		$Connection = new Connection();
97 97
 		$sth_dest = $Connection->db->prepare($query_dest);
98 98
 		try {
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$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);
102 102
 				$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);
103 103
 				$sth_dest->execute($query_dest_values);
104
-            		}
104
+					}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106 106
 		} catch(PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
110
-                return '';
110
+				return '';
111 111
 	}
112 112
 	public static function retrieve_route_oneworld($database_file) {
113 113
 		global $globalDebug, $globalTransaction;
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 		try {
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121
-                        $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
123
-                        return "error : ".$e->getMessage();
124
-                }
121
+						$sth->execute(array(':source' => 'oneworld'));
122
+				} catch(PDOException $e) {
123
+						return "error : ".$e->getMessage();
124
+				}
125 125
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
126
+			if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129 129
 		if ($fh = fopen($database_file,"r")) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 			if ($globalTransaction) $Connection->db->commit();
149 149
 		}
150
-                return '';
150
+				return '';
151 151
 	}
152 152
 	
153 153
 	public static function retrieve_route_skyteam($database_file) {
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 		try {
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162
-                        $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
164
-                        return "error : ".$e->getMessage();
165
-                }
162
+						$sth->execute(array(':source' => 'skyteam'));
163
+				} catch(PDOException $e) {
164
+						return "error : ".$e->getMessage();
165
+				}
166 166
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
167
+			if ($globalDebug) echo " - Add routes to DB -";
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
192 192
 		}
193
-                return '';
193
+				return '';
194 194
 	}
195 195
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 196
 		global $globalTransaction;
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 		try {
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202
-                        $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
204
-                        return "error : ".$e->getMessage();
205
-                }
202
+						$sth->execute(array(':source' => $database_file));
203
+				} catch(PDOException $e) {
204
+						return "error : ".$e->getMessage();
205
+				}
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
207 207
 		try {
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210
-                        $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
212
-                        return "error : ".$e->getMessage();
213
-                }
210
+						$sth->execute(array(':source' => $database_file));
211
+				} catch(PDOException $e) {
212
+						return "error : ".$e->getMessage();
213
+				}
214 214
 
215
-    		update_db::connect_sqlite($database_file);
215
+			update_db::connect_sqlite($database_file);
216 216
 		$query = 'select * from Aircraft';
217 217
 		try {
218
-                        $sth = update_db::$db_sqlite->prepare($query);
219
-                        $sth->execute();
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
218
+						$sth = update_db::$db_sqlite->prepare($query);
219
+						$sth->execute();
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 		//$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)';
224 224
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
225 225
 		
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 231
 		try {
232 232
 			if ($globalTransaction) $Connection->db->beginTransaction();
233
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 234
 			//$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']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237 237
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
-				    $sth_dest_owner->execute($query_dest_owner_values);
240
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
+					$sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243
-            		}
243
+					}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245 245
 		} catch(PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 		try {
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254
-                        $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
256
-                        return "error : ".$e->getMessage();
257
-                }
254
+						$sth->execute(array(':source' => $database_file));
255
+				} catch(PDOException $e) {
256
+						return "error : ".$e->getMessage();
257
+				}
258 258
 		return '';
259 259
 	}
260 260
 
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 		try {
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269
-                        $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
271
-                        return "error : ".$e->getMessage();
272
-                }
269
+						$sth->execute(array(':source' => $database_file));
270
+				} catch(PDOException $e) {
271
+						return "error : ".$e->getMessage();
272
+				}
273 273
 		
274 274
 		if ($fh = fopen($database_file,"r")) {
275 275
 			//$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)';
@@ -279,26 +279,26 @@  discard block
 block discarded – undo
279 279
 			$sth_dest = $Connection->db->prepare($query_dest);
280 280
 			try {
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282
-            			while (!feof($fh)) {
283
-            				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+						while (!feof($fh)) {
283
+							$values = array();
284
+							$line = $Common->hex2str(fgets($fh,9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
289
-            				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
291
-            				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
-            				$sth_search = $Connection->db->prepare($query_search);
286
+							$values['ModeS'] = substr($line,0,6);
287
+							$values['Registration'] = trim(substr($line,69,6));
288
+							$aircraft_name = trim(substr($line,48,6));
289
+							// Check if we can find ICAO, else set it to GLID
290
+							$aircraft_name_split = explode(' ',$aircraft_name);
291
+							$search_more = '';
292
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
+							$sth_search = $Connection->db->prepare($query_search);
295 295
 					try {
296
-                                    		$sth_search->execute();
297
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
-	            				//if (count($result) > 0) {
299
-	            				if (isset($result['icao']) && $result['icao'] != '') {
300
-	            				    $values['ICAOTypeCode'] = $result['icao'];
301
-	            				} 
296
+											$sth_search->execute();
297
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
+								//if (count($result) > 0) {
299
+								if (isset($result['icao']) && $result['icao'] != '') {
300
+									$values['ICAOTypeCode'] = $result['icao'];
301
+								} 
302 302
 					} catch(PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		try {
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324
-                        $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
326
-                        return "error : ".$e->getMessage();
327
-                }
324
+						$sth->execute(array(':source' => $database_file));
325
+				} catch(PDOException $e) {
326
+						return "error : ".$e->getMessage();
327
+				}
328 328
 		return '';
329 329
 	}
330 330
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 		try {
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338
-                        $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
340
-                        return "error : ".$e->getMessage();
341
-                }
338
+						$sth->execute(array(':source' => $database_file));
339
+				} catch(PDOException $e) {
340
+						return "error : ".$e->getMessage();
341
+				}
342 342
 		
343 343
 		if ($fh = fopen($database_file,"r")) {
344 344
 			//$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)';
@@ -349,25 +349,25 @@  discard block
 block discarded – undo
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351 351
 				$tmp = fgetcsv($fh,9999,',',"'");
352
-            			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
352
+						while (!feof($fh)) {
353
+							$line = fgetcsv($fh,9999,',',"'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
357
-            				$values['ModeS'] = $line[1];
358
-            				$values['Registration'] = $line[3];
359
-            				$values['ICAOTypeCode'] = '';
360
-            				$aircraft_name = $line[2];
361
-            				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
363
-            				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
-            				$sth_search = $Connection->db->prepare($query_search);
357
+							$values['ModeS'] = $line[1];
358
+							$values['Registration'] = $line[3];
359
+							$values['ICAOTypeCode'] = '';
360
+							$aircraft_name = $line[2];
361
+							// Check if we can find ICAO, else set it to GLID
362
+							$aircraft_name_split = explode(' ',$aircraft_name);
363
+							$search_more = '';
364
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
+							$sth_search = $Connection->db->prepare($query_search);
367 367
 					try {
368
-                                    		$sth_search->execute();
369
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
+											$sth_search->execute();
369
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371 371
 					} catch(PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 		try {
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393
-                        $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
395
-                        return "error : ".$e->getMessage();
396
-                }
393
+						$sth->execute(array(':source' => $database_file));
394
+				} catch(PDOException $e) {
395
+						return "error : ".$e->getMessage();
396
+				}
397 397
 		return '';
398 398
 	}
399 399
 
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 		try {
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407
-                        $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
409
-                        return "error : ".$e->getMessage();
410
-                }
407
+						$sth->execute(array(':source' => $database_file));
408
+				} catch(PDOException $e) {
409
+						return "error : ".$e->getMessage();
410
+				}
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413 413
 		if ($fh = fopen($database_file,"r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
416
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
417 417
 		        
418 418
 			$Connection = new Connection();
419 419
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -421,126 +421,126 @@  discard block
 block discarded – undo
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423 423
 				$tmp = fgetcsv($fh,9999,',','"');
424
-            			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
426
-            				$values = array();
427
-            				//print_r($line);
428
-            				if ($country == 'F') {
429
-            				    $values['registration'] = $line[0];
430
-            				    $values['base'] = $line[4];
431
-            				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
-					    $values['cancel'] = $line[7];
424
+						while (!feof($fh)) {
425
+							$line = fgetcsv($fh,9999,',','"');
426
+							$values = array();
427
+							//print_r($line);
428
+							if ($country == 'F') {
429
+								$values['registration'] = $line[0];
430
+								$values['base'] = $line[4];
431
+								$values['owner'] = $line[5];
432
+								if ($line[6] == '') $values['date_first_reg'] = null;
433
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
+						$values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436
-					    // TODO : add modeS & reg to aircraft_modes
437
-            				    $values['registration'] = $line[0];
438
-            				    $values['base'] = $line[3];
439
-            				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
-					    $values['cancel'] = '';
443
-					    $values['modes'] = $line[7];
444
-					    $values['icao'] = $line[8];
436
+						// TODO : add modeS & reg to aircraft_modes
437
+								$values['registration'] = $line[0];
438
+								$values['base'] = $line[3];
439
+								$values['owner'] = $line[2];
440
+								if ($line[1] == '') $values['date_first_reg'] = null;
441
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
+						$values['cancel'] = '';
443
+						$values['modes'] = $line[7];
444
+						$values['icao'] = $line[8];
445 445
 					    
446 446
 					} elseif ($country == 'HB') {
447
-					    // TODO : add modeS & reg to aircraft_modes
448
-            				    $values['registration'] = $line[0];
449
-            				    $values['base'] = null;
450
-            				    $values['owner'] = $line[5];
451
-            				    $values['date_first_reg'] = null;
452
-					    $values['cancel'] = '';
453
-					    $values['modes'] = $line[4];
454
-					    $values['icao'] = $line[7];
447
+						// TODO : add modeS & reg to aircraft_modes
448
+								$values['registration'] = $line[0];
449
+								$values['base'] = null;
450
+								$values['owner'] = $line[5];
451
+								$values['date_first_reg'] = null;
452
+						$values['cancel'] = '';
453
+						$values['modes'] = $line[4];
454
+						$values['icao'] = $line[7];
455 455
 					} elseif ($country == 'OK') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[3];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
-					    $values['cancel'] = '';
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[3];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								if ($line[18] == '') $values['date_first_reg'] = null;
461
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
+						$values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464
-					    // TODO : add modeS & reg to aircraft_modes
465
-            				    $values['registration'] = $line[0];
466
-            				    $values['base'] = null;
467
-            				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
-
471
-					    $values['cancel'] = $line[39];
464
+						// TODO : add modeS & reg to aircraft_modes
465
+								$values['registration'] = $line[0];
466
+								$values['base'] = null;
467
+								$values['owner'] = $line[12];
468
+								if ($line[28] == '') $values['date_first_reg'] = null;
469
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
+
471
+						$values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
473
-            				    $values['registration'] = $line[0];
474
-            				    $values['base'] = null;
475
-            				    $values['owner'] = $line[4];
476
-            				    $values['date_first_reg'] = null;
477
-					    $values['cancel'] = '';
473
+								$values['registration'] = $line[0];
474
+								$values['base'] = null;
475
+								$values['owner'] = $line[4];
476
+								$values['date_first_reg'] = null;
477
+						$values['cancel'] = '';
478 478
 					} elseif ($country == 'CC') {
479
-            				    $values['registration'] = $line[0];
480
-            				    $values['base'] = null;
481
-            				    $values['owner'] = $line[6];
482
-            				    $values['date_first_reg'] = null;
483
-					    $values['cancel'] = '';
479
+								$values['registration'] = $line[0];
480
+								$values['base'] = null;
481
+								$values['owner'] = $line[6];
482
+								$values['date_first_reg'] = null;
483
+						$values['cancel'] = '';
484 484
 					} elseif ($country == 'HJ') {
485
-            				    $values['registration'] = $line[0];
486
-            				    $values['base'] = null;
487
-            				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
-					    $values['cancel'] = '';
485
+								$values['registration'] = $line[0];
486
+								$values['base'] = null;
487
+								$values['owner'] = $line[8];
488
+								if ($line[7] == '') $values['date_first_reg'] = null;
489
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
+						$values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492
-            				    $values['registration'] = $line[0];
493
-            				    $values['base'] = null;
494
-            				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
-					    $values['cancel'] = $line[7];
492
+								$values['registration'] = $line[0];
493
+								$values['base'] = null;
494
+								$values['owner'] = $line[4];
495
+								if ($line[6] == '') $values['date_first_reg'] = null;
496
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+						$values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499
-            				    $values['registration'] = $line[0];
500
-            				    $values['base'] = null;
501
-            				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
-					    $values['cancel'] = '';
499
+								$values['registration'] = $line[0];
500
+								$values['base'] = null;
501
+								$values['owner'] = $line[4];
502
+								if ($line[5] == '') $values['date_first_reg'] = null;
503
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
+						$values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506
-            				    $values['registration'] = $line[0];
507
-            				    $values['base'] = null;
508
-            				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
-					    $values['cancel'] = '';
506
+								$values['registration'] = $line[0];
507
+								$values['base'] = null;
508
+								$values['owner'] = $line[3];
509
+								if ($line[7] == '') $values['date_first_reg'] = null;
510
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
+						$values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513
-            				    $values['registration'] = $line[0];
514
-            				    $values['base'] = null;
515
-            				    $values['owner'] = $line[3];
516
-            				    $values['date_first_reg'] = null;
517
-					    $values['cancel'] = '';
518
-					    $values['modes'] = $line[5];
519
-					    $values['icao'] = $line[9];
513
+								$values['registration'] = $line[0];
514
+								$values['base'] = null;
515
+								$values['owner'] = $line[3];
516
+								$values['date_first_reg'] = null;
517
+						$values['cancel'] = '';
518
+						$values['modes'] = $line[5];
519
+						$values['icao'] = $line[9];
520 520
 					} elseif ($country == 'M') {
521
-            				    $values['registration'] = $line[0];
522
-            				    $values['base'] = null;
523
-            				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
-					    $values['modes'] = $line[4];
527
-					    $values['icao'] = $line[10];
521
+								$values['registration'] = $line[0];
522
+								$values['base'] = null;
523
+								$values['owner'] = $line[6];
524
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
+						$values['modes'] = $line[4];
527
+						$values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529
-            				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
-					    $values['modes'] = $line[5];
532
-					    $values['icao'] = $line[6];
529
+								$values['registration'] = $line[0];
530
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
+						$values['modes'] = $line[5];
532
+						$values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534
-            				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
-					    $values['modes'] = $line[4];
537
-					    $values['icao'] = $line[5];
534
+								$values['registration'] = $line[0];
535
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
+						$values['modes'] = $line[4];
537
+						$values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
539
-            				    $values['registration'] = $line[0];
540
-            				    $values['base'] = null;
541
-            				    $values['owner'] = $line[3];
542
-            				    $values['date_first_reg'] = null;
543
-					    $values['cancel'] = '';
539
+								$values['registration'] = $line[0];
540
+								$values['base'] = null;
541
+								$values['owner'] = $line[3];
542
+								$values['date_first_reg'] = null;
543
+						$values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546 546
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
                         return "error : ".$e->getMessage();
674 674
                 }
675 675
                 */
676
-                /*
676
+				/*
677 677
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
678 678
 		try {
679 679
 			$Connection = new Connection();
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
 		try {
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921
-                        $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
923
-                        return "error : ".$e->getMessage();
924
-                }
921
+						$sth->execute(array(':source' => 'translation.csv'));
922
+				} catch(PDOException $e) {
923
+						return "error : ".$e->getMessage();
924
+				}
925 925
 
926 926
 		
927 927
 		//update_db::unzip($out_file);
@@ -940,21 +940,21 @@  discard block
 block discarded – undo
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
943
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
-                                                //echo substr($operator, 0, 2)."\n";;
945
-                                                if (count($airline_array) > 0) {
943
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
+												//echo substr($operator, 0, 2)."\n";;
945
+												if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947 947
 							$operator = $airline_array[0]['icao'].substr($operator,2);
948
-                                                }
949
-                                        }
948
+												}
949
+										}
950 950
 					
951 951
 					$operator_correct = $data[3];
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
-                                                if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
-                                            	}
957
-                                        }
953
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
+												if (count($airline_array) > 0) {
955
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
+												}
957
+										}
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			//$Connection->db->commit();
969 969
 		}
970 970
 		return '';
971
-        }
971
+		}
972 972
 	
973 973
 	public static function translation_fam() {
974 974
 		global $tmp_dir, $globalTransaction;
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 			//$Connection->db->commit();
1007 1007
 		}
1008 1008
 		return '';
1009
-        }
1009
+		}
1010 1010
 
1011 1011
 	/*
1012 1012
 	* This function use FAA public data.
@@ -1018,19 +1018,19 @@  discard block
 block discarded – undo
1018 1018
 		try {
1019 1019
 			$Connection = new Connection();
1020 1020
 			$sth = $Connection->db->prepare($query);
1021
-                        $sth->execute(array(':source' => 'website_faa'));
1022
-                } catch(PDOException $e) {
1023
-                        return "error : ".$e->getMessage();
1024
-                }
1021
+						$sth->execute(array(':source' => 'website_faa'));
1022
+				} catch(PDOException $e) {
1023
+						return "error : ".$e->getMessage();
1024
+				}
1025 1025
 
1026 1026
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1027 1027
 		try {
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030
-                        $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1032
-                        return "error : ".$e->getMessage();
1033
-                }
1030
+						$sth->execute(array(':source' => 'website_faa'));
1031
+				} catch(PDOException $e) {
1032
+						return "error : ".$e->getMessage();
1033
+				}
1034 1034
 
1035 1035
 		$delimiter = ",";
1036 1036
 		$mfr = array();
@@ -1106,17 +1106,17 @@  discard block
 block discarded – undo
1106 1106
 		}
1107 1107
 		//print_r($mfr);
1108 1108
 		return '';
1109
-        }
1109
+		}
1110 1110
 	public static function modes_fam() {
1111 1111
 		global $tmp_dir, $globalTransaction;
1112 1112
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1113 1113
 		try {
1114 1114
 			$Connection = new Connection();
1115 1115
 			$sth = $Connection->db->prepare($query);
1116
-                        $sth->execute(array(':source' => 'website_fam'));
1117
-                } catch(PDOException $e) {
1118
-                        return "error : ".$e->getMessage();
1119
-                }
1116
+						$sth->execute(array(':source' => 'website_fam'));
1117
+				} catch(PDOException $e) {
1118
+						return "error : ".$e->getMessage();
1119
+				}
1120 1120
 
1121 1121
 		
1122 1122
 		//update_db::unzip($out_file);
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 			if ($globalTransaction) $Connection->db->commit();
1147 1147
 		}
1148 1148
 		return '';
1149
-        }
1149
+		}
1150 1150
         
1151 1151
 	public static function owner_fam() {
1152 1152
 		global $tmp_dir, $globalTransaction;
@@ -1154,10 +1154,10 @@  discard block
 block discarded – undo
1154 1154
 		try {
1155 1155
 			$Connection = new Connection();
1156 1156
 			$sth = $Connection->db->prepare($query);
1157
-                        $sth->execute(array(':source' => 'website_fam'));
1158
-                } catch(PDOException $e) {
1159
-                        return "error : ".$e->getMessage();
1160
-                }
1157
+						$sth->execute(array(':source' => 'website_fam'));
1158
+				} catch(PDOException $e) {
1159
+						return "error : ".$e->getMessage();
1160
+				}
1161 1161
 
1162 1162
 		$delimiter = "\t";
1163 1163
 		$Connection = new Connection();
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 			if ($globalTransaction) $Connection->db->commit();
1184 1184
 		}
1185 1185
 		return '';
1186
-        }
1186
+		}
1187 1187
 
1188 1188
 	public static function routes_fam() {
1189 1189
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 			if ($globalTransaction) $Connection->db->commit();
1219 1219
 		}
1220 1220
 		return '';
1221
-        }
1221
+		}
1222 1222
 
1223 1223
 	public static function marine_identity_fam() {
1224 1224
 		global $tmp_dir, $globalTransaction;
@@ -1226,10 +1226,10 @@  discard block
 block discarded – undo
1226 1226
 		try {
1227 1227
 			$Connection = new Connection();
1228 1228
 			$sth = $Connection->db->prepare($query);
1229
-                        $sth->execute();
1230
-                } catch(PDOException $e) {
1231
-                        return "error : ".$e->getMessage();
1232
-                }
1229
+						$sth->execute();
1230
+				} catch(PDOException $e) {
1231
+						return "error : ".$e->getMessage();
1232
+				}
1233 1233
 
1234 1234
 		
1235 1235
 		//update_db::unzip($out_file);
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 			if ($globalTransaction) $Connection->db->commit();
1260 1260
 		}
1261 1261
 		return '';
1262
-        }
1262
+		}
1263 1263
 
1264 1264
 	public static function satellite_fam() {
1265 1265
 		global $tmp_dir, $globalTransaction;
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 			if ($globalTransaction) $Connection->db->commit();
1331 1331
 		}
1332 1332
 		return '';
1333
-        }
1333
+		}
1334 1334
 
1335 1335
 	public static function tle($filename,$tletype) {
1336 1336
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1341,10 +1341,10 @@  discard block
 block discarded – undo
1341 1341
 		try {
1342 1342
 			$Connection = new Connection();
1343 1343
 			$sth = $Connection->db->prepare($query);
1344
-                        $sth->execute(array(':source' => $filename));
1345
-                } catch(PDOException $e) {
1346
-                        return "error : ".$e->getMessage();
1347
-                }
1344
+						$sth->execute(array(':source' => $filename));
1345
+				} catch(PDOException $e) {
1346
+						return "error : ".$e->getMessage();
1347
+				}
1348 1348
 		
1349 1349
 		$Connection = new Connection();
1350 1350
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 			//$Connection->db->commit();
1380 1380
 		}
1381 1381
 		return '';
1382
-        }
1382
+		}
1383 1383
 
1384 1384
 	public static function satellite_ucsdb($filename) {
1385 1385
 		global $tmp_dir, $globalTransaction;
@@ -1628,11 +1628,11 @@  discard block
 block discarded – undo
1628 1628
 						try {
1629 1629
 							$sth = $Connection->db->prepare($query);
1630 1630
 							$sth->execute(array(
1631
-							    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1632
-							    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1633
-							    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1634
-							    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1635
-							    )
1631
+								':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1632
+								':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1633
+								':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1634
+								':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1635
+								)
1636 1636
 							);
1637 1637
 						} catch(PDOException $e) {
1638 1638
 							return "error : ".$e->getMessage();
@@ -1655,13 +1655,13 @@  discard block
 block discarded – undo
1655 1655
 			//$Connection->db->commit();
1656 1656
 		}
1657 1657
 		return '';
1658
-        }
1658
+		}
1659 1659
 
1660 1660
 	/**
1661
-        * Convert a HTML table to an array
1662
-        * @param String $data HTML page
1663
-        * @return Array array of the tables in HTML page
1664
-        */
1661
+	 * Convert a HTML table to an array
1662
+	 * @param String $data HTML page
1663
+	 * @return Array array of the tables in HTML page
1664
+	 */
1665 1665
 /*
1666 1666
         private static function table2array($data) {
1667 1667
                 $html = str_get_html($data);
@@ -1691,11 +1691,11 @@  discard block
 block discarded – undo
1691 1691
                 return(array_filter($tabledata));
1692 1692
         }
1693 1693
 */
1694
-       /**
1695
-        * Get data from form result
1696
-        * @param String $url form URL
1697
-        * @return String the result
1698
-        */
1694
+	   /**
1695
+	    * Get data from form result
1696
+	    * @param String $url form URL
1697
+	    * @return String the result
1698
+	    */
1699 1699
 /*
1700 1700
         private static function getData($url) {
1701 1701
                 $ch = curl_init();
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 			if ($globalTransaction) $Connection->db->commit();
1789 1789
 		}
1790 1790
 		return '';
1791
-        }
1791
+		}
1792 1792
 
1793 1793
 	public static function ivao_airlines($filename) {
1794 1794
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1798,10 +1798,10 @@  discard block
 block discarded – undo
1798 1798
 		try {
1799 1799
 			$Connection = new Connection();
1800 1800
 			$sth = $Connection->db->prepare($query);
1801
-                        $sth->execute();
1802
-                } catch(PDOException $e) {
1803
-                        return "error : ".$e->getMessage();
1804
-                }
1801
+						$sth->execute();
1802
+				} catch(PDOException $e) {
1803
+						return "error : ".$e->getMessage();
1804
+				}
1805 1805
 
1806 1806
 		$header = NULL;
1807 1807
 		$delimiter = ':';
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
 			if ($globalTransaction) $Connection->db->commit();
1826 1826
 		}
1827 1827
 		return '';
1828
-        }
1828
+		}
1829 1829
 	
1830 1830
 	public static function update_airspace() {
1831 1831
 		global $tmp_dir, $globalDBdriver;
@@ -1835,11 +1835,11 @@  discard block
 block discarded – undo
1835 1835
 			$query = 'DROP TABLE airspace';
1836 1836
 			try {
1837 1837
 				$sth = $Connection->db->prepare($query);
1838
-                    		$sth->execute();
1839
-	                } catch(PDOException $e) {
1838
+							$sth->execute();
1839
+					} catch(PDOException $e) {
1840 1840
 				return "error : ".$e->getMessage();
1841
-	                }
1842
-	        }
1841
+					}
1842
+			}
1843 1843
 
1844 1844
 
1845 1845
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1894,10 +1894,10 @@  discard block
 block discarded – undo
1894 1894
 			$query = 'DROP TABLE countries';
1895 1895
 			try {
1896 1896
 				$sth = $Connection->db->prepare($query);
1897
-            	        	$sth->execute();
1898
-	                } catch(PDOException $e) {
1899
-    	                	echo "error : ".$e->getMessage();
1900
-	                }
1897
+							$sth->execute();
1898
+					} catch(PDOException $e) {
1899
+							echo "error : ".$e->getMessage();
1900
+					}
1901 1901
 		}
1902 1902
 		if ($globalDBdriver == 'mysql') {
1903 1903
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2452,11 +2452,11 @@  discard block
 block discarded – undo
2452 2452
 						$query = 'DROP TABLE airspace';
2453 2453
 						try {
2454 2454
 							$sth = $Connection->db->prepare($query);
2455
-    	    	    					$sth->execute();
2456
-			            		} catch(PDOException $e) {
2455
+										$sth->execute();
2456
+								} catch(PDOException $e) {
2457 2457
 							return "error : ".$e->getMessage();
2458
-		            			}
2459
-		    			}
2458
+								}
2459
+						}
2460 2460
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2461 2461
 					update_db::insert_airspace_version($airspace_md5);
2462 2462
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2666,12 +2666,12 @@  discard block
 block discarded – undo
2666 2666
 		echo $data;
2667 2667
 		*/
2668 2668
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2669
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2670
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2671
-		    $result = fread($fh,100000000);
2672
-		    //echo $result;
2673
-		    //var_dump(str_get_html($result));
2674
-		    //print_r(self::table2array($result));
2669
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2670
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2671
+			$result = fread($fh,100000000);
2672
+			//echo $result;
2673
+			//var_dump(str_get_html($result));
2674
+			//print_r(self::table2array($result));
2675 2675
 		}
2676 2676
 
2677 2677
 	}
@@ -2685,10 +2685,10 @@  discard block
 block discarded – undo
2685 2685
 		try {
2686 2686
 			$Connection = new Connection();
2687 2687
 			$sth = $Connection->db->prepare($query);
2688
-                        $sth->execute();
2689
-                } catch(PDOException $e) {
2690
-                        return "error : ".$e->getMessage();
2691
-                }
2688
+						$sth->execute();
2689
+				} catch(PDOException $e) {
2690
+						return "error : ".$e->getMessage();
2691
+				}
2692 2692
 
2693 2693
 		$error = '';
2694 2694
 		if ($globalDebug) echo "Notam : Download...";
@@ -2744,8 +2744,8 @@  discard block
 block discarded – undo
2744 2744
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2745 2745
 					$data['permanent'] = 0;
2746 2746
 				} else {
2747
-				    $data['date_end'] = NULL;
2748
-				    $data['permanent'] = 1;
2747
+					$data['date_end'] = NULL;
2748
+					$data['permanent'] = 1;
2749 2749
 				}
2750 2750
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2751 2751
 				$NOTAM = new NOTAM();
@@ -2819,13 +2819,13 @@  discard block
 block discarded – undo
2819 2819
 		try {
2820 2820
 			$Connection = new Connection();
2821 2821
 			$sth = $Connection->db->prepare($query);
2822
-                        $sth->execute();
2823
-                } catch(PDOException $e) {
2824
-                        return "error : ".$e->getMessage();
2825
-                }
2826
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2827
-                if ($row['nb'] > 0) return false;
2828
-                else return true;
2822
+						$sth->execute();
2823
+				} catch(PDOException $e) {
2824
+						return "error : ".$e->getMessage();
2825
+				}
2826
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2827
+				if ($row['nb'] > 0) return false;
2828
+				else return true;
2829 2829
 	}
2830 2830
 
2831 2831
 	public static function insert_last_update() {
@@ -2834,10 +2834,10 @@  discard block
 block discarded – undo
2834 2834
 		try {
2835 2835
 			$Connection = new Connection();
2836 2836
 			$sth = $Connection->db->prepare($query);
2837
-                        $sth->execute();
2838
-                } catch(PDOException $e) {
2839
-                        return "error : ".$e->getMessage();
2840
-                }
2837
+						$sth->execute();
2838
+				} catch(PDOException $e) {
2839
+						return "error : ".$e->getMessage();
2840
+				}
2841 2841
 	}
2842 2842
 
2843 2843
 	public static function check_airspace_version($version) {
@@ -2845,13 +2845,13 @@  discard block
 block discarded – undo
2845 2845
 		try {
2846 2846
 			$Connection = new Connection();
2847 2847
 			$sth = $Connection->db->prepare($query);
2848
-                        $sth->execute(array(':version' => $version));
2849
-                } catch(PDOException $e) {
2850
-                        return "error : ".$e->getMessage();
2851
-                }
2852
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2853
-                if ($row['nb'] > 0) return true;
2854
-                else return false;
2848
+						$sth->execute(array(':version' => $version));
2849
+				} catch(PDOException $e) {
2850
+						return "error : ".$e->getMessage();
2851
+				}
2852
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2853
+				if ($row['nb'] > 0) return true;
2854
+				else return false;
2855 2855
 	}
2856 2856
 
2857 2857
 	public static function check_geoid_version($version) {
@@ -2859,13 +2859,13 @@  discard block
 block discarded – undo
2859 2859
 		try {
2860 2860
 			$Connection = new Connection();
2861 2861
 			$sth = $Connection->db->prepare($query);
2862
-                        $sth->execute(array(':version' => $version));
2863
-                } catch(PDOException $e) {
2864
-                        return "error : ".$e->getMessage();
2865
-                }
2866
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2867
-                if ($row['nb'] > 0) return true;
2868
-                else return false;
2862
+						$sth->execute(array(':version' => $version));
2863
+				} catch(PDOException $e) {
2864
+						return "error : ".$e->getMessage();
2865
+				}
2866
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2867
+				if ($row['nb'] > 0) return true;
2868
+				else return false;
2869 2869
 	}
2870 2870
 
2871 2871
 	public static function check_marine_identity_version($version) {
@@ -2915,10 +2915,10 @@  discard block
 block discarded – undo
2915 2915
 		try {
2916 2916
 			$Connection = new Connection();
2917 2917
 			$sth = $Connection->db->prepare($query);
2918
-                        $sth->execute(array(':version' => $version));
2919
-                } catch(PDOException $e) {
2920
-                        return "error : ".$e->getMessage();
2921
-                }
2918
+						$sth->execute(array(':version' => $version));
2919
+				} catch(PDOException $e) {
2920
+						return "error : ".$e->getMessage();
2921
+				}
2922 2922
 	}
2923 2923
 
2924 2924
 	public static function insert_marine_identity_version($version) {
@@ -2955,13 +2955,13 @@  discard block
 block discarded – undo
2955 2955
 		try {
2956 2956
 			$Connection = new Connection();
2957 2957
 			$sth = $Connection->db->prepare($query);
2958
-                        $sth->execute();
2959
-                } catch(PDOException $e) {
2960
-                        return "error : ".$e->getMessage();
2961
-                }
2962
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2963
-                if ($row['nb'] > 0) return false;
2964
-                else return true;
2958
+						$sth->execute();
2959
+				} catch(PDOException $e) {
2960
+						return "error : ".$e->getMessage();
2961
+				}
2962
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2963
+				if ($row['nb'] > 0) return false;
2964
+				else return true;
2965 2965
 	}
2966 2966
 
2967 2967
 	public static function insert_last_notam_update() {
@@ -2970,10 +2970,10 @@  discard block
 block discarded – undo
2970 2970
 		try {
2971 2971
 			$Connection = new Connection();
2972 2972
 			$sth = $Connection->db->prepare($query);
2973
-                        $sth->execute();
2974
-                } catch(PDOException $e) {
2975
-                        return "error : ".$e->getMessage();
2976
-                }
2973
+						$sth->execute();
2974
+				} catch(PDOException $e) {
2975
+						return "error : ".$e->getMessage();
2976
+				}
2977 2977
 	}
2978 2978
 
2979 2979
 	public static function check_last_airspace_update() {
@@ -2986,13 +2986,13 @@  discard block
 block discarded – undo
2986 2986
 		try {
2987 2987
 			$Connection = new Connection();
2988 2988
 			$sth = $Connection->db->prepare($query);
2989
-                        $sth->execute();
2990
-                } catch(PDOException $e) {
2991
-                        return "error : ".$e->getMessage();
2992
-                }
2993
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2994
-                if ($row['nb'] > 0) return false;
2995
-                else return true;
2989
+						$sth->execute();
2990
+				} catch(PDOException $e) {
2991
+						return "error : ".$e->getMessage();
2992
+				}
2993
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2994
+				if ($row['nb'] > 0) return false;
2995
+				else return true;
2996 2996
 	}
2997 2997
 
2998 2998
 	public static function insert_last_airspace_update() {
@@ -3001,10 +3001,10 @@  discard block
 block discarded – undo
3001 3001
 		try {
3002 3002
 			$Connection = new Connection();
3003 3003
 			$sth = $Connection->db->prepare($query);
3004
-                        $sth->execute();
3005
-                } catch(PDOException $e) {
3006
-                        return "error : ".$e->getMessage();
3007
-                }
3004
+						$sth->execute();
3005
+				} catch(PDOException $e) {
3006
+						return "error : ".$e->getMessage();
3007
+				}
3008 3008
 	}
3009 3009
 
3010 3010
 	public static function check_last_geoid_update() {
@@ -3017,13 +3017,13 @@  discard block
 block discarded – undo
3017 3017
 		try {
3018 3018
 			$Connection = new Connection();
3019 3019
 			$sth = $Connection->db->prepare($query);
3020
-                        $sth->execute();
3021
-                } catch(PDOException $e) {
3022
-                        return "error : ".$e->getMessage();
3023
-                }
3024
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3025
-                if ($row['nb'] > 0) return false;
3026
-                else return true;
3020
+						$sth->execute();
3021
+				} catch(PDOException $e) {
3022
+						return "error : ".$e->getMessage();
3023
+				}
3024
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3025
+				if ($row['nb'] > 0) return false;
3026
+				else return true;
3027 3027
 	}
3028 3028
 
3029 3029
 	public static function insert_last_geoid_update() {
@@ -3032,10 +3032,10 @@  discard block
 block discarded – undo
3032 3032
 		try {
3033 3033
 			$Connection = new Connection();
3034 3034
 			$sth = $Connection->db->prepare($query);
3035
-                        $sth->execute();
3036
-                } catch(PDOException $e) {
3037
-                        return "error : ".$e->getMessage();
3038
-                }
3035
+						$sth->execute();
3036
+				} catch(PDOException $e) {
3037
+						return "error : ".$e->getMessage();
3038
+				}
3039 3039
 	}
3040 3040
 
3041 3041
 	public static function check_last_owner_update() {
@@ -3048,13 +3048,13 @@  discard block
 block discarded – undo
3048 3048
 		try {
3049 3049
 			$Connection = new Connection();
3050 3050
 			$sth = $Connection->db->prepare($query);
3051
-                        $sth->execute();
3052
-                } catch(PDOException $e) {
3053
-                        return "error : ".$e->getMessage();
3054
-                }
3055
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3056
-                if ($row['nb'] > 0) return false;
3057
-                else return true;
3051
+						$sth->execute();
3052
+				} catch(PDOException $e) {
3053
+						return "error : ".$e->getMessage();
3054
+				}
3055
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3056
+				if ($row['nb'] > 0) return false;
3057
+				else return true;
3058 3058
 	}
3059 3059
 
3060 3060
 	public static function insert_last_owner_update() {
@@ -3063,10 +3063,10 @@  discard block
 block discarded – undo
3063 3063
 		try {
3064 3064
 			$Connection = new Connection();
3065 3065
 			$sth = $Connection->db->prepare($query);
3066
-                        $sth->execute();
3067
-                } catch(PDOException $e) {
3068
-                        return "error : ".$e->getMessage();
3069
-                }
3066
+						$sth->execute();
3067
+				} catch(PDOException $e) {
3068
+						return "error : ".$e->getMessage();
3069
+				}
3070 3070
 	}
3071 3071
 	public static function check_last_schedules_update() {
3072 3072
 		global $globalDBdriver;
@@ -3078,13 +3078,13 @@  discard block
 block discarded – undo
3078 3078
 		try {
3079 3079
 			$Connection = new Connection();
3080 3080
 			$sth = $Connection->db->prepare($query);
3081
-                        $sth->execute();
3082
-                } catch(PDOException $e) {
3083
-                        return "error : ".$e->getMessage();
3084
-                }
3085
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3086
-                if ($row['nb'] > 0) return false;
3087
-                else return true;
3081
+						$sth->execute();
3082
+				} catch(PDOException $e) {
3083
+						return "error : ".$e->getMessage();
3084
+				}
3085
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3086
+				if ($row['nb'] > 0) return false;
3087
+				else return true;
3088 3088
 	}
3089 3089
 
3090 3090
 	public static function insert_last_schedules_update() {
@@ -3264,10 +3264,10 @@  discard block
 block discarded – undo
3264 3264
 		try {
3265 3265
 			$Connection = new Connection();
3266 3266
 			$sth = $Connection->db->prepare($query);
3267
-                        $sth->execute();
3268
-                } catch(PDOException $e) {
3269
-                        return "error : ".$e->getMessage();
3270
-                }
3267
+						$sth->execute();
3268
+				} catch(PDOException $e) {
3269
+						return "error : ".$e->getMessage();
3270
+				}
3271 3271
 	}
3272 3272
 	public static function delete_duplicateowner() {
3273 3273
 		global $globalDBdriver;
@@ -3279,10 +3279,10 @@  discard block
 block discarded – undo
3279 3279
 		try {
3280 3280
 			$Connection = new Connection();
3281 3281
 			$sth = $Connection->db->prepare($query);
3282
-                        $sth->execute();
3283
-                } catch(PDOException $e) {
3284
-                        return "error : ".$e->getMessage();
3285
-                }
3282
+						$sth->execute();
3283
+				} catch(PDOException $e) {
3284
+						return "error : ".$e->getMessage();
3285
+				}
3286 3286
 	}
3287 3287
 	
3288 3288
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +347 added lines, -347 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		fclose($fp);
26 26
 	}
27 27
 
28
-	public static function gunzip($in_file,$out_file_name = '') {
28
+	public static function gunzip($in_file, $out_file_name = '') {
29 29
 		//echo $in_file.' -> '.$out_file_name."\n";
30 30
 		$buffer_size = 4096; // read 4kb at a time
31 31
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32 32
 		if ($in_file != '' && file_exists($in_file)) {
33 33
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
34
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
35
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
36 36
 			else {
37 37
 				echo 'gzopen not available';
38 38
 				die;
39 39
 			}
40 40
 			$out_file = fopen($out_file_name, 'wb'); 
41
-			while(!gzeof($file)) {
41
+			while (!gzeof($file)) {
42 42
 				fwrite($out_file, gzread($file, $buffer_size));
43 43
 			}  
44 44
 			fclose($out_file);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			self::$db_sqlite = new PDO('sqlite:'.$database);
64 64
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79 79
                         $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         return "error : ".$e->getMessage();
82 82
                 }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		try {
89 89
                         $sth = update_db::$db_sqlite->prepare($query);
90 90
                         $sth->execute();
91
-                } catch(PDOException $e) {
91
+                } catch (PDOException $e) {
92 92
                         return "error : ".$e->getMessage();
93 93
                 }
94 94
 		//$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)';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100 100
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$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);
102
-				$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
+				$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);
103 103
 				$sth_dest->execute($query_dest_values);
104 104
             		}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
126 126
     		if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129
-		if ($fh = fopen($database_file,"r")) {
129
+		if ($fh = fopen($database_file, "r")) {
130 130
 			$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)';
131 131
 			$Connection = new Connection();
132 132
 			$sth_dest = $Connection->db->prepare($query_dest);
133 133
 			if ($globalTransaction) $Connection->db->beginTransaction();
134 134
 			while (!feof($fh)) {
135
-				$line = fgetcsv($fh,9999,',');
135
+				$line = fgetcsv($fh, 9999, ',');
136 136
 				if ($line[0] != '') {
137 137
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
138 138
 						try {
139
-							$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
+							$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');
140 140
 							$sth_dest->execute($query_dest_values);
141
-						} catch(PDOException $e) {
141
+						} catch (PDOException $e) {
142 142
 							if ($globalTransaction) $Connection->db->rollBack(); 
143 143
 							return "error : ".$e->getMessage();
144 144
 						}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162 162
                         $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         return "error : ".$e->getMessage();
165 165
                 }
166 166
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
171
-		if ($fh = fopen($database_file,"r")) {
171
+		if ($fh = fopen($database_file, "r")) {
172 172
 			$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)';
173 173
 			$Connection = new Connection();
174 174
 			$sth_dest = $Connection->db->prepare($query_dest);
175 175
 			try {
176 176
 				if ($globalTransaction) $Connection->db->beginTransaction();
177 177
 				while (!feof($fh)) {
178
-					$line = fgetcsv($fh,9999,',');
178
+					$line = fgetcsv($fh, 9999, ',');
179 179
 					if ($line[0] != '') {
180
-						$datebe = explode('  -  ',$line[2]);
180
+						$datebe = explode('  -  ', $line[2]);
181 181
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
182
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
182
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
183 183
 							$sth_dest->execute($query_dest_values);
184 184
 						}
185 185
 					}
186 186
 				}
187 187
 				if ($globalTransaction) $Connection->db->commit();
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				if ($globalTransaction) $Connection->db->rollBack(); 
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202 202
                         $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         return "error : ".$e->getMessage();
205 205
                 }
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210 210
                         $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         return "error : ".$e->getMessage();
213 213
                 }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		try {
218 218
                         $sth = update_db::$db_sqlite->prepare($query);
219 219
                         $sth->execute();
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 		//$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)';
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 			//$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']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237
-				$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
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
241 241
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243 243
             		}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245
-		} catch(PDOException $e) {
245
+		} catch (PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
247 247
 		}
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254 254
                         $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
255
+                } catch (PDOException $e) {
256 256
                         return "error : ".$e->getMessage();
257 257
                 }
258 258
 		return '';
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269 269
                         $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
270
+                } catch (PDOException $e) {
271 271
                         return "error : ".$e->getMessage();
272 272
                 }
273 273
 		
274
-		if ($fh = fopen($database_file,"r")) {
274
+		if ($fh = fopen($database_file, "r")) {
275 275
 			//$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)';
276 276
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
277 277
 		
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282 282
             			while (!feof($fh)) {
283 283
             				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
284
+            				$line = $Common->hex2str(fgets($fh, 9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
286
+            				$values['ModeS'] = substr($line, 0, 6);
287
+            				$values['Registration'] = trim(substr($line, 69, 6));
288
+            				$aircraft_name = trim(substr($line, 48, 6));
289 289
             				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
+            				$aircraft_name_split = explode(' ', $aircraft_name);
291 291
             				$search_more = '';
292 292
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293 293
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	            				if (isset($result['icao']) && $result['icao'] != '') {
300 300
 	            				    $values['ICAOTypeCode'] = $result['icao'];
301 301
 	            				} 
302
-					} catch(PDOException $e) {
302
+					} catch (PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
305 305
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
306 306
 					// Add data to db
307 307
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 308
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
309
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
309
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
310 310
 						//print_r($query_dest_values);
311 311
 						$sth_dest->execute($query_dest_values);
312 312
 					}
313 313
 				}
314 314
 				if ($globalTransaction) $Connection->db->commit();
315
-			} catch(PDOException $e) {
315
+			} catch (PDOException $e) {
316 316
 				return "error : ".$e->getMessage();
317 317
 			}
318 318
 		}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324 324
                         $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
325
+                } catch (PDOException $e) {
326 326
                         return "error : ".$e->getMessage();
327 327
                 }
328 328
 		return '';
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338 338
                         $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
339
+                } catch (PDOException $e) {
340 340
                         return "error : ".$e->getMessage();
341 341
                 }
342 342
 		
343
-		if ($fh = fopen($database_file,"r")) {
343
+		if ($fh = fopen($database_file, "r")) {
344 344
 			//$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)';
345 345
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
346 346
 		
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 			$sth_dest = $Connection->db->prepare($query_dest);
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351
-				$tmp = fgetcsv($fh,9999,',',"'");
351
+				$tmp = fgetcsv($fh, 9999, ',', "'");
352 352
             			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
353
+            				$line = fgetcsv($fh, 9999, ',', "'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             				$values['ICAOTypeCode'] = '';
360 360
             				$aircraft_name = $line[2];
361 361
             				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
362
+            				$aircraft_name_split = explode(' ', $aircraft_name);
363 363
             				$search_more = '';
364 364
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365 365
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
                                     		$sth_search->execute();
369 369
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370 370
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371
-					} catch(PDOException $e) {
371
+					} catch (PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
374 374
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375 375
 					// Add data to db
376 376
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
377 377
 						//$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']);
378
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
378
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
379 379
 						//print_r($query_dest_values);
380 380
 						$sth_dest->execute($query_dest_values);
381 381
 					}
382 382
 				}
383 383
 				if ($globalTransaction) $Connection->db->commit();
384
-			} catch(PDOException $e) {
384
+			} catch (PDOException $e) {
385 385
 				return "error : ".$e->getMessage();
386 386
 			}
387 387
 		}
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
                         $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
394
+                } catch (PDOException $e) {
395 395
                         return "error : ".$e->getMessage();
396 396
                 }
397 397
 		return '';
398 398
 	}
399 399
 
400
-	public static function retrieve_owner($database_file,$country = 'F') {
400
+	public static function retrieve_owner($database_file, $country = 'F') {
401 401
 		global $globalTransaction, $globalMasterSource;
402 402
 		//$query = 'TRUNCATE TABLE aircraft_modes';
403 403
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407 407
                         $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
408
+                } catch (PDOException $e) {
409 409
                         return "error : ".$e->getMessage();
410 410
                 }
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413
-		if ($fh = fopen($database_file,"r")) {
413
+		if ($fh = fopen($database_file, "r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416 416
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 			$sth_modes = $Connection->db->prepare($query_modes);
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423
-				$tmp = fgetcsv($fh,9999,',','"');
423
+				$tmp = fgetcsv($fh, 9999, ',', '"');
424 424
             			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
425
+            				$line = fgetcsv($fh, 9999, ',', '"');
426 426
             				$values = array();
427 427
             				//print_r($line);
428 428
             				if ($country == 'F') {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             				    $values['base'] = $line[4];
431 431
             				    $values['owner'] = $line[5];
432 432
             				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
433
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
434 434
 					    $values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436 436
 					    // TODO : add modeS & reg to aircraft_modes
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             				    $values['base'] = $line[3];
439 439
             				    $values['owner'] = $line[2];
440 440
             				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
441
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
442 442
 					    $values['cancel'] = '';
443 443
 					    $values['modes'] = $line[7];
444 444
 					    $values['icao'] = $line[8];
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             				    $values['base'] = null;
459 459
             				    $values['owner'] = $line[5];
460 460
             				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
461
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
462 462
 					    $values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464 464
 					    // TODO : add modeS & reg to aircraft_modes
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             				    $values['base'] = null;
467 467
             				    $values['owner'] = $line[12];
468 468
             				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
469
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
470 470
 
471 471
 					    $values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -486,28 +486,28 @@  discard block
 block discarded – undo
486 486
             				    $values['base'] = null;
487 487
             				    $values['owner'] = $line[8];
488 488
             				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
489
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
490 490
 					    $values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492 492
             				    $values['registration'] = $line[0];
493 493
             				    $values['base'] = null;
494 494
             				    $values['owner'] = $line[4];
495 495
             				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
497 497
 					    $values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499 499
             				    $values['registration'] = $line[0];
500 500
             				    $values['base'] = null;
501 501
             				    $values['owner'] = $line[4];
502 502
             				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
503
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
504 504
 					    $values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506 506
             				    $values['registration'] = $line[0];
507 507
             				    $values['base'] = null;
508 508
             				    $values['owner'] = $line[3];
509 509
             				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
510
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
511 511
 					    $values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513 513
             				    $values['registration'] = $line[0];
@@ -521,18 +521,18 @@  discard block
 block discarded – undo
521 521
             				    $values['registration'] = $line[0];
522 522
             				    $values['base'] = null;
523 523
             				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
525
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
526 526
 					    $values['modes'] = $line[4];
527 527
 					    $values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529 529
             				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
530
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
531 531
 					    $values['modes'] = $line[5];
532 532
 					    $values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534 534
             				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
535
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
536 536
 					    $values['modes'] = $line[4];
537 537
 					    $values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
 					    $values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
546
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
547 547
 						$sth_dest->execute($query_dest_values);
548 548
 					}
549 549
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
550 550
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
551
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
551
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
552 552
 						$sth_modes->execute($query_modes_values);
553 553
 					}
554 554
 				}
555 555
 				if ($globalTransaction) $Connection->db->commit();
556
-			} catch(PDOException $e) {
556
+			} catch (PDOException $e) {
557 557
 				return "error : ".$e->getMessage();
558 558
 			}
559 559
 		}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		if ($globalTransaction) $Connection->db->beginTransaction();
692 692
   
693 693
 		$i = 0;
694
-		while($row = sparql_fetch_array($result))
694
+		while ($row = sparql_fetch_array($result))
695 695
 		{
696 696
 			if ($i >= 1) {
697 697
 			//print_r($row);
@@ -711,33 +711,33 @@  discard block
 block discarded – undo
711 711
 				$row['image'] = '';
712 712
 				$row['image_thumb'] = '';
713 713
 			} else {
714
-				$image = str_replace(' ','_',$row['image']);
714
+				$image = str_replace(' ', '_', $row['image']);
715 715
 				$digest = md5($image);
716
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
717
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
718
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
719
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
716
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
717
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
718
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
719
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
720 720
 			}
721 721
 			
722
-			$country = explode('-',$row['country']);
722
+			$country = explode('-', $row['country']);
723 723
 			$row['country'] = $country[0];
724 724
 			
725 725
 			$row['type'] = trim($row['type']);
726
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
726
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
727 727
 				$row['type'] = 'military';
728 728
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
729 729
 				$row['type'] = 'small_airport';
730 730
 			}
731 731
 			
732
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
733
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
732
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
733
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
734 734
 			//print_r($query_dest_values);
735 735
 			
736 736
 			if ($row['icao'] != '') {
737 737
 				try {
738 738
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
739 739
 					$sth->execute(array(':icao' => $row['icao']));
740
-				} catch(PDOException $e) {
740
+				} catch (PDOException $e) {
741 741
 					return "error : ".$e->getMessage();
742 742
 				}
743 743
 					if ($sth->fetchColumn() > 0) {
@@ -745,15 +745,15 @@  discard block
 block discarded – undo
745 745
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
746 746
 						try {
747 747
 							$sth = $Connection->db->prepare($query);
748
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
749
-						} catch(PDOException $e) {
748
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
749
+						} catch (PDOException $e) {
750 750
 							return "error : ".$e->getMessage();
751 751
 						}
752 752
 						echo $row['icao'].' : '.$row['type']."\n";
753 753
 					} else {
754 754
 						try {
755 755
 							$sth_dest->execute($query_dest_values);
756
-						} catch(PDOException $e) {
756
+						} catch (PDOException $e) {
757 757
 							return "error : ".$e->getMessage();
758 758
 						}
759 759
 					}
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		echo "Download data from ourairports.com...\n";
805 805
 		$delimiter = ',';
806 806
 		$out_file = $tmp_dir.'airports.csv';
807
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
807
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
808 808
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
809 809
 		echo "Add data from ourairports.com...\n";
810 810
 
@@ -815,33 +815,33 @@  discard block
 block discarded – undo
815 815
 			//$Connection->db->beginTransaction();
816 816
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 817
 			{
818
-				if(!$header) $header = $row;
818
+				if (!$header) $header = $row;
819 819
 				else {
820 820
 					$data = array();
821 821
 					$data = array_combine($header, $row);
822 822
 					try {
823 823
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
824 824
 						$sth->execute(array(':icao' => $data['ident']));
825
-					} catch(PDOException $e) {
825
+					} catch (PDOException $e) {
826 826
 						return "error : ".$e->getMessage();
827 827
 					}
828 828
 					if ($sth->fetchColumn() > 0) {
829 829
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
830 830
 						try {
831 831
 							$sth = $Connection->db->prepare($query);
832
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
833
-						} catch(PDOException $e) {
832
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
833
+						} catch (PDOException $e) {
834 834
 							return "error : ".$e->getMessage();
835 835
 						}
836 836
 					} else {
837 837
 						if ($data['gps_code'] == $data['ident']) {
838 838
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
839 839
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
840
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
840
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
841 841
 						try {
842 842
 							$sth = $Connection->db->prepare($query);
843 843
 							$sth->execute($query_values);
844
-						} catch(PDOException $e) {
844
+						} catch (PDOException $e) {
845 845
 							return "error : ".$e->getMessage();
846 846
 						}
847 847
 						$i++;
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		
857 857
 		echo "Download data from another free database...\n";
858 858
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
859
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
860 860
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
861 861
 		update_db::unzip($out_file);
862 862
 		$header = NULL;
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 			//$Connection->db->beginTransaction();
869 869
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 870
 			{
871
-				if(!$header) $header = $row;
871
+				if (!$header) $header = $row;
872 872
 				else {
873 873
 					$data = $row;
874 874
 
875 875
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
876 876
 					try {
877 877
 						$sth = $Connection->db->prepare($query);
878
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
879
-					} catch(PDOException $e) {
878
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
879
+					} catch (PDOException $e) {
880 880
 						return "error : ".$e->getMessage();
881 881
 					}
882 882
 				}
@@ -890,15 +890,15 @@  discard block
 block discarded – undo
890 890
 		try {
891 891
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
892 892
 			$sth->execute();
893
-		} catch(PDOException $e) {
893
+		} catch (PDOException $e) {
894 894
 			return "error : ".$e->getMessage();
895 895
 		}
896 896
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
897 897
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
898 898
 			try {
899 899
 				$sth2 = $Connection->db->prepare($query2);
900
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
901
-			} catch(PDOException $e) {
900
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
901
+			} catch (PDOException $e) {
902 902
 				return "error : ".$e->getMessage();
903 903
 			}
904 904
 		}
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921 921
                         $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
922
+                } catch (PDOException $e) {
923 923
                         return "error : ".$e->getMessage();
924 924
                 }
925 925
 
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
937 937
 			{
938 938
 				$i++;
939
-				if($i > 12) {
939
+				if ($i > 12) {
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
                                                 //echo substr($operator, 0, 2)."\n";;
945 945
                                                 if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947
-							$operator = $airline_array[0]['icao'].substr($operator,2);
947
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
948 948
                                                 }
949 949
                                         }
950 950
 					
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953 953
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954 954
                                                 if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
955
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
956 956
                                             	}
957 957
                                         }
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
961
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
-					} catch(PDOException $e) {
961
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
+					} catch (PDOException $e) {
963 963
 						return "error : ".$e->getMessage();
964 964
 					}
965 965
 				}
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 			$Connection = new Connection();
978 978
 			$sth = $Connection->db->prepare($query);
979 979
 			$sth->execute(array(':source' => 'website_fam'));
980
-		} catch(PDOException $e) {
980
+		} catch (PDOException $e) {
981 981
 			return "error : ".$e->getMessage();
982 982
 		}
983 983
 		//update_db::unzip($out_file);
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
996 996
 					try {
997 997
 						$sth = $Connection->db->prepare($query);
998
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
999
-					} catch(PDOException $e) {
998
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
999
+					} catch (PDOException $e) {
1000 1000
 						return "error : ".$e->getMessage();
1001 1001
 					}
1002 1002
 				}
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 			$Connection = new Connection();
1020 1020
 			$sth = $Connection->db->prepare($query);
1021 1021
                         $sth->execute(array(':source' => 'website_faa'));
1022
-                } catch(PDOException $e) {
1022
+                } catch (PDOException $e) {
1023 1023
                         return "error : ".$e->getMessage();
1024 1024
                 }
1025 1025
 
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030 1030
                         $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1031
+                } catch (PDOException $e) {
1032 1032
                         return "error : ".$e->getMessage();
1033 1033
                 }
1034 1034
 
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1046 1046
 					try {
1047 1047
 						$sths = $Connection->db->prepare($query_search);
1048
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1049
-					} catch(PDOException $e) {
1048
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1049
+					} catch (PDOException $e) {
1050 1050
 						return "error s : ".$e->getMessage();
1051 1051
 					}
1052 1052
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 							//}
1060 1060
 						try {
1061 1061
 							$sthi = $Connection->db->prepare($queryi);
1062
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1063
-						} catch(PDOException $e) {
1062
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1063
+						} catch (PDOException $e) {
1064 1064
 							return "error u : ".$e->getMessage();
1065 1065
 						}
1066 1066
 					} else {
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 						try {
1069 1069
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1070 1070
 							$sthsm->execute(array(':mfr' => $data[2]));
1071
-						} catch(PDOException $e) {
1071
+						} catch (PDOException $e) {
1072 1072
 							return "error mfr : ".$e->getMessage();
1073 1073
 						}
1074 1074
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1079 1079
 							try {
1080 1080
 								$sthf = $Connection->db->prepare($queryf);
1081
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1082
-							} catch(PDOException $e) {
1081
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1082
+							} catch (PDOException $e) {
1083 1083
 								return "error f : ".$e->getMessage();
1084 1084
 							}
1085 1085
 						}
@@ -1089,13 +1089,13 @@  discard block
 block discarded – undo
1089 1089
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1090 1090
 						try {
1091 1091
 							$sth = $Connection->db->prepare($query);
1092
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1093
-						} catch(PDOException $e) {
1092
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1093
+						} catch (PDOException $e) {
1094 1094
 							return "error i : ".$e->getMessage();
1095 1095
 						}
1096 1096
 					}
1097 1097
 				}
1098
-				if ($i % 90 == 0) {
1098
+				if ($i%90 == 0) {
1099 1099
 					if ($globalTransaction) $Connection->db->commit();
1100 1100
 					if ($globalTransaction) $Connection->db->beginTransaction();
1101 1101
 				}
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 			$Connection = new Connection();
1115 1115
 			$sth = $Connection->db->prepare($query);
1116 1116
                         $sth->execute(array(':source' => 'website_fam'));
1117
-                } catch(PDOException $e) {
1117
+                } catch (PDOException $e) {
1118 1118
                         return "error : ".$e->getMessage();
1119 1119
                 }
1120 1120
 
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1136 1136
 					try {
1137 1137
 						$sth = $Connection->db->prepare($query);
1138
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1139
-					} catch(PDOException $e) {
1138
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1139
+					} catch (PDOException $e) {
1140 1140
 						return "error : ".$e->getMessage();
1141 1141
 					}
1142 1142
 				}
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			$Connection = new Connection();
1156 1156
 			$sth = $Connection->db->prepare($query);
1157 1157
                         $sth->execute(array(':source' => 'website_fam'));
1158
-                } catch(PDOException $e) {
1158
+                } catch (PDOException $e) {
1159 1159
                         return "error : ".$e->getMessage();
1160 1160
                 }
1161 1161
 
@@ -1171,8 +1171,8 @@  discard block
 block discarded – undo
1171 1171
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1172 1172
 					try {
1173 1173
 						$sth = $Connection->db->prepare($query);
1174
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1175
-					} catch(PDOException $e) {
1174
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1175
+					} catch (PDOException $e) {
1176 1176
 						//print_r($data);
1177 1177
 						return "error : ".$e->getMessage();
1178 1178
 					}
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 			$Connection = new Connection();
1193 1193
 			$sth = $Connection->db->prepare($query);
1194 1194
 			$sth->execute(array(':source' => 'website_fam'));
1195
-		} catch(PDOException $e) {
1195
+		} catch (PDOException $e) {
1196 1196
 			return "error : ".$e->getMessage();
1197 1197
 		}
1198 1198
 		$delimiter = "\t";
@@ -1207,9 +1207,9 @@  discard block
 block discarded – undo
1207 1207
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1208 1208
 					try {
1209 1209
 						$sth = $Connection->db->prepare($query);
1210
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1211
-					} catch(PDOException $e) {
1212
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1210
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1211
+					} catch (PDOException $e) {
1212
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1213 1213
 					}
1214 1214
 				}
1215 1215
 				$i++;
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			$Connection = new Connection();
1228 1228
 			$sth = $Connection->db->prepare($query);
1229 1229
                         $sth->execute();
1230
-                } catch(PDOException $e) {
1230
+                } catch (PDOException $e) {
1231 1231
                         return "error : ".$e->getMessage();
1232 1232
                 }
1233 1233
 
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1249 1249
 					try {
1250 1250
 						$sth = $Connection->db->prepare($query);
1251
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1252
-					} catch(PDOException $e) {
1251
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1252
+					} catch (PDOException $e) {
1253 1253
 						return "error : ".$e->getMessage();
1254 1254
 					}
1255 1255
 				}
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 			$Connection = new Connection();
1269 1269
 			$sth = $Connection->db->prepare($query);
1270 1270
 			$sth->execute();
1271
-		} catch(PDOException $e) {
1271
+		} catch (PDOException $e) {
1272 1272
 			return "error : ".$e->getMessage();
1273 1273
 		}
1274 1274
 		$delimiter = "\t";
@@ -1285,8 +1285,8 @@  discard block
 block discarded – undo
1285 1285
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1286 1286
 					try {
1287 1287
 						$sth = $Connection->db->prepare($query);
1288
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1289
-					} catch(PDOException $e) {
1288
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1289
+					} catch (PDOException $e) {
1290 1290
 						return "error : ".$e->getMessage();
1291 1291
 					}
1292 1292
 				}
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 			$Connection = new Connection();
1306 1306
 			$sth = $Connection->db->prepare($query);
1307 1307
 			$sth->execute();
1308
-		} catch(PDOException $e) {
1308
+		} catch (PDOException $e) {
1309 1309
 			return "error : ".$e->getMessage();
1310 1310
 		}
1311 1311
 
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 					try {
1322 1322
 						$sth = $Connection->db->prepare($query);
1323 1323
 						$sth->execute(array(':icao' => $icao));
1324
-					} catch(PDOException $e) {
1324
+					} catch (PDOException $e) {
1325 1325
 						return "error : ".$e->getMessage();
1326 1326
 					}
1327 1327
 				}
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 		return '';
1333 1333
         }
1334 1334
 
1335
-	public static function tle($filename,$tletype) {
1335
+	public static function tle($filename, $tletype) {
1336 1336
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1337 1337
 		global $tmp_dir, $globalTransaction;
1338 1338
 		//$Spotter = new Spotter();
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 			$Connection = new Connection();
1343 1343
 			$sth = $Connection->db->prepare($query);
1344 1344
                         $sth->execute(array(':source' => $filename));
1345
-                } catch(PDOException $e) {
1345
+                } catch (PDOException $e) {
1346 1346
                         return "error : ".$e->getMessage();
1347 1347
                 }
1348 1348
 		
@@ -1367,8 +1367,8 @@  discard block
 block discarded – undo
1367 1367
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1368 1368
 					try {
1369 1369
 						$sth = $Connection->db->prepare($query);
1370
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1371
-					} catch(PDOException $e) {
1370
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1371
+					} catch (PDOException $e) {
1372 1372
 						return "error : ".$e->getMessage();
1373 1373
 					}
1374 1374
 
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 			$Connection = new Connection();
1389 1389
 			$sth = $Connection->db->prepare($query);
1390 1390
 			$sth->execute(array(':source' => $filename));
1391
-		} catch(PDOException $e) {
1391
+		} catch (PDOException $e) {
1392 1392
 			return "error : ".$e->getMessage();
1393 1393
 		}
1394 1394
 		
@@ -1399,13 +1399,13 @@  discard block
 block discarded – undo
1399 1399
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1400 1400
 			//$Connection->db->beginTransaction();
1401 1401
 			$dbdata = array();
1402
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1402
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1403 1403
 			{
1404 1404
 				if ($i > 0 && $data[0] != '') {
1405 1405
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1406
-					$period = str_replace(',','',$data[14]);
1407
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1408
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1406
+					$period = str_replace(',', '', $data[14]);
1407
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1408
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1409 1409
 					else $launch_date = NULL;
1410 1410
 					$data = array_map(function($value) {
1411 1411
 						return trim($value) === '' ? null : $value;
@@ -1415,8 +1415,8 @@  discard block
 block discarded – undo
1415 1415
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1416 1416
 					try {
1417 1417
 						$sth = $Connection->db->prepare($query);
1418
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',','',$data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',','',$data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+',','),'',$data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',','-1900',' (BOL)',' (EOL)'),'',$data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',',' (BOL)',' (EOL)'),'',$data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20],':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1419
-					} catch(PDOException $e) {
1418
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',', '', $data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',', '', $data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+', ','), '', $data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',', '-1900', ' (BOL)', ' (EOL)'), '', $data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',', ' (BOL)', ' (EOL)'), '', $data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20], ':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1419
+					} catch (PDOException $e) {
1420 1420
 						return "error : ".$e->getMessage();
1421 1421
 					}
1422 1422
 				}
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1456 1456
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1457 1457
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1458
-			'EST' => array('country' => 'Estonia','owner' => ''),
1458
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1459 1459
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1460 1460
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1461 1461
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1579,10 +1579,10 @@  discard block
 block discarded – undo
1579 1579
 			while (($data = fgets($handle, 1000)) !== FALSE)
1580 1580
 			{
1581 1581
 				$result = array();
1582
-				$result['cospar'] = trim(substr($data,0,11));
1583
-				$result['norad'] = trim(substr($data,13,6));
1584
-				$result['operational'] = trim(substr($data,21,1));
1585
-				$result['name'] = trim(substr($data,23,24));
1582
+				$result['cospar'] = trim(substr($data, 0, 11));
1583
+				$result['norad'] = trim(substr($data, 13, 6));
1584
+				$result['operational'] = trim(substr($data, 21, 1));
1585
+				$result['name'] = trim(substr($data, 23, 24));
1586 1586
 				/*
1587 1587
 				    * R/B(1) = Rocket body, first stage
1588 1588
 				    * R/B(2) = Rocket body, second stage
@@ -1594,19 +1594,19 @@  discard block
 block discarded – undo
1594 1594
 				    * An ampersand (&) indicates two or more objects are attached
1595 1595
 				*/
1596 1596
 				
1597
-				$owner_code = trim(substr($data,49,5));
1597
+				$owner_code = trim(substr($data, 49, 5));
1598 1598
 				$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1599 1599
 				$result['owner'] = $satcat_sources[$owner_code]['owner'];
1600
-				$result['launch_date'] = trim(substr($data,56,10));
1601
-				$launch_site_code = trim(substr($data,68,5));
1600
+				$result['launch_date'] = trim(substr($data, 56, 10));
1601
+				$launch_site_code = trim(substr($data, 68, 5));
1602 1602
 				$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1603
-				$result['lifetime'] = trim(substr($data,75,10));
1604
-				$result['period'] = trim(substr($data,87,7));
1605
-				$result['inclination'] = trim(substr($data,96,5));
1606
-				$result['apogee'] = trim(substr($data,103,6));
1607
-				$result['perigee'] = trim(substr($data,111,6));
1603
+				$result['lifetime'] = trim(substr($data, 75, 10));
1604
+				$result['period'] = trim(substr($data, 87, 7));
1605
+				$result['inclination'] = trim(substr($data, 96, 5));
1606
+				$result['apogee'] = trim(substr($data, 103, 6));
1607
+				$result['perigee'] = trim(substr($data, 111, 6));
1608 1608
 				//$result['radarcross'] = trim(substr($data,119,8));
1609
-				$result['status'] = trim(substr($data,129,3));
1609
+				$result['status'] = trim(substr($data, 129, 3));
1610 1610
 				print_r($result);
1611 1611
 				$result = array_map(function($value) {
1612 1612
 					return trim($value) === '' ? null : $value;
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 						$sth = $Connection->db->prepare($query);
1620 1620
 						$sth->execute(array(':cospar' => $result['cospar']));
1621 1621
 						$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1622
-					} catch(PDOException $e) {
1622
+					} catch (PDOException $e) {
1623 1623
 						return "error : ".$e->getMessage();
1624 1624
 					}
1625 1625
 					if (empty($exist)) {
@@ -1631,10 +1631,10 @@  discard block
 block discarded – undo
1631 1631
 							    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1632 1632
 							    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1633 1633
 							    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1634
-							    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1634
+							    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1635 1635
 							    )
1636 1636
 							);
1637
-						} catch(PDOException $e) {
1637
+						} catch (PDOException $e) {
1638 1638
 							return "error : ".$e->getMessage();
1639 1639
 						}
1640 1640
 					} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1642,8 +1642,8 @@  discard block
 block discarded – undo
1642 1642
 						try {
1643 1643
 							$Connection = new Connection();
1644 1644
 							$sth = $Connection->db->prepare($query);
1645
-							$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1646
-						} catch(PDOException $e) {
1645
+							$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1646
+						} catch (PDOException $e) {
1647 1647
 							return "error : ".$e->getMessage();
1648 1648
 						}
1649 1649
 					}
@@ -1761,13 +1761,13 @@  discard block
 block discarded – undo
1761 1761
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1762 1762
 			{
1763 1763
 				$i++;
1764
-				if($i > 3 && count($row) > 2) {
1764
+				if ($i > 3 && count($row) > 2) {
1765 1765
 					$data = array_values(array_filter($row));
1766 1766
 					$cntdata = count($data);
1767 1767
 					if ($cntdata > 10) {
1768 1768
 						$value = $data[9];
1769 1769
 						
1770
-						for ($i =10;$i < $cntdata;$i++) {
1770
+						for ($i = 10; $i < $cntdata; $i++) {
1771 1771
 							$value .= ' '.$data[$i];
1772 1772
 						}
1773 1773
 						$data[9] = $value;
@@ -1777,8 +1777,8 @@  discard block
 block discarded – undo
1777 1777
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1778 1778
 						try {
1779 1779
 							$sth = $Connection->db->prepare($query);
1780
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1781
-						} catch(PDOException $e) {
1780
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1781
+						} catch (PDOException $e) {
1782 1782
 							return "error : ".$e->getMessage();
1783 1783
 						}
1784 1784
 					}
@@ -1799,7 +1799,7 @@  discard block
 block discarded – undo
1799 1799
 			$Connection = new Connection();
1800 1800
 			$sth = $Connection->db->prepare($query);
1801 1801
                         $sth->execute();
1802
-                } catch(PDOException $e) {
1802
+                } catch (PDOException $e) {
1803 1803
                         return "error : ".$e->getMessage();
1804 1804
                 }
1805 1805
 
@@ -1811,12 +1811,12 @@  discard block
 block discarded – undo
1811 1811
 			if ($globalTransaction) $Connection->db->beginTransaction();
1812 1812
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1813 1813
 			{
1814
-				if(count($row) > 1) {
1814
+				if (count($row) > 1) {
1815 1815
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1816 1816
 					try {
1817 1817
 						$sth = $Connection->db->prepare($query);
1818
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1819
-					} catch(PDOException $e) {
1818
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1819
+					} catch (PDOException $e) {
1820 1820
 						return "error : ".$e->getMessage();
1821 1821
 					}
1822 1822
 				}
@@ -1836,21 +1836,21 @@  discard block
 block discarded – undo
1836 1836
 			try {
1837 1837
 				$sth = $Connection->db->prepare($query);
1838 1838
                     		$sth->execute();
1839
-	                } catch(PDOException $e) {
1839
+	                } catch (PDOException $e) {
1840 1840
 				return "error : ".$e->getMessage();
1841 1841
 	                }
1842 1842
 	        }
1843 1843
 
1844 1844
 
1845
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1845
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1846 1846
 		else {
1847
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1847
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1848 1848
 			$query = "CREATE EXTENSION postgis";
1849
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1849
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1850 1850
 			try {
1851 1851
 				$sth = $Connection->db->prepare($query);
1852 1852
 				$sth->execute();
1853
-			} catch(PDOException $e) {
1853
+			} catch (PDOException $e) {
1854 1854
 				return "error : ".$e->getMessage();
1855 1855
 			}
1856 1856
 		}
@@ -1863,7 +1863,7 @@  discard block
 block discarded – undo
1863 1863
 		include_once('class.create_db.php');
1864 1864
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1865 1865
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1866
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1866
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1867 1867
 		$error = '';
1868 1868
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1869 1869
 			if ($globalDebug) echo "Gunzip...";
@@ -1895,14 +1895,14 @@  discard block
 block discarded – undo
1895 1895
 			try {
1896 1896
 				$sth = $Connection->db->prepare($query);
1897 1897
             	        	$sth->execute();
1898
-	                } catch(PDOException $e) {
1898
+	                } catch (PDOException $e) {
1899 1899
     	                	echo "error : ".$e->getMessage();
1900 1900
 	                }
1901 1901
 		}
1902 1902
 		if ($globalDBdriver == 'mysql') {
1903
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1903
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1904 1904
 		} else {
1905
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1905
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1906 1906
 		}
1907 1907
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1908 1908
 		return $error;
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1916 1916
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1917 1917
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1918
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1918
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1919 1919
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1920 1920
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1921 1921
 		return $error;
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1936 1936
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1937 1937
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1938
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1938
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1939 1939
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1940 1940
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1941 1941
 		if ($error != '') {
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 		global $tmp_dir, $globalDebug;
1949 1949
 		$error = '';
1950 1950
 		if ($globalDebug) echo "Routes : Download...";
1951
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1951
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1952 1952
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1953 1953
 			if ($globalDebug) echo "Gunzip...";
1954 1954
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 		global $tmp_dir, $globalDebug;
1965 1965
 		$error = '';
1966 1966
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1967
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1967
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1968 1968
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1969 1969
 			if ($globalDebug) echo "Gunzip...";
1970 1970
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1980,7 +1980,7 @@  discard block
 block discarded – undo
1980 1980
 		global $tmp_dir, $globalDebug;
1981 1981
 		$error = '';
1982 1982
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1983
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1983
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1984 1984
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1985 1985
 			if ($globalDebug) echo "Gunzip...";
1986 1986
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
 */
2009 2009
 		if ($globalDebug) echo "Modes : Download...";
2010 2010
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2011
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2011
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2012 2012
 
2013 2013
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2014 2014
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2028,7 +2028,7 @@  discard block
 block discarded – undo
2028 2028
 	public static function update_ModeS_faa() {
2029 2029
 		global $tmp_dir, $globalDebug;
2030 2030
 		if ($globalDebug) echo "Modes FAA: Download...";
2031
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2031
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2032 2032
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2033 2033
 			if ($globalDebug) echo "Unzip...";
2034 2034
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2044,7 +2044,7 @@  discard block
 block discarded – undo
2044 2044
 	public static function update_ModeS_flarm() {
2045 2045
 		global $tmp_dir, $globalDebug;
2046 2046
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2047
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2047
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2048 2048
 		if (file_exists($tmp_dir.'data.fln')) {
2049 2049
 			if ($globalDebug) echo "Add to DB...";
2050 2050
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
 	public static function update_ModeS_ogn() {
2059 2059
 		global $tmp_dir, $globalDebug;
2060 2060
 		if ($globalDebug) echo "Modes OGN: Download...";
2061
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2061
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2062 2062
 		if (file_exists($tmp_dir.'ogn.csv')) {
2063 2063
 			if ($globalDebug) echo "Add to DB...";
2064 2064
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2073,201 +2073,201 @@  discard block
 block discarded – undo
2073 2073
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2074 2074
 		
2075 2075
 		if ($globalDebug) echo "Owner France: Download...";
2076
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2076
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2077 2077
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2078 2078
 			if ($globalDebug) echo "Add to DB...";
2079
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2079
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2080 2080
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2081 2081
 		if ($error != '') {
2082 2082
 			return $error;
2083 2083
 		} elseif ($globalDebug) echo "Done\n";
2084 2084
 		
2085 2085
 		if ($globalDebug) echo "Owner Ireland: Download...";
2086
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2086
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2087 2087
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2088 2088
 			if ($globalDebug) echo "Add to DB...";
2089
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2089
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2090 2090
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2091 2091
 		if ($error != '') {
2092 2092
 			return $error;
2093 2093
 		} elseif ($globalDebug) echo "Done\n";
2094 2094
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2095
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2095
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2096 2096
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2097 2097
 			if ($globalDebug) echo "Add to DB...";
2098
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2098
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2099 2099
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2100 2100
 		if ($error != '') {
2101 2101
 			return $error;
2102 2102
 		} elseif ($globalDebug) echo "Done\n";
2103 2103
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2104
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2104
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2105 2105
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2106 2106
 			if ($globalDebug) echo "Add to DB...";
2107
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2107
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2108 2108
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2109 2109
 		if ($error != '') {
2110 2110
 			return $error;
2111 2111
 		} elseif ($globalDebug) echo "Done\n";
2112 2112
 		if ($globalDebug) echo "Owner Australia: Download...";
2113
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2113
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2114 2114
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2115 2115
 			if ($globalDebug) echo "Add to DB...";
2116
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2116
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2117 2117
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2118 2118
 		if ($error != '') {
2119 2119
 			return $error;
2120 2120
 		} elseif ($globalDebug) echo "Done\n";
2121 2121
 		if ($globalDebug) echo "Owner Austria: Download...";
2122
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2122
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2123 2123
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2124 2124
 			if ($globalDebug) echo "Add to DB...";
2125
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2125
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2126 2126
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2127 2127
 		if ($error != '') {
2128 2128
 			return $error;
2129 2129
 		} elseif ($globalDebug) echo "Done\n";
2130 2130
 		if ($globalDebug) echo "Owner Chile: Download...";
2131
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2131
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2132 2132
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2133 2133
 			if ($globalDebug) echo "Add to DB...";
2134
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2134
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2135 2135
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2136 2136
 		if ($error != '') {
2137 2137
 			return $error;
2138 2138
 		} elseif ($globalDebug) echo "Done\n";
2139 2139
 		if ($globalDebug) echo "Owner Colombia: Download...";
2140
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2140
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2141 2141
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2142 2142
 			if ($globalDebug) echo "Add to DB...";
2143
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2143
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2144 2144
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2145 2145
 		if ($error != '') {
2146 2146
 			return $error;
2147 2147
 		} elseif ($globalDebug) echo "Done\n";
2148 2148
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2149
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2149
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2150 2150
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2151 2151
 			if ($globalDebug) echo "Add to DB...";
2152
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2152
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2153 2153
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2154 2154
 		if ($error != '') {
2155 2155
 			return $error;
2156 2156
 		} elseif ($globalDebug) echo "Done\n";
2157 2157
 		if ($globalDebug) echo "Owner Brazil: Download...";
2158
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2158
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2159 2159
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2160 2160
 			if ($globalDebug) echo "Add to DB...";
2161
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2161
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2162 2162
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2163 2163
 		if ($error != '') {
2164 2164
 			return $error;
2165 2165
 		} elseif ($globalDebug) echo "Done\n";
2166 2166
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2167
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2167
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2168 2168
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2169 2169
 			if ($globalDebug) echo "Add to DB...";
2170
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2170
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2171 2171
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2172 2172
 		if ($error != '') {
2173 2173
 			return $error;
2174 2174
 		} elseif ($globalDebug) echo "Done\n";
2175 2175
 		if ($globalDebug) echo "Owner Croatia: Download...";
2176
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2176
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2177 2177
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2178 2178
 			if ($globalDebug) echo "Add to DB...";
2179
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2179
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2180 2180
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2181 2181
 		if ($error != '') {
2182 2182
 			return $error;
2183 2183
 		} elseif ($globalDebug) echo "Done\n";
2184 2184
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2185
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2185
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2186 2186
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2187 2187
 			if ($globalDebug) echo "Add to DB...";
2188
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2188
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2189 2189
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2190 2190
 		if ($error != '') {
2191 2191
 			return $error;
2192 2192
 		} elseif ($globalDebug) echo "Done\n";
2193 2193
 		if ($globalDebug) echo "Owner Maldives: Download...";
2194
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2194
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2195 2195
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2196 2196
 			if ($globalDebug) echo "Add to DB...";
2197
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2197
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2198 2198
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2199 2199
 		if ($error != '') {
2200 2200
 			return $error;
2201 2201
 		} elseif ($globalDebug) echo "Done\n";
2202 2202
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2203
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2203
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2204 2204
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2205 2205
 			if ($globalDebug) echo "Add to DB...";
2206
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2206
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2207 2207
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2208 2208
 		if ($error != '') {
2209 2209
 			return $error;
2210 2210
 		} elseif ($globalDebug) echo "Done\n";
2211 2211
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2212
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2212
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2213 2213
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2214 2214
 			if ($globalDebug) echo "Add to DB...";
2215
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2215
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2216 2216
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2217 2217
 		if ($error != '') {
2218 2218
 			return $error;
2219 2219
 		} elseif ($globalDebug) echo "Done\n";
2220 2220
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2221
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2221
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2222 2222
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2223 2223
 			if ($globalDebug) echo "Add to DB...";
2224
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2224
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2225 2225
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2226 2226
 		if ($error != '') {
2227 2227
 			return $error;
2228 2228
 		} elseif ($globalDebug) echo "Done\n";
2229 2229
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2230
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2230
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2231 2231
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2232 2232
 			if ($globalDebug) echo "Add to DB...";
2233
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2233
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2234 2234
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2235 2235
 		if ($error != '') {
2236 2236
 			return $error;
2237 2237
 		} elseif ($globalDebug) echo "Done\n";
2238 2238
 		if ($globalDebug) echo "Owner Iceland: Download...";
2239
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2239
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2240 2240
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2241 2241
 			if ($globalDebug) echo "Add to DB...";
2242
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2242
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2243 2243
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2244 2244
 		if ($error != '') {
2245 2245
 			return $error;
2246 2246
 		} elseif ($globalDebug) echo "Done\n";
2247 2247
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2248
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2248
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2249 2249
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2250 2250
 			if ($globalDebug) echo "Add to DB...";
2251
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2251
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2252 2252
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2253 2253
 		if ($error != '') {
2254 2254
 			return $error;
2255 2255
 		} elseif ($globalDebug) echo "Done\n";
2256 2256
 		if ($globalMasterSource) {
2257 2257
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2258
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2258
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2259 2259
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2260 2260
 				if ($globalDebug) echo "Add to DB...";
2261
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2261
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2262 2262
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2263 2263
 			if ($error != '') {
2264 2264
 				return $error;
2265 2265
 			} elseif ($globalDebug) echo "Done\n";
2266 2266
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2267
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2267
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2268 2268
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2269 2269
 				if ($globalDebug) echo "Add to DB...";
2270
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2270
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2271 2271
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2272 2272
 			if ($error != '') {
2273 2273
 				return $error;
@@ -2280,7 +2280,7 @@  discard block
 block discarded – undo
2280 2280
 		global $tmp_dir, $globalDebug;
2281 2281
 		$error = '';
2282 2282
 		if ($globalDebug) echo "Translation : Download...";
2283
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2283
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2284 2284
 		if (file_exists($tmp_dir.'translation.zip')) {
2285 2285
 			if ($globalDebug) echo "Unzip...";
2286 2286
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2296,7 +2296,7 @@  discard block
 block discarded – undo
2296 2296
 	public static function update_translation_fam() {
2297 2297
 		global $tmp_dir, $globalDebug;
2298 2298
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2299
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2299
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2300 2300
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
2301 2301
 			if ($globalDebug) echo "Gunzip...";
2302 2302
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -2311,7 +2311,7 @@  discard block
 block discarded – undo
2311 2311
 	public static function update_ModeS_fam() {
2312 2312
 		global $tmp_dir, $globalDebug;
2313 2313
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2314
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2314
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2315 2315
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2316 2316
 			if ($globalDebug) echo "Gunzip...";
2317 2317
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -2327,9 +2327,9 @@  discard block
 block discarded – undo
2327 2327
 		global $tmp_dir, $globalDebug, $globalOwner;
2328 2328
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2329 2329
 		if ($globalOwner === TRUE) {
2330
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2330
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2331 2331
 		} else {
2332
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2332
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2333 2333
 		}
2334 2334
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2335 2335
 			if ($globalDebug) echo "Gunzip...";
@@ -2345,7 +2345,7 @@  discard block
 block discarded – undo
2345 2345
 	public static function update_routes_fam() {
2346 2346
 		global $tmp_dir, $globalDebug;
2347 2347
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2348
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2348
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2349 2349
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2350 2350
 			if ($globalDebug) echo "Gunzip...";
2351 2351
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2359,13 +2359,13 @@  discard block
 block discarded – undo
2359 2359
 	}
2360 2360
 	public static function update_marine_identity_fam() {
2361 2361
 		global $tmp_dir, $globalDebug;
2362
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2362
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2363 2363
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2364
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2364
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2365 2365
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2366 2366
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2367 2367
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2368
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2368
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2369 2369
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2370 2370
 					if ($globalDebug) echo "Gunzip...";
2371 2371
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2385,13 +2385,13 @@  discard block
 block discarded – undo
2385 2385
 
2386 2386
 	public static function update_satellite_fam() {
2387 2387
 		global $tmp_dir, $globalDebug;
2388
-		update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2388
+		update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2389 2389
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2390
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2390
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2391 2391
 			$satellite_md5 = $satellite_md5_file[0];
2392 2392
 			if (!update_db::check_satellite_version($marine_identity_md5)) {
2393 2393
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2394
-				update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2394
+				update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2395 2395
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2396 2396
 					if ($globalDebug) echo "Gunzip...";
2397 2397
 					update_db::gunzip($tmp_dir.'satellite.tsv.gz');
@@ -2411,7 +2411,7 @@  discard block
 block discarded – undo
2411 2411
 	public static function update_banned_fam() {
2412 2412
 		global $tmp_dir, $globalDebug;
2413 2413
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2414
-		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2414
+		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2415 2415
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2416 2416
 			//if ($globalDebug) echo "Gunzip...";
2417 2417
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2430,18 +2430,18 @@  discard block
 block discarded – undo
2430 2430
 		$error = '';
2431 2431
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2432 2432
 		if ($globalDBdriver == 'mysql') {
2433
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2433
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2434 2434
 		} else {
2435
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2435
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2436 2436
 		}
2437 2437
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2438
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2438
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2439 2439
 			$airspace_md5 = $airspace_md5_file[0];
2440 2440
 			if (!update_db::check_airspace_version($airspace_md5)) {
2441 2441
 				if ($globalDBdriver == 'mysql') {
2442
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2442
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2443 2443
 				} else {
2444
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2444
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2445 2445
 				}
2446 2446
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2447 2447
 					if ($globalDebug) echo "Gunzip...";
@@ -2453,7 +2453,7 @@  discard block
 block discarded – undo
2453 2453
 						try {
2454 2454
 							$sth = $Connection->db->prepare($query);
2455 2455
     	    	    					$sth->execute();
2456
-			            		} catch(PDOException $e) {
2456
+			            		} catch (PDOException $e) {
2457 2457
 							return "error : ".$e->getMessage();
2458 2458
 		            			}
2459 2459
 		    			}
@@ -2472,15 +2472,15 @@  discard block
 block discarded – undo
2472 2472
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2473 2473
 		$error = '';
2474 2474
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2475
-		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2475
+		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2476 2476
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2477
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2477
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2478 2478
 			$geoid_md5 = $geoid_md5_file[0];
2479 2479
 			if (!update_db::check_geoid_version($geoid_md5)) {
2480
-				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2480
+				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2481 2481
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2482 2482
 					if ($globalDebug) echo "Gunzip...";
2483
-					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2483
+					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2484 2484
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2485 2485
 						update_db::insert_geoid_version($geoid_md5);
2486 2486
 					}
@@ -2496,15 +2496,15 @@  discard block
 block discarded – undo
2496 2496
 	public static function update_tle() {
2497 2497
 		global $tmp_dir, $globalDebug;
2498 2498
 		if ($globalDebug) echo "Download TLE : Download...";
2499
-		$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',
2500
-		'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',
2501
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2499
+		$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',
2500
+		'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',
2501
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt', 'visual.txt', 'sarsat.txt', 'argos.txt', 'ses.txt', 'iridium-NEXT.txt', 'beidou.txt');
2502 2502
 		foreach ($alltle as $filename) {
2503 2503
 			if ($globalDebug) echo "downloading ".$filename.'...';
2504
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2504
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2505 2505
 			if (file_exists($tmp_dir.$filename)) {
2506 2506
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2507
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2507
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2508 2508
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2509 2509
 			if ($error != '') {
2510 2510
 				echo $error."\n";
@@ -2516,7 +2516,7 @@  discard block
 block discarded – undo
2516 2516
 	public static function update_ucsdb() {
2517 2517
 		global $tmp_dir, $globalDebug;
2518 2518
 		if ($globalDebug) echo "Download UCS DB : Download...";
2519
-		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2519
+		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt', $tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2520 2520
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2521 2521
 			if ($globalDebug) echo "Add to DB...";
2522 2522
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
@@ -2530,7 +2530,7 @@  discard block
 block discarded – undo
2530 2530
 	public static function update_celestrak() {
2531 2531
 		global $tmp_dir, $globalDebug;
2532 2532
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2533
-		update_db::download('https://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2533
+		update_db::download('https://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2534 2534
 		if (file_exists($tmp_dir.'satcat.txt')) {
2535 2535
 			if ($globalDebug) echo "Add to DB...";
2536 2536
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2545,32 +2545,32 @@  discard block
 block discarded – undo
2545 2545
 		global $tmp_dir, $globalDebug;
2546 2546
 		$error = '';
2547 2547
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2548
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2548
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2549 2549
 		if (file_exists($tmp_dir.'models.md5sum')) {
2550 2550
 			if ($globalDebug) echo "Check files...\n";
2551 2551
 			$newmodelsdb = array();
2552
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2553
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2552
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2553
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2554 2554
 					$model = trim($row[2]);
2555 2555
 					$newmodelsdb[$model] = trim($row[0]);
2556 2556
 				}
2557 2557
 			}
2558 2558
 			$modelsdb = array();
2559 2559
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2560
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2561
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2560
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2561
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2562 2562
 						$model = trim($row[2]);
2563 2563
 						$modelsdb[$model] = trim($row[0]);
2564 2564
 					}
2565 2565
 				}
2566 2566
 			}
2567
-			$diff = array_diff($newmodelsdb,$modelsdb);
2567
+			$diff = array_diff($newmodelsdb, $modelsdb);
2568 2568
 			foreach ($diff as $key => $value) {
2569 2569
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2570
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2570
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2571 2571
 				
2572 2572
 			}
2573
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2573
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2574 2574
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2575 2575
 		if ($error != '') {
2576 2576
 			return $error;
@@ -2582,32 +2582,32 @@  discard block
 block discarded – undo
2582 2582
 		global $tmp_dir, $globalDebug;
2583 2583
 		$error = '';
2584 2584
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2585
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2585
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2586 2586
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2587 2587
 			if ($globalDebug) echo "Check files...\n";
2588 2588
 			$newmodelsdb = array();
2589
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2590
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2589
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2590
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2591 2591
 					$model = trim($row[2]);
2592 2592
 					$newmodelsdb[$model] = trim($row[0]);
2593 2593
 				}
2594 2594
 			}
2595 2595
 			$modelsdb = array();
2596 2596
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2597
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2598
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2597
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2598
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2599 2599
 						$model = trim($row[2]);
2600 2600
 						$modelsdb[$model] = trim($row[0]);
2601 2601
 					}
2602 2602
 				}
2603 2603
 			}
2604
-			$diff = array_diff($newmodelsdb,$modelsdb);
2604
+			$diff = array_diff($newmodelsdb, $modelsdb);
2605 2605
 			foreach ($diff as $key => $value) {
2606 2606
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2607
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2607
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2608 2608
 				
2609 2609
 			}
2610
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2610
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2611 2611
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2612 2612
 		if ($error != '') {
2613 2613
 			return $error;
@@ -2619,32 +2619,32 @@  discard block
 block discarded – undo
2619 2619
 		global $tmp_dir, $globalDebug;
2620 2620
 		$error = '';
2621 2621
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2622
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2622
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2623 2623
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2624 2624
 			if ($globalDebug) echo "Check files...\n";
2625 2625
 			$newmodelsdb = array();
2626
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2627
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2626
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2627
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2628 2628
 					$model = trim($row[2]);
2629 2629
 					$newmodelsdb[$model] = trim($row[0]);
2630 2630
 				}
2631 2631
 			}
2632 2632
 			$modelsdb = array();
2633 2633
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2634
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2635
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2634
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2635
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2636 2636
 						$model = trim($row[2]);
2637 2637
 						$modelsdb[$model] = trim($row[0]);
2638 2638
 					}
2639 2639
 				}
2640 2640
 			}
2641
-			$diff = array_diff($newmodelsdb,$modelsdb);
2641
+			$diff = array_diff($newmodelsdb, $modelsdb);
2642 2642
 			foreach ($diff as $key => $value) {
2643 2643
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2644
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2644
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2645 2645
 				
2646 2646
 			}
2647
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2647
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2648 2648
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2649 2649
 		if ($error != '') {
2650 2650
 			return $error;
@@ -2667,8 +2667,8 @@  discard block
 block discarded – undo
2667 2667
 		*/
2668 2668
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2669 2669
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2670
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2671
-		    $result = fread($fh,100000000);
2670
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2671
+		    $result = fread($fh, 100000000);
2672 2672
 		    //echo $result;
2673 2673
 		    //var_dump(str_get_html($result));
2674 2674
 		    //print_r(self::table2array($result));
@@ -2686,23 +2686,23 @@  discard block
 block discarded – undo
2686 2686
 			$Connection = new Connection();
2687 2687
 			$sth = $Connection->db->prepare($query);
2688 2688
                         $sth->execute();
2689
-                } catch(PDOException $e) {
2689
+                } catch (PDOException $e) {
2690 2690
                         return "error : ".$e->getMessage();
2691 2691
                 }
2692 2692
 
2693 2693
 		$error = '';
2694 2694
 		if ($globalDebug) echo "Notam : Download...";
2695
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2695
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2696 2696
 		if (file_exists($tmp_dir.'notam.rss')) {
2697
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2697
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2698 2698
 			foreach ($notams['channel']['item'] as $notam) {
2699
-				$title = explode(':',$notam['title']);
2699
+				$title = explode(':', $notam['title']);
2700 2700
 				$data['ref'] = trim($title[0]);
2701 2701
 				unset($title[0]);
2702
-				$data['title'] = trim(implode(':',$title));
2703
-				$description = strip_tags($notam['description'],'<pre>');
2704
-				preg_match(':^(.*?)<pre>:',$description,$match);
2705
-				$q = explode('/',$match[1]);
2702
+				$data['title'] = trim(implode(':', $title));
2703
+				$description = strip_tags($notam['description'], '<pre>');
2704
+				preg_match(':^(.*?)<pre>:', $description, $match);
2705
+				$q = explode('/', $match[1]);
2706 2706
 				$data['fir'] = $q[0];
2707 2707
 				$data['code'] = $q[1];
2708 2708
 				$ifrvfr = $q[2];
@@ -2718,30 +2718,30 @@  discard block
 block discarded – undo
2718 2718
 				$data['lower_limit'] = $q[5];
2719 2719
 				$data['upper_limit'] = $q[6];
2720 2720
 				$latlonrad = $q[7];
2721
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2722
-				$latitude = $Common->convertDec($las,'latitude');
2723
-				$longitude = $Common->convertDec($lns,'longitude');
2721
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2722
+				$latitude = $Common->convertDec($las, 'latitude');
2723
+				$longitude = $Common->convertDec($lns, 'longitude');
2724 2724
 				if ($lac == 'S') $latitude = '-'.$latitude;
2725 2725
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2726 2726
 				$data['center_latitude'] = $latitude;
2727 2727
 				$data['center_longitude'] = $longitude;
2728 2728
 				$data['radius'] = intval($radius);
2729 2729
 				
2730
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2730
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2731 2731
 				$data['text'] = $match[1];
2732
-				preg_match(':</pre>(.*?)$:',$description,$match);
2732
+				preg_match(':</pre>(.*?)$:', $description, $match);
2733 2733
 				$fromto = $match[1];
2734
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2734
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2735 2735
 				$fromall = trim($match[1]);
2736
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2736
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2737 2737
 				$from = trim($match[1]);
2738
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2739
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2738
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2739
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2740 2740
 				$toall = trim($match[1]);
2741
-				if (!preg_match(':Permanent:',$toall)) {
2742
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2741
+				if (!preg_match(':Permanent:', $toall)) {
2742
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2743 2743
 					$to = trim($match[1]);
2744
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2744
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2745 2745
 					$data['permanent'] = 0;
2746 2746
 				} else {
2747 2747
 				    $data['date_end'] = NULL;
@@ -2749,7 +2749,7 @@  discard block
 block discarded – undo
2749 2749
 				}
2750 2750
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2751 2751
 				$NOTAM = new NOTAM();
2752
-				$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']);
2752
+				$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']);
2753 2753
 				unset($data);
2754 2754
 			} 
2755 2755
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2772,16 +2772,16 @@  discard block
 block discarded – undo
2772 2772
 				$Connection = new Connection();
2773 2773
 				$sth = $Connection->db->prepare($query);
2774 2774
 				$sth->execute();
2775
-			} catch(PDOException $e) {
2775
+			} catch (PDOException $e) {
2776 2776
 				return "error : ".$e->getMessage();
2777 2777
 			}
2778 2778
 		}
2779 2779
 		$Common = new Common();
2780 2780
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2781
-		$airspace_json = json_decode($airspace_lst,true);
2781
+		$airspace_json = json_decode($airspace_lst, true);
2782 2782
 		foreach ($airspace_json['records'] as $airspace) {
2783 2783
 			if ($globalDebug) echo $airspace['name']."...\n";
2784
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2784
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2785 2785
 			if (file_exists($tmp_dir.$airspace['name'])) {
2786 2786
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2787 2787
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2803,7 +2803,7 @@  discard block
 block discarded – undo
2803 2803
 				$Connection = new Connection();
2804 2804
 				$sth = $Connection->db->prepare($query);
2805 2805
 				$sth->execute(array(':new' => $new, ':old' => $old));
2806
-			} catch(PDOException $e) {
2806
+			} catch (PDOException $e) {
2807 2807
 				return "error : ".$e->getMessage();
2808 2808
 			}
2809 2809
 		}
@@ -2820,7 +2820,7 @@  discard block
 block discarded – undo
2820 2820
 			$Connection = new Connection();
2821 2821
 			$sth = $Connection->db->prepare($query);
2822 2822
                         $sth->execute();
2823
-                } catch(PDOException $e) {
2823
+                } catch (PDOException $e) {
2824 2824
                         return "error : ".$e->getMessage();
2825 2825
                 }
2826 2826
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2835,7 +2835,7 @@  discard block
 block discarded – undo
2835 2835
 			$Connection = new Connection();
2836 2836
 			$sth = $Connection->db->prepare($query);
2837 2837
                         $sth->execute();
2838
-                } catch(PDOException $e) {
2838
+                } catch (PDOException $e) {
2839 2839
                         return "error : ".$e->getMessage();
2840 2840
                 }
2841 2841
 	}
@@ -2846,7 +2846,7 @@  discard block
 block discarded – undo
2846 2846
 			$Connection = new Connection();
2847 2847
 			$sth = $Connection->db->prepare($query);
2848 2848
                         $sth->execute(array(':version' => $version));
2849
-                } catch(PDOException $e) {
2849
+                } catch (PDOException $e) {
2850 2850
                         return "error : ".$e->getMessage();
2851 2851
                 }
2852 2852
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2860,7 +2860,7 @@  discard block
 block discarded – undo
2860 2860
 			$Connection = new Connection();
2861 2861
 			$sth = $Connection->db->prepare($query);
2862 2862
                         $sth->execute(array(':version' => $version));
2863
-                } catch(PDOException $e) {
2863
+                } catch (PDOException $e) {
2864 2864
                         return "error : ".$e->getMessage();
2865 2865
                 }
2866 2866
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2874,7 +2874,7 @@  discard block
 block discarded – undo
2874 2874
 			$Connection = new Connection();
2875 2875
 			$sth = $Connection->db->prepare($query);
2876 2876
 			$sth->execute(array(':version' => $version));
2877
-		} catch(PDOException $e) {
2877
+		} catch (PDOException $e) {
2878 2878
 			return "error : ".$e->getMessage();
2879 2879
 		}
2880 2880
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2888,7 +2888,7 @@  discard block
 block discarded – undo
2888 2888
 			$Connection = new Connection();
2889 2889
 			$sth = $Connection->db->prepare($query);
2890 2890
 			$sth->execute(array(':version' => $version));
2891
-		} catch(PDOException $e) {
2891
+		} catch (PDOException $e) {
2892 2892
 			return "error : ".$e->getMessage();
2893 2893
 		}
2894 2894
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2904,7 +2904,7 @@  discard block
 block discarded – undo
2904 2904
 			$Connection = new Connection();
2905 2905
 			$sth = $Connection->db->prepare($query);
2906 2906
 			$sth->execute(array(':version' => $version));
2907
-		} catch(PDOException $e) {
2907
+		} catch (PDOException $e) {
2908 2908
 			return "error : ".$e->getMessage();
2909 2909
 		}
2910 2910
 	}
@@ -2916,7 +2916,7 @@  discard block
 block discarded – undo
2916 2916
 			$Connection = new Connection();
2917 2917
 			$sth = $Connection->db->prepare($query);
2918 2918
                         $sth->execute(array(':version' => $version));
2919
-                } catch(PDOException $e) {
2919
+                } catch (PDOException $e) {
2920 2920
                         return "error : ".$e->getMessage();
2921 2921
                 }
2922 2922
 	}
@@ -2928,7 +2928,7 @@  discard block
 block discarded – undo
2928 2928
 			$Connection = new Connection();
2929 2929
 			$sth = $Connection->db->prepare($query);
2930 2930
 			$sth->execute(array(':version' => $version));
2931
-		} catch(PDOException $e) {
2931
+		} catch (PDOException $e) {
2932 2932
 			return "error : ".$e->getMessage();
2933 2933
 		}
2934 2934
 	}
@@ -2940,7 +2940,7 @@  discard block
 block discarded – undo
2940 2940
 			$Connection = new Connection();
2941 2941
 			$sth = $Connection->db->prepare($query);
2942 2942
 			$sth->execute(array(':version' => $version));
2943
-		} catch(PDOException $e) {
2943
+		} catch (PDOException $e) {
2944 2944
 			return "error : ".$e->getMessage();
2945 2945
 		}
2946 2946
 	}
@@ -2956,7 +2956,7 @@  discard block
 block discarded – undo
2956 2956
 			$Connection = new Connection();
2957 2957
 			$sth = $Connection->db->prepare($query);
2958 2958
                         $sth->execute();
2959
-                } catch(PDOException $e) {
2959
+                } catch (PDOException $e) {
2960 2960
                         return "error : ".$e->getMessage();
2961 2961
                 }
2962 2962
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2971,7 +2971,7 @@  discard block
 block discarded – undo
2971 2971
 			$Connection = new Connection();
2972 2972
 			$sth = $Connection->db->prepare($query);
2973 2973
                         $sth->execute();
2974
-                } catch(PDOException $e) {
2974
+                } catch (PDOException $e) {
2975 2975
                         return "error : ".$e->getMessage();
2976 2976
                 }
2977 2977
 	}
@@ -2987,7 +2987,7 @@  discard block
 block discarded – undo
2987 2987
 			$Connection = new Connection();
2988 2988
 			$sth = $Connection->db->prepare($query);
2989 2989
                         $sth->execute();
2990
-                } catch(PDOException $e) {
2990
+                } catch (PDOException $e) {
2991 2991
                         return "error : ".$e->getMessage();
2992 2992
                 }
2993 2993
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3002,7 +3002,7 @@  discard block
 block discarded – undo
3002 3002
 			$Connection = new Connection();
3003 3003
 			$sth = $Connection->db->prepare($query);
3004 3004
                         $sth->execute();
3005
-                } catch(PDOException $e) {
3005
+                } catch (PDOException $e) {
3006 3006
                         return "error : ".$e->getMessage();
3007 3007
                 }
3008 3008
 	}
@@ -3018,7 +3018,7 @@  discard block
 block discarded – undo
3018 3018
 			$Connection = new Connection();
3019 3019
 			$sth = $Connection->db->prepare($query);
3020 3020
                         $sth->execute();
3021
-                } catch(PDOException $e) {
3021
+                } catch (PDOException $e) {
3022 3022
                         return "error : ".$e->getMessage();
3023 3023
                 }
3024 3024
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3033,7 +3033,7 @@  discard block
 block discarded – undo
3033 3033
 			$Connection = new Connection();
3034 3034
 			$sth = $Connection->db->prepare($query);
3035 3035
                         $sth->execute();
3036
-                } catch(PDOException $e) {
3036
+                } catch (PDOException $e) {
3037 3037
                         return "error : ".$e->getMessage();
3038 3038
                 }
3039 3039
 	}
@@ -3049,7 +3049,7 @@  discard block
 block discarded – undo
3049 3049
 			$Connection = new Connection();
3050 3050
 			$sth = $Connection->db->prepare($query);
3051 3051
                         $sth->execute();
3052
-                } catch(PDOException $e) {
3052
+                } catch (PDOException $e) {
3053 3053
                         return "error : ".$e->getMessage();
3054 3054
                 }
3055 3055
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3064,7 +3064,7 @@  discard block
 block discarded – undo
3064 3064
 			$Connection = new Connection();
3065 3065
 			$sth = $Connection->db->prepare($query);
3066 3066
                         $sth->execute();
3067
-                } catch(PDOException $e) {
3067
+                } catch (PDOException $e) {
3068 3068
                         return "error : ".$e->getMessage();
3069 3069
                 }
3070 3070
 	}
@@ -3079,7 +3079,7 @@  discard block
 block discarded – undo
3079 3079
 			$Connection = new Connection();
3080 3080
 			$sth = $Connection->db->prepare($query);
3081 3081
                         $sth->execute();
3082
-                } catch(PDOException $e) {
3082
+                } catch (PDOException $e) {
3083 3083
                         return "error : ".$e->getMessage();
3084 3084
                 }
3085 3085
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3094,7 +3094,7 @@  discard block
 block discarded – undo
3094 3094
 			$Connection = new Connection();
3095 3095
 			$sth = $Connection->db->prepare($query);
3096 3096
 			$sth->execute();
3097
-		} catch(PDOException $e) {
3097
+		} catch (PDOException $e) {
3098 3098
 			return "error : ".$e->getMessage();
3099 3099
 		}
3100 3100
 	}
@@ -3110,7 +3110,7 @@  discard block
 block discarded – undo
3110 3110
 			$Connection = new Connection();
3111 3111
 			$sth = $Connection->db->prepare($query);
3112 3112
 			$sth->execute();
3113
-		} catch(PDOException $e) {
3113
+		} catch (PDOException $e) {
3114 3114
 			return "error : ".$e->getMessage();
3115 3115
 		}
3116 3116
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3125,7 +3125,7 @@  discard block
 block discarded – undo
3125 3125
 			$Connection = new Connection();
3126 3126
 			$sth = $Connection->db->prepare($query);
3127 3127
 			$sth->execute();
3128
-		} catch(PDOException $e) {
3128
+		} catch (PDOException $e) {
3129 3129
 			return "error : ".$e->getMessage();
3130 3130
 		}
3131 3131
 	}
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
 			$Connection = new Connection();
3142 3142
 			$sth = $Connection->db->prepare($query);
3143 3143
 			$sth->execute();
3144
-		} catch(PDOException $e) {
3144
+		} catch (PDOException $e) {
3145 3145
 			return "error : ".$e->getMessage();
3146 3146
 		}
3147 3147
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3156,7 +3156,7 @@  discard block
 block discarded – undo
3156 3156
 			$Connection = new Connection();
3157 3157
 			$sth = $Connection->db->prepare($query);
3158 3158
 			$sth->execute();
3159
-		} catch(PDOException $e) {
3159
+		} catch (PDOException $e) {
3160 3160
 			return "error : ".$e->getMessage();
3161 3161
 		}
3162 3162
 	}
@@ -3172,7 +3172,7 @@  discard block
 block discarded – undo
3172 3172
 			$Connection = new Connection();
3173 3173
 			$sth = $Connection->db->prepare($query);
3174 3174
 			$sth->execute();
3175
-		} catch(PDOException $e) {
3175
+		} catch (PDOException $e) {
3176 3176
 			return "error : ".$e->getMessage();
3177 3177
 		}
3178 3178
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
 			$Connection = new Connection();
3188 3188
 			$sth = $Connection->db->prepare($query);
3189 3189
 			$sth->execute();
3190
-		} catch(PDOException $e) {
3190
+		} catch (PDOException $e) {
3191 3191
 			return "error : ".$e->getMessage();
3192 3192
 		}
3193 3193
 	}
@@ -3203,7 +3203,7 @@  discard block
 block discarded – undo
3203 3203
 			$Connection = new Connection();
3204 3204
 			$sth = $Connection->db->prepare($query);
3205 3205
 			$sth->execute();
3206
-		} catch(PDOException $e) {
3206
+		} catch (PDOException $e) {
3207 3207
 			return "error : ".$e->getMessage();
3208 3208
 		}
3209 3209
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3222,7 +3222,7 @@  discard block
 block discarded – undo
3222 3222
 			$Connection = new Connection();
3223 3223
 			$sth = $Connection->db->prepare($query);
3224 3224
 			$sth->execute();
3225
-		} catch(PDOException $e) {
3225
+		} catch (PDOException $e) {
3226 3226
 			return "error : ".$e->getMessage();
3227 3227
 		}
3228 3228
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3237,7 +3237,7 @@  discard block
 block discarded – undo
3237 3237
 			$Connection = new Connection();
3238 3238
 			$sth = $Connection->db->prepare($query);
3239 3239
 			$sth->execute();
3240
-		} catch(PDOException $e) {
3240
+		} catch (PDOException $e) {
3241 3241
 			return "error : ".$e->getMessage();
3242 3242
 		}
3243 3243
 	}
@@ -3249,7 +3249,7 @@  discard block
 block discarded – undo
3249 3249
 			$Connection = new Connection();
3250 3250
 			$sth = $Connection->db->prepare($query);
3251 3251
 			$sth->execute();
3252
-		} catch(PDOException $e) {
3252
+		} catch (PDOException $e) {
3253 3253
 			return "error : ".$e->getMessage();
3254 3254
 		}
3255 3255
 	}
@@ -3265,7 +3265,7 @@  discard block
 block discarded – undo
3265 3265
 			$Connection = new Connection();
3266 3266
 			$sth = $Connection->db->prepare($query);
3267 3267
                         $sth->execute();
3268
-                } catch(PDOException $e) {
3268
+                } catch (PDOException $e) {
3269 3269
                         return "error : ".$e->getMessage();
3270 3270
                 }
3271 3271
 	}
@@ -3280,7 +3280,7 @@  discard block
 block discarded – undo
3280 3280
 			$Connection = new Connection();
3281 3281
 			$sth = $Connection->db->prepare($query);
3282 3282
                         $sth->execute();
3283
-                } catch(PDOException $e) {
3283
+                } catch (PDOException $e) {
3284 3284
                         return "error : ".$e->getMessage();
3285 3285
                 }
3286 3286
 	}
Please login to merge, or discard this patch.
Braces   +1026 added lines, -356 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19 19
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
20
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
20
+		if ($referer != '') {
21
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
22
+		}
21 23
 		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');
22 24
 		curl_setopt($ch, CURLOPT_FILE, $fp);
23 25
 		curl_exec($ch);
@@ -28,12 +30,16 @@  discard block
 block discarded – undo
28 30
 	public static function gunzip($in_file,$out_file_name = '') {
29 31
 		//echo $in_file.' -> '.$out_file_name."\n";
30 32
 		$buffer_size = 4096; // read 4kb at a time
31
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
33
+		if ($out_file_name == '') {
34
+			$out_file_name = str_replace('.gz', '', $in_file);
35
+		}
32 36
 		if ($in_file != '' && file_exists($in_file)) {
33 37
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
36
-			else {
38
+			if (function_exists('gzopen')) {
39
+				$file = gzopen($in_file,'rb');
40
+			} elseif (function_exists('gzopen64')) {
41
+				$file = gzopen64($in_file,'rb');
42
+			} else {
37 43
 				echo 'gzopen not available';
38 44
 				die;
39 45
 			}
@@ -54,8 +60,12 @@  discard block
 block discarded – undo
54 60
 			if ($res === TRUE) {
55 61
 				$zip->extractTo($path);
56 62
 				$zip->close();
57
-			} else return false;
58
-		} else return false;
63
+			} else {
64
+				return false;
65
+			}
66
+		} else {
67
+			return false;
68
+		}
59 69
 	}
60 70
 	
61 71
 	public static function connect_sqlite($database) {
@@ -70,7 +80,9 @@  discard block
 block discarded – undo
70 80
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 81
 		global $globalDebug, $globalTransaction;
72 82
 		//$query = 'TRUNCATE TABLE routes';
73
-		if ($globalDebug) echo " - Delete previous routes from DB -";
83
+		if ($globalDebug) {
84
+			echo " - Delete previous routes from DB -";
85
+		}
74 86
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
75 87
 		$Connection = new Connection();
76 88
 		try {
@@ -81,7 +93,9 @@  discard block
 block discarded – undo
81 93
                         return "error : ".$e->getMessage();
82 94
                 }
83 95
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
96
+    		if ($globalDebug) {
97
+    			echo " - Add routes to DB -";
98
+    		}
85 99
     		update_db::connect_sqlite($database_file);
86 100
 		//$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';
87 101
 		$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";
@@ -96,15 +110,21 @@  discard block
 block discarded – undo
96 110
 		$Connection = new Connection();
97 111
 		$sth_dest = $Connection->db->prepare($query_dest);
98 112
 		try {
99
-			if ($globalTransaction) $Connection->db->beginTransaction();
113
+			if ($globalTransaction) {
114
+				$Connection->db->beginTransaction();
115
+			}
100 116
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 117
 				//$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);
102 118
 				$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);
103 119
 				$sth_dest->execute($query_dest_values);
104 120
             		}
105
-			if ($globalTransaction) $Connection->db->commit();
121
+			if ($globalTransaction) {
122
+				$Connection->db->commit();
123
+			}
106 124
 		} catch(PDOException $e) {
107
-			if ($globalTransaction) $Connection->db->rollBack(); 
125
+			if ($globalTransaction) {
126
+				$Connection->db->rollBack();
127
+			}
108 128
 			return "error : ".$e->getMessage();
109 129
 		}
110 130
                 return '';
@@ -112,7 +132,9 @@  discard block
 block discarded – undo
112 132
 	public static function retrieve_route_oneworld($database_file) {
113 133
 		global $globalDebug, $globalTransaction;
114 134
 		//$query = 'TRUNCATE TABLE routes';
115
-		if ($globalDebug) echo " - Delete previous routes from DB -";
135
+		if ($globalDebug) {
136
+			echo " - Delete previous routes from DB -";
137
+		}
116 138
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
117 139
 		$Connection = new Connection();
118 140
 		try {
@@ -123,14 +145,18 @@  discard block
 block discarded – undo
123 145
                         return "error : ".$e->getMessage();
124 146
                 }
125 147
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
148
+    		if ($globalDebug) {
149
+    			echo " - Add routes to DB -";
150
+    		}
127 151
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 152
 		$Spotter = new Spotter();
129 153
 		if ($fh = fopen($database_file,"r")) {
130 154
 			$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)';
131 155
 			$Connection = new Connection();
132 156
 			$sth_dest = $Connection->db->prepare($query_dest);
133
-			if ($globalTransaction) $Connection->db->beginTransaction();
157
+			if ($globalTransaction) {
158
+				$Connection->db->beginTransaction();
159
+			}
134 160
 			while (!feof($fh)) {
135 161
 				$line = fgetcsv($fh,9999,',');
136 162
 				if ($line[0] != '') {
@@ -139,13 +165,17 @@  discard block
 block discarded – undo
139 165
 							$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');
140 166
 							$sth_dest->execute($query_dest_values);
141 167
 						} catch(PDOException $e) {
142
-							if ($globalTransaction) $Connection->db->rollBack(); 
168
+							if ($globalTransaction) {
169
+								$Connection->db->rollBack();
170
+							}
143 171
 							return "error : ".$e->getMessage();
144 172
 						}
145 173
 					}
146 174
 				}
147 175
 			}
148
-			if ($globalTransaction) $Connection->db->commit();
176
+			if ($globalTransaction) {
177
+				$Connection->db->commit();
178
+			}
149 179
 		}
150 180
                 return '';
151 181
 	}
@@ -153,7 +183,9 @@  discard block
 block discarded – undo
153 183
 	public static function retrieve_route_skyteam($database_file) {
154 184
 		global $globalDebug, $globalTransaction;
155 185
 		//$query = 'TRUNCATE TABLE routes';
156
-		if ($globalDebug) echo " - Delete previous routes from DB -";
186
+		if ($globalDebug) {
187
+			echo " - Delete previous routes from DB -";
188
+		}
157 189
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
158 190
 		$Connection = new Connection();
159 191
 		try {
@@ -164,7 +196,9 @@  discard block
 block discarded – undo
164 196
                         return "error : ".$e->getMessage();
165 197
                 }
166 198
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
199
+    		if ($globalDebug) {
200
+    			echo " - Add routes to DB -";
201
+    		}
168 202
 
169 203
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 204
 		$Spotter = new Spotter();
@@ -173,7 +207,9 @@  discard block
 block discarded – undo
173 207
 			$Connection = new Connection();
174 208
 			$sth_dest = $Connection->db->prepare($query_dest);
175 209
 			try {
176
-				if ($globalTransaction) $Connection->db->beginTransaction();
210
+				if ($globalTransaction) {
211
+					$Connection->db->beginTransaction();
212
+				}
177 213
 				while (!feof($fh)) {
178 214
 					$line = fgetcsv($fh,9999,',');
179 215
 					if ($line[0] != '') {
@@ -184,9 +220,13 @@  discard block
 block discarded – undo
184 220
 						}
185 221
 					}
186 222
 				}
187
-				if ($globalTransaction) $Connection->db->commit();
223
+				if ($globalTransaction) {
224
+					$Connection->db->commit();
225
+				}
188 226
 			} catch(PDOException $e) {
189
-				if ($globalTransaction) $Connection->db->rollBack(); 
227
+				if ($globalTransaction) {
228
+					$Connection->db->rollBack();
229
+				}
190 230
 				return "error : ".$e->getMessage();
191 231
 			}
192 232
 		}
@@ -229,11 +269,16 @@  discard block
 block discarded – undo
229 269
 		$sth_dest = $Connection->db->prepare($query_dest);
230 270
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 271
 		try {
232
-			if ($globalTransaction) $Connection->db->beginTransaction();
272
+			if ($globalTransaction) {
273
+				$Connection->db->beginTransaction();
274
+			}
233 275
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 276
 			//$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']);
235
-				if ($values['UserString4'] == 'M') $type = 'military';
236
-				else $type = null;
277
+				if ($values['UserString4'] == 'M') {
278
+					$type = 'military';
279
+				} else {
280
+					$type = null;
281
+				}
237 282
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 283
 				$sth_dest->execute($query_dest_values);
239 284
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -241,7 +286,9 @@  discard block
 block discarded – undo
241 286
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 287
 				}
243 288
             		}
244
-			if ($globalTransaction) $Connection->db->commit();
289
+			if ($globalTransaction) {
290
+				$Connection->db->commit();
291
+			}
245 292
 		} catch(PDOException $e) {
246 293
 			return "error : ".$e->getMessage();
247 294
 		}
@@ -278,7 +325,9 @@  discard block
 block discarded – undo
278 325
 			$Connection = new Connection();
279 326
 			$sth_dest = $Connection->db->prepare($query_dest);
280 327
 			try {
281
-				if ($globalTransaction) $Connection->db->beginTransaction();
328
+				if ($globalTransaction) {
329
+					$Connection->db->beginTransaction();
330
+				}
282 331
             			while (!feof($fh)) {
283 332
             				$values = array();
284 333
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -289,7 +338,9 @@  discard block
 block discarded – undo
289 338
             				// Check if we can find ICAO, else set it to GLID
290 339
             				$aircraft_name_split = explode(' ',$aircraft_name);
291 340
             				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
342
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
343
+            				}
293 344
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294 345
             				$sth_search = $Connection->db->prepare($query_search);
295 346
 					try {
@@ -302,7 +353,9 @@  discard block
 block discarded – undo
302 353
 					} catch(PDOException $e) {
303 354
 						return "error : ".$e->getMessage();
304 355
 					}
305
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
356
+					if (!isset($values['ICAOTypeCode'])) {
357
+						$values['ICAOTypeCode'] = 'GLID';
358
+					}
306 359
 					// Add data to db
307 360
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 361
 						//$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']);
@@ -311,7 +364,9 @@  discard block
 block discarded – undo
311 364
 						$sth_dest->execute($query_dest_values);
312 365
 					}
313 366
 				}
314
-				if ($globalTransaction) $Connection->db->commit();
367
+				if ($globalTransaction) {
368
+					$Connection->db->commit();
369
+				}
315 370
 			} catch(PDOException $e) {
316 371
 				return "error : ".$e->getMessage();
317 372
 			}
@@ -347,7 +402,9 @@  discard block
 block discarded – undo
347 402
 			$Connection = new Connection();
348 403
 			$sth_dest = $Connection->db->prepare($query_dest);
349 404
 			try {
350
-				if ($globalTransaction) $Connection->db->beginTransaction();
405
+				if ($globalTransaction) {
406
+					$Connection->db->beginTransaction();
407
+				}
351 408
 				$tmp = fgetcsv($fh,9999,',',"'");
352 409
             			while (!feof($fh)) {
353 410
             				$line = fgetcsv($fh,9999,',',"'");
@@ -361,13 +418,17 @@  discard block
 block discarded – undo
361 418
             				// Check if we can find ICAO, else set it to GLID
362 419
             				$aircraft_name_split = explode(' ',$aircraft_name);
363 420
             				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
422
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
423
+            				}
365 424
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366 425
             				$sth_search = $Connection->db->prepare($query_search);
367 426
 					try {
368 427
                                     		$sth_search->execute();
369 428
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
429
+	            				if (isset($result['icao']) && $result['icao'] != '') {
430
+	            					$values['ICAOTypeCode'] = $result['icao'];
431
+	            				}
371 432
 					} catch(PDOException $e) {
372 433
 						return "error : ".$e->getMessage();
373 434
 					}
@@ -380,7 +441,9 @@  discard block
 block discarded – undo
380 441
 						$sth_dest->execute($query_dest_values);
381 442
 					}
382 443
 				}
383
-				if ($globalTransaction) $Connection->db->commit();
444
+				if ($globalTransaction) {
445
+					$Connection->db->commit();
446
+				}
384 447
 			} catch(PDOException $e) {
385 448
 				return "error : ".$e->getMessage();
386 449
 			}
@@ -419,7 +482,9 @@  discard block
 block discarded – undo
419 482
 			$sth_dest = $Connection->db->prepare($query_dest);
420 483
 			$sth_modes = $Connection->db->prepare($query_modes);
421 484
 			try {
422
-				if ($globalTransaction) $Connection->db->beginTransaction();
485
+				if ($globalTransaction) {
486
+					$Connection->db->beginTransaction();
487
+				}
423 488
 				$tmp = fgetcsv($fh,9999,',','"');
424 489
             			while (!feof($fh)) {
425 490
             				$line = fgetcsv($fh,9999,',','"');
@@ -429,16 +494,22 @@  discard block
 block discarded – undo
429 494
             				    $values['registration'] = $line[0];
430 495
             				    $values['base'] = $line[4];
431 496
             				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+            				    if ($line[6] == '') {
498
+            				    	$values['date_first_reg'] = null;
499
+            				    } else {
500
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
501
+					    }
434 502
 					    $values['cancel'] = $line[7];
435 503
 					} elseif ($country == 'EI') {
436 504
 					    // TODO : add modeS & reg to aircraft_modes
437 505
             				    $values['registration'] = $line[0];
438 506
             				    $values['base'] = $line[3];
439 507
             				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
508
+            				    if ($line[1] == '') {
509
+            				    	$values['date_first_reg'] = null;
510
+            				    } else {
511
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
512
+					    }
442 513
 					    $values['cancel'] = '';
443 514
 					    $values['modes'] = $line[7];
444 515
 					    $values['icao'] = $line[8];
@@ -457,16 +528,22 @@  discard block
 block discarded – undo
457 528
             				    $values['registration'] = $line[3];
458 529
             				    $values['base'] = null;
459 530
             				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
531
+            				    if ($line[18] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
535
+					    }
462 536
 					    $values['cancel'] = '';
463 537
 					} elseif ($country == 'VH') {
464 538
 					    // TODO : add modeS & reg to aircraft_modes
465 539
             				    $values['registration'] = $line[0];
466 540
             				    $values['base'] = null;
467 541
             				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
542
+            				    if ($line[28] == '') {
543
+            				    	$values['date_first_reg'] = null;
544
+            				    } else {
545
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
546
+					    }
470 547
 
471 548
 					    $values['cancel'] = $line[39];
472 549
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -485,29 +562,41 @@  discard block
 block discarded – undo
485 562
             				    $values['registration'] = $line[0];
486 563
             				    $values['base'] = null;
487 564
             				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
565
+            				    if ($line[7] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
569
+					    }
490 570
 					    $values['cancel'] = '';
491 571
 					} elseif ($country == 'PP') {
492 572
             				    $values['registration'] = $line[0];
493 573
             				    $values['base'] = null;
494 574
             				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
575
+            				    if ($line[6] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
579
+					    }
497 580
 					    $values['cancel'] = $line[7];
498 581
 					} elseif ($country == 'E7') {
499 582
             				    $values['registration'] = $line[0];
500 583
             				    $values['base'] = null;
501 584
             				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
585
+            				    if ($line[5] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
589
+					    }
504 590
 					    $values['cancel'] = '';
505 591
 					} elseif ($country == '8Q') {
506 592
             				    $values['registration'] = $line[0];
507 593
             				    $values['base'] = null;
508 594
             				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
595
+            				    if ($line[7] == '') {
596
+            				    	$values['date_first_reg'] = null;
597
+            				    } else {
598
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
599
+					    }
511 600
 					    $values['cancel'] = '';
512 601
 					} elseif ($country == 'ZK') {
513 602
             				    $values['registration'] = $line[0];
@@ -552,7 +641,9 @@  discard block
 block discarded – undo
552 641
 						$sth_modes->execute($query_modes_values);
553 642
 					}
554 643
 				}
555
-				if ($globalTransaction) $Connection->db->commit();
644
+				if ($globalTransaction) {
645
+					$Connection->db->commit();
646
+				}
556 647
 			} catch(PDOException $e) {
557 648
 				return "error : ".$e->getMessage();
558 649
 			}
@@ -688,25 +779,45 @@  discard block
 block discarded – undo
688 779
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
689 780
 		$Connection = new Connection();
690 781
 		$sth_dest = $Connection->db->prepare($query_dest);
691
-		if ($globalTransaction) $Connection->db->beginTransaction();
782
+		if ($globalTransaction) {
783
+			$Connection->db->beginTransaction();
784
+		}
692 785
   
693 786
 		$i = 0;
694 787
 		while($row = sparql_fetch_array($result))
695 788
 		{
696 789
 			if ($i >= 1) {
697 790
 			//print_r($row);
698
-			if (!isset($row['iata'])) $row['iata'] = '';
699
-			if (!isset($row['icao'])) $row['icao'] = '';
700
-			if (!isset($row['type'])) $row['type'] = '';
701
-			if (!isset($row['altitude'])) $row['altitude'] = '';
791
+			if (!isset($row['iata'])) {
792
+				$row['iata'] = '';
793
+			}
794
+			if (!isset($row['icao'])) {
795
+				$row['icao'] = '';
796
+			}
797
+			if (!isset($row['type'])) {
798
+				$row['type'] = '';
799
+			}
800
+			if (!isset($row['altitude'])) {
801
+				$row['altitude'] = '';
802
+			}
702 803
 			if (isset($row['city_bis'])) {
703 804
 				$row['city'] = $row['city_bis'];
704 805
 			}
705
-			if (!isset($row['city'])) $row['city'] = '';
706
-			if (!isset($row['country'])) $row['country'] = '';
707
-			if (!isset($row['homepage'])) $row['homepage'] = '';
708
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
709
-			if (!isset($row['name'])) continue;
806
+			if (!isset($row['city'])) {
807
+				$row['city'] = '';
808
+			}
809
+			if (!isset($row['country'])) {
810
+				$row['country'] = '';
811
+			}
812
+			if (!isset($row['homepage'])) {
813
+				$row['homepage'] = '';
814
+			}
815
+			if (!isset($row['wikipedia_page'])) {
816
+				$row['wikipedia_page'] = '';
817
+			}
818
+			if (!isset($row['name'])) {
819
+				continue;
820
+			}
710 821
 			if (!isset($row['image'])) {
711 822
 				$row['image'] = '';
712 823
 				$row['image_thumb'] = '';
@@ -762,7 +873,9 @@  discard block
 block discarded – undo
762 873
 
763 874
 			$i++;
764 875
 		}
765
-		if ($globalTransaction) $Connection->db->commit();
876
+		if ($globalTransaction) {
877
+			$Connection->db->commit();
878
+		}
766 879
 		/*
767 880
 		echo "Delete duplicate rows...\n";
768 881
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -805,7 +918,9 @@  discard block
 block discarded – undo
805 918
 		$delimiter = ',';
806 919
 		$out_file = $tmp_dir.'airports.csv';
807 920
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
808
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
921
+		if (!file_exists($out_file) || !is_readable($out_file)) {
922
+			return FALSE;
923
+		}
809 924
 		echo "Add data from ourairports.com...\n";
810 925
 
811 926
 		$header = NULL;
@@ -815,8 +930,9 @@  discard block
 block discarded – undo
815 930
 			//$Connection->db->beginTransaction();
816 931
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 932
 			{
818
-				if(!$header) $header = $row;
819
-				else {
933
+				if(!$header) {
934
+					$header = $row;
935
+				} else {
820 936
 					$data = array();
821 937
 					$data = array_combine($header, $row);
822 938
 					try {
@@ -857,7 +973,9 @@  discard block
 block discarded – undo
857 973
 		echo "Download data from another free database...\n";
858 974
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859 975
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
860
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
976
+		if (!file_exists($out_file) || !is_readable($out_file)) {
977
+			return FALSE;
978
+		}
861 979
 		update_db::unzip($out_file);
862 980
 		$header = NULL;
863 981
 		echo "Add data from another free database...\n";
@@ -868,8 +986,9 @@  discard block
 block discarded – undo
868 986
 			//$Connection->db->beginTransaction();
869 987
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 988
 			{
871
-				if(!$header) $header = $row;
872
-				else {
989
+				if(!$header) {
990
+					$header = $row;
991
+				} else {
873 992
 					$data = $row;
874 993
 
875 994
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1038,7 +1157,9 @@  discard block
 block discarded – undo
1038 1157
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1039 1158
 		{
1040 1159
 			$i = 0;
1041
-			if ($globalTransaction) $Connection->db->beginTransaction();
1160
+			if ($globalTransaction) {
1161
+				$Connection->db->beginTransaction();
1162
+			}
1042 1163
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1043 1164
 			{
1044 1165
 				if ($i > 0) {
@@ -1051,7 +1172,9 @@  discard block
 block discarded – undo
1051 1172
 					}
1052 1173
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1053 1174
 					if (!empty($result_search)) {
1054
-						if ($globalDebug) echo '.';
1175
+						if ($globalDebug) {
1176
+							echo '.';
1177
+						}
1055 1178
 							//if ($globalDBdriver == 'mysql') {
1056 1179
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1057 1180
 							//} else {
@@ -1073,8 +1196,12 @@  discard block
 block discarded – undo
1073 1196
 						}
1074 1197
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1075 1198
 						if (!empty($result_search_mfr)) {
1076
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1077
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1199
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1200
+								$data[16] = $data[23];
1201
+							}
1202
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1203
+								$data[16] = $data[15];
1204
+							}
1078 1205
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1079 1206
 							try {
1080 1207
 								$sthf = $Connection->db->prepare($queryf);
@@ -1085,7 +1212,9 @@  discard block
 block discarded – undo
1085 1212
 						}
1086 1213
 					}
1087 1214
 					if (strtotime($data[29]) > time()) {
1088
-						if ($globalDebug) echo 'i';
1215
+						if ($globalDebug) {
1216
+							echo 'i';
1217
+						}
1089 1218
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1090 1219
 						try {
1091 1220
 							$sth = $Connection->db->prepare($query);
@@ -1096,13 +1225,19 @@  discard block
 block discarded – undo
1096 1225
 					}
1097 1226
 				}
1098 1227
 				if ($i % 90 == 0) {
1099
-					if ($globalTransaction) $Connection->db->commit();
1100
-					if ($globalTransaction) $Connection->db->beginTransaction();
1228
+					if ($globalTransaction) {
1229
+						$Connection->db->commit();
1230
+					}
1231
+					if ($globalTransaction) {
1232
+						$Connection->db->beginTransaction();
1233
+					}
1101 1234
 				}
1102 1235
 				$i++;
1103 1236
 			}
1104 1237
 			fclose($handle);
1105
-			if ($globalTransaction) $Connection->db->commit();
1238
+			if ($globalTransaction) {
1239
+				$Connection->db->commit();
1240
+			}
1106 1241
 		}
1107 1242
 		//print_r($mfr);
1108 1243
 		return '';
@@ -1127,11 +1262,15 @@  discard block
 block discarded – undo
1127 1262
 			$i = 0;
1128 1263
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1129 1264
 			//$Connection->db->beginTransaction();
1130
-			if ($globalTransaction) $Connection->db->beginTransaction();
1265
+			if ($globalTransaction) {
1266
+				$Connection->db->beginTransaction();
1267
+			}
1131 1268
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1132 1269
 			{
1133 1270
 				if ($i > 0) {
1134
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1271
+					if ($data[1] == 'NULL') {
1272
+						$data[1] = $data[0];
1273
+					}
1135 1274
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1136 1275
 					try {
1137 1276
 						$sth = $Connection->db->prepare($query);
@@ -1143,7 +1282,9 @@  discard block
 block discarded – undo
1143 1282
 				$i++;
1144 1283
 			}
1145 1284
 			fclose($handle);
1146
-			if ($globalTransaction) $Connection->db->commit();
1285
+			if ($globalTransaction) {
1286
+				$Connection->db->commit();
1287
+			}
1147 1288
 		}
1148 1289
 		return '';
1149 1290
         }
@@ -1164,7 +1305,9 @@  discard block
 block discarded – undo
1164 1305
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1165 1306
 		{
1166 1307
 			$i = 0;
1167
-			if ($globalTransaction) $Connection->db->beginTransaction();
1308
+			if ($globalTransaction) {
1309
+				$Connection->db->beginTransaction();
1310
+			}
1168 1311
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1169 1312
 			{
1170 1313
 				if ($i > 0) {
@@ -1180,7 +1323,9 @@  discard block
 block discarded – undo
1180 1323
 				$i++;
1181 1324
 			}
1182 1325
 			fclose($handle);
1183
-			if ($globalTransaction) $Connection->db->commit();
1326
+			if ($globalTransaction) {
1327
+				$Connection->db->commit();
1328
+			}
1184 1329
 		}
1185 1330
 		return '';
1186 1331
         }
@@ -1200,7 +1345,9 @@  discard block
 block discarded – undo
1200 1345
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1201 1346
 		{
1202 1347
 			$i = 0;
1203
-			if ($globalTransaction) $Connection->db->beginTransaction();
1348
+			if ($globalTransaction) {
1349
+				$Connection->db->beginTransaction();
1350
+			}
1204 1351
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1205 1352
 			{
1206 1353
 				if ($i > 0) {
@@ -1209,13 +1356,17 @@  discard block
 block discarded – undo
1209 1356
 						$sth = $Connection->db->prepare($query);
1210 1357
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1211 1358
 					} catch(PDOException $e) {
1212
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1359
+						if ($globalDebug) {
1360
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1361
+						}
1213 1362
 					}
1214 1363
 				}
1215 1364
 				$i++;
1216 1365
 			}
1217 1366
 			fclose($handle);
1218
-			if ($globalTransaction) $Connection->db->commit();
1367
+			if ($globalTransaction) {
1368
+				$Connection->db->commit();
1369
+			}
1219 1370
 		}
1220 1371
 		return '';
1221 1372
         }
@@ -1240,7 +1391,9 @@  discard block
 block discarded – undo
1240 1391
 			$i = 0;
1241 1392
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1242 1393
 			//$Connection->db->beginTransaction();
1243
-			if ($globalTransaction) $Connection->db->beginTransaction();
1394
+			if ($globalTransaction) {
1395
+				$Connection->db->beginTransaction();
1396
+			}
1244 1397
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1245 1398
 			{
1246 1399
 				if ($i > 0) {
@@ -1256,7 +1409,9 @@  discard block
 block discarded – undo
1256 1409
 				$i++;
1257 1410
 			}
1258 1411
 			fclose($handle);
1259
-			if ($globalTransaction) $Connection->db->commit();
1412
+			if ($globalTransaction) {
1413
+				$Connection->db->commit();
1414
+			}
1260 1415
 		}
1261 1416
 		return '';
1262 1417
         }
@@ -1276,7 +1431,9 @@  discard block
 block discarded – undo
1276 1431
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1277 1432
 		{
1278 1433
 			$i = 0;
1279
-			if ($globalTransaction) $Connection->db->beginTransaction();
1434
+			if ($globalTransaction) {
1435
+				$Connection->db->beginTransaction();
1436
+			}
1280 1437
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1281 1438
 			{
1282 1439
 				if ($i > 0) {
@@ -1293,7 +1450,9 @@  discard block
 block discarded – undo
1293 1450
 				$i++;
1294 1451
 			}
1295 1452
 			fclose($handle);
1296
-			if ($globalTransaction) $Connection->db->commit();
1453
+			if ($globalTransaction) {
1454
+				$Connection->db->commit();
1455
+			}
1297 1456
 		}
1298 1457
 		return '';
1299 1458
 	}
@@ -1312,7 +1471,9 @@  discard block
 block discarded – undo
1312 1471
 		$Connection = new Connection();
1313 1472
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1314 1473
 		{
1315
-			if ($globalTransaction) $Connection->db->beginTransaction();
1474
+			if ($globalTransaction) {
1475
+				$Connection->db->beginTransaction();
1476
+			}
1316 1477
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1317 1478
 			{
1318 1479
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1327,7 +1488,9 @@  discard block
 block discarded – undo
1327 1488
 				}
1328 1489
 			}
1329 1490
 			fclose($handle);
1330
-			if ($globalTransaction) $Connection->db->commit();
1491
+			if ($globalTransaction) {
1492
+				$Connection->db->commit();
1493
+			}
1331 1494
 		}
1332 1495
 		return '';
1333 1496
         }
@@ -1404,9 +1567,14 @@  discard block
 block discarded – undo
1404 1567
 				if ($i > 0 && $data[0] != '') {
1405 1568
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1406 1569
 					$period = str_replace(',','',$data[14]);
1407
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1408
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1409
-					else $launch_date = NULL;
1570
+					if (!empty($period) && strpos($period,'days')) {
1571
+						$period = str_replace(' days','',$period)*24*60;
1572
+					}
1573
+					if ($data[18] != '') {
1574
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1575
+					} else {
1576
+						$launch_date = NULL;
1577
+					}
1410 1578
 					$data = array_map(function($value) {
1411 1579
 						return trim($value) === '' ? null : $value;
1412 1580
 					}, $data);
@@ -1757,7 +1925,9 @@  discard block
 block discarded – undo
1757 1925
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1758 1926
 		{
1759 1927
 			$i = 0;
1760
-			if ($globalTransaction) $Connection->db->beginTransaction();
1928
+			if ($globalTransaction) {
1929
+				$Connection->db->beginTransaction();
1930
+			}
1761 1931
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1762 1932
 			{
1763 1933
 				$i++;
@@ -1785,7 +1955,9 @@  discard block
 block discarded – undo
1785 1955
 				}
1786 1956
 			}
1787 1957
 			fclose($handle);
1788
-			if ($globalTransaction) $Connection->db->commit();
1958
+			if ($globalTransaction) {
1959
+				$Connection->db->commit();
1960
+			}
1789 1961
 		}
1790 1962
 		return '';
1791 1963
         }
@@ -1808,7 +1980,9 @@  discard block
 block discarded – undo
1808 1980
 		$Connection = new Connection();
1809 1981
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1810 1982
 		{
1811
-			if ($globalTransaction) $Connection->db->beginTransaction();
1983
+			if ($globalTransaction) {
1984
+				$Connection->db->beginTransaction();
1985
+			}
1812 1986
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1813 1987
 			{
1814 1988
 				if(count($row) > 1) {
@@ -1822,7 +1996,9 @@  discard block
 block discarded – undo
1822 1996
 				}
1823 1997
 			}
1824 1998
 			fclose($handle);
1825
-			if ($globalTransaction) $Connection->db->commit();
1999
+			if ($globalTransaction) {
2000
+				$Connection->db->commit();
2001
+			}
1826 2002
 		}
1827 2003
 		return '';
1828 2004
         }
@@ -1842,8 +2018,9 @@  discard block
 block discarded – undo
1842 2018
 	        }
1843 2019
 
1844 2020
 
1845
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1846
-		else {
2021
+		if ($globalDBdriver == 'mysql') {
2022
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2023
+		} else {
1847 2024
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1848 2025
 			$query = "CREATE EXTENSION postgis";
1849 2026
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1862,20 +2039,30 @@  discard block
 block discarded – undo
1862 2039
 		global $tmp_dir, $globalDebug;
1863 2040
 		include_once('class.create_db.php');
1864 2041
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1865
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2042
+		if ($globalDebug) {
2043
+			echo "NOTAM from FlightAirMap website : Download...";
2044
+		}
1866 2045
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1867 2046
 		$error = '';
1868 2047
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1869
-			if ($globalDebug) echo "Gunzip...";
2048
+			if ($globalDebug) {
2049
+				echo "Gunzip...";
2050
+			}
1870 2051
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1871
-			if ($globalDebug) echo "Add to DB...";
2052
+			if ($globalDebug) {
2053
+				echo "Add to DB...";
2054
+			}
1872 2055
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1873 2056
 			$NOTAM = new NOTAM();
1874 2057
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1875
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2058
+		} else {
2059
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2060
+		}
1876 2061
 		if ($error != '') {
1877 2062
 			return $error;
1878
-		} elseif ($globalDebug) echo "Done\n";
2063
+		} elseif ($globalDebug) {
2064
+			echo "Done\n";
2065
+		}
1879 2066
 		return '';
1880 2067
 	}
1881 2068
 
@@ -1929,67 +2116,111 @@  discard block
 block discarded – undo
1929 2116
 		//if ($globalDebug) echo "IVAO : Download...";
1930 2117
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1931 2118
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1932
-			if ($globalDebug) echo "Unzip...";
2119
+			if ($globalDebug) {
2120
+				echo "Unzip...";
2121
+			}
1933 2122
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1934
-			if ($globalDebug) echo "Add to DB...";
2123
+			if ($globalDebug) {
2124
+				echo "Add to DB...";
2125
+			}
1935 2126
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1936
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2127
+			if ($globalDebug) {
2128
+				echo "Copy airlines logos to airlines images directory...";
2129
+			}
1937 2130
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1938
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1939
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1940
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2131
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2132
+					$error = "Failed to copy airlines logo.";
2133
+				}
2134
+			} else {
2135
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2136
+			}
2137
+		} else {
2138
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2139
+		}
1941 2140
 		if ($error != '') {
1942 2141
 			return $error;
1943
-		} elseif ($globalDebug) echo "Done\n";
2142
+		} elseif ($globalDebug) {
2143
+			echo "Done\n";
2144
+		}
1944 2145
 		return '';
1945 2146
 	}
1946 2147
 
1947 2148
 	public static function update_routes() {
1948 2149
 		global $tmp_dir, $globalDebug;
1949 2150
 		$error = '';
1950
-		if ($globalDebug) echo "Routes : Download...";
2151
+		if ($globalDebug) {
2152
+			echo "Routes : Download...";
2153
+		}
1951 2154
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1952 2155
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1953
-			if ($globalDebug) echo "Gunzip...";
2156
+			if ($globalDebug) {
2157
+				echo "Gunzip...";
2158
+			}
1954 2159
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1955
-			if ($globalDebug) echo "Add to DB...";
2160
+			if ($globalDebug) {
2161
+				echo "Add to DB...";
2162
+			}
1956 2163
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1957
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2164
+		} else {
2165
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2166
+		}
1958 2167
 		if ($error != '') {
1959 2168
 			return $error;
1960
-		} elseif ($globalDebug) echo "Done\n";
2169
+		} elseif ($globalDebug) {
2170
+			echo "Done\n";
2171
+		}
1961 2172
 		return '';
1962 2173
 	}
1963 2174
 	public static function update_oneworld() {
1964 2175
 		global $tmp_dir, $globalDebug;
1965 2176
 		$error = '';
1966
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2177
+		if ($globalDebug) {
2178
+			echo "Schedules Oneworld : Download...";
2179
+		}
1967 2180
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1968 2181
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1969
-			if ($globalDebug) echo "Gunzip...";
2182
+			if ($globalDebug) {
2183
+				echo "Gunzip...";
2184
+			}
1970 2185
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1971
-			if ($globalDebug) echo "Add to DB...";
2186
+			if ($globalDebug) {
2187
+				echo "Add to DB...";
2188
+			}
1972 2189
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1973
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2190
+		} else {
2191
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2192
+		}
1974 2193
 		if ($error != '') {
1975 2194
 			return $error;
1976
-		} elseif ($globalDebug) echo "Done\n";
2195
+		} elseif ($globalDebug) {
2196
+			echo "Done\n";
2197
+		}
1977 2198
 		return '';
1978 2199
 	}
1979 2200
 	public static function update_skyteam() {
1980 2201
 		global $tmp_dir, $globalDebug;
1981 2202
 		$error = '';
1982
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2203
+		if ($globalDebug) {
2204
+			echo "Schedules Skyteam : Download...";
2205
+		}
1983 2206
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1984 2207
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1985
-			if ($globalDebug) echo "Gunzip...";
2208
+			if ($globalDebug) {
2209
+				echo "Gunzip...";
2210
+			}
1986 2211
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1987
-			if ($globalDebug) echo "Add to DB...";
2212
+			if ($globalDebug) {
2213
+				echo "Add to DB...";
2214
+			}
1988 2215
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1989
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2216
+		} else {
2217
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2218
+		}
1990 2219
 		if ($error != '') {
1991 2220
 			return $error;
1992
-		} elseif ($globalDebug) echo "Done\n";
2221
+		} elseif ($globalDebug) {
2222
+			echo "Done\n";
2223
+		}
1993 2224
 		return '';
1994 2225
 	}
1995 2226
 	public static function update_ModeS() {
@@ -2006,355 +2237,619 @@  discard block
 block discarded – undo
2006 2237
 			exit;
2007 2238
 		} elseif ($globalDebug) echo "Done\n";
2008 2239
 */
2009
-		if ($globalDebug) echo "Modes : Download...";
2010
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2240
+		if ($globalDebug) {
2241
+			echo "Modes : Download...";
2242
+		}
2243
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2011 2244
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2012 2245
 
2013 2246
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2014 2247
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2015
-			if ($globalDebug) echo "Unzip...";
2016
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2248
+			if ($globalDebug) {
2249
+				echo "Unzip...";
2250
+			}
2251
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2017 2252
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2018
-			if ($globalDebug) echo "Add to DB...";
2253
+			if ($globalDebug) {
2254
+				echo "Add to DB...";
2255
+			}
2019 2256
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2020 2257
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2021
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2258
+		} else {
2259
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2260
+		}
2022 2261
 		if ($error != '') {
2023 2262
 			return $error;
2024
-		} elseif ($globalDebug) echo "Done\n";
2263
+		} elseif ($globalDebug) {
2264
+			echo "Done\n";
2265
+		}
2025 2266
 		return '';
2026 2267
 	}
2027 2268
 
2028 2269
 	public static function update_ModeS_faa() {
2029 2270
 		global $tmp_dir, $globalDebug;
2030
-		if ($globalDebug) echo "Modes FAA: Download...";
2271
+		if ($globalDebug) {
2272
+			echo "Modes FAA: Download...";
2273
+		}
2031 2274
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2032 2275
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2033
-			if ($globalDebug) echo "Unzip...";
2276
+			if ($globalDebug) {
2277
+				echo "Unzip...";
2278
+			}
2034 2279
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2035
-			if ($globalDebug) echo "Add to DB...";
2280
+			if ($globalDebug) {
2281
+				echo "Add to DB...";
2282
+			}
2036 2283
 			$error = update_db::modes_faa();
2037
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2284
+		} else {
2285
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2286
+		}
2038 2287
 		if ($error != '') {
2039 2288
 			return $error;
2040
-		} elseif ($globalDebug) echo "Done\n";
2289
+		} elseif ($globalDebug) {
2290
+			echo "Done\n";
2291
+		}
2041 2292
 		return '';
2042 2293
 	}
2043 2294
 
2044 2295
 	public static function update_ModeS_flarm() {
2045 2296
 		global $tmp_dir, $globalDebug;
2046
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2297
+		if ($globalDebug) {
2298
+			echo "Modes Flarmnet: Download...";
2299
+		}
2047 2300
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2048 2301
 		if (file_exists($tmp_dir.'data.fln')) {
2049
-			if ($globalDebug) echo "Add to DB...";
2302
+			if ($globalDebug) {
2303
+				echo "Add to DB...";
2304
+			}
2050 2305
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2051
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2306
+		} else {
2307
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2308
+		}
2052 2309
 		if ($error != '') {
2053 2310
 			return $error;
2054
-		} elseif ($globalDebug) echo "Done\n";
2311
+		} elseif ($globalDebug) {
2312
+			echo "Done\n";
2313
+		}
2055 2314
 		return '';
2056 2315
 	}
2057 2316
 
2058 2317
 	public static function update_ModeS_ogn() {
2059 2318
 		global $tmp_dir, $globalDebug;
2060
-		if ($globalDebug) echo "Modes OGN: Download...";
2319
+		if ($globalDebug) {
2320
+			echo "Modes OGN: Download...";
2321
+		}
2061 2322
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2062 2323
 		if (file_exists($tmp_dir.'ogn.csv')) {
2063
-			if ($globalDebug) echo "Add to DB...";
2324
+			if ($globalDebug) {
2325
+				echo "Add to DB...";
2326
+			}
2064 2327
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2065
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2328
+		} else {
2329
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2330
+		}
2066 2331
 		if ($error != '') {
2067 2332
 			return $error;
2068
-		} elseif ($globalDebug) echo "Done\n";
2333
+		} elseif ($globalDebug) {
2334
+			echo "Done\n";
2335
+		}
2069 2336
 		return '';
2070 2337
 	}
2071 2338
 
2072 2339
 	public static function update_owner() {
2073 2340
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2074 2341
 		
2075
-		if ($globalDebug) echo "Owner France: Download...";
2342
+		if ($globalDebug) {
2343
+			echo "Owner France: Download...";
2344
+		}
2076 2345
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2077 2346
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2078
-			if ($globalDebug) echo "Add to DB...";
2347
+			if ($globalDebug) {
2348
+				echo "Add to DB...";
2349
+			}
2079 2350
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2080
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2351
+		} else {
2352
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2353
+		}
2081 2354
 		if ($error != '') {
2082 2355
 			return $error;
2083
-		} elseif ($globalDebug) echo "Done\n";
2356
+		} elseif ($globalDebug) {
2357
+			echo "Done\n";
2358
+		}
2084 2359
 		
2085
-		if ($globalDebug) echo "Owner Ireland: Download...";
2360
+		if ($globalDebug) {
2361
+			echo "Owner Ireland: Download...";
2362
+		}
2086 2363
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2087 2364
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2088
-			if ($globalDebug) echo "Add to DB...";
2365
+			if ($globalDebug) {
2366
+				echo "Add to DB...";
2367
+			}
2089 2368
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2090
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2369
+		} else {
2370
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2371
+		}
2091 2372
 		if ($error != '') {
2092 2373
 			return $error;
2093
-		} elseif ($globalDebug) echo "Done\n";
2094
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2374
+		} elseif ($globalDebug) {
2375
+			echo "Done\n";
2376
+		}
2377
+		if ($globalDebug) {
2378
+			echo "Owner Switzerland: Download...";
2379
+		}
2095 2380
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2096 2381
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2097
-			if ($globalDebug) echo "Add to DB...";
2382
+			if ($globalDebug) {
2383
+				echo "Add to DB...";
2384
+			}
2098 2385
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2099
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2386
+		} else {
2387
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2388
+		}
2100 2389
 		if ($error != '') {
2101 2390
 			return $error;
2102
-		} elseif ($globalDebug) echo "Done\n";
2103
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2391
+		} elseif ($globalDebug) {
2392
+			echo "Done\n";
2393
+		}
2394
+		if ($globalDebug) {
2395
+			echo "Owner Czech Republic: Download...";
2396
+		}
2104 2397
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2105 2398
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2106
-			if ($globalDebug) echo "Add to DB...";
2399
+			if ($globalDebug) {
2400
+				echo "Add to DB...";
2401
+			}
2107 2402
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2108
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2403
+		} else {
2404
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2405
+		}
2109 2406
 		if ($error != '') {
2110 2407
 			return $error;
2111
-		} elseif ($globalDebug) echo "Done\n";
2112
-		if ($globalDebug) echo "Owner Australia: Download...";
2408
+		} elseif ($globalDebug) {
2409
+			echo "Done\n";
2410
+		}
2411
+		if ($globalDebug) {
2412
+			echo "Owner Australia: Download...";
2413
+		}
2113 2414
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2114 2415
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2115
-			if ($globalDebug) echo "Add to DB...";
2416
+			if ($globalDebug) {
2417
+				echo "Add to DB...";
2418
+			}
2116 2419
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2117
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2420
+		} else {
2421
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2422
+		}
2118 2423
 		if ($error != '') {
2119 2424
 			return $error;
2120
-		} elseif ($globalDebug) echo "Done\n";
2121
-		if ($globalDebug) echo "Owner Austria: Download...";
2425
+		} elseif ($globalDebug) {
2426
+			echo "Done\n";
2427
+		}
2428
+		if ($globalDebug) {
2429
+			echo "Owner Austria: Download...";
2430
+		}
2122 2431
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2123 2432
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2124
-			if ($globalDebug) echo "Add to DB...";
2433
+			if ($globalDebug) {
2434
+				echo "Add to DB...";
2435
+			}
2125 2436
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2126
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2437
+		} else {
2438
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2439
+		}
2127 2440
 		if ($error != '') {
2128 2441
 			return $error;
2129
-		} elseif ($globalDebug) echo "Done\n";
2130
-		if ($globalDebug) echo "Owner Chile: Download...";
2442
+		} elseif ($globalDebug) {
2443
+			echo "Done\n";
2444
+		}
2445
+		if ($globalDebug) {
2446
+			echo "Owner Chile: Download...";
2447
+		}
2131 2448
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2132 2449
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2133
-			if ($globalDebug) echo "Add to DB...";
2450
+			if ($globalDebug) {
2451
+				echo "Add to DB...";
2452
+			}
2134 2453
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2135
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2454
+		} else {
2455
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2456
+		}
2136 2457
 		if ($error != '') {
2137 2458
 			return $error;
2138
-		} elseif ($globalDebug) echo "Done\n";
2139
-		if ($globalDebug) echo "Owner Colombia: Download...";
2459
+		} elseif ($globalDebug) {
2460
+			echo "Done\n";
2461
+		}
2462
+		if ($globalDebug) {
2463
+			echo "Owner Colombia: Download...";
2464
+		}
2140 2465
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2141 2466
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2142
-			if ($globalDebug) echo "Add to DB...";
2467
+			if ($globalDebug) {
2468
+				echo "Add to DB...";
2469
+			}
2143 2470
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2144
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2471
+		} else {
2472
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2473
+		}
2145 2474
 		if ($error != '') {
2146 2475
 			return $error;
2147
-		} elseif ($globalDebug) echo "Done\n";
2148
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2476
+		} elseif ($globalDebug) {
2477
+			echo "Done\n";
2478
+		}
2479
+		if ($globalDebug) {
2480
+			echo "Owner Bosnia Herzegobina: Download...";
2481
+		}
2149 2482
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2150 2483
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2151
-			if ($globalDebug) echo "Add to DB...";
2484
+			if ($globalDebug) {
2485
+				echo "Add to DB...";
2486
+			}
2152 2487
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2153
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2488
+		} else {
2489
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2490
+		}
2154 2491
 		if ($error != '') {
2155 2492
 			return $error;
2156
-		} elseif ($globalDebug) echo "Done\n";
2157
-		if ($globalDebug) echo "Owner Brazil: Download...";
2493
+		} elseif ($globalDebug) {
2494
+			echo "Done\n";
2495
+		}
2496
+		if ($globalDebug) {
2497
+			echo "Owner Brazil: Download...";
2498
+		}
2158 2499
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2159 2500
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2160
-			if ($globalDebug) echo "Add to DB...";
2501
+			if ($globalDebug) {
2502
+				echo "Add to DB...";
2503
+			}
2161 2504
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2162
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2505
+		} else {
2506
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2507
+		}
2163 2508
 		if ($error != '') {
2164 2509
 			return $error;
2165
-		} elseif ($globalDebug) echo "Done\n";
2166
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2510
+		} elseif ($globalDebug) {
2511
+			echo "Done\n";
2512
+		}
2513
+		if ($globalDebug) {
2514
+			echo "Owner Cayman Islands: Download...";
2515
+		}
2167 2516
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2168 2517
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2169
-			if ($globalDebug) echo "Add to DB...";
2518
+			if ($globalDebug) {
2519
+				echo "Add to DB...";
2520
+			}
2170 2521
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2171
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2522
+		} else {
2523
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2524
+		}
2172 2525
 		if ($error != '') {
2173 2526
 			return $error;
2174
-		} elseif ($globalDebug) echo "Done\n";
2175
-		if ($globalDebug) echo "Owner Croatia: Download...";
2527
+		} elseif ($globalDebug) {
2528
+			echo "Done\n";
2529
+		}
2530
+		if ($globalDebug) {
2531
+			echo "Owner Croatia: Download...";
2532
+		}
2176 2533
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2177 2534
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2178
-			if ($globalDebug) echo "Add to DB...";
2535
+			if ($globalDebug) {
2536
+				echo "Add to DB...";
2537
+			}
2179 2538
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2180
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2539
+		} else {
2540
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2541
+		}
2181 2542
 		if ($error != '') {
2182 2543
 			return $error;
2183
-		} elseif ($globalDebug) echo "Done\n";
2184
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2544
+		} elseif ($globalDebug) {
2545
+			echo "Done\n";
2546
+		}
2547
+		if ($globalDebug) {
2548
+			echo "Owner Luxembourg: Download...";
2549
+		}
2185 2550
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2186 2551
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2187
-			if ($globalDebug) echo "Add to DB...";
2552
+			if ($globalDebug) {
2553
+				echo "Add to DB...";
2554
+			}
2188 2555
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2189
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2556
+		} else {
2557
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2558
+		}
2190 2559
 		if ($error != '') {
2191 2560
 			return $error;
2192
-		} elseif ($globalDebug) echo "Done\n";
2193
-		if ($globalDebug) echo "Owner Maldives: Download...";
2561
+		} elseif ($globalDebug) {
2562
+			echo "Done\n";
2563
+		}
2564
+		if ($globalDebug) {
2565
+			echo "Owner Maldives: Download...";
2566
+		}
2194 2567
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2195 2568
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2196
-			if ($globalDebug) echo "Add to DB...";
2569
+			if ($globalDebug) {
2570
+				echo "Add to DB...";
2571
+			}
2197 2572
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2198
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2573
+		} else {
2574
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2575
+		}
2199 2576
 		if ($error != '') {
2200 2577
 			return $error;
2201
-		} elseif ($globalDebug) echo "Done\n";
2202
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2578
+		} elseif ($globalDebug) {
2579
+			echo "Done\n";
2580
+		}
2581
+		if ($globalDebug) {
2582
+			echo "Owner New Zealand: Download...";
2583
+		}
2203 2584
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2204 2585
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2205
-			if ($globalDebug) echo "Add to DB...";
2586
+			if ($globalDebug) {
2587
+				echo "Add to DB...";
2588
+			}
2206 2589
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2207
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2590
+		} else {
2591
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2592
+		}
2208 2593
 		if ($error != '') {
2209 2594
 			return $error;
2210
-		} elseif ($globalDebug) echo "Done\n";
2211
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2595
+		} elseif ($globalDebug) {
2596
+			echo "Done\n";
2597
+		}
2598
+		if ($globalDebug) {
2599
+			echo "Owner Papua New Guinea: Download...";
2600
+		}
2212 2601
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2213 2602
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2214
-			if ($globalDebug) echo "Add to DB...";
2603
+			if ($globalDebug) {
2604
+				echo "Add to DB...";
2605
+			}
2215 2606
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2216
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2607
+		} else {
2608
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2609
+		}
2217 2610
 		if ($error != '') {
2218 2611
 			return $error;
2219
-		} elseif ($globalDebug) echo "Done\n";
2220
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2612
+		} elseif ($globalDebug) {
2613
+			echo "Done\n";
2614
+		}
2615
+		if ($globalDebug) {
2616
+			echo "Owner Slovakia: Download...";
2617
+		}
2221 2618
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2222 2619
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2223
-			if ($globalDebug) echo "Add to DB...";
2620
+			if ($globalDebug) {
2621
+				echo "Add to DB...";
2622
+			}
2224 2623
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2225
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2624
+		} else {
2625
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2626
+		}
2226 2627
 		if ($error != '') {
2227 2628
 			return $error;
2228
-		} elseif ($globalDebug) echo "Done\n";
2229
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2629
+		} elseif ($globalDebug) {
2630
+			echo "Done\n";
2631
+		}
2632
+		if ($globalDebug) {
2633
+			echo "Owner Ecuador: Download...";
2634
+		}
2230 2635
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2231 2636
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2232
-			if ($globalDebug) echo "Add to DB...";
2637
+			if ($globalDebug) {
2638
+				echo "Add to DB...";
2639
+			}
2233 2640
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2234
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2641
+		} else {
2642
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2643
+		}
2235 2644
 		if ($error != '') {
2236 2645
 			return $error;
2237
-		} elseif ($globalDebug) echo "Done\n";
2238
-		if ($globalDebug) echo "Owner Iceland: Download...";
2646
+		} elseif ($globalDebug) {
2647
+			echo "Done\n";
2648
+		}
2649
+		if ($globalDebug) {
2650
+			echo "Owner Iceland: Download...";
2651
+		}
2239 2652
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2240 2653
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2241
-			if ($globalDebug) echo "Add to DB...";
2654
+			if ($globalDebug) {
2655
+				echo "Add to DB...";
2656
+			}
2242 2657
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2243
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2658
+		} else {
2659
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2660
+		}
2244 2661
 		if ($error != '') {
2245 2662
 			return $error;
2246
-		} elseif ($globalDebug) echo "Done\n";
2247
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2663
+		} elseif ($globalDebug) {
2664
+			echo "Done\n";
2665
+		}
2666
+		if ($globalDebug) {
2667
+			echo "Owner Isle of Man: Download...";
2668
+		}
2248 2669
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2249 2670
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2250
-			if ($globalDebug) echo "Add to DB...";
2671
+			if ($globalDebug) {
2672
+				echo "Add to DB...";
2673
+			}
2251 2674
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2252
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2675
+		} else {
2676
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2677
+		}
2253 2678
 		if ($error != '') {
2254 2679
 			return $error;
2255
-		} elseif ($globalDebug) echo "Done\n";
2680
+		} elseif ($globalDebug) {
2681
+			echo "Done\n";
2682
+		}
2256 2683
 		if ($globalMasterSource) {
2257
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2684
+			if ($globalDebug) {
2685
+				echo "ModeS Netherlands: Download...";
2686
+			}
2258 2687
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2259 2688
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2260
-				if ($globalDebug) echo "Add to DB...";
2689
+				if ($globalDebug) {
2690
+					echo "Add to DB...";
2691
+				}
2261 2692
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2262
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2693
+			} else {
2694
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2695
+			}
2263 2696
 			if ($error != '') {
2264 2697
 				return $error;
2265
-			} elseif ($globalDebug) echo "Done\n";
2266
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2698
+			} elseif ($globalDebug) {
2699
+				echo "Done\n";
2700
+			}
2701
+			if ($globalDebug) {
2702
+				echo "ModeS Denmark: Download...";
2703
+			}
2267 2704
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2268 2705
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2269
-				if ($globalDebug) echo "Add to DB...";
2706
+				if ($globalDebug) {
2707
+					echo "Add to DB...";
2708
+				}
2270 2709
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2271
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2710
+			} else {
2711
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2712
+			}
2272 2713
 			if ($error != '') {
2273 2714
 				return $error;
2274
-			} elseif ($globalDebug) echo "Done\n";
2275
-		} elseif ($globalDebug) echo "Done\n";
2715
+			} elseif ($globalDebug) {
2716
+				echo "Done\n";
2717
+			}
2718
+		} elseif ($globalDebug) {
2719
+			echo "Done\n";
2720
+		}
2276 2721
 		return '';
2277 2722
 	}
2278 2723
 
2279 2724
 	public static function update_translation() {
2280 2725
 		global $tmp_dir, $globalDebug;
2281 2726
 		$error = '';
2282
-		if ($globalDebug) echo "Translation : Download...";
2727
+		if ($globalDebug) {
2728
+			echo "Translation : Download...";
2729
+		}
2283 2730
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2284 2731
 		if (file_exists($tmp_dir.'translation.zip')) {
2285
-			if ($globalDebug) echo "Unzip...";
2732
+			if ($globalDebug) {
2733
+				echo "Unzip...";
2734
+			}
2286 2735
 			update_db::unzip($tmp_dir.'translation.zip');
2287
-			if ($globalDebug) echo "Add to DB...";
2736
+			if ($globalDebug) {
2737
+				echo "Add to DB...";
2738
+			}
2288 2739
 			$error = update_db::translation();
2289
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2740
+		} else {
2741
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2742
+		}
2290 2743
 		if ($error != '') {
2291 2744
 			return $error;
2292
-		} elseif ($globalDebug) echo "Done\n";
2745
+		} elseif ($globalDebug) {
2746
+			echo "Done\n";
2747
+		}
2293 2748
 		return '';
2294 2749
 	}
2295 2750
 
2296 2751
 	public static function update_translation_fam() {
2297 2752
 		global $tmp_dir, $globalDebug;
2298
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2753
+		if ($globalDebug) {
2754
+			echo "Translation from FlightAirMap website : Download...";
2755
+		}
2299 2756
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2300 2757
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
2301
-			if ($globalDebug) echo "Gunzip...";
2758
+			if ($globalDebug) {
2759
+				echo "Gunzip...";
2760
+			}
2302 2761
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
2303
-			if ($globalDebug) echo "Add to DB...";
2762
+			if ($globalDebug) {
2763
+				echo "Add to DB...";
2764
+			}
2304 2765
 			$error = update_db::translation_fam();
2305
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2766
+		} else {
2767
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2768
+		}
2306 2769
 		if ($error != '') {
2307 2770
 			return $error;
2308
-		} elseif ($globalDebug) echo "Done\n";
2771
+		} elseif ($globalDebug) {
2772
+			echo "Done\n";
2773
+		}
2309 2774
 		return '';
2310 2775
 	}
2311 2776
 	public static function update_ModeS_fam() {
2312 2777
 		global $tmp_dir, $globalDebug;
2313
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2778
+		if ($globalDebug) {
2779
+			echo "ModeS from FlightAirMap website : Download...";
2780
+		}
2314 2781
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2315 2782
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2316
-			if ($globalDebug) echo "Gunzip...";
2783
+			if ($globalDebug) {
2784
+				echo "Gunzip...";
2785
+			}
2317 2786
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
2318
-			if ($globalDebug) echo "Add to DB...";
2787
+			if ($globalDebug) {
2788
+				echo "Add to DB...";
2789
+			}
2319 2790
 			$error = update_db::modes_fam();
2320
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2791
+		} else {
2792
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2793
+		}
2321 2794
 		if ($error != '') {
2322 2795
 			return $error;
2323
-		} elseif ($globalDebug) echo "Done\n";
2796
+		} elseif ($globalDebug) {
2797
+			echo "Done\n";
2798
+		}
2324 2799
 		return '';
2325 2800
 	}
2326 2801
 	public static function update_owner_fam() {
2327 2802
 		global $tmp_dir, $globalDebug, $globalOwner;
2328
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2803
+		if ($globalDebug) {
2804
+			echo "owner from FlightAirMap website : Download...";
2805
+		}
2329 2806
 		if ($globalOwner === TRUE) {
2330 2807
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2331 2808
 		} else {
2332 2809
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2333 2810
 		}
2334 2811
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2335
-			if ($globalDebug) echo "Gunzip...";
2812
+			if ($globalDebug) {
2813
+				echo "Gunzip...";
2814
+			}
2336 2815
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2337
-			if ($globalDebug) echo "Add to DB...";
2816
+			if ($globalDebug) {
2817
+				echo "Add to DB...";
2818
+			}
2338 2819
 			$error = update_db::owner_fam();
2339
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2820
+		} else {
2821
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2822
+		}
2340 2823
 		if ($error != '') {
2341 2824
 			return $error;
2342
-		} elseif ($globalDebug) echo "Done\n";
2825
+		} elseif ($globalDebug) {
2826
+			echo "Done\n";
2827
+		}
2343 2828
 		return '';
2344 2829
 	}
2345 2830
 	public static function update_routes_fam() {
2346 2831
 		global $tmp_dir, $globalDebug;
2347
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2832
+		if ($globalDebug) {
2833
+			echo "Routes from FlightAirMap website : Download...";
2834
+		}
2348 2835
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2349 2836
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2350
-			if ($globalDebug) echo "Gunzip...";
2837
+			if ($globalDebug) {
2838
+				echo "Gunzip...";
2839
+			}
2351 2840
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2352
-			if ($globalDebug) echo "Add to DB...";
2841
+			if ($globalDebug) {
2842
+				echo "Add to DB...";
2843
+			}
2353 2844
 			$error = update_db::routes_fam();
2354
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2845
+		} else {
2846
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2847
+		}
2355 2848
 		if ($error != '') {
2356 2849
 			return $error;
2357
-		} elseif ($globalDebug) echo "Done\n";
2850
+		} elseif ($globalDebug) {
2851
+			echo "Done\n";
2852
+		}
2358 2853
 		return '';
2359 2854
 	}
2360 2855
 	public static function update_marine_identity_fam() {
@@ -2364,14 +2859,22 @@  discard block
 block discarded – undo
2364 2859
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2365 2860
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2366 2861
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2367
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2862
+				if ($globalDebug) {
2863
+					echo "Marine identity from FlightAirMap website : Download...";
2864
+				}
2368 2865
 				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2369 2866
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2370
-					if ($globalDebug) echo "Gunzip...";
2867
+					if ($globalDebug) {
2868
+						echo "Gunzip...";
2869
+					}
2371 2870
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2372
-					if ($globalDebug) echo "Add to DB...";
2871
+					if ($globalDebug) {
2872
+						echo "Add to DB...";
2873
+					}
2373 2874
 					$error = update_db::marine_identity_fam();
2374
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2875
+				} else {
2876
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2877
+				}
2375 2878
 				if ($error != '') {
2376 2879
 					return $error;
2377 2880
 				} elseif ($globalDebug) {
@@ -2390,14 +2893,22 @@  discard block
 block discarded – undo
2390 2893
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2391 2894
 			$satellite_md5 = $satellite_md5_file[0];
2392 2895
 			if (!update_db::check_satellite_version($marine_identity_md5)) {
2393
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2896
+				if ($globalDebug) {
2897
+					echo "Satellite from FlightAirMap website : Download...";
2898
+				}
2394 2899
 				update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2395 2900
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2396
-					if ($globalDebug) echo "Gunzip...";
2901
+					if ($globalDebug) {
2902
+						echo "Gunzip...";
2903
+					}
2397 2904
 					update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2398
-					if ($globalDebug) echo "Add to DB...";
2905
+					if ($globalDebug) {
2906
+						echo "Add to DB...";
2907
+					}
2399 2908
 					$error = update_db::satellite_fam();
2400
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2909
+				} else {
2910
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2911
+				}
2401 2912
 				if ($error != '') {
2402 2913
 					return $error;
2403 2914
 				} elseif ($globalDebug) {
@@ -2410,17 +2921,25 @@  discard block
 block discarded – undo
2410 2921
 	}
2411 2922
 	public static function update_banned_fam() {
2412 2923
 		global $tmp_dir, $globalDebug;
2413
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2924
+		if ($globalDebug) {
2925
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2926
+		}
2414 2927
 		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2415 2928
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2416 2929
 			//if ($globalDebug) echo "Gunzip...";
2417 2930
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2418
-			if ($globalDebug) echo "Add to DB...";
2931
+			if ($globalDebug) {
2932
+				echo "Add to DB...";
2933
+			}
2419 2934
 			$error = update_db::banned_fam();
2420
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2935
+		} else {
2936
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2937
+		}
2421 2938
 		if ($error != '') {
2422 2939
 			return $error;
2423
-		} elseif ($globalDebug) echo "Done\n";
2940
+		} elseif ($globalDebug) {
2941
+			echo "Done\n";
2942
+		}
2424 2943
 		return '';
2425 2944
 	}
2426 2945
 
@@ -2428,7 +2947,9 @@  discard block
 block discarded – undo
2428 2947
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2429 2948
 		include_once('class.create_db.php');
2430 2949
 		$error = '';
2431
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2950
+		if ($globalDebug) {
2951
+			echo "Airspace from FlightAirMap website : Download...";
2952
+		}
2432 2953
 		if ($globalDBdriver == 'mysql') {
2433 2954
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2434 2955
 		} else {
@@ -2444,9 +2965,13 @@  discard block
 block discarded – undo
2444 2965
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2445 2966
 				}
2446 2967
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2447
-					if ($globalDebug) echo "Gunzip...";
2968
+					if ($globalDebug) {
2969
+						echo "Gunzip...";
2970
+					}
2448 2971
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2449
-					if ($globalDebug) echo "Add to DB...";
2972
+					if ($globalDebug) {
2973
+						echo "Add to DB...";
2974
+					}
2450 2975
 					$Connection = new Connection();
2451 2976
 					if ($Connection->tableExists('airspace')) {
2452 2977
 						$query = 'DROP TABLE airspace';
@@ -2459,19 +2984,27 @@  discard block
 block discarded – undo
2459 2984
 		    			}
2460 2985
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2461 2986
 					update_db::insert_airspace_version($airspace_md5);
2462
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2987
+				} else {
2988
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2989
+				}
2463 2990
 			}
2464
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2991
+		} else {
2992
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2993
+		}
2465 2994
 		if ($error != '') {
2466 2995
 			return $error;
2467
-		} elseif ($globalDebug) echo "Done\n";
2996
+		} elseif ($globalDebug) {
2997
+			echo "Done\n";
2998
+		}
2468 2999
 		return '';
2469 3000
 	}
2470 3001
 
2471 3002
 	public static function update_geoid_fam() {
2472 3003
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2473 3004
 		$error = '';
2474
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3005
+		if ($globalDebug) {
3006
+			echo "Geoid from FlightAirMap website : Download...";
3007
+		}
2475 3008
 		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2476 3009
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2477 3010
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2479,75 +3012,113 @@  discard block
 block discarded – undo
2479 3012
 			if (!update_db::check_geoid_version($geoid_md5)) {
2480 3013
 				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2481 3014
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2482
-					if ($globalDebug) echo "Gunzip...";
3015
+					if ($globalDebug) {
3016
+						echo "Gunzip...";
3017
+					}
2483 3018
 					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2484 3019
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2485 3020
 						update_db::insert_geoid_version($geoid_md5);
2486 3021
 					}
2487
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3022
+				} else {
3023
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3024
+				}
2488 3025
 			}
2489
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3026
+		} else {
3027
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3028
+		}
2490 3029
 		if ($error != '') {
2491 3030
 			return $error;
2492
-		} elseif ($globalDebug) echo "Done\n";
3031
+		} elseif ($globalDebug) {
3032
+			echo "Done\n";
3033
+		}
2493 3034
 		return '';
2494 3035
 	}
2495 3036
 
2496 3037
 	public static function update_tle() {
2497 3038
 		global $tmp_dir, $globalDebug;
2498
-		if ($globalDebug) echo "Download TLE : Download...";
3039
+		if ($globalDebug) {
3040
+			echo "Download TLE : Download...";
3041
+		}
2499 3042
 		$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',
2500 3043
 		'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',
2501 3044
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2502 3045
 		foreach ($alltle as $filename) {
2503
-			if ($globalDebug) echo "downloading ".$filename.'...';
3046
+			if ($globalDebug) {
3047
+				echo "downloading ".$filename.'...';
3048
+			}
2504 3049
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2505 3050
 			if (file_exists($tmp_dir.$filename)) {
2506
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3051
+				if ($globalDebug) {
3052
+					echo "Add to DB ".$filename."...";
3053
+				}
2507 3054
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2508
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3055
+			} else {
3056
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3057
+			}
2509 3058
 			if ($error != '') {
2510 3059
 				echo $error."\n";
2511
-			} elseif ($globalDebug) echo "Done\n";
3060
+			} elseif ($globalDebug) {
3061
+				echo "Done\n";
3062
+			}
2512 3063
 		}
2513 3064
 		return '';
2514 3065
 	}
2515 3066
 
2516 3067
 	public static function update_ucsdb() {
2517 3068
 		global $tmp_dir, $globalDebug;
2518
-		if ($globalDebug) echo "Download UCS DB : Download...";
3069
+		if ($globalDebug) {
3070
+			echo "Download UCS DB : Download...";
3071
+		}
2519 3072
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2520 3073
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2521
-			if ($globalDebug) echo "Add to DB...";
3074
+			if ($globalDebug) {
3075
+				echo "Add to DB...";
3076
+			}
2522 3077
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2523
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3078
+		} else {
3079
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3080
+		}
2524 3081
 		if ($error != '') {
2525 3082
 			echo $error."\n";
2526
-		} elseif ($globalDebug) echo "Done\n";
3083
+		} elseif ($globalDebug) {
3084
+			echo "Done\n";
3085
+		}
2527 3086
 		return '';
2528 3087
 	}
2529 3088
 
2530 3089
 	public static function update_celestrak() {
2531 3090
 		global $tmp_dir, $globalDebug;
2532
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3091
+		if ($globalDebug) {
3092
+			echo "Download Celestrak DB : Download...";
3093
+		}
2533 3094
 		update_db::download('https://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2534 3095
 		if (file_exists($tmp_dir.'satcat.txt')) {
2535
-			if ($globalDebug) echo "Add to DB...";
3096
+			if ($globalDebug) {
3097
+				echo "Add to DB...";
3098
+			}
2536 3099
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2537
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3100
+		} else {
3101
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3102
+		}
2538 3103
 		if ($error != '') {
2539 3104
 			echo $error."\n";
2540
-		} elseif ($globalDebug) echo "Done\n";
3105
+		} elseif ($globalDebug) {
3106
+			echo "Done\n";
3107
+		}
2541 3108
 		return '';
2542 3109
 	}
2543 3110
 
2544 3111
 	public static function update_models() {
2545 3112
 		global $tmp_dir, $globalDebug;
2546 3113
 		$error = '';
2547
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3114
+		if ($globalDebug) {
3115
+			echo "Models from FlightAirMap website : Download...";
3116
+		}
2548 3117
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2549 3118
 		if (file_exists($tmp_dir.'models.md5sum')) {
2550
-			if ($globalDebug) echo "Check files...\n";
3119
+			if ($globalDebug) {
3120
+				echo "Check files...\n";
3121
+			}
2551 3122
 			$newmodelsdb = array();
2552 3123
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2553 3124
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2566,25 +3137,35 @@  discard block
 block discarded – undo
2566 3137
 			}
2567 3138
 			$diff = array_diff($newmodelsdb,$modelsdb);
2568 3139
 			foreach ($diff as $key => $value) {
2569
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3140
+				if ($globalDebug) {
3141
+					echo 'Downloading model '.$key.' ...'."\n";
3142
+				}
2570 3143
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2571 3144
 				
2572 3145
 			}
2573 3146
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2574
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3147
+		} else {
3148
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3149
+		}
2575 3150
 		if ($error != '') {
2576 3151
 			return $error;
2577
-		} elseif ($globalDebug) echo "Done\n";
3152
+		} elseif ($globalDebug) {
3153
+			echo "Done\n";
3154
+		}
2578 3155
 		return '';
2579 3156
 	}
2580 3157
 
2581 3158
 	public static function update_space_models() {
2582 3159
 		global $tmp_dir, $globalDebug;
2583 3160
 		$error = '';
2584
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3161
+		if ($globalDebug) {
3162
+			echo "Space models from FlightAirMap website : Download...";
3163
+		}
2585 3164
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2586 3165
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2587
-			if ($globalDebug) echo "Check files...\n";
3166
+			if ($globalDebug) {
3167
+				echo "Check files...\n";
3168
+			}
2588 3169
 			$newmodelsdb = array();
2589 3170
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2590 3171
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2603,25 +3184,35 @@  discard block
 block discarded – undo
2603 3184
 			}
2604 3185
 			$diff = array_diff($newmodelsdb,$modelsdb);
2605 3186
 			foreach ($diff as $key => $value) {
2606
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3187
+				if ($globalDebug) {
3188
+					echo 'Downloading space model '.$key.' ...'."\n";
3189
+				}
2607 3190
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2608 3191
 				
2609 3192
 			}
2610 3193
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2611
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3194
+		} else {
3195
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3196
+		}
2612 3197
 		if ($error != '') {
2613 3198
 			return $error;
2614
-		} elseif ($globalDebug) echo "Done\n";
3199
+		} elseif ($globalDebug) {
3200
+			echo "Done\n";
3201
+		}
2615 3202
 		return '';
2616 3203
 	}
2617 3204
 
2618 3205
 	public static function update_vehicules_models() {
2619 3206
 		global $tmp_dir, $globalDebug;
2620 3207
 		$error = '';
2621
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3208
+		if ($globalDebug) {
3209
+			echo "Vehicules models from FlightAirMap website : Download...";
3210
+		}
2622 3211
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2623 3212
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2624
-			if ($globalDebug) echo "Check files...\n";
3213
+			if ($globalDebug) {
3214
+				echo "Check files...\n";
3215
+			}
2625 3216
 			$newmodelsdb = array();
2626 3217
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2627 3218
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2640,15 +3231,21 @@  discard block
 block discarded – undo
2640 3231
 			}
2641 3232
 			$diff = array_diff($newmodelsdb,$modelsdb);
2642 3233
 			foreach ($diff as $key => $value) {
2643
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3234
+				if ($globalDebug) {
3235
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3236
+				}
2644 3237
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2645 3238
 				
2646 3239
 			}
2647 3240
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2648
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3241
+		} else {
3242
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3243
+		}
2649 3244
 		if ($error != '') {
2650 3245
 			return $error;
2651
-		} elseif ($globalDebug) echo "Done\n";
3246
+		} elseif ($globalDebug) {
3247
+			echo "Done\n";
3248
+		}
2652 3249
 		return '';
2653 3250
 	}
2654 3251
 
@@ -2691,7 +3288,9 @@  discard block
 block discarded – undo
2691 3288
                 }
2692 3289
 
2693 3290
 		$error = '';
2694
-		if ($globalDebug) echo "Notam : Download...";
3291
+		if ($globalDebug) {
3292
+			echo "Notam : Download...";
3293
+		}
2695 3294
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2696 3295
 		if (file_exists($tmp_dir.'notam.rss')) {
2697 3296
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2706,14 +3305,30 @@  discard block
 block discarded – undo
2706 3305
 				$data['fir'] = $q[0];
2707 3306
 				$data['code'] = $q[1];
2708 3307
 				$ifrvfr = $q[2];
2709
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2710
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2711
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2712
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2713
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2714
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2715
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2716
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3308
+				if ($ifrvfr == 'IV') {
3309
+					$data['rules'] = 'IFR/VFR';
3310
+				}
3311
+				if ($ifrvfr == 'I') {
3312
+					$data['rules'] = 'IFR';
3313
+				}
3314
+				if ($ifrvfr == 'V') {
3315
+					$data['rules'] = 'VFR';
3316
+				}
3317
+				if ($q[4] == 'A') {
3318
+					$data['scope'] = 'Airport warning';
3319
+				}
3320
+				if ($q[4] == 'E') {
3321
+					$data['scope'] = 'Enroute warning';
3322
+				}
3323
+				if ($q[4] == 'W') {
3324
+					$data['scope'] = 'Navigation warning';
3325
+				}
3326
+				if ($q[4] == 'AE') {
3327
+					$data['scope'] = 'Airport/Enroute warning';
3328
+				}
3329
+				if ($q[4] == 'AW') {
3330
+					$data['scope'] = 'Airport/Navigation warning';
3331
+				}
2717 3332
 				//$data['scope'] = $q[4];
2718 3333
 				$data['lower_limit'] = $q[5];
2719 3334
 				$data['upper_limit'] = $q[6];
@@ -2721,8 +3336,12 @@  discard block
 block discarded – undo
2721 3336
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2722 3337
 				$latitude = $Common->convertDec($las,'latitude');
2723 3338
 				$longitude = $Common->convertDec($lns,'longitude');
2724
-				if ($lac == 'S') $latitude = '-'.$latitude;
2725
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3339
+				if ($lac == 'S') {
3340
+					$latitude = '-'.$latitude;
3341
+				}
3342
+				if ($lnc == 'W') {
3343
+					$longitude = '-'.$longitude;
3344
+				}
2726 3345
 				$data['center_latitude'] = $latitude;
2727 3346
 				$data['center_longitude'] = $longitude;
2728 3347
 				$data['radius'] = intval($radius);
@@ -2752,10 +3371,14 @@  discard block
 block discarded – undo
2752 3371
 				$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']);
2753 3372
 				unset($data);
2754 3373
 			} 
2755
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3374
+		} else {
3375
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3376
+		}
2756 3377
 		if ($error != '') {
2757 3378
 			return $error;
2758
-		} elseif ($globalDebug) echo "Done\n";
3379
+		} elseif ($globalDebug) {
3380
+			echo "Done\n";
3381
+		}
2759 3382
 		return '';
2760 3383
 	}
2761 3384
 	
@@ -2780,7 +3403,9 @@  discard block
 block discarded – undo
2780 3403
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2781 3404
 		$airspace_json = json_decode($airspace_lst,true);
2782 3405
 		foreach ($airspace_json['records'] as $airspace) {
2783
-			if ($globalDebug) echo $airspace['name']."...\n";
3406
+			if ($globalDebug) {
3407
+				echo $airspace['name']."...\n";
3408
+			}
2784 3409
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2785 3410
 			if (file_exists($tmp_dir.$airspace['name'])) {
2786 3411
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2824,8 +3449,11 @@  discard block
 block discarded – undo
2824 3449
                         return "error : ".$e->getMessage();
2825 3450
                 }
2826 3451
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2827
-                if ($row['nb'] > 0) return false;
2828
-                else return true;
3452
+                if ($row['nb'] > 0) {
3453
+                	return false;
3454
+                } else {
3455
+                	return true;
3456
+                }
2829 3457
 	}
2830 3458
 
2831 3459
 	public static function insert_last_update() {
@@ -2850,8 +3478,11 @@  discard block
 block discarded – undo
2850 3478
                         return "error : ".$e->getMessage();
2851 3479
                 }
2852 3480
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2853
-                if ($row['nb'] > 0) return true;
2854
-                else return false;
3481
+                if ($row['nb'] > 0) {
3482
+                	return true;
3483
+                } else {
3484
+                	return false;
3485
+                }
2855 3486
 	}
2856 3487
 
2857 3488
 	public static function check_geoid_version($version) {
@@ -2864,8 +3495,11 @@  discard block
 block discarded – undo
2864 3495
                         return "error : ".$e->getMessage();
2865 3496
                 }
2866 3497
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2867
-                if ($row['nb'] > 0) return true;
2868
-                else return false;
3498
+                if ($row['nb'] > 0) {
3499
+                	return true;
3500
+                } else {
3501
+                	return false;
3502
+                }
2869 3503
 	}
2870 3504
 
2871 3505
 	public static function check_marine_identity_version($version) {
@@ -2878,8 +3512,11 @@  discard block
 block discarded – undo
2878 3512
 			return "error : ".$e->getMessage();
2879 3513
 		}
2880 3514
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2881
-		if ($row['nb'] > 0) return true;
2882
-		else return false;
3515
+		if ($row['nb'] > 0) {
3516
+			return true;
3517
+		} else {
3518
+			return false;
3519
+		}
2883 3520
 	}
2884 3521
 
2885 3522
 	public static function check_satellite_version($version) {
@@ -2892,8 +3529,11 @@  discard block
 block discarded – undo
2892 3529
 			return "error : ".$e->getMessage();
2893 3530
 		}
2894 3531
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2895
-		if ($row['nb'] > 0) return true;
2896
-		else return false;
3532
+		if ($row['nb'] > 0) {
3533
+			return true;
3534
+		} else {
3535
+			return false;
3536
+		}
2897 3537
 	}
2898 3538
 
2899 3539
 
@@ -2960,8 +3600,11 @@  discard block
 block discarded – undo
2960 3600
                         return "error : ".$e->getMessage();
2961 3601
                 }
2962 3602
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2963
-                if ($row['nb'] > 0) return false;
2964
-                else return true;
3603
+                if ($row['nb'] > 0) {
3604
+                	return false;
3605
+                } else {
3606
+                	return true;
3607
+                }
2965 3608
 	}
2966 3609
 
2967 3610
 	public static function insert_last_notam_update() {
@@ -2991,8 +3634,11 @@  discard block
 block discarded – undo
2991 3634
                         return "error : ".$e->getMessage();
2992 3635
                 }
2993 3636
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2994
-                if ($row['nb'] > 0) return false;
2995
-                else return true;
3637
+                if ($row['nb'] > 0) {
3638
+                	return false;
3639
+                } else {
3640
+                	return true;
3641
+                }
2996 3642
 	}
2997 3643
 
2998 3644
 	public static function insert_last_airspace_update() {
@@ -3022,8 +3668,11 @@  discard block
 block discarded – undo
3022 3668
                         return "error : ".$e->getMessage();
3023 3669
                 }
3024 3670
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3025
-                if ($row['nb'] > 0) return false;
3026
-                else return true;
3671
+                if ($row['nb'] > 0) {
3672
+                	return false;
3673
+                } else {
3674
+                	return true;
3675
+                }
3027 3676
 	}
3028 3677
 
3029 3678
 	public static function insert_last_geoid_update() {
@@ -3053,8 +3702,11 @@  discard block
 block discarded – undo
3053 3702
                         return "error : ".$e->getMessage();
3054 3703
                 }
3055 3704
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3056
-                if ($row['nb'] > 0) return false;
3057
-                else return true;
3705
+                if ($row['nb'] > 0) {
3706
+                	return false;
3707
+                } else {
3708
+                	return true;
3709
+                }
3058 3710
 	}
3059 3711
 
3060 3712
 	public static function insert_last_owner_update() {
@@ -3083,8 +3735,11 @@  discard block
 block discarded – undo
3083 3735
                         return "error : ".$e->getMessage();
3084 3736
                 }
3085 3737
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3086
-                if ($row['nb'] > 0) return false;
3087
-                else return true;
3738
+                if ($row['nb'] > 0) {
3739
+                	return false;
3740
+                } else {
3741
+                	return true;
3742
+                }
3088 3743
 	}
3089 3744
 
3090 3745
 	public static function insert_last_schedules_update() {
@@ -3114,8 +3769,11 @@  discard block
 block discarded – undo
3114 3769
 			return "error : ".$e->getMessage();
3115 3770
 		}
3116 3771
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3117
-		if ($row['nb'] > 0) return false;
3118
-		else return true;
3772
+		if ($row['nb'] > 0) {
3773
+			return false;
3774
+		} else {
3775
+			return true;
3776
+		}
3119 3777
 	}
3120 3778
 
3121 3779
 	public static function insert_last_tle_update() {
@@ -3145,8 +3803,11 @@  discard block
 block discarded – undo
3145 3803
 			return "error : ".$e->getMessage();
3146 3804
 		}
3147 3805
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3148
-		if ($row['nb'] > 0) return false;
3149
-		else return true;
3806
+		if ($row['nb'] > 0) {
3807
+			return false;
3808
+		} else {
3809
+			return true;
3810
+		}
3150 3811
 	}
3151 3812
 
3152 3813
 	public static function insert_last_ucsdb_update() {
@@ -3176,8 +3837,11 @@  discard block
 block discarded – undo
3176 3837
 			return "error : ".$e->getMessage();
3177 3838
 		}
3178 3839
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3179
-		if ($row['nb'] > 0) return false;
3180
-		else return true;
3840
+		if ($row['nb'] > 0) {
3841
+			return false;
3842
+		} else {
3843
+			return true;
3844
+		}
3181 3845
 	}
3182 3846
 
3183 3847
 	public static function insert_last_celestrak_update() {
@@ -3207,8 +3871,11 @@  discard block
 block discarded – undo
3207 3871
 			return "error : ".$e->getMessage();
3208 3872
 		}
3209 3873
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3210
-		if ($row['nb'] > 0) return false;
3211
-		else return true;
3874
+		if ($row['nb'] > 0) {
3875
+			return false;
3876
+		} else {
3877
+			return true;
3878
+		}
3212 3879
 	}
3213 3880
 
3214 3881
 	public static function check_last_satellite_update() {
@@ -3226,8 +3893,11 @@  discard block
 block discarded – undo
3226 3893
 			return "error : ".$e->getMessage();
3227 3894
 		}
3228 3895
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3229
-		if ($row['nb'] > 0) return false;
3230
-		else return true;
3896
+		if ($row['nb'] > 0) {
3897
+			return false;
3898
+		} else {
3899
+			return true;
3900
+		}
3231 3901
 	}
3232 3902
 
3233 3903
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.Connection.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@  discard block
 block discarded – undo
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 46;
8 8
 	
9
+	/**
10
+	 * @param string $dbname
11
+	 */
9 12
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10 13
 	    global $globalNoDB;
11 14
 	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
@@ -142,6 +145,9 @@  discard block
 block discarded – undo
142 145
 		return true;
143 146
 	}
144 147
 
148
+	/**
149
+	 * @param string $table
150
+	 */
145 151
 	public function tableExists($table)
146 152
 	{
147 153
 		global $globalDBdriver, $globalDBname;
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
 	public $latest_schema = 46;
8 8
 	
9 9
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10
-	    global $globalNoDB;
11
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
10
+		global $globalNoDB;
11
+		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
13
-	    } else {
13
+		} else {
14 14
 		if ($dbc === null) {
15
-		    if ($this->db === null && $dbname === null) {
15
+			if ($this->db === null && $dbname === null) {
16 16
 			if ($user === null && $pass === null) {
17
-			    $this->createDBConnection();
17
+				$this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+				$this->createDBConnection(null,$user,$pass);
20 20
 			}
21
-		    } else {
21
+			} else {
22 22
 			$this->createDBConnection($dbname);
23
-		    }
23
+			}
24 24
 		} elseif ($dbname === null || $dbname === 'default') {
25
-	    	    $this->db = $dbc;
26
-	    	    if ($this->connectionExists() === false) {
25
+				$this->db = $dbc;
26
+				if ($this->connectionExists() === false) {
27 27
 			/*
28 28
 			echo 'Restart Connection !!!'."\n";
29 29
 			$e = new \Exception;
30 30
 			var_dump($e->getTraceAsString());
31 31
 			*/
32 32
 			$this->createDBConnection();
33
-		    }
33
+			}
34 34
 		} else {
35
-		    //$this->connectionExists();
36
-		    $this->dbs[$dbname] = $dbc;
35
+			//$this->connectionExists();
36
+			$this->dbs[$dbname] = $dbc;
37
+		}
37 38
 		}
38
-	    }
39 39
 	}
40 40
 
41 41
 	public function db() {
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 
58 58
 	/**
59
-	* Creates the database connection
60
-	*
61
-	* @return Boolean of the database connection
62
-	*
63
-	*/
59
+	 * Creates the database connection
60
+	 *
61
+	 * @return Boolean of the database connection
62
+	 *
63
+	 */
64 64
 
65 65
 	public function createDBConnection($DBname = null, $user = null, $pass = null)
66 66
 	{
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			return false;
159 159
 		}
160 160
 		if($results->rowCount()>0) {
161
-		    return true; 
161
+			return true; 
162 162
 		}
163 163
 		else return false;
164 164
 	}
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 				$sum = $sum->fetchColumn(0);
177 177
 			} else $sum = 0;
178 178
 			if (intval($sum) !== 2) {
179
-			     return false;
179
+				 return false;
180 180
 			}
181 181
 			
182 182
 		} catch(PDOException $e) {
183 183
 			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
184
-            			throw $e;
185
-	                }
186
-	                //echo 'error ! '.$e->getMessage();
184
+						throw $e;
185
+					}
186
+					//echo 'error ! '.$e->getMessage();
187 187
 			return false;
188 188
 		}
189 189
 		return true; 
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 		$version = 0;
288 288
 		if ($this->tableExists('aircraft')) {
289 289
 			if (!$this->tableExists('config')) {
290
-	    			$version = '1';
291
-	    			return $version;
290
+					$version = '1';
291
+					return $version;
292 292
 			} else {
293 293
 				$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
294 294
 				try {
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 	* @return Boolean if latest version or not
310 310
 	*/
311 311
 	public function latest() {
312
-	    global $globalNoDB;
313
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
314
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
315
-	    else return false;
312
+		global $globalNoDB;
313
+		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
314
+		if ($this->check_schema_version() == $this->latest_schema) return true;
315
+		else return false;
316 316
 	}
317 317
 
318 318
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 46;
8 8
 	
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 	    global $globalNoDB;
11 11
 	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 			if ($user === null && $pass === null) {
17 17
 			    $this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+			    $this->createDBConnection(null, $user, $pass);
20 20
 			}
21 21
 		    } else {
22 22
 			$this->createDBConnection($dbname);
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		while (true) {
101 101
 			try {
102 102
 				if ($globalDBSdriver == 'mysql') {
103
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
103
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
104 104
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 105
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
106
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
107
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
108
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
109
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
110
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
111 111
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 112
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 113
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
118 118
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
119 119
 				} else {
120
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
120
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
121 121
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
123
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
124
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
125
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
126
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
127
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
128 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 129
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 130
 				}
131 131
 				break;
132
-			} catch(PDOException $e) {
132
+			} catch (PDOException $e) {
133 133
 				$i++;
134 134
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
135 135
 				//exit;
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 		try {
155 155
 			//$Connection = new Connection();
156 156
 			$results = $this->db->query($query);
157
-		} catch(PDOException $e) {
157
+		} catch (PDOException $e) {
158 158
 			return false;
159 159
 		}
160
-		if($results->rowCount()>0) {
160
+		if ($results->rowCount() > 0) {
161 161
 		    return true; 
162 162
 		}
163 163
 		else return false;
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 			     return false;
180 180
 			}
181 181
 			
182
-		} catch(PDOException $e) {
183
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
+		} catch (PDOException $e) {
183
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
184 184
             			throw $e;
185 185
 	                }
186 186
 	                //echo 'error ! '.$e->getMessage();
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	/*
193 193
 	* Check if index exist
194 194
 	*/
195
-	public function indexExists($table,$index)
195
+	public function indexExists($table, $index)
196 196
 	{
197 197
 		global $globalDBdriver, $globalDBname;
198 198
 		if ($globalDBdriver == 'mysql') {
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		try {
204 204
 			//$Connection = new Connection();
205 205
 			$results = $this->db->query($query);
206
-		} catch(PDOException $e) {
206
+		} catch (PDOException $e) {
207 207
 			return false;
208 208
 		}
209 209
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
210
-		if($nb[0]['nb'] > 0) {
210
+		if ($nb[0]['nb'] > 0) {
211 211
 			return true; 
212 212
 		}
213 213
 		else return false;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$query = "SELECT * FROM ".$table." LIMIT 0";
223 223
 		try {
224 224
 			$results = $this->db->query($query);
225
-		} catch(PDOException $e) {
225
+		} catch (PDOException $e) {
226 226
 			return "error : ".$e->getMessage()."\n";
227 227
 		}
228 228
 		$columns = array();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		return $columns;
235 235
 	}
236 236
 
237
-	public function getColumnType($table,$column) {
237
+	public function getColumnType($table, $column) {
238 238
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
239 239
 		$tomet = $select->getColumnMeta(0);
240 240
 		return $tomet['native_type'];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	* Check if a column name exist in a table
245 245
 	* @return Boolean column exist or not
246 246
 	*/
247
-	public function checkColumnName($table,$name)
247
+	public function checkColumnName($table, $name)
248 248
 	{
249 249
 		global $globalDBdriver, $globalDBname;
250 250
 		if ($globalDBdriver == 'mysql') {
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 		}
255 255
 			try {
256 256
 				$sth = $this->db()->prepare($query);
257
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
258
-			} catch(PDOException $e) {
257
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
258
+			} catch (PDOException $e) {
259 259
 				echo "error : ".$e->getMessage()."\n";
260 260
 			}
261 261
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 				try {
295 295
 					$sth = $this->db->prepare($query);
296 296
 					$sth->execute();
297
-				} catch(PDOException $e) {
297
+				} catch (PDOException $e) {
298 298
 					return "error : ".$e->getMessage()."\n";
299 299
 				}
300 300
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +83 added lines, -32 removed lines patch added patch discarded remove patch
@@ -73,8 +73,11 @@  discard block
 block discarded – undo
73 73
 				$globalDBSname = $globalDBname;
74 74
 				$globalDBSuser = $globalDBuser;
75 75
 				$globalDBSpass = $globalDBpass;
76
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
77
-				else $globalDBSport = $globalDBport;
76
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
77
+					$globalDBSport = 3306;
78
+				} else {
79
+					$globalDBSport = $globalDBport;
80
+				}
78 81
 			} else {
79 82
 				$DBname = 'default';
80 83
 				$globalDBSdriver = $globalDBdriver;
@@ -82,8 +85,11 @@  discard block
 block discarded – undo
82 85
 				$globalDBSname = $globalDBname;
83 86
 				$globalDBSuser = $user;
84 87
 				$globalDBSpass = $pass;
85
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
86
-				else $globalDBSport = $globalDBport;
88
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
89
+					$globalDBSport = 3306;
90
+				} else {
91
+					$globalDBSport = $globalDBport;
92
+				}
87 93
 			}
88 94
 		} else {
89 95
 			$globalDBSdriver = $globalDB[$DBname]['driver'];
@@ -91,11 +97,16 @@  discard block
 block discarded – undo
91 97
 			$globalDBSname = $globalDB[$DBname]['name'];
92 98
 			$globalDBSuser = $globalDB[$DBname]['user'];
93 99
 			$globalDBSpass = $globalDB[$DBname]['pass'];
94
-			if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port'];
95
-			else $globalDBSport = 3306;
100
+			if (isset($globalDB[$DBname]['port'])) {
101
+				$globalDBSport = $globalDB[$DBname]['port'];
102
+			} else {
103
+				$globalDBSport = 3306;
104
+			}
96 105
 		}
97 106
 		// Set number of try to connect to DB
98
-		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5;
107
+		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) {
108
+			$globalDBretry = 5;
109
+		}
99 110
 		$i = 0;
100 111
 		while (true) {
101 112
 			try {
@@ -104,10 +115,16 @@  discard block
 block discarded – undo
104 115
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 116
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106 117
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
118
+					if (!isset($globalDBTimeOut)) {
119
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
120
+					} else {
121
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
122
+					}
123
+					if (!isset($globalDBPersistent)) {
124
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
125
+					} else {
126
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
127
+					}
111 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 129
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 130
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -121,24 +138,36 @@  discard block
 block discarded – undo
121 138
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 139
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123 140
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
141
+					if (!isset($globalDBTimeOut)) {
142
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
143
+					} else {
144
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
145
+					}
146
+					if (!isset($globalDBPersistent)) {
147
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
148
+					} else {
149
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
150
+					}
128 151
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 152
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 153
 				}
131 154
 				break;
132 155
 			} catch(PDOException $e) {
133 156
 				$i++;
134
-				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
157
+				if (isset($globalDebug) && $globalDebug) {
158
+					echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
159
+				}
135 160
 				//exit;
136 161
 				sleep(5);
137
-				if ($i > $globalDBretry) return false;
162
+				if ($i > $globalDBretry) {
163
+					return false;
164
+				}
138 165
 				//return false;
139 166
 			}
140 167
 		}
141
-		if ($DBname === 'default') $this->db = $this->dbs['default'];
168
+		if ($DBname === 'default') {
169
+			$this->db = $this->dbs['default'];
170
+		}
142 171
 		return true;
143 172
 	}
144 173
 
@@ -150,7 +179,9 @@  discard block
 block discarded – undo
150 179
 		} else {
151 180
 			$query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'";
152 181
 		}
153
-		if ($this->db == NULL) return false;
182
+		if ($this->db == NULL) {
183
+			return false;
184
+		}
154 185
 		try {
155 186
 			//$Connection = new Connection();
156 187
 			$results = $this->db->query($query);
@@ -159,22 +190,31 @@  discard block
 block discarded – undo
159 190
 		}
160 191
 		if($results->rowCount()>0) {
161 192
 		    return true; 
193
+		} else {
194
+			return false;
162 195
 		}
163
-		else return false;
164 196
 	}
165 197
 
166 198
 	public function connectionExists()
167 199
 	{
168 200
 		global $globalDBdriver, $globalDBCheckConnection, $globalNoDB;
169
-		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true;
170
-		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
201
+		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) {
202
+			return true;
203
+		}
204
+		if (isset($globalNoDB) && $globalNoDB === TRUE) {
205
+			return true;
206
+		}
171 207
 		$query = "SELECT 1 + 1";
172
-		if ($this->db === null) return false;
208
+		if ($this->db === null) {
209
+			return false;
210
+		}
173 211
 		try {
174 212
 			$sum = @$this->db->query($query);
175 213
 			if ($sum instanceof \PDOStatement) {
176 214
 				$sum = $sum->fetchColumn(0);
177
-			} else $sum = 0;
215
+			} else {
216
+				$sum = 0;
217
+			}
178 218
 			if (intval($sum) !== 2) {
179 219
 			     return false;
180 220
 			}
@@ -209,8 +249,9 @@  discard block
 block discarded – undo
209 249
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
210 250
 		if($nb[0]['nb'] > 0) {
211 251
 			return true; 
252
+		} else {
253
+			return false;
212 254
 		}
213
-		else return false;
214 255
 	}
215 256
 
216 257
 	/*
@@ -260,9 +301,12 @@  discard block
 block discarded – undo
260 301
 			}
261 302
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
262 303
 			$sth->closeCursor();
263
-			if ($result['nb'] > 0) return true;
264
-			else return false;
265
-/*		} else {
304
+			if ($result['nb'] > 0) {
305
+				return true;
306
+			} else {
307
+				return false;
308
+			}
309
+			/*		} else {
266 310
 			$query = "SELECT * FROM ".$table." LIMIT 0";
267 311
 			try {
268 312
 				$results = $this->db->query($query);
@@ -301,7 +345,9 @@  discard block
 block discarded – undo
301 345
 				$sth->closeCursor();
302 346
 				return $result['value'];
303 347
 			}
304
-		} else return $version;
348
+		} else {
349
+			return $version;
350
+		}
305 351
 	}
306 352
 	
307 353
 	/*
@@ -310,9 +356,14 @@  discard block
 block discarded – undo
310 356
 	*/
311 357
 	public function latest() {
312 358
 	    global $globalNoDB;
313
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
314
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
315
-	    else return false;
359
+	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
360
+	    	return true;
361
+	    }
362
+	    if ($this->check_schema_version() == $this->latest_schema) {
363
+	    	return true;
364
+	    } else {
365
+	    	return false;
366
+	    }
316 367
 	}
317 368
 
318 369
 }
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     <?php }; if (isset($globalSatellite) && $globalSatellite) { ?><td><div id="ibxsatellite"><h4><?php echo _("Satellites Displayed"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?>
47 47
 </tr></table></div>
48 48
 <?php
49
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
49
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
50 50
 ?>
51 51
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
52 52
 <?php
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
71 71
 <?php
72 72
 	}
73
-    }
73
+	}
74 74
 ?>
75 75
 
76 76
 <div id="sidebar" class="sidebar collapsed">
@@ -81,34 +81,34 @@  discard block
 block discarded – undo
81 81
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
82 82
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
83 83
 <?php
84
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
84
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
85 85
 	if (isset($globalArchive) && $globalArchive == TRUE) {
86 86
 ?>
87 87
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
88 88
 <?php
89 89
 	}
90
-    }
90
+	}
91 91
 ?>
92 92
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
93 93
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
94 94
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
95 95
 <?php
96
-    if (isset($globalMap3D) && $globalMap3D) {
96
+	if (isset($globalMap3D) && $globalMap3D) {
97 97
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
98 98
 ?>
99 99
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
100 100
 <?php
101
-        } else {
102
-    	    if (isset($globalSatellite) && $globalSatellite) {
101
+		} else {
102
+			if (isset($globalSatellite) && $globalSatellite) {
103 103
 ?>
104 104
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
105 105
 <?php
106
-	    }
106
+		}
107 107
 ?>
108 108
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
109 109
 <?php
110 110
 	}
111
-    }
111
+	}
112 112
 ?>
113 113
     </ul>
114 114
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 ?>
184 184
         </div>
185 185
 <?php
186
-    if (isset($globalArchive) && $globalArchive == TRUE) {
186
+	if (isset($globalArchive) && $globalArchive == TRUE) {
187 187
 ?>
188 188
         <div class="sidebar-pane" id="archive">
189 189
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	    </form>
244 244
 	</div>
245 245
 <?php
246
-    }
246
+	}
247 247
 ?>
248 248
         <div class="sidebar-pane" id="settings">
249 249
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -254,56 +254,56 @@  discard block
 block discarded – undo
254 254
 			    <?php
255 255
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
256 256
 				else $MapType = $_COOKIE['MapType'];
257
-			    ?>
257
+				?>
258 258
 			    <?php
259 259
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
260
-			    ?>
260
+				?>
261 261
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
262 262
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
263 263
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
264 264
 			    <?php
265 265
 				}
266
-			    ?>
266
+				?>
267 267
 			    <?php
268
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
269
-			    ?>
268
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
269
+				?>
270 270
 			    <?php
271
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
272
-			    ?>
271
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
272
+				?>
273 273
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
274 274
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
275 275
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
276 276
 			    <?php
277
-				    }
278
-			    ?>
277
+					}
278
+				?>
279 279
 			    <?php
280
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
281
-			    ?>
280
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
281
+				?>
282 282
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
283 283
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
284 284
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
285 285
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
286 286
 			    <?php
287
-				    }
288
-			    ?>
287
+					}
288
+				?>
289 289
 			    <?php
290
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
291
-			    ?>
290
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
291
+				?>
292 292
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
293 293
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
294 294
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
295 295
 			    <?php
296
-				    }
297
-			    ?>
296
+					}
297
+				?>
298 298
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
299 299
 			    <?php
300 300
 				}
301
-			    ?>
301
+				?>
302 302
 			    <?php
303
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
303
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
304 304
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
305 305
 					else $MapBoxId = $_COOKIE['MapTypeId'];
306
-			    ?>
306
+				?>
307 307
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
308 308
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
309 309
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
318 318
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
319 319
 			    <?php
320
-				    }
321
-			    ?>
320
+					}
321
+				?>
322 322
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
323 323
 			</select>
324 324
 		    </li>
325 325
 <?php
326
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
326
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
327 327
 ?>
328 328
 		    <li><?php echo _("Type of Terrain:"); ?>
329 329
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 			</select>
335 335
 		    </li>
336 336
 <?php
337
-    }
337
+	}
338 338
 ?>
339 339
 <?php
340
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
340
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
341 341
 ?>
342 342
 		    
343 343
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -346,89 +346,89 @@  discard block
 block discarded – undo
346 346
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || !isset($_COOKIE['MapRemainingRoute']) || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
347 347
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
348 348
 <?php
349
-    }
349
+	}
350 350
 ?>
351 351
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
352 352
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
353 353
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) print 'checked'; ?> ><?php echo _("Display weather station on map"); ?></label></div></li>
354 354
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) print 'checked'; ?> ><?php echo _("Display lightning on map"); ?></label></div></li>
355 355
 <?php
356
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
356
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
357 357
 ?>
358 358
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
359 359
 <?php
360
-    }
361
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
360
+	}
361
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
362 362
 ?>
363 363
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
364 364
 <?php
365
-    }
365
+	}
366 366
 ?>
367 367
 
368 368
 		    <?php
369 369
 			if (function_exists('array_column')) {
370
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
371
-		    ?>
370
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
371
+			?>
372 372
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
373 373
 		    <?php
374
-			    }
374
+				}
375 375
 			} elseif (isset($globalSources)) {
376
-			    $dispolar = false;
377
-			    foreach ($globalSources as $testsource) {
378
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
379
-			    }
380
-			    if ($dispolar) {
381
-		    ?>
376
+				$dispolar = false;
377
+				foreach ($globalSources as $testsource) {
378
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
379
+				}
380
+				if ($dispolar) {
381
+			?>
382 382
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
383 383
 		    <?php
384
-			    }
385
-		        }
386
-		    ?>
384
+				}
385
+				}
386
+			?>
387 387
 <?php
388
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
388
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
389 389
 ?>
390 390
 
391 391
 		    <?php
392 392
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
393
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
394
-		    ?>
393
+					if (extension_loaded('gd') && function_exists('gd_info')) {
394
+			?>
395 395
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
396 396
 		    <?php 
397 397
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
398
-		    ?>
398
+			?>
399 399
 		    <li><?php echo _("Aircraft icon color:"); ?>
400 400
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
401 401
 		    </li>
402 402
 		    <?php
403 403
 				}
404
-			    }
405
-		        }
406
-		    ?>
404
+				}
405
+				}
406
+			?>
407 407
 		    <?php
408 408
 			if (isset($globalMarine) && $globalMarine === TRUE) {
409
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
410
-		    ?>
409
+				if (extension_loaded('gd') && function_exists('gd_info')) {
410
+			?>
411 411
 		    <li><?php echo _("Marine icon color:"); ?>
412 412
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
413 413
 		    </li>
414 414
 		    <?php
415
-			    }
416
-		        }
417
-		    ?>
415
+				}
416
+				}
417
+			?>
418 418
 		    <?php
419 419
 			if (isset($globalTracker) && $globalTracker === TRUE) {
420
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
421
-		    ?>
420
+				if (extension_loaded('gd') && function_exists('gd_info')) {
421
+			?>
422 422
 		    <li><?php echo _("Tracker icon color:"); ?>
423 423
 			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
424 424
 		    </li>
425 425
 		    <?php
426
-			    }
427
-		        }
428
-		    ?>
426
+				}
427
+				}
428
+			?>
429 429
 		    <?php
430 430
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
431
-		    ?>
431
+			?>
432 432
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
433 433
 			<div class="range">
434 434
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 		    </li>
438 438
 		    <?php
439 439
 			}
440
-		    ?>
440
+			?>
441 441
 <?php
442
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
442
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
443 443
 ?>
444 444
 <?php
445 445
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 		    </li>
471 471
 <?php
472 472
 	}
473
-    }
473
+	}
474 474
 ?>
475 475
 		    <li><?php echo _("Distance unit:"); ?>
476 476
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -503,19 +503,19 @@  discard block
 block discarded – undo
503 503
 		    <ul>
504 504
 		    <?php
505 505
 			if (!isset($globalAircraft) || $globalAircraft) {
506
-		    ?>
506
+			?>
507 507
 		    <?php
508 508
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
509
-		    ?>
509
+			?>
510 510
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
511 511
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
512 512
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
513 513
 		    <?php
514 514
 			}
515
-		    ?>
515
+			?>
516 516
 		    <?php
517 517
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
518
-		    ?>
518
+			?>
519 519
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
520 520
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
521 521
 			<?php } ?>
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 			<?php } ?>
525 525
 		    <?php
526 526
 			}
527
-		    ?>
527
+			?>
528 528
 		    <li><?php echo _("Display airlines:"); ?>
529 529
 		    <br/>
530 530
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -544,14 +544,14 @@  discard block
 block discarded – undo
544 544
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
545 545
 					}
546 546
 				}
547
-			    ?>
547
+				?>
548 548
 			</select>
549 549
 		    </li>
550 550
 		    <?php
551 551
 			$Spotter = new Spotter();
552 552
 			$allalliancenames = $Spotter->getAllAllianceNames();
553 553
 			if (!empty($allalliancenames)) {
554
-		    ?>
554
+			?>
555 555
 		    <li><?php echo _("Display alliance:"); ?>
556 556
 		    <br/>
557 557
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -565,18 +565,18 @@  discard block
 block discarded – undo
565 565
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
566 566
 					}
567 567
 				}
568
-			    ?>
568
+				?>
569 569
 			</select>
570 570
 		    </li>
571 571
 		    <?php
572 572
 			}
573
-		    ?>
573
+			?>
574 574
 		    <?php
575 575
 			}
576
-		    ?>
576
+			?>
577 577
 		    <?php
578 578
 			if (isset($globalAPRS) && $globalAPRS) {
579
-		    ?>
579
+			?>
580 580
 		    <li><?php echo _("Display APRS sources name:"); ?>
581 581
 			<select class="selectpicker" multiple onchange="sources(this);">
582 582
 			    <?php
@@ -588,18 +588,18 @@  discard block
 block discarded – undo
588 588
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
589 589
 					}
590 590
 				}
591
-			    ?>
591
+				?>
592 592
 			</select>
593 593
 		    </li>
594 594
 		    <?php
595 595
 			}
596
-		    ?>
596
+			?>
597 597
 		    <?php
598 598
 			if (!isset($globalAircraft) && $globalAircraft) {
599
-		    ?>
599
+			?>
600 600
 		    <?php
601 601
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
602
-		    ?>
602
+			?>
603 603
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
604 604
 			<select class="selectpicker" onchange="airlinestype(this);">
605 605
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -610,14 +610,14 @@  discard block
 block discarded – undo
610 610
 		    </li>
611 611
 		    <?php
612 612
 			}
613
-		    ?>
613
+			?>
614 614
 		    <li>
615 615
 			<?php echo _("Display flight with ident:"); ?>
616 616
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
617 617
 		    </li>
618 618
 		    <?php
619 619
 			}
620
-		    ?>
620
+			?>
621 621
 		</ul>
622 622
 	    </form>
623 623
 	    <form method="post">
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	    </form>
627 627
     	</div>
628 628
 <?php
629
-    if (isset($globalSatellite) && $globalSatellite && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
629
+	if (isset($globalSatellite) && $globalSatellite && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
630 630
 ?>
631 631
         <div class="sidebar-pane" id="satellites">
632 632
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -666,14 +666,14 @@  discard block
 block discarded – undo
666 666
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
667 667
 					}
668 668
 				}
669
-			    ?>
669
+				?>
670 670
 			</select>
671 671
 		    </li>
672 672
 		</ul>
673 673
 	    </form>
674 674
 	</div>
675 675
 <?php
676
-    }
676
+	}
677 677
 ?>
678 678
     </div>
679 679
 </div>
Please login to merge, or discard this patch.
require/class.Satellite.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	/**
127
-	* Gets all launch site
128
-	*
129
-	* @return Array the launch site list
130
-	*
131
-	*/
127
+	 * Gets all launch site
128
+	 *
129
+	 * @return Array the launch site list
130
+	 *
131
+	 */
132 132
 	public function countAllLaunchSite($limit = true, $filters = array())
133 133
 	{
134 134
 		global $globalDBdriver;
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 	}
154 154
 
155 155
 	/**
156
-	* Gets all owners
157
-	*
158
-	* @return Array the owners list
159
-	*
160
-	*/
156
+	 * Gets all owners
157
+	 *
158
+	 * @return Array the owners list
159
+	 *
160
+	 */
161 161
 	public function countAllOwners($limit = true, $filters = array())
162 162
 	{
163 163
 		global $globalDBdriver;
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Gets all countries owners
186
-	*
187
-	* @return Array the countries list
188
-	*
189
-	*/
185
+	 * Gets all countries owners
186
+	 *
187
+	 * @return Array the countries list
188
+	 *
189
+	 */
190 190
 	public function countAllCountriesOwners($limit = true, $filters = array())
191 191
 	{
192 192
 		global $globalDBdriver;
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	}
212 212
 
213 213
 	/**
214
-	* Counts all launch dates during the last year
215
-	*
216
-	* @return Array the launch date list
217
-	*
218
-	*/
214
+	 * Counts all launch dates during the last year
215
+	 *
216
+	 * @return Array the launch date list
217
+	 *
218
+	 */
219 219
 	public function countAllMonthsLastYear($filters = array(), $sincedate = '')
220 220
 	{
221 221
 		global $globalTimezone, $globalDBdriver;
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 	}
257 257
 
258 258
 	/**
259
-	* Counts all dates during the last 10 years
260
-	*
261
-	* @return Array the date list
262
-	*
263
-	*/
259
+	 * Counts all dates during the last 10 years
260
+	 *
261
+	 * @return Array the date list
262
+	 *
263
+	 */
264 264
 	public function countAllYears($filters = array(), $sincedate = '')
265 265
 	{
266 266
 		global $globalTimezone, $globalDBdriver;
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		try {
20 20
 			$sth = $this->db->prepare($query);
21 21
 			$sth->execute(array(':name' => $name));
22
-		} catch(PDOException $e) {
22
+		} catch (PDOException $e) {
23 23
 			echo $e->getMessage();
24 24
 		}
25 25
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		try {
32 32
 			$sth = $this->db->prepare($query);
33 33
 			$sth->execute();
34
-		} catch(PDOException $e) {
34
+		} catch (PDOException $e) {
35 35
 			echo $e->getMessage();
36 36
 		}
37 37
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		try {
44 44
 			$sth = $this->db->prepare($query);
45 45
 			$sth->execute();
46
-		} catch(PDOException $e) {
46
+		} catch (PDOException $e) {
47 47
 			echo $e->getMessage();
48 48
 		}
49 49
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		try {
56 56
 			$sth = $this->db->prepare($query);
57 57
 			$sth->execute(array(':type' => $type));
58
-		} catch(PDOException $e) {
58
+		} catch (PDOException $e) {
59 59
 			echo $e->getMessage();
60 60
 		}
61 61
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -63,48 +63,48 @@  discard block
 block discarded – undo
63 63
 		else return array();
64 64
 	}
65 65
 	
66
-	public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) {
66
+	public function position_all($timestamp_begin = '', $timestamp_end = '', $second = 10) {
67 67
 		$all_sat = $this->get_tle_names();
68 68
 		$result = array();
69 69
 		foreach ($all_sat as $sat) {
70
-			$position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second);
71
-			$result = array_merge($position,$result);
70
+			$position = $this->position($sat['tle_name'], $timestamp_begin, $timestamp_end, $second);
71
+			$result = array_merge($position, $result);
72 72
 		}
73 73
 		return $result;
74 74
 	}
75 75
 
76
-	public function position_all_type($type,$timestamp_begin = '',$timestamp_end = '',$second = 10) {
76
+	public function position_all_type($type, $timestamp_begin = '', $timestamp_end = '', $second = 10) {
77 77
 		$all_sat = $this->get_tle_names_type($type);
78 78
 		$result = array();
79 79
 		foreach ($all_sat as $sat) {
80
-			$position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second);
81
-			$result = array_merge($position,$result);
80
+			$position = $this->position($sat['tle_name'], $timestamp_begin, $timestamp_end, $second);
81
+			$result = array_merge($position, $result);
82 82
 		}
83 83
 		return $result;
84 84
 	}
85 85
 
86
-	public function position($name,$timestamp_begin = '',$timestamp_end = '',$second = 10) {
86
+	public function position($name, $timestamp_begin = '', $timestamp_end = '', $second = 10) {
87 87
 		$qth = new Predict_QTH();
88 88
 		$qth->lat = floatval(37.790252);
89 89
 		$qth->lon = floatval(-122.419968);
90 90
 	
91 91
 		$tle_file = $this->get_tle($name);
92 92
 		$type = $tle_file['tle_type'];
93
-		$tle = new Predict_TLE($tle_file['tle_name'],$tle_file['tle_tle1'],$tle_file['tle_tle2']);
93
+		$tle = new Predict_TLE($tle_file['tle_name'], $tle_file['tle_tle1'], $tle_file['tle_tle2']);
94 94
 		$sat = new Predict_Sat($tle);
95 95
 		$predict = new Predict();
96 96
 		//if ($timestamp == '') $now = Predict_Time::get_current_daynum();
97 97
 		if ($timestamp_begin == '') $timestamp_begin = time();
98 98
 		if ($timestamp_end == '') {
99 99
 			$now = Predict_Time::unix2daynum($timestamp_begin);
100
-			$predict->predict_calc($sat,$qth,$now);
101
-			return array('name' => $name, 'latitude' => $sat->ssplat,'longitude' => $sat->ssplon, 'altitude' => $sat->alt,'speed' => $sat->velo*60*60,'timestamp' => $timestamp_begin,'type' => $type);
100
+			$predict->predict_calc($sat, $qth, $now);
101
+			return array('name' => $name, 'latitude' => $sat->ssplat, 'longitude' => $sat->ssplon, 'altitude' => $sat->alt, 'speed' => $sat->velo*60*60, 'timestamp' => $timestamp_begin, 'type' => $type);
102 102
 		} else {
103 103
 			$result = array();
104
-			for ($timestamp = $timestamp_begin; $timestamp <= $timestamp_end; $timestamp=$timestamp+$second) {
104
+			for ($timestamp = $timestamp_begin; $timestamp <= $timestamp_end; $timestamp = $timestamp + $second) {
105 105
 				$now = Predict_Time::unix2daynum($timestamp);
106
-				$predict->predict_calc($sat,$qth,$now);
107
-				$result[] = array('name' => $name,'latitude' => $sat->ssplat,'longitude' => $sat->ssplon, 'altitude' => $sat->alt,'speed' => $sat->velo*60*60,'timestamp' => $timestamp,'type' => $type);
106
+				$predict->predict_calc($sat, $qth, $now);
107
+				$result[] = array('name' => $name, 'latitude' => $sat->ssplat, 'longitude' => $sat->ssplon, 'altitude' => $sat->alt, 'speed' => $sat->velo*60*60, 'timestamp' => $timestamp, 'type' => $type);
108 108
 			}
109 109
 			return $result;
110 110
 		}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		try {
116 116
 			$sth = $this->db->prepare($query);
117 117
 			$sth->execute(array(':name' => $name.'%'));
118
-		} catch(PDOException $e) {
118
+		} catch (PDOException $e) {
119 119
 			echo $e->getMessage();
120 120
 		}
121 121
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		$sth->execute($query_values);
144 144
 		$launch_site_array = array();
145 145
 		$temp_array = array();
146
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
146
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
147 147
 		{
148 148
 			$temp_array['launch_site'] = $row['launch_site'];
149 149
 			$temp_array['launch_site_count'] = $row['launch_site_count'];
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		$sth->execute($query_values);
173 173
 		$owner_array = array();
174 174
 		$temp_array = array();
175
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
175
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
176 176
 		{
177 177
 			$temp_array['owner_name'] = $row['owner_name'];
178 178
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		$sth->execute($query_values);
202 202
 		$owner_array = array();
203 203
 		$temp_array = array();
204
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
204
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
205 205
 		{
206 206
 			$temp_array['country_name'] = $row['country_name'];
207 207
 			$temp_array['country_count'] = $row['country_count'];
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		$sth->execute($query_data);
246 246
 		$date_array = array();
247 247
 		$temp_array = array();
248
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
248
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
249 249
 		{
250 250
 			$temp_array['year_name'] = $row['year_name'];
251 251
 			$temp_array['month_name'] = $row['month_name'];
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		$sth->execute($query_data);
291 291
 		$date_array = array();
292 292
 		$temp_array = array();
293
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
293
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
294 294
 		{
295 295
 			$temp_array['year_name'] = $row['year_name'];
296 296
 			$temp_array['date_count'] = $row['date_count'];
Please login to merge, or discard this patch.
Braces   +55 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,8 +23,11 @@  discard block
 block discarded – undo
23 23
 			echo $e->getMessage();
24 24
 		}
25 25
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
26
-		if (isset($result[0])) return $result[0];
27
-		else return array();
26
+		if (isset($result[0])) {
27
+			return $result[0];
28
+		} else {
29
+			return array();
30
+		}
28 31
 	}
29 32
 	public function get_tle_types() {
30 33
 		$query = 'SELECT DISTINCT tle_type FROM tle ORDER BY tle_type';
@@ -35,8 +38,11 @@  discard block
 block discarded – undo
35 38
 			echo $e->getMessage();
36 39
 		}
37 40
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
38
-		if (isset($result[0])) return $result;
39
-		else return array();
41
+		if (isset($result[0])) {
42
+			return $result;
43
+		} else {
44
+			return array();
45
+		}
40 46
 	}
41 47
 	public function get_tle_names() {
42 48
 		$query = 'SELECT DISTINCT tle_name, tle_type FROM tle';
@@ -47,8 +53,11 @@  discard block
 block discarded – undo
47 53
 			echo $e->getMessage();
48 54
 		}
49 55
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
50
-		if (isset($result[0])) return $result;
51
-		else return array();
56
+		if (isset($result[0])) {
57
+			return $result;
58
+		} else {
59
+			return array();
60
+		}
52 61
 	}
53 62
 	public function get_tle_names_type($type) {
54 63
 		$query = 'SELECT tle_name, tle_type FROM tle WHERE tle_type = :type ORDER BY tle_name';
@@ -59,8 +68,11 @@  discard block
 block discarded – undo
59 68
 			echo $e->getMessage();
60 69
 		}
61 70
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
62
-		if (isset($result[0])) return $result;
63
-		else return array();
71
+		if (isset($result[0])) {
72
+			return $result;
73
+		} else {
74
+			return array();
75
+		}
64 76
 	}
65 77
 	
66 78
 	public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) {
@@ -94,7 +106,9 @@  discard block
 block discarded – undo
94 106
 		$sat = new Predict_Sat($tle);
95 107
 		$predict = new Predict();
96 108
 		//if ($timestamp == '') $now = Predict_Time::get_current_daynum();
97
-		if ($timestamp_begin == '') $timestamp_begin = time();
109
+		if ($timestamp_begin == '') {
110
+			$timestamp_begin = time();
111
+		}
98 112
 		if ($timestamp_end == '') {
99 113
 			$now = Predict_Time::unix2daynum($timestamp_begin);
100 114
 			$predict->predict_calc($sat,$qth,$now);
@@ -119,8 +133,11 @@  discard block
 block discarded – undo
119 133
 			echo $e->getMessage();
120 134
 		}
121 135
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
122
-		if (isset($result[0])) return $result[0];
123
-		else return array();
136
+		if (isset($result[0])) {
137
+			return $result[0];
138
+		} else {
139
+			return array();
140
+		}
124 141
 	}
125 142
 
126 143
 	/**
@@ -138,7 +155,9 @@  discard block
 block discarded – undo
138 155
 		    FROM satellite".$filter_query." satellite.launch_site <> '' AND satellite.launch_site IS NOT NULL";
139 156
 		$query_values = array();
140 157
 		$query .= " GROUP BY satellite.launch_site ORDER BY launch_site_count DESC";
141
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
158
+		if ($limit) {
159
+			$query .= " LIMIT 10 OFFSET 0";
160
+		}
142 161
 		$sth = $this->db->prepare($query);
143 162
 		$sth->execute($query_values);
144 163
 		$launch_site_array = array();
@@ -167,7 +186,9 @@  discard block
 block discarded – undo
167 186
 		    FROM satellite".$filter_query." satellite.owner <> '' AND satellite.owner IS NOT NULL";
168 187
 		$query_values = array();
169 188
 		$query .= " GROUP BY satellite.owner ORDER BY owner_count DESC";
170
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
189
+		if ($limit) {
190
+			$query .= " LIMIT 10 OFFSET 0";
191
+		}
171 192
 		$sth = $this->db->prepare($query);
172 193
 		$sth->execute($query_values);
173 194
 		$owner_array = array();
@@ -196,7 +217,9 @@  discard block
 block discarded – undo
196 217
 		    FROM satellite".$filter_query." satellite.country_owner <> '' AND satellite.country_owner IS NOT NULL";
197 218
 		$query_values = array();
198 219
 		$query .= " GROUP BY satellite.country_owner ORDER BY country_count DESC";
199
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
220
+		if ($limit) {
221
+			$query .= " LIMIT 10 OFFSET 0";
222
+		}
200 223
 		$sth = $this->db->prepare($query);
201 224
 		$sth->execute($query_values);
202 225
 		$owner_array = array();
@@ -223,20 +246,26 @@  discard block
 block discarded – undo
223 246
 			date_default_timezone_set($globalTimezone);
224 247
 			$datetime = new DateTime();
225 248
 			$offset = $datetime->format('P');
226
-		} else $offset = '+00:00';
249
+		} else {
250
+			$offset = '+00:00';
251
+		}
227 252
 		//$filter_query = $this->getFilter($filters,true,true);
228 253
 		$filter_query = ' WHERE';
229 254
 		if ($globalDBdriver == 'mysql') {
230 255
 			$query  = "SELECT MONTH(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count
231 256
 				FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
232
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
257
+			if ($sincedate != '') {
258
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
259
+			}
233 260
 			$query .= " GROUP BY year_name, month_name
234 261
 				ORDER BY year_name, month_name ASC";
235 262
 			$query_data = array(':offset' => $offset);
236 263
 		} else {
237 264
 			$query  = "SELECT EXTRACT(MONTH FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count
238 265
 				FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'";
239
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
266
+			if ($sincedate != '') {
267
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
268
+			}
240 269
 			$query .= " GROUP BY year_name, month_name
241 270
 				ORDER BY year_name, month_name ASC";
242 271
 			$query_data = array(':offset' => $offset);
@@ -268,20 +297,26 @@  discard block
 block discarded – undo
268 297
 			date_default_timezone_set($globalTimezone);
269 298
 			$datetime = new DateTime();
270 299
 			$offset = $datetime->format('P');
271
-		} else $offset = '+00:00';
300
+		} else {
301
+			$offset = '+00:00';
302
+		}
272 303
 		//$filter_query = $this->getFilter($filters,true,true);
273 304
 		$filter_query = ' WHERE';
274 305
 		if ($globalDBdriver == 'mysql') {
275 306
 			$query  = "SELECT YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count
276 307
 				FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 YEAR)";
277
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
308
+			if ($sincedate != '') {
309
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
310
+			}
278 311
 			$query .= " GROUP BY year_name
279 312
 				ORDER BY year_name ASC";
280 313
 			$query_data = array(':offset' => $offset);
281 314
 		} else {
282 315
 			$query  = "SELECT EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count
283 316
 				FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '10 YEARS'";
284
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
317
+			if ($sincedate != '') {
318
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
319
+			}
285 320
 			$query .= " GROUP BY year_name
286 321
 				ORDER BY year_name ASC";
287 322
 			$query_data = array(':offset' => $offset);
Please login to merge, or discard this patch.
space-data.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 <button type="button" class="close">&times;</button>
10 10
 <?php
11 11
 
12
-$sat = filter_input(INPUT_GET,'sat',FILTER_SANITIZE_STRING);
12
+$sat = filter_input(INPUT_GET, 'sat', FILTER_SANITIZE_STRING);
13 13
 $sat = urldecode($sat);
14 14
 //$info = $Satellite->get_info(str_replace(' ','-',$sat));
15 15
 //print_r($info);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	$aircraft_name = 'INTEGRAL';
49 49
 //	$ground_speed = 14970;
50 50
 	$launch_date = '17 October 2002';
51
-} elseif (strpos($sat,'IRIDIUM') !== false) {
51
+} elseif (strpos($sat, 'IRIDIUM') !== false) {
52 52
 	$image = 'https://upload.wikimedia.org/wikipedia/commons/b/b6/Iridium_Satellite.jpg';
53 53
 	$image_copyright = 'Cliff';
54 54
 	$ident = 'Iridium satellite constellation';
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
 	$aircraft_name = $sat;
57 57
 //	$ground_speed = 14970;
58 58
 //	$launch_date = '29 september 2011';
59
-} elseif (strpos($sat,'ORBCOMM') !== false) {
59
+} elseif (strpos($sat, 'ORBCOMM') !== false) {
60 60
 	$ident = 'Orbcomm';
61 61
 	$aircraft_wiki = 'https://en.wikipedia.org/wiki/Orbcomm_(satellite)';
62 62
 	$aircraft_name = $sat;
63
-} elseif (strpos($sat,'GLOBALSTAR') !== false) {
63
+} elseif (strpos($sat, 'GLOBALSTAR') !== false) {
64 64
 	$ident = 'Globalstar';
65 65
 	$aircraft_wiki = 'https://en.wikipedia.org/wiki/Globalstar';
66 66
 	$aircraft_name = $sat;
67
-	$satname = str_replace(array('[+]','[-]'),'',$sat);
68
-} elseif (strpos($sat,'OSCAR 7') !== false) {
67
+	$satname = str_replace(array('[+]', '[-]'), '', $sat);
68
+} elseif (strpos($sat, 'OSCAR 7') !== false) {
69 69
 	$image = 'https://upload.wikimedia.org/wikipedia/en/a/ad/AMSAT-OSCAR_7.jpg';
70 70
 	$image_copyright = 'Amsat.org';
71 71
 	$ident = 'AMSAT-OSCAR 7';
72 72
 	$aircraft_wiki = 'https://en.wikipedia.org/wiki/AMSAT-OSCAR_7';
73 73
 	$aircraft_name = $sat;
74 74
 	$launch_date = '15 November 1974';
75
-} elseif (strpos($sat,'santaclaus') !== false) {
75
+} elseif (strpos($sat, 'santaclaus') !== false) {
76 76
 	$image = 'https://upload.wikimedia.org/wikipedia/commons/4/49/Jonathan_G_Meath_portrays_Santa_Claus.jpg';
77 77
 	$image_copyright = 'Jonathan G Meath';
78 78
 	$ident = 'Santa Claus';
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 //	$launch_date = '15 November 1974';
82 82
 } else {
83 83
 	$ident = $sat;
84
-	if (strpos($sat,'(')) $satname = $sat;
85
-	else $satname = str_replace(array(' '),'-',$sat);
84
+	if (strpos($sat, '(')) $satname = $sat;
85
+	else $satname = str_replace(array(' '), '-', $sat);
86 86
 }
87 87
 if (!isset($satname)) $satname = $sat;
88 88
 $info = $Satellite->get_info(strtolower(trim($satname)));
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		print '<div><span>'._("Orbit").'</span>'.$info['orbit'].'</div>';
146 146
 	}
147 147
 	if ($info['launch_date'] != '') {
148
-		print '<div><span>'._("Launch Date").'</span>'.date('Y-m-d',strtotime($info['launch_date'])).'</div>';
148
+		print '<div><span>'._("Launch Date").'</span>'.date('Y-m-d', strtotime($info['launch_date'])).'</div>';
149 149
 	}
150 150
 	if ($info['launch_site'] != '') {
151 151
 		print '<div><span>'._("Launch Site").'</span>'.$info['launch_site'].'</div>';
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,10 +81,15 @@
 block discarded – undo
81 81
 //	$launch_date = '15 November 1974';
82 82
 } else {
83 83
 	$ident = $sat;
84
-	if (strpos($sat,'(')) $satname = $sat;
85
-	else $satname = str_replace(array(' '),'-',$sat);
84
+	if (strpos($sat,'(')) {
85
+		$satname = $sat;
86
+	} else {
87
+		$satname = str_replace(array(' '),'-',$sat);
88
+	}
89
+	}
90
+if (!isset($satname)) {
91
+	$satname = $sat;
86 92
 }
87
-if (!isset($satname)) $satname = $sat;
88 93
 $info = $Satellite->get_info(strtolower(trim($satname)));
89 94
 $position = $Satellite->position($sat);
90 95
 $ground_speed = $position['speed'];
Please login to merge, or discard this patch.
header.php 2 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 ?>
162 162
 <?php 
163
-    if (isset($_POST['archive'])) {
163
+	if (isset($_POST['archive'])) {
164 164
 ?>
165 165
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
166 166
 <?php 
167
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
167
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
168 168
 ?>
169 169
 
170 170
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
171 171
 <?php    
172
-	    }
173
-    } else {
172
+		}
173
+	} else {
174 174
 ?>
175 175
 <?php
176 176
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 */
183 183
 ?>
184 184
 <?php 
185
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
185
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
186 186
 ?>
187 187
 <?php
188 188
 //		if (isset($globalBeta) && $globalBeta) {
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
 <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script>
209 209
 <?php
210 210
 		}
211
-	    }
211
+		}
212 212
 ?>
213 213
 <?php
214 214
 //	}
215 215
 ?>
216 216
 <?php
217
-    }
217
+	}
218 218
 }
219 219
 ?>
220 220
 <?php
@@ -388,61 +388,61 @@  discard block
 block discarded – undo
388 388
       <ul class="nav navbar-nav">
389 389
 
390 390
 <?php 
391
-    $sub = false;
392
-    if (
391
+	$sub = false;
392
+	if (
393 393
 	(
394
-	    (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
394
+		(!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
395 395
 	) || 
396 396
 	(
397
-	    isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
397
+		isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
398 398
 	) || 
399 399
 	(
400
-	    isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
400
+		isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
401 401
 	) || 
402 402
 	(
403
-	    isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
403
+		isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
404 404
 	)
405
-    ) {
405
+	) {
406 406
 	$sub = true;
407
-    }
407
+	}
408 408
 ?>
409 409
 <?php
410
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
410
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
411 411
 ?>
412 412
     <li class="dropdown">
413 413
 <?php
414
-    if ($sub) {
414
+	if ($sub) {
415 415
 ?>
416 416
       	<li class="dropdown">
417 417
           <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Aircrafts"); ?> <b class="caret"></b></a>
418 418
 	<ul class="dropdown-menu multi-level">
419 419
       	<li class="dropdown-submenu">
420 420
 <?php
421
-    }
421
+	}
422 422
 ?>
423 423
           <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
424 424
           <ul class="dropdown-menu">
425 425
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
426 426
 <?php
427
-    if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
427
+	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
428 428
 ?>
429 429
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
430 430
 <?php
431
-    }
431
+	}
432 432
 ?>
433 433
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
434 434
 <?php
435
-    if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
435
+	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
436 436
 ?>
437 437
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
438 438
 <?php
439
-    } 
440
-    if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
439
+	} 
440
+	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
441 441
 
442 442
 ?>
443 443
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
444 444
 <?php
445
-    }
445
+	}
446 446
 ?>
447 447
 			<li><hr /></li>
448 448
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -450,43 +450,43 @@  discard block
 block discarded – undo
450 450
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
451 451
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
452 452
             <?php
453
-        	if ($globalACARS) {
454
-        	    if (isset($globalDemo) && $globalDemo) {
455
-    	    ?>
453
+			if ($globalACARS) {
454
+				if (isset($globalDemo) && $globalDemo) {
455
+			?>
456 456
             <li><hr /></li>
457 457
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
458 458
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
459 459
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
460 460
             <?php
461
-        	    } else {
462
-    	    ?>
461
+				} else {
462
+			?>
463 463
             <li><hr /></li>
464 464
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
465 465
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
466 466
             <?php
467
-        	    }
468
-        	}
469
-    	    ?>
467
+				}
468
+			}
469
+			?>
470 470
     	    <?php
471
-    	        if (isset($globalAccidents) && $globalAccidents) {
472
-    	    ?>
471
+				if (isset($globalAccidents) && $globalAccidents) {
472
+			?>
473 473
             <li><hr /></li>
474 474
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
475 475
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
476 476
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
477 477
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
478 478
             <?php
479
-        	}
480
-    	    ?>
479
+			}
480
+			?>
481 481
             <li><hr /></li>
482 482
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
483 483
             <?php
484 484
 		if (!isset($globalNoUpcoming) || $globalNoUpcoming === FALSE) {
485
-	    ?>
485
+		?>
486 486
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
487 487
 	    <?php
488 488
 		}
489
-	    ?>
489
+		?>
490 490
           </ul>
491 491
         </li>
492 492
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
@@ -513,14 +513,14 @@  discard block
 block discarded – undo
513 513
     </ul>
514 514
 <?php
515 515
 	}
516
-    }
516
+	}
517 517
 ?>
518 518
 <?php
519
-    if (isset($globalMarine) && $globalMarine) {
519
+	if (isset($globalMarine) && $globalMarine) {
520 520
 ?>
521 521
     <li class="dropdown">
522 522
 <?php
523
-        if ($sub) {
523
+		if ($sub) {
524 524
 ?>
525 525
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Vessels"); ?> <b class="caret"></b></a>
526 526
 	<ul class="dropdown-menu multi-level">
@@ -545,14 +545,14 @@  discard block
 block discarded – undo
545 545
 	}
546 546
 ?>
547 547
 <?php
548
-    }
548
+	}
549 549
 ?>
550 550
 <?php
551
-    if (isset($globalTracker) && $globalTracker) {
551
+	if (isset($globalTracker) && $globalTracker) {
552 552
 ?>
553 553
     <li class="dropdown">
554 554
 <?php
555
-        if ($sub) {
555
+		if ($sub) {
556 556
 ?>
557 557
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a>
558 558
 	<ul class="dropdown-menu multi-level">
@@ -577,14 +577,14 @@  discard block
 block discarded – undo
577 577
 	}
578 578
 ?>
579 579
 <?php
580
-    }
580
+	}
581 581
 ?>
582 582
 <?php
583
-    if (isset($globalSatellite) && $globalSatellite) {
583
+	if (isset($globalSatellite) && $globalSatellite) {
584 584
 ?>
585 585
     <li class="dropdown">
586 586
 <?php
587
-        if ($sub) {
587
+		if ($sub) {
588 588
 ?>
589 589
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Satellite"); ?> <b class="caret"></b></a>
590 590
 	<ul class="dropdown-menu multi-level">
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	}
612 612
 ?>
613 613
 <?php
614
-    }
614
+	}
615 615
 ?>
616 616
 
617 617
         <li class="dropdown">
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
           	<li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li>
621 621
           	<li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li>
622 622
 <?php
623
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
623
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
624 624
 ?>
625 625
 		<li><hr /></li>
626 626
 		<li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li>
627 627
 <?php
628
-    }
628
+	}
629 629
 ?>
630 630
 	    <?php if (isset($globalContribute) && $globalContribute) { ?>
631 631
                 <li><hr /></li>
@@ -646,14 +646,14 @@  discard block
 block discarded – undo
646 646
   	    <form>
647 647
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
648 648
   		    <?php
649
-  		        $Language = new Language();
650
-  		        $alllang = $Language->getLanguages();
651
-  		        foreach ($alllang as $key => $lang) {
652
-  		            print '<option value="'.$key.'"';
653
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
654
-  		            print '>'.$lang[0].'</option>';
655
-  		        }
656
-  		    ?>
649
+  				$Language = new Language();
650
+  				$alllang = $Language->getLanguages();
651
+  				foreach ($alllang as $key => $lang) {
652
+  					print '<option value="'.$key.'"';
653
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
654
+  					print '>'.$lang[0].'</option>';
655
+  				}
656
+  			?>
657 657
   		</select>
658 658
   	    </form>
659 659
   	</div>
@@ -684,18 +684,18 @@  discard block
 block discarded – undo
684 684
 ?>
685 685
     <div class="top-header clear" role="main">
686 686
 <?php
687
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
687
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
688 688
 ?>
689 689
     <div id="archive-map"></div>
690 690
 <?php
691
-    }
691
+	}
692 692
 ?>
693 693
     </div>
694 694
 <?php
695 695
 }
696 696
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
697 697
 {
698
-    ?>
698
+	?>
699 699
     <div class="top-header clear" role="main">
700 700
         <div id="map"></div>
701 701
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -706,15 +706,15 @@  discard block
 block discarded – undo
706 706
         var zoom = 13;
707 707
 //create the map
708 708
 <?php
709
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
709
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
710 710
 ?>
711 711
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
712 712
 <?php
713
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
713
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
714 714
 ?>
715 715
   map = L.map('map', { zoomControl:true });
716 716
 <?php
717
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
717
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
718 718
 ?>
719 719
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
720 720
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -722,22 +722,22 @@  discard block
 block discarded – undo
722 722
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
723 723
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
724 724
 <?php
725
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
725
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
726 726
 ?>
727 727
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
728 728
 <?php
729
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
729
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
730 730
 ?>
731 731
   map = L.map('map', { zoomControl:true });
732 732
 <?php
733
-    }
733
+	}
734 734
 ?>
735 735
   //initialize the layer group for the aircrft markers
736 736
   var layer_data = L.layerGroup();
737 737
 
738 738
   //a few title layers
739 739
 <?php
740
-    if ($globalMapProvider == 'Mapbox') {
740
+	if ($globalMapProvider == 'Mapbox') {
741 741
 ?>
742 742
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
743 743
     maxZoom: 18,
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
     token : '<?php print $globalMapboxToken; ?>'
749 749
   }).addTo(map);
750 750
 <?php
751
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
751
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
752 752
 ?>
753 753
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
754 754
     maxZoom: 18,
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
758 758
   }).addTo(map);
759 759
 <?php
760
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
760
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
761 761
 ?>
762 762
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
763 763
     maxZoom: 18,
@@ -766,27 +766,27 @@  discard block
 block discarded – undo
766 766
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
767 767
   }).addTo(map);
768 768
 <?php
769
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
769
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
770 770
 ?>
771 771
     var googleLayer = new L.Google('ROADMAP');
772 772
     map.addLayer(googleLayer);
773 773
 <?php
774
-    } elseif ($globalMapProvider == 'Google-Satellite') {
774
+	} elseif ($globalMapProvider == 'Google-Satellite') {
775 775
 ?>
776 776
     var googleLayer = new L.Google('SATELLITE');
777 777
     map.addLayer(googleLayer);
778 778
 <?php
779
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
779
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
780 780
 ?>
781 781
     var googleLayer = new L.Google('HYBRID');
782 782
     map.addLayer(googleLayer);
783 783
 <?php
784
-    } elseif ($globalMapProvider == 'Google-Terrain') {
784
+	} elseif ($globalMapProvider == 'Google-Terrain') {
785 785
 ?>
786 786
     var googleLayer = new L.Google('Terrain');
787 787
     map.addLayer(googleLayer);
788 788
 <?php
789
-    } elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
789
+	} elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
790 790
 	$customid = $globalMapProvider;
791 791
 ?>
792 792
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
797 797
     }).addTo(map);
798 798
 <?php
799
-    //} elseif ($globalMapProvider == 'OpenStreetMap') {
800
-    } else {
799
+	//} elseif ($globalMapProvider == 'OpenStreetMap') {
800
+	} else {
801 801
 ?>
802 802
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
803 803
     maxZoom: 18,
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
   }).addTo(map);
807 807
 
808 808
 <?php
809
-    }
809
+	}
810 810
 ?>
811 811
         </script>
812 812
     </div>
Please login to merge, or discard this patch.
Braces   +77 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,10 +3,15 @@  discard block
 block discarded – undo
3 3
 //gets the page file and stores it in a variable
4 4
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
5 5
 $current_page = $file_path['filename'];
6
-if ($globalTimezone == '') $globalTimezone = 'UTC';
6
+if ($globalTimezone == '') {
7
+	$globalTimezone = 'UTC';
8
+}
7 9
 date_default_timezone_set($globalTimezone);
8
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9
-else $MapType = $globalMapProvider;
10
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
11
+	$MapType = $_COOKIE['MapType'];
12
+} else {
13
+	$MapType = $globalMapProvider;
14
+}
10 15
 if (isset($_GET['3d'])) {
11 16
 	setcookie('MapFormat','3d');
12 17
 } else if (isset($_GET['2d'])) {
@@ -231,7 +236,13 @@  discard block
 block discarded – undo
231 236
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
232 237
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
233 238
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
234
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
239
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
240
+	print '&latitude='.$latitude;
241
+}
242
+?><?php if(isset($longitude)) {
243
+	print '&longitude='.$longitude;
244
+}
245
+?>&<?php print time(); ?>"></script>
235 246
 <?php
236 247
 		if (!isset($type) || $type == 'aircraft') {
237 248
 ?>
@@ -300,7 +311,13 @@  discard block
 block discarded – undo
300 311
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
301 312
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
302 313
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
303
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
314
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
315
+	print '&latitude='.$latitude;
316
+}
317
+?><?php if(isset($longitude)) {
318
+	print '&longitude='.$longitude;
319
+}
320
+?>&<?php print time(); ?>"></script>
304 321
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
305 322
 <?php
306 323
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -381,7 +398,12 @@  discard block
 block discarded – undo
381 398
         <span class="icon-bar"></span>
382 399
       </button>
383 400
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a>
384
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
401
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
402
+	print '/';
403
+} else {
404
+	print $globalURL;
405
+}
406
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
385 407
     </div>
386 408
     <div class="collapse navbar-collapse">
387 409
 
@@ -420,7 +442,10 @@  discard block
 block discarded – undo
420 442
 <?php
421 443
     }
422 444
 ?>
423
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
445
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
446
+	echo 'right-';
447
+}
448
+?>caret"></b></a>
424 449
           <ul class="dropdown-menu">
425 450
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
426 451
 <?php
@@ -491,8 +516,14 @@  discard block
 block discarded – undo
491 516
         </li>
492 517
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
493 518
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
494
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
495
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
519
+        <li class="dropdown<?php if ($sub) {
520
+	echo '-submenu';
521
+}
522
+?>">
523
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
524
+	echo 'right-';
525
+}
526
+?>caret"></b></a>
496 527
           <ul class="dropdown-menu">
497 528
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
498 529
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -528,7 +559,10 @@  discard block
 block discarded – undo
528 559
 <?php
529 560
 	}
530 561
 ?>
531
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
562
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
563
+	echo 'right-';
564
+}
565
+?>caret"></b></a>
532 566
 		<ul class="dropdown-menu">
533 567
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
534 568
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -560,7 +594,10 @@  discard block
 block discarded – undo
560 594
 <?php
561 595
 	}
562 596
 ?>
563
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
597
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
598
+	echo 'right-';
599
+}
600
+?>caret"></b></a>
564 601
 		<ul class="dropdown-menu">
565 602
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
566 603
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -593,7 +630,10 @@  discard block
 block discarded – undo
593 630
 	}
594 631
 ?>
595 632
 <!--
596
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
633
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
634
+	echo 'right-';
635
+}
636
+?>caret"></b></a>
597 637
 		<ul class="dropdown-menu">
598 638
 		    <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li>
599 639
 		    <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -650,7 +690,9 @@  discard block
 block discarded – undo
650 690
   		        $alllang = $Language->getLanguages();
651 691
   		        foreach ($alllang as $key => $lang) {
652 692
   		            print '<option value="'.$key.'"';
653
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
693
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
694
+  		            	print ' selected ';
695
+  		            }
654 696
   		            print '>'.$lang[0].'</option>';
655 697
   		        }
656 698
   		    ?>
@@ -790,9 +832,24 @@  discard block
 block discarded – undo
790 832
 	$customid = $globalMapProvider;
791 833
 ?>
792 834
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
793
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
794
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
795
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
835
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
836
+	print $globalMapCustomLayer[$customid]['maxZoom'];
837
+} else {
838
+	print '18';
839
+}
840
+?>,
841
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
842
+	print $globalMapCustomLayer[$customid]['minZoom'];
843
+} else {
844
+	print '0';
845
+}
846
+?>,
847
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
848
+	print 'false';
849
+} else {
850
+	print 'true';
851
+}
852
+?>,
796 853
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
797 854
     }).addTo(map);
798 855
 <?php
@@ -815,4 +872,7 @@  discard block
 block discarded – undo
815 872
 
816 873
 ?>
817 874
 
818
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
875
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
876
+	print 'index ';
877
+}
878
+?>clear">
Please login to merge, or discard this patch.
statistics-sub-menu.php 1 patch
Braces   +110 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,7 +6,13 @@  discard block
 block discarded – undo
6 6
 	if (!isset($type) || $type != 'satellite') {
7 7
 ?>
8 8
 		<form id="changedate" method="post">
9
-			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
9
+			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
10
+	echo $year.'-';
11
+}
12
+?><?php if (isset($month) && $month != '') {
13
+	echo $month;
14
+}
15
+?>" />
10 16
 		</form>
11 17
 <?php
12 18
 	}
@@ -38,7 +44,9 @@  discard block
 block discarded – undo
38 44
 						print '<option disabled>──────────</option>';
39 45
 					}
40 46
 					$Stats = new Stats();
41
-					if (!isset($filter_name)) $filter_name = '';
47
+					if (!isset($filter_name)) {
48
+						$filter_name = '';
49
+					}
42 50
 					$airlines = $Stats->getAllAirlineNames($filter_name);
43 51
 					foreach($airlines as $airline) {
44 52
 						if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) {
@@ -67,10 +75,22 @@  discard block
 block discarded – undo
67 75
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
68 76
 		    </a>
69 77
 		    <ul class="dropdown-menu">
70
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Aircraft"); ?></a></li>
71
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Registration"); ?></a></li>
72
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Manufacturer"); ?></a></li>
73
-			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Country"); ?></a></li>
78
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
79
+	echo '/'.$airline_icao;
80
+}
81
+?>"><?php echo _("Aircraft"); ?></a></li>
82
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
83
+	echo '/'.$airline_icao;
84
+}
85
+?>"><?php echo _("Registration"); ?></a></li>
86
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
87
+	echo '/'.$airline_icao;
88
+}
89
+?>"><?php echo _("Manufacturer"); ?></a></li>
90
+			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
91
+	echo '/'.$airline_icao;
92
+}
93
+?>"><?php echo _("Country"); ?></a></li>
74 94
 		    </ul>
75 95
 		</li>
76 96
 		<li class="dropdown">
@@ -81,12 +101,21 @@  discard block
 block discarded – undo
81 101
 <?php
82 102
 		if (!isset($airline_icao) || $airline_icao == 'all') {
83 103
 ?>
84
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline"); ?></a></li>
85
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline by Country"); ?></a></li>
104
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
105
+	echo '/'.$airline_icao;
106
+}
107
+?>"><?php echo _("Airline"); ?></a></li>
108
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
109
+	echo '/'.$airline_icao;
110
+}
111
+?>"><?php echo _("Airline by Country"); ?></a></li>
86 112
 <?php
87 113
 		}
88 114
 ?>
89
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Callsign"); ?></a></li>
115
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
116
+	echo '/'.$airline_icao;
117
+}
118
+?>"><?php echo _("Callsign"); ?></a></li>
90 119
 		    </ul>
91 120
 		</li>
92 121
 		<li class="dropdown">
@@ -94,10 +123,22 @@  discard block
 block discarded – undo
94 123
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
95 124
 		    </a>
96 125
 		    <ul class="dropdown-menu" role="menu">
97
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport"); ?></a></li>
98
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
99
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport"); ?></a></li>
100
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
126
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
127
+	echo '/'.$airline_icao;
128
+}
129
+?>"><?php echo _("Departure Airport"); ?></a></li>
130
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
131
+	echo '/'.$airline_icao;
132
+}
133
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
134
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
135
+	echo '/'.$airline_icao;
136
+}
137
+?>"><?php echo _("Arrival Airport"); ?></a></li>
138
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
139
+	echo '/'.$airline_icao;
140
+}
141
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
101 142
 		    </ul>
102 143
 		</li>
103 144
 		<li class="dropdown">
@@ -105,8 +146,14 @@  discard block
 block discarded – undo
105 146
 		      <?php echo _("Route"); ?> <span class="caret"></span>
106 147
 		    </a>
107 148
 		    <ul class="dropdown-menu" role="menu">
108
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Airport"); ?></a></li>
109
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Waypoint"); ?></a></li>
149
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
150
+	echo '/'.$airline_icao;
151
+}
152
+?>"><?php echo _("Route by Airport"); ?></a></li>
153
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
154
+	echo '/'.$airline_icao;
155
+}
156
+?>"><?php echo _("Route by Waypoint"); ?></a></li>
110 157
 		    </ul>
111 158
 		</li>
112 159
 		<li class="dropdown">
@@ -114,8 +161,14 @@  discard block
 block discarded – undo
114 161
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
115 162
 		    </a>
116 163
 		    <ul class="dropdown-menu" role="menu">
117
-		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Date"); ?></a></li>
118
-			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Time"); ?></a></li>
164
+		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
165
+	echo '/'.$airline_icao;
166
+}
167
+?>"><?php echo _("Date"); ?></a></li>
168
+			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
169
+	echo '/'.$airline_icao;
170
+}
171
+?>"><?php echo _("Time"); ?></a></li>
119 172
 		    </ul>
120 173
 		</li>
121 174
 		<?php
@@ -163,9 +216,18 @@  discard block
 block discarded – undo
163 216
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
164 217
 		    </a>
165 218
 		    <ul class="dropdown-menu">
166
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
167
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
168
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
219
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
220
+	echo '/'.$airline_icao;
221
+}
222
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
223
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
224
+	echo '/'.$airline_icao;
225
+}
226
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
227
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
228
+	echo '/'.$airline_icao;
229
+}
230
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
169 231
 			<!-- <li><a href="<?php print $globalURL; ?>/statistics/country"><?php echo _("Country"); ?></a></li> -->
170 232
 		    </ul>
171 233
 		</li>
@@ -177,12 +239,21 @@  discard block
 block discarded – undo
177 239
 <?php
178 240
 		if (!isset($airline_icao) || $airline_icao == 'all') {
179 241
 ?>
180
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
181
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
242
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
243
+	echo '/'.$airline_icao;
244
+}
245
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
246
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
247
+	echo '/'.$airline_icao;
248
+}
249
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
182 250
 <?php
183 251
 		}
184 252
 ?>
185
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
253
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
254
+	echo '/'.$airline_icao;
255
+}
256
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
186 257
 		    </ul>
187 258
 		</li>
188 259
 		<li class="dropdown">
@@ -190,10 +261,22 @@  discard block
 block discarded – undo
190 261
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
191 262
 		    </a>
192 263
 		    <ul class="dropdown-menu" role="menu">
193
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
194
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
195
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
196
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
264
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
265
+	echo '/'.$airline_icao;
266
+}
267
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
268
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
269
+	echo '/'.$airline_icao;
270
+}
271
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
272
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
273
+	echo '/'.$airline_icao;
274
+}
275
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
276
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
277
+	echo '/'.$airline_icao;
278
+}
279
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
197 280
 		    </ul>
198 281
 		</li>
199 282
 		<!--
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 1 patch
Braces   +24 added lines, -4 removed lines patch added patch discarded remove patch
@@ -257,7 +257,12 @@  discard block
 block discarded – undo
257 257
 //				viewer.dataSources.get(dsn).entities.remove(entity);
258 258
 //			}
259 259
 			//console.log(entity.lastupdate);
260
-			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
260
+			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
261
+	print $globalMapRefresh*2000;
262
+} else {
263
+	print '60000';
264
+}
265
+?>)) {
261 266
 //				console.log('Remove an entity date');
262 267
 				viewer.dataSources.get(dsn).entities.remove(entity);
263 268
 			} else {
@@ -544,7 +549,12 @@  discard block
 block discarded – undo
544 549
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
545 550
 ?>
546 551
 update_polarLayer();
547
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
552
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
553
+	print $globalMapRefresh*1000*2;
554
+} else {
555
+	print '60000';
556
+}
557
+?>);
548 558
 <?php
549 559
 		}
550 560
 ?>
@@ -642,7 +652,12 @@  discard block
 block discarded – undo
642 652
 				}
643 653
 			}
644 654
 		}
645
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
655
+	,<?php if (isset($globalMapRefresh)) {
656
+	print $globalMapRefresh*1000;
657
+} else {
658
+	print '30000';
659
+}
660
+?>);
646 661
 } else {
647 662
 	//var widget = new Cesium.CesiumWidget('archivebox');
648 663
 //	var timeline = new Cesium.Timeline(viewer);
@@ -661,7 +676,12 @@  discard block
 block discarded – undo
661 676
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
662 677
 ?>
663 678
 update_atcLayer();
664
-setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
679
+setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) {
680
+	print $globalMapRefresh*1000*2;
681
+} else {
682
+	print '60000';
683
+}
684
+?>);
665 685
 <?php
666 686
     }
667 687
 ?>
Please login to merge, or discard this patch.
js/map-satellite.3d.js.php 1 patch
Braces   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,12 @@
 block discarded – undo
52 52
 	} else {
53 53
 		for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) {
54 54
 			var entity = viewer.dataSources.get(dsn).entities.values[i];
55
-			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
55
+			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
56
+	print $globalMapRefresh*2000;
57
+} else {
58
+	print '60000';
59
+}
60
+?>)) {
56 61
 				viewer.dataSources.get(dsn).entities.remove(entity);
57 62
 			}
58 63
 		}
Please login to merge, or discard this patch.