Completed
Push — master ( 91ef4a...f9a26b )
by Yannick
23:48
created
install/class.create_db.php 1 patch
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 			//foreach ($lines as $line)
19 19
 			while (($line = fgets($handle,4096)) !== false)
20 20
 			{
21
-				if (substr($line,0,2) == '--' || $line == '') continue;
21
+				if (substr($line,0,2) == '--' || $line == '') {
22
+					continue;
23
+				}
22 24
 				$templine .= $line;
23 25
 				if (substr(trim($line), -1,1) == ';')
24 26
 				{
@@ -44,7 +46,9 @@  discard block
 block discarded – undo
44 46
 		//foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
45 47
 		while(false !== ($filename = readdir($dh)))
46 48
 		{
47
-			if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
49
+			if (preg_match('/\.sql$/',$filename)) {
50
+				$error .= create_db::import_file($directory.$filename);
51
+			}
48 52
 		}
49 53
 		return $error;
50 54
 	}
@@ -57,19 +61,29 @@  discard block
 block discarded – undo
57 61
 		$db = filter_var($db,FILTER_SANITIZE_STRING);
58 62
 		$db_type = filter_var($db_type,FILTER_SANITIZE_STRING);
59 63
 		$host = filter_var($host,FILTER_SANITIZE_STRING);
60
-		if ($db_type == 'mysql' && $port == '') $port = 3306;
61
-		elseif ($port == '') $port = 5432;
64
+		if ($db_type == 'mysql' && $port == '') {
65
+			$port = 3306;
66
+		} elseif ($port == '') {
67
+			$port = 5432;
68
+		}
62 69
 		// Dirty hack
63 70
 		if ($host != 'localhost' && $host != '127.0.0.1') {
64 71
 			$grantright = $_SERVER['SERVER_ADDR'];
65
-		} else $grantright = 'localhost';
72
+		} else {
73
+			$grantright = 'localhost';
74
+		}
66 75
 		try {
67
-			if ($host == 'localhost') $dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass);
68
-			else $dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass);
76
+			if ($host == 'localhost') {
77
+				$dbh = new PDO($db_type.':host=127.0.0.1',$root,$root_pass);
78
+			} else {
79
+				$dbh = new PDO($db_type.':host='.$host.';port='.$port,$root,$root_pass);
80
+			}
69 81
 			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
70 82
 			if ($db_type == 'mysql') {
71 83
 				$dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
72
-				if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
84
+				if ($grantright == 'localhost') {
85
+					$dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
86
+				}
73 87
 			} else if ($db_type == 'pgsql') {
74 88
 				$dbh->exec("CREATE DATABASE ".$db.";");
75 89
 				$dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."';
Please login to merge, or discard this patch.
install/class.update_db.php 1 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
         }
@@ -1403,9 +1566,14 @@  discard block
 block discarded – undo
1403 1566
 				if ($i > 0 && $data[0] != '') {
1404 1567
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1405 1568
 					$period = str_replace(',','',$data[14]);
1406
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1407
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1408
-					else $launch_date = NULL;
1569
+					if (!empty($period) && strpos($period,'days')) {
1570
+						$period = str_replace(' days','',$period)*24*60;
1571
+					}
1572
+					if ($data[18] != '') {
1573
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1574
+					} else {
1575
+						$launch_date = NULL;
1576
+					}
1409 1577
 					$data = array_map(function($value) {
1410 1578
 						return trim($value) === '' ? null : $value;
1411 1579
 					}, $data);
@@ -1758,7 +1926,9 @@  discard block
 block discarded – undo
1758 1926
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1759 1927
 		{
1760 1928
 			$i = 0;
1761
-			if ($globalTransaction) $Connection->db->beginTransaction();
1929
+			if ($globalTransaction) {
1930
+				$Connection->db->beginTransaction();
1931
+			}
1762 1932
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1763 1933
 			{
1764 1934
 				$i++;
@@ -1786,7 +1956,9 @@  discard block
 block discarded – undo
1786 1956
 				}
1787 1957
 			}
1788 1958
 			fclose($handle);
1789
-			if ($globalTransaction) $Connection->db->commit();
1959
+			if ($globalTransaction) {
1960
+				$Connection->db->commit();
1961
+			}
1790 1962
 		}
1791 1963
 		return '';
1792 1964
         }
@@ -1809,7 +1981,9 @@  discard block
 block discarded – undo
1809 1981
 		$Connection = new Connection();
1810 1982
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1811 1983
 		{
1812
-			if ($globalTransaction) $Connection->db->beginTransaction();
1984
+			if ($globalTransaction) {
1985
+				$Connection->db->beginTransaction();
1986
+			}
1813 1987
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1814 1988
 			{
1815 1989
 				if(count($row) > 1) {
@@ -1823,7 +1997,9 @@  discard block
 block discarded – undo
1823 1997
 				}
1824 1998
 			}
1825 1999
 			fclose($handle);
1826
-			if ($globalTransaction) $Connection->db->commit();
2000
+			if ($globalTransaction) {
2001
+				$Connection->db->commit();
2002
+			}
1827 2003
 		}
1828 2004
 		return '';
1829 2005
         }
@@ -1843,8 +2019,9 @@  discard block
 block discarded – undo
1843 2019
 	        }
1844 2020
 
1845 2021
 
1846
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1847
-		else {
2022
+		if ($globalDBdriver == 'mysql') {
2023
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2024
+		} else {
1848 2025
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1849 2026
 			$query = "CREATE EXTENSION postgis";
1850 2027
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1863,20 +2040,30 @@  discard block
 block discarded – undo
1863 2040
 		global $tmp_dir, $globalDebug;
1864 2041
 		include_once('class.create_db.php');
1865 2042
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1866
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2043
+		if ($globalDebug) {
2044
+			echo "NOTAM from FlightAirMap website : Download...";
2045
+		}
1867 2046
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1868 2047
 		$error = '';
1869 2048
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1870
-			if ($globalDebug) echo "Gunzip...";
2049
+			if ($globalDebug) {
2050
+				echo "Gunzip...";
2051
+			}
1871 2052
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1872
-			if ($globalDebug) echo "Add to DB...";
2053
+			if ($globalDebug) {
2054
+				echo "Add to DB...";
2055
+			}
1873 2056
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1874 2057
 			$NOTAM = new NOTAM();
1875 2058
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1876
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2059
+		} else {
2060
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2061
+		}
1877 2062
 		if ($error != '') {
1878 2063
 			return $error;
1879
-		} elseif ($globalDebug) echo "Done\n";
2064
+		} elseif ($globalDebug) {
2065
+			echo "Done\n";
2066
+		}
1880 2067
 		return '';
1881 2068
 	}
1882 2069
 
@@ -1930,67 +2117,111 @@  discard block
 block discarded – undo
1930 2117
 		//if ($globalDebug) echo "IVAO : Download...";
1931 2118
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1932 2119
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1933
-			if ($globalDebug) echo "Unzip...";
2120
+			if ($globalDebug) {
2121
+				echo "Unzip...";
2122
+			}
1934 2123
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1935
-			if ($globalDebug) echo "Add to DB...";
2124
+			if ($globalDebug) {
2125
+				echo "Add to DB...";
2126
+			}
1936 2127
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1937
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2128
+			if ($globalDebug) {
2129
+				echo "Copy airlines logos to airlines images directory...";
2130
+			}
1938 2131
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1939
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1940
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1941
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2132
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2133
+					$error = "Failed to copy airlines logo.";
2134
+				}
2135
+			} else {
2136
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2137
+			}
2138
+		} else {
2139
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2140
+		}
1942 2141
 		if ($error != '') {
1943 2142
 			return $error;
1944
-		} elseif ($globalDebug) echo "Done\n";
2143
+		} elseif ($globalDebug) {
2144
+			echo "Done\n";
2145
+		}
1945 2146
 		return '';
1946 2147
 	}
1947 2148
 
1948 2149
 	public static function update_routes() {
1949 2150
 		global $tmp_dir, $globalDebug;
1950 2151
 		$error = '';
1951
-		if ($globalDebug) echo "Routes : Download...";
2152
+		if ($globalDebug) {
2153
+			echo "Routes : Download...";
2154
+		}
1952 2155
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1953 2156
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1954
-			if ($globalDebug) echo "Gunzip...";
2157
+			if ($globalDebug) {
2158
+				echo "Gunzip...";
2159
+			}
1955 2160
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1956
-			if ($globalDebug) echo "Add to DB...";
2161
+			if ($globalDebug) {
2162
+				echo "Add to DB...";
2163
+			}
1957 2164
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1958
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2165
+		} else {
2166
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2167
+		}
1959 2168
 		if ($error != '') {
1960 2169
 			return $error;
1961
-		} elseif ($globalDebug) echo "Done\n";
2170
+		} elseif ($globalDebug) {
2171
+			echo "Done\n";
2172
+		}
1962 2173
 		return '';
1963 2174
 	}
1964 2175
 	public static function update_oneworld() {
1965 2176
 		global $tmp_dir, $globalDebug;
1966 2177
 		$error = '';
1967
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2178
+		if ($globalDebug) {
2179
+			echo "Schedules Oneworld : Download...";
2180
+		}
1968 2181
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1969 2182
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1970
-			if ($globalDebug) echo "Gunzip...";
2183
+			if ($globalDebug) {
2184
+				echo "Gunzip...";
2185
+			}
1971 2186
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1972
-			if ($globalDebug) echo "Add to DB...";
2187
+			if ($globalDebug) {
2188
+				echo "Add to DB...";
2189
+			}
1973 2190
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1974
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2191
+		} else {
2192
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2193
+		}
1975 2194
 		if ($error != '') {
1976 2195
 			return $error;
1977
-		} elseif ($globalDebug) echo "Done\n";
2196
+		} elseif ($globalDebug) {
2197
+			echo "Done\n";
2198
+		}
1978 2199
 		return '';
1979 2200
 	}
1980 2201
 	public static function update_skyteam() {
1981 2202
 		global $tmp_dir, $globalDebug;
1982 2203
 		$error = '';
1983
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2204
+		if ($globalDebug) {
2205
+			echo "Schedules Skyteam : Download...";
2206
+		}
1984 2207
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1985 2208
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1986
-			if ($globalDebug) echo "Gunzip...";
2209
+			if ($globalDebug) {
2210
+				echo "Gunzip...";
2211
+			}
1987 2212
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1988
-			if ($globalDebug) echo "Add to DB...";
2213
+			if ($globalDebug) {
2214
+				echo "Add to DB...";
2215
+			}
1989 2216
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1990
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2217
+		} else {
2218
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2219
+		}
1991 2220
 		if ($error != '') {
1992 2221
 			return $error;
1993
-		} elseif ($globalDebug) echo "Done\n";
2222
+		} elseif ($globalDebug) {
2223
+			echo "Done\n";
2224
+		}
1994 2225
 		return '';
1995 2226
 	}
1996 2227
 	public static function update_ModeS() {
@@ -2007,355 +2238,619 @@  discard block
 block discarded – undo
2007 2238
 			exit;
2008 2239
 		} elseif ($globalDebug) echo "Done\n";
2009 2240
 */
2010
-		if ($globalDebug) echo "Modes : Download...";
2011
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2241
+		if ($globalDebug) {
2242
+			echo "Modes : Download...";
2243
+		}
2244
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2012 2245
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2013 2246
 
2014 2247
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2015 2248
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2016
-			if ($globalDebug) echo "Unzip...";
2017
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2249
+			if ($globalDebug) {
2250
+				echo "Unzip...";
2251
+			}
2252
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2018 2253
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2019
-			if ($globalDebug) echo "Add to DB...";
2254
+			if ($globalDebug) {
2255
+				echo "Add to DB...";
2256
+			}
2020 2257
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2021 2258
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2022
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2259
+		} else {
2260
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2261
+		}
2023 2262
 		if ($error != '') {
2024 2263
 			return $error;
2025
-		} elseif ($globalDebug) echo "Done\n";
2264
+		} elseif ($globalDebug) {
2265
+			echo "Done\n";
2266
+		}
2026 2267
 		return '';
2027 2268
 	}
2028 2269
 
2029 2270
 	public static function update_ModeS_faa() {
2030 2271
 		global $tmp_dir, $globalDebug;
2031
-		if ($globalDebug) echo "Modes FAA: Download...";
2272
+		if ($globalDebug) {
2273
+			echo "Modes FAA: Download...";
2274
+		}
2032 2275
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2033 2276
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2034
-			if ($globalDebug) echo "Unzip...";
2277
+			if ($globalDebug) {
2278
+				echo "Unzip...";
2279
+			}
2035 2280
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2036
-			if ($globalDebug) echo "Add to DB...";
2281
+			if ($globalDebug) {
2282
+				echo "Add to DB...";
2283
+			}
2037 2284
 			$error = update_db::modes_faa();
2038
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2285
+		} else {
2286
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2287
+		}
2039 2288
 		if ($error != '') {
2040 2289
 			return $error;
2041
-		} elseif ($globalDebug) echo "Done\n";
2290
+		} elseif ($globalDebug) {
2291
+			echo "Done\n";
2292
+		}
2042 2293
 		return '';
2043 2294
 	}
2044 2295
 
2045 2296
 	public static function update_ModeS_flarm() {
2046 2297
 		global $tmp_dir, $globalDebug;
2047
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2298
+		if ($globalDebug) {
2299
+			echo "Modes Flarmnet: Download...";
2300
+		}
2048 2301
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2049 2302
 		if (file_exists($tmp_dir.'data.fln')) {
2050
-			if ($globalDebug) echo "Add to DB...";
2303
+			if ($globalDebug) {
2304
+				echo "Add to DB...";
2305
+			}
2051 2306
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2052
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2307
+		} else {
2308
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2309
+		}
2053 2310
 		if ($error != '') {
2054 2311
 			return $error;
2055
-		} elseif ($globalDebug) echo "Done\n";
2312
+		} elseif ($globalDebug) {
2313
+			echo "Done\n";
2314
+		}
2056 2315
 		return '';
2057 2316
 	}
2058 2317
 
2059 2318
 	public static function update_ModeS_ogn() {
2060 2319
 		global $tmp_dir, $globalDebug;
2061
-		if ($globalDebug) echo "Modes OGN: Download...";
2320
+		if ($globalDebug) {
2321
+			echo "Modes OGN: Download...";
2322
+		}
2062 2323
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2063 2324
 		if (file_exists($tmp_dir.'ogn.csv')) {
2064
-			if ($globalDebug) echo "Add to DB...";
2325
+			if ($globalDebug) {
2326
+				echo "Add to DB...";
2327
+			}
2065 2328
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2066
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2329
+		} else {
2330
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2331
+		}
2067 2332
 		if ($error != '') {
2068 2333
 			return $error;
2069
-		} elseif ($globalDebug) echo "Done\n";
2334
+		} elseif ($globalDebug) {
2335
+			echo "Done\n";
2336
+		}
2070 2337
 		return '';
2071 2338
 	}
2072 2339
 
2073 2340
 	public static function update_owner() {
2074 2341
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2075 2342
 		
2076
-		if ($globalDebug) echo "Owner France: Download...";
2343
+		if ($globalDebug) {
2344
+			echo "Owner France: Download...";
2345
+		}
2077 2346
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2078 2347
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2079
-			if ($globalDebug) echo "Add to DB...";
2348
+			if ($globalDebug) {
2349
+				echo "Add to DB...";
2350
+			}
2080 2351
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2081
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2352
+		} else {
2353
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2354
+		}
2082 2355
 		if ($error != '') {
2083 2356
 			return $error;
2084
-		} elseif ($globalDebug) echo "Done\n";
2357
+		} elseif ($globalDebug) {
2358
+			echo "Done\n";
2359
+		}
2085 2360
 		
2086
-		if ($globalDebug) echo "Owner Ireland: Download...";
2361
+		if ($globalDebug) {
2362
+			echo "Owner Ireland: Download...";
2363
+		}
2087 2364
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2088 2365
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2089
-			if ($globalDebug) echo "Add to DB...";
2366
+			if ($globalDebug) {
2367
+				echo "Add to DB...";
2368
+			}
2090 2369
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2091
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2370
+		} else {
2371
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2372
+		}
2092 2373
 		if ($error != '') {
2093 2374
 			return $error;
2094
-		} elseif ($globalDebug) echo "Done\n";
2095
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2375
+		} elseif ($globalDebug) {
2376
+			echo "Done\n";
2377
+		}
2378
+		if ($globalDebug) {
2379
+			echo "Owner Switzerland: Download...";
2380
+		}
2096 2381
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2097 2382
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2098
-			if ($globalDebug) echo "Add to DB...";
2383
+			if ($globalDebug) {
2384
+				echo "Add to DB...";
2385
+			}
2099 2386
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2100
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2387
+		} else {
2388
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2389
+		}
2101 2390
 		if ($error != '') {
2102 2391
 			return $error;
2103
-		} elseif ($globalDebug) echo "Done\n";
2104
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2392
+		} elseif ($globalDebug) {
2393
+			echo "Done\n";
2394
+		}
2395
+		if ($globalDebug) {
2396
+			echo "Owner Czech Republic: Download...";
2397
+		}
2105 2398
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2106 2399
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2107
-			if ($globalDebug) echo "Add to DB...";
2400
+			if ($globalDebug) {
2401
+				echo "Add to DB...";
2402
+			}
2108 2403
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2109
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2404
+		} else {
2405
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2406
+		}
2110 2407
 		if ($error != '') {
2111 2408
 			return $error;
2112
-		} elseif ($globalDebug) echo "Done\n";
2113
-		if ($globalDebug) echo "Owner Australia: Download...";
2409
+		} elseif ($globalDebug) {
2410
+			echo "Done\n";
2411
+		}
2412
+		if ($globalDebug) {
2413
+			echo "Owner Australia: Download...";
2414
+		}
2114 2415
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2115 2416
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2116
-			if ($globalDebug) echo "Add to DB...";
2417
+			if ($globalDebug) {
2418
+				echo "Add to DB...";
2419
+			}
2117 2420
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2118
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2421
+		} else {
2422
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2423
+		}
2119 2424
 		if ($error != '') {
2120 2425
 			return $error;
2121
-		} elseif ($globalDebug) echo "Done\n";
2122
-		if ($globalDebug) echo "Owner Austria: Download...";
2426
+		} elseif ($globalDebug) {
2427
+			echo "Done\n";
2428
+		}
2429
+		if ($globalDebug) {
2430
+			echo "Owner Austria: Download...";
2431
+		}
2123 2432
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2124 2433
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2125
-			if ($globalDebug) echo "Add to DB...";
2434
+			if ($globalDebug) {
2435
+				echo "Add to DB...";
2436
+			}
2126 2437
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2127
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2438
+		} else {
2439
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2440
+		}
2128 2441
 		if ($error != '') {
2129 2442
 			return $error;
2130
-		} elseif ($globalDebug) echo "Done\n";
2131
-		if ($globalDebug) echo "Owner Chile: Download...";
2443
+		} elseif ($globalDebug) {
2444
+			echo "Done\n";
2445
+		}
2446
+		if ($globalDebug) {
2447
+			echo "Owner Chile: Download...";
2448
+		}
2132 2449
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2133 2450
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2134
-			if ($globalDebug) echo "Add to DB...";
2451
+			if ($globalDebug) {
2452
+				echo "Add to DB...";
2453
+			}
2135 2454
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2136
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2455
+		} else {
2456
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2457
+		}
2137 2458
 		if ($error != '') {
2138 2459
 			return $error;
2139
-		} elseif ($globalDebug) echo "Done\n";
2140
-		if ($globalDebug) echo "Owner Colombia: Download...";
2460
+		} elseif ($globalDebug) {
2461
+			echo "Done\n";
2462
+		}
2463
+		if ($globalDebug) {
2464
+			echo "Owner Colombia: Download...";
2465
+		}
2141 2466
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2142 2467
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2143
-			if ($globalDebug) echo "Add to DB...";
2468
+			if ($globalDebug) {
2469
+				echo "Add to DB...";
2470
+			}
2144 2471
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2145
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2472
+		} else {
2473
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2474
+		}
2146 2475
 		if ($error != '') {
2147 2476
 			return $error;
2148
-		} elseif ($globalDebug) echo "Done\n";
2149
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2477
+		} elseif ($globalDebug) {
2478
+			echo "Done\n";
2479
+		}
2480
+		if ($globalDebug) {
2481
+			echo "Owner Bosnia Herzegobina: Download...";
2482
+		}
2150 2483
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2151 2484
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2152
-			if ($globalDebug) echo "Add to DB...";
2485
+			if ($globalDebug) {
2486
+				echo "Add to DB...";
2487
+			}
2153 2488
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2154
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2489
+		} else {
2490
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2491
+		}
2155 2492
 		if ($error != '') {
2156 2493
 			return $error;
2157
-		} elseif ($globalDebug) echo "Done\n";
2158
-		if ($globalDebug) echo "Owner Brazil: Download...";
2494
+		} elseif ($globalDebug) {
2495
+			echo "Done\n";
2496
+		}
2497
+		if ($globalDebug) {
2498
+			echo "Owner Brazil: Download...";
2499
+		}
2159 2500
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2160 2501
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2161
-			if ($globalDebug) echo "Add to DB...";
2502
+			if ($globalDebug) {
2503
+				echo "Add to DB...";
2504
+			}
2162 2505
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2163
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2506
+		} else {
2507
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2508
+		}
2164 2509
 		if ($error != '') {
2165 2510
 			return $error;
2166
-		} elseif ($globalDebug) echo "Done\n";
2167
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2511
+		} elseif ($globalDebug) {
2512
+			echo "Done\n";
2513
+		}
2514
+		if ($globalDebug) {
2515
+			echo "Owner Cayman Islands: Download...";
2516
+		}
2168 2517
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2169 2518
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2170
-			if ($globalDebug) echo "Add to DB...";
2519
+			if ($globalDebug) {
2520
+				echo "Add to DB...";
2521
+			}
2171 2522
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2172
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2523
+		} else {
2524
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2525
+		}
2173 2526
 		if ($error != '') {
2174 2527
 			return $error;
2175
-		} elseif ($globalDebug) echo "Done\n";
2176
-		if ($globalDebug) echo "Owner Croatia: Download...";
2528
+		} elseif ($globalDebug) {
2529
+			echo "Done\n";
2530
+		}
2531
+		if ($globalDebug) {
2532
+			echo "Owner Croatia: Download...";
2533
+		}
2177 2534
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2178 2535
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2179
-			if ($globalDebug) echo "Add to DB...";
2536
+			if ($globalDebug) {
2537
+				echo "Add to DB...";
2538
+			}
2180 2539
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2181
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2540
+		} else {
2541
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2542
+		}
2182 2543
 		if ($error != '') {
2183 2544
 			return $error;
2184
-		} elseif ($globalDebug) echo "Done\n";
2185
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2545
+		} elseif ($globalDebug) {
2546
+			echo "Done\n";
2547
+		}
2548
+		if ($globalDebug) {
2549
+			echo "Owner Luxembourg: Download...";
2550
+		}
2186 2551
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2187 2552
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2188
-			if ($globalDebug) echo "Add to DB...";
2553
+			if ($globalDebug) {
2554
+				echo "Add to DB...";
2555
+			}
2189 2556
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2190
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2557
+		} else {
2558
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2559
+		}
2191 2560
 		if ($error != '') {
2192 2561
 			return $error;
2193
-		} elseif ($globalDebug) echo "Done\n";
2194
-		if ($globalDebug) echo "Owner Maldives: Download...";
2562
+		} elseif ($globalDebug) {
2563
+			echo "Done\n";
2564
+		}
2565
+		if ($globalDebug) {
2566
+			echo "Owner Maldives: Download...";
2567
+		}
2195 2568
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2196 2569
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2197
-			if ($globalDebug) echo "Add to DB...";
2570
+			if ($globalDebug) {
2571
+				echo "Add to DB...";
2572
+			}
2198 2573
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2199
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2574
+		} else {
2575
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2576
+		}
2200 2577
 		if ($error != '') {
2201 2578
 			return $error;
2202
-		} elseif ($globalDebug) echo "Done\n";
2203
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2579
+		} elseif ($globalDebug) {
2580
+			echo "Done\n";
2581
+		}
2582
+		if ($globalDebug) {
2583
+			echo "Owner New Zealand: Download...";
2584
+		}
2204 2585
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2205 2586
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2206
-			if ($globalDebug) echo "Add to DB...";
2587
+			if ($globalDebug) {
2588
+				echo "Add to DB...";
2589
+			}
2207 2590
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2208
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2591
+		} else {
2592
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2593
+		}
2209 2594
 		if ($error != '') {
2210 2595
 			return $error;
2211
-		} elseif ($globalDebug) echo "Done\n";
2212
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2596
+		} elseif ($globalDebug) {
2597
+			echo "Done\n";
2598
+		}
2599
+		if ($globalDebug) {
2600
+			echo "Owner Papua New Guinea: Download...";
2601
+		}
2213 2602
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2214 2603
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2215
-			if ($globalDebug) echo "Add to DB...";
2604
+			if ($globalDebug) {
2605
+				echo "Add to DB...";
2606
+			}
2216 2607
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2217
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2608
+		} else {
2609
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2610
+		}
2218 2611
 		if ($error != '') {
2219 2612
 			return $error;
2220
-		} elseif ($globalDebug) echo "Done\n";
2221
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2613
+		} elseif ($globalDebug) {
2614
+			echo "Done\n";
2615
+		}
2616
+		if ($globalDebug) {
2617
+			echo "Owner Slovakia: Download...";
2618
+		}
2222 2619
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2223 2620
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2224
-			if ($globalDebug) echo "Add to DB...";
2621
+			if ($globalDebug) {
2622
+				echo "Add to DB...";
2623
+			}
2225 2624
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2226
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2625
+		} else {
2626
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2627
+		}
2227 2628
 		if ($error != '') {
2228 2629
 			return $error;
2229
-		} elseif ($globalDebug) echo "Done\n";
2230
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2630
+		} elseif ($globalDebug) {
2631
+			echo "Done\n";
2632
+		}
2633
+		if ($globalDebug) {
2634
+			echo "Owner Ecuador: Download...";
2635
+		}
2231 2636
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2232 2637
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2233
-			if ($globalDebug) echo "Add to DB...";
2638
+			if ($globalDebug) {
2639
+				echo "Add to DB...";
2640
+			}
2234 2641
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2235
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2642
+		} else {
2643
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2644
+		}
2236 2645
 		if ($error != '') {
2237 2646
 			return $error;
2238
-		} elseif ($globalDebug) echo "Done\n";
2239
-		if ($globalDebug) echo "Owner Iceland: Download...";
2647
+		} elseif ($globalDebug) {
2648
+			echo "Done\n";
2649
+		}
2650
+		if ($globalDebug) {
2651
+			echo "Owner Iceland: Download...";
2652
+		}
2240 2653
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2241 2654
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2242
-			if ($globalDebug) echo "Add to DB...";
2655
+			if ($globalDebug) {
2656
+				echo "Add to DB...";
2657
+			}
2243 2658
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2244
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2659
+		} else {
2660
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2661
+		}
2245 2662
 		if ($error != '') {
2246 2663
 			return $error;
2247
-		} elseif ($globalDebug) echo "Done\n";
2248
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2664
+		} elseif ($globalDebug) {
2665
+			echo "Done\n";
2666
+		}
2667
+		if ($globalDebug) {
2668
+			echo "Owner Isle of Man: Download...";
2669
+		}
2249 2670
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2250 2671
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2251
-			if ($globalDebug) echo "Add to DB...";
2672
+			if ($globalDebug) {
2673
+				echo "Add to DB...";
2674
+			}
2252 2675
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2253
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2676
+		} else {
2677
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2678
+		}
2254 2679
 		if ($error != '') {
2255 2680
 			return $error;
2256
-		} elseif ($globalDebug) echo "Done\n";
2681
+		} elseif ($globalDebug) {
2682
+			echo "Done\n";
2683
+		}
2257 2684
 		if ($globalMasterSource) {
2258
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2685
+			if ($globalDebug) {
2686
+				echo "ModeS Netherlands: Download...";
2687
+			}
2259 2688
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2260 2689
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2261
-				if ($globalDebug) echo "Add to DB...";
2690
+				if ($globalDebug) {
2691
+					echo "Add to DB...";
2692
+				}
2262 2693
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2263
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2694
+			} else {
2695
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2696
+			}
2264 2697
 			if ($error != '') {
2265 2698
 				return $error;
2266
-			} elseif ($globalDebug) echo "Done\n";
2267
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2699
+			} elseif ($globalDebug) {
2700
+				echo "Done\n";
2701
+			}
2702
+			if ($globalDebug) {
2703
+				echo "ModeS Denmark: Download...";
2704
+			}
2268 2705
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2269 2706
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2270
-				if ($globalDebug) echo "Add to DB...";
2707
+				if ($globalDebug) {
2708
+					echo "Add to DB...";
2709
+				}
2271 2710
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2272
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2711
+			} else {
2712
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2713
+			}
2273 2714
 			if ($error != '') {
2274 2715
 				return $error;
2275
-			} elseif ($globalDebug) echo "Done\n";
2276
-		} elseif ($globalDebug) echo "Done\n";
2716
+			} elseif ($globalDebug) {
2717
+				echo "Done\n";
2718
+			}
2719
+		} elseif ($globalDebug) {
2720
+			echo "Done\n";
2721
+		}
2277 2722
 		return '';
2278 2723
 	}
2279 2724
 
2280 2725
 	public static function update_translation() {
2281 2726
 		global $tmp_dir, $globalDebug;
2282 2727
 		$error = '';
2283
-		if ($globalDebug) echo "Translation : Download...";
2728
+		if ($globalDebug) {
2729
+			echo "Translation : Download...";
2730
+		}
2284 2731
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2285 2732
 		if (file_exists($tmp_dir.'translation.zip')) {
2286
-			if ($globalDebug) echo "Unzip...";
2733
+			if ($globalDebug) {
2734
+				echo "Unzip...";
2735
+			}
2287 2736
 			update_db::unzip($tmp_dir.'translation.zip');
2288
-			if ($globalDebug) echo "Add to DB...";
2737
+			if ($globalDebug) {
2738
+				echo "Add to DB...";
2739
+			}
2289 2740
 			$error = update_db::translation();
2290
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2741
+		} else {
2742
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2743
+		}
2291 2744
 		if ($error != '') {
2292 2745
 			return $error;
2293
-		} elseif ($globalDebug) echo "Done\n";
2746
+		} elseif ($globalDebug) {
2747
+			echo "Done\n";
2748
+		}
2294 2749
 		return '';
2295 2750
 	}
2296 2751
 
2297 2752
 	public static function update_translation_fam() {
2298 2753
 		global $tmp_dir, $globalDebug;
2299
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2754
+		if ($globalDebug) {
2755
+			echo "Translation from FlightAirMap website : Download...";
2756
+		}
2300 2757
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2301 2758
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
2302
-			if ($globalDebug) echo "Gunzip...";
2759
+			if ($globalDebug) {
2760
+				echo "Gunzip...";
2761
+			}
2303 2762
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
2304
-			if ($globalDebug) echo "Add to DB...";
2763
+			if ($globalDebug) {
2764
+				echo "Add to DB...";
2765
+			}
2305 2766
 			$error = update_db::translation_fam();
2306
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2767
+		} else {
2768
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2769
+		}
2307 2770
 		if ($error != '') {
2308 2771
 			return $error;
2309
-		} elseif ($globalDebug) echo "Done\n";
2772
+		} elseif ($globalDebug) {
2773
+			echo "Done\n";
2774
+		}
2310 2775
 		return '';
2311 2776
 	}
2312 2777
 	public static function update_ModeS_fam() {
2313 2778
 		global $tmp_dir, $globalDebug;
2314
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2779
+		if ($globalDebug) {
2780
+			echo "ModeS from FlightAirMap website : Download...";
2781
+		}
2315 2782
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2316 2783
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2317
-			if ($globalDebug) echo "Gunzip...";
2784
+			if ($globalDebug) {
2785
+				echo "Gunzip...";
2786
+			}
2318 2787
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
2319
-			if ($globalDebug) echo "Add to DB...";
2788
+			if ($globalDebug) {
2789
+				echo "Add to DB...";
2790
+			}
2320 2791
 			$error = update_db::modes_fam();
2321
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2792
+		} else {
2793
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2794
+		}
2322 2795
 		if ($error != '') {
2323 2796
 			return $error;
2324
-		} elseif ($globalDebug) echo "Done\n";
2797
+		} elseif ($globalDebug) {
2798
+			echo "Done\n";
2799
+		}
2325 2800
 		return '';
2326 2801
 	}
2327 2802
 	public static function update_owner_fam() {
2328 2803
 		global $tmp_dir, $globalDebug, $globalOwner;
2329
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2804
+		if ($globalDebug) {
2805
+			echo "owner from FlightAirMap website : Download...";
2806
+		}
2330 2807
 		if ($globalOwner === TRUE) {
2331 2808
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2332 2809
 		} else {
2333 2810
 			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2334 2811
 		}
2335 2812
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2336
-			if ($globalDebug) echo "Gunzip...";
2813
+			if ($globalDebug) {
2814
+				echo "Gunzip...";
2815
+			}
2337 2816
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2338
-			if ($globalDebug) echo "Add to DB...";
2817
+			if ($globalDebug) {
2818
+				echo "Add to DB...";
2819
+			}
2339 2820
 			$error = update_db::owner_fam();
2340
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2821
+		} else {
2822
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2823
+		}
2341 2824
 		if ($error != '') {
2342 2825
 			return $error;
2343
-		} elseif ($globalDebug) echo "Done\n";
2826
+		} elseif ($globalDebug) {
2827
+			echo "Done\n";
2828
+		}
2344 2829
 		return '';
2345 2830
 	}
2346 2831
 	public static function update_routes_fam() {
2347 2832
 		global $tmp_dir, $globalDebug;
2348
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2833
+		if ($globalDebug) {
2834
+			echo "Routes from FlightAirMap website : Download...";
2835
+		}
2349 2836
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2350 2837
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2351
-			if ($globalDebug) echo "Gunzip...";
2838
+			if ($globalDebug) {
2839
+				echo "Gunzip...";
2840
+			}
2352 2841
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2353
-			if ($globalDebug) echo "Add to DB...";
2842
+			if ($globalDebug) {
2843
+				echo "Add to DB...";
2844
+			}
2354 2845
 			$error = update_db::routes_fam();
2355
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2846
+		} else {
2847
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2848
+		}
2356 2849
 		if ($error != '') {
2357 2850
 			return $error;
2358
-		} elseif ($globalDebug) echo "Done\n";
2851
+		} elseif ($globalDebug) {
2852
+			echo "Done\n";
2853
+		}
2359 2854
 		return '';
2360 2855
 	}
2361 2856
 	public static function update_marine_identity_fam() {
@@ -2365,14 +2860,22 @@  discard block
 block discarded – undo
2365 2860
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2366 2861
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2367 2862
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2368
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2863
+				if ($globalDebug) {
2864
+					echo "Marine identity from FlightAirMap website : Download...";
2865
+				}
2369 2866
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2370 2867
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2371
-					if ($globalDebug) echo "Gunzip...";
2868
+					if ($globalDebug) {
2869
+						echo "Gunzip...";
2870
+					}
2372 2871
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2373
-					if ($globalDebug) echo "Add to DB...";
2872
+					if ($globalDebug) {
2873
+						echo "Add to DB...";
2874
+					}
2374 2875
 					$error = update_db::marine_identity_fam();
2375
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2876
+				} else {
2877
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2878
+				}
2376 2879
 				if ($error != '') {
2377 2880
 					return $error;
2378 2881
 				} elseif ($globalDebug) {
@@ -2391,14 +2894,22 @@  discard block
 block discarded – undo
2391 2894
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2392 2895
 			$satellite_md5 = $satellite_md5_file[0];
2393 2896
 			if (!update_db::check_satellite_version($satellite_md5)) {
2394
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2897
+				if ($globalDebug) {
2898
+					echo "Satellite from FlightAirMap website : Download...";
2899
+				}
2395 2900
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2396 2901
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2397
-					if ($globalDebug) echo "Gunzip...";
2902
+					if ($globalDebug) {
2903
+						echo "Gunzip...";
2904
+					}
2398 2905
 					update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2399
-					if ($globalDebug) echo "Add to DB...";
2906
+					if ($globalDebug) {
2907
+						echo "Add to DB...";
2908
+					}
2400 2909
 					$error = update_db::satellite_fam();
2401
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2910
+				} else {
2911
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2912
+				}
2402 2913
 				if ($error != '') {
2403 2914
 					return $error;
2404 2915
 				} elseif ($globalDebug) {
@@ -2411,17 +2922,25 @@  discard block
 block discarded – undo
2411 2922
 	}
2412 2923
 	public static function update_banned_fam() {
2413 2924
 		global $tmp_dir, $globalDebug;
2414
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2925
+		if ($globalDebug) {
2926
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2927
+		}
2415 2928
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2416 2929
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2417 2930
 			//if ($globalDebug) echo "Gunzip...";
2418 2931
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2419
-			if ($globalDebug) echo "Add to DB...";
2932
+			if ($globalDebug) {
2933
+				echo "Add to DB...";
2934
+			}
2420 2935
 			$error = update_db::banned_fam();
2421
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2936
+		} else {
2937
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2938
+		}
2422 2939
 		if ($error != '') {
2423 2940
 			return $error;
2424
-		} elseif ($globalDebug) echo "Done\n";
2941
+		} elseif ($globalDebug) {
2942
+			echo "Done\n";
2943
+		}
2425 2944
 		return '';
2426 2945
 	}
2427 2946
 
@@ -2429,7 +2948,9 @@  discard block
 block discarded – undo
2429 2948
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2430 2949
 		include_once('class.create_db.php');
2431 2950
 		$error = '';
2432
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2951
+		if ($globalDebug) {
2952
+			echo "Airspace from FlightAirMap website : Download...";
2953
+		}
2433 2954
 		if ($globalDBdriver == 'mysql') {
2434 2955
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2435 2956
 		} else {
@@ -2445,9 +2966,13 @@  discard block
 block discarded – undo
2445 2966
 					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2446 2967
 				}
2447 2968
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2448
-					if ($globalDebug) echo "Gunzip...";
2969
+					if ($globalDebug) {
2970
+						echo "Gunzip...";
2971
+					}
2449 2972
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2450
-					if ($globalDebug) echo "Add to DB...";
2973
+					if ($globalDebug) {
2974
+						echo "Add to DB...";
2975
+					}
2451 2976
 					$Connection = new Connection();
2452 2977
 					if ($Connection->tableExists('airspace')) {
2453 2978
 						$query = 'DROP TABLE airspace';
@@ -2460,19 +2985,27 @@  discard block
 block discarded – undo
2460 2985
 		    			}
2461 2986
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2462 2987
 					update_db::insert_airspace_version($airspace_md5);
2463
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2988
+				} else {
2989
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2990
+				}
2464 2991
 			}
2465
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2992
+		} else {
2993
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2994
+		}
2466 2995
 		if ($error != '') {
2467 2996
 			return $error;
2468
-		} elseif ($globalDebug) echo "Done\n";
2997
+		} elseif ($globalDebug) {
2998
+			echo "Done\n";
2999
+		}
2469 3000
 		return '';
2470 3001
 	}
2471 3002
 
2472 3003
 	public static function update_geoid_fam() {
2473 3004
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2474 3005
 		$error = '';
2475
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3006
+		if ($globalDebug) {
3007
+			echo "Geoid from FlightAirMap website : Download...";
3008
+		}
2476 3009
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2477 3010
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2478 3011
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2480,75 +3013,113 @@  discard block
 block discarded – undo
2480 3013
 			if (!update_db::check_geoid_version($geoid_md5)) {
2481 3014
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2482 3015
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2483
-					if ($globalDebug) echo "Gunzip...";
3016
+					if ($globalDebug) {
3017
+						echo "Gunzip...";
3018
+					}
2484 3019
 					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2485 3020
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2486 3021
 						update_db::insert_geoid_version($geoid_md5);
2487 3022
 					}
2488
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3023
+				} else {
3024
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3025
+				}
2489 3026
 			}
2490
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3027
+		} else {
3028
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3029
+		}
2491 3030
 		if ($error != '') {
2492 3031
 			return $error;
2493
-		} elseif ($globalDebug) echo "Done\n";
3032
+		} elseif ($globalDebug) {
3033
+			echo "Done\n";
3034
+		}
2494 3035
 		return '';
2495 3036
 	}
2496 3037
 
2497 3038
 	public static function update_tle() {
2498 3039
 		global $tmp_dir, $globalDebug;
2499
-		if ($globalDebug) echo "Download TLE : Download...";
3040
+		if ($globalDebug) {
3041
+			echo "Download TLE : Download...";
3042
+		}
2500 3043
 		$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',
2501 3044
 		'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',
2502 3045
 		'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');
2503 3046
 		foreach ($alltle as $filename) {
2504
-			if ($globalDebug) echo "downloading ".$filename.'...';
3047
+			if ($globalDebug) {
3048
+				echo "downloading ".$filename.'...';
3049
+			}
2505 3050
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2506 3051
 			if (file_exists($tmp_dir.$filename)) {
2507
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3052
+				if ($globalDebug) {
3053
+					echo "Add to DB ".$filename."...";
3054
+				}
2508 3055
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2509
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3056
+			} else {
3057
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3058
+			}
2510 3059
 			if ($error != '') {
2511 3060
 				echo $error."\n";
2512
-			} elseif ($globalDebug) echo "Done\n";
3061
+			} elseif ($globalDebug) {
3062
+				echo "Done\n";
3063
+			}
2513 3064
 		}
2514 3065
 		return '';
2515 3066
 	}
2516 3067
 
2517 3068
 	public static function update_ucsdb() {
2518 3069
 		global $tmp_dir, $globalDebug;
2519
-		if ($globalDebug) echo "Download UCS DB : Download...";
3070
+		if ($globalDebug) {
3071
+			echo "Download UCS DB : Download...";
3072
+		}
2520 3073
 		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');
2521 3074
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2522
-			if ($globalDebug) echo "Add to DB...";
3075
+			if ($globalDebug) {
3076
+				echo "Add to DB...";
3077
+			}
2523 3078
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2524
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3079
+		} else {
3080
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3081
+		}
2525 3082
 		if ($error != '') {
2526 3083
 			echo $error."\n";
2527
-		} elseif ($globalDebug) echo "Done\n";
3084
+		} elseif ($globalDebug) {
3085
+			echo "Done\n";
3086
+		}
2528 3087
 		return '';
2529 3088
 	}
2530 3089
 
2531 3090
 	public static function update_celestrak() {
2532 3091
 		global $tmp_dir, $globalDebug;
2533
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3092
+		if ($globalDebug) {
3093
+			echo "Download Celestrak DB : Download...";
3094
+		}
2534 3095
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2535 3096
 		if (file_exists($tmp_dir.'satcat.txt')) {
2536
-			if ($globalDebug) echo "Add to DB...";
3097
+			if ($globalDebug) {
3098
+				echo "Add to DB...";
3099
+			}
2537 3100
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2538
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3101
+		} else {
3102
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3103
+		}
2539 3104
 		if ($error != '') {
2540 3105
 			echo $error."\n";
2541
-		} elseif ($globalDebug) echo "Done\n";
3106
+		} elseif ($globalDebug) {
3107
+			echo "Done\n";
3108
+		}
2542 3109
 		return '';
2543 3110
 	}
2544 3111
 
2545 3112
 	public static function update_models() {
2546 3113
 		global $tmp_dir, $globalDebug;
2547 3114
 		$error = '';
2548
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3115
+		if ($globalDebug) {
3116
+			echo "Models from FlightAirMap website : Download...";
3117
+		}
2549 3118
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2550 3119
 		if (file_exists($tmp_dir.'models.md5sum')) {
2551
-			if ($globalDebug) echo "Check files...\n";
3120
+			if ($globalDebug) {
3121
+				echo "Check files...\n";
3122
+			}
2552 3123
 			$newmodelsdb = array();
2553 3124
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2554 3125
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2567,25 +3138,35 @@  discard block
 block discarded – undo
2567 3138
 			}
2568 3139
 			$diff = array_diff($newmodelsdb,$modelsdb);
2569 3140
 			foreach ($diff as $key => $value) {
2570
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3141
+				if ($globalDebug) {
3142
+					echo 'Downloading model '.$key.' ...'."\n";
3143
+				}
2571 3144
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2572 3145
 				
2573 3146
 			}
2574 3147
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2575
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3148
+		} else {
3149
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3150
+		}
2576 3151
 		if ($error != '') {
2577 3152
 			return $error;
2578
-		} elseif ($globalDebug) echo "Done\n";
3153
+		} elseif ($globalDebug) {
3154
+			echo "Done\n";
3155
+		}
2579 3156
 		return '';
2580 3157
 	}
2581 3158
 
2582 3159
 	public static function update_space_models() {
2583 3160
 		global $tmp_dir, $globalDebug;
2584 3161
 		$error = '';
2585
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3162
+		if ($globalDebug) {
3163
+			echo "Space models from FlightAirMap website : Download...";
3164
+		}
2586 3165
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2587 3166
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2588
-			if ($globalDebug) echo "Check files...\n";
3167
+			if ($globalDebug) {
3168
+				echo "Check files...\n";
3169
+			}
2589 3170
 			$newmodelsdb = array();
2590 3171
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2591 3172
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2604,25 +3185,35 @@  discard block
 block discarded – undo
2604 3185
 			}
2605 3186
 			$diff = array_diff($newmodelsdb,$modelsdb);
2606 3187
 			foreach ($diff as $key => $value) {
2607
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3188
+				if ($globalDebug) {
3189
+					echo 'Downloading space model '.$key.' ...'."\n";
3190
+				}
2608 3191
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2609 3192
 				
2610 3193
 			}
2611 3194
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2612
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3195
+		} else {
3196
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3197
+		}
2613 3198
 		if ($error != '') {
2614 3199
 			return $error;
2615
-		} elseif ($globalDebug) echo "Done\n";
3200
+		} elseif ($globalDebug) {
3201
+			echo "Done\n";
3202
+		}
2616 3203
 		return '';
2617 3204
 	}
2618 3205
 
2619 3206
 	public static function update_vehicules_models() {
2620 3207
 		global $tmp_dir, $globalDebug;
2621 3208
 		$error = '';
2622
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3209
+		if ($globalDebug) {
3210
+			echo "Vehicules models from FlightAirMap website : Download...";
3211
+		}
2623 3212
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2624 3213
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2625
-			if ($globalDebug) echo "Check files...\n";
3214
+			if ($globalDebug) {
3215
+				echo "Check files...\n";
3216
+			}
2626 3217
 			$newmodelsdb = array();
2627 3218
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2628 3219
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2641,15 +3232,21 @@  discard block
 block discarded – undo
2641 3232
 			}
2642 3233
 			$diff = array_diff($newmodelsdb,$modelsdb);
2643 3234
 			foreach ($diff as $key => $value) {
2644
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3235
+				if ($globalDebug) {
3236
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3237
+				}
2645 3238
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2646 3239
 				
2647 3240
 			}
2648 3241
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2649
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3242
+		} else {
3243
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3244
+		}
2650 3245
 		if ($error != '') {
2651 3246
 			return $error;
2652
-		} elseif ($globalDebug) echo "Done\n";
3247
+		} elseif ($globalDebug) {
3248
+			echo "Done\n";
3249
+		}
2653 3250
 		return '';
2654 3251
 	}
2655 3252
 
@@ -2692,7 +3289,9 @@  discard block
 block discarded – undo
2692 3289
                 }
2693 3290
 
2694 3291
 		$error = '';
2695
-		if ($globalDebug) echo "Notam : Download...";
3292
+		if ($globalDebug) {
3293
+			echo "Notam : Download...";
3294
+		}
2696 3295
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2697 3296
 		if (file_exists($tmp_dir.'notam.rss')) {
2698 3297
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2707,14 +3306,30 @@  discard block
 block discarded – undo
2707 3306
 				$data['fir'] = $q[0];
2708 3307
 				$data['code'] = $q[1];
2709 3308
 				$ifrvfr = $q[2];
2710
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2711
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2712
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2713
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2714
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2715
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2716
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2717
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3309
+				if ($ifrvfr == 'IV') {
3310
+					$data['rules'] = 'IFR/VFR';
3311
+				}
3312
+				if ($ifrvfr == 'I') {
3313
+					$data['rules'] = 'IFR';
3314
+				}
3315
+				if ($ifrvfr == 'V') {
3316
+					$data['rules'] = 'VFR';
3317
+				}
3318
+				if ($q[4] == 'A') {
3319
+					$data['scope'] = 'Airport warning';
3320
+				}
3321
+				if ($q[4] == 'E') {
3322
+					$data['scope'] = 'Enroute warning';
3323
+				}
3324
+				if ($q[4] == 'W') {
3325
+					$data['scope'] = 'Navigation warning';
3326
+				}
3327
+				if ($q[4] == 'AE') {
3328
+					$data['scope'] = 'Airport/Enroute warning';
3329
+				}
3330
+				if ($q[4] == 'AW') {
3331
+					$data['scope'] = 'Airport/Navigation warning';
3332
+				}
2718 3333
 				//$data['scope'] = $q[4];
2719 3334
 				$data['lower_limit'] = $q[5];
2720 3335
 				$data['upper_limit'] = $q[6];
@@ -2722,8 +3337,12 @@  discard block
 block discarded – undo
2722 3337
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2723 3338
 				$latitude = $Common->convertDec($las,'latitude');
2724 3339
 				$longitude = $Common->convertDec($lns,'longitude');
2725
-				if ($lac == 'S') $latitude = '-'.$latitude;
2726
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3340
+				if ($lac == 'S') {
3341
+					$latitude = '-'.$latitude;
3342
+				}
3343
+				if ($lnc == 'W') {
3344
+					$longitude = '-'.$longitude;
3345
+				}
2727 3346
 				$data['center_latitude'] = $latitude;
2728 3347
 				$data['center_longitude'] = $longitude;
2729 3348
 				$data['radius'] = intval($radius);
@@ -2753,10 +3372,14 @@  discard block
 block discarded – undo
2753 3372
 				$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']);
2754 3373
 				unset($data);
2755 3374
 			} 
2756
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3375
+		} else {
3376
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3377
+		}
2757 3378
 		if ($error != '') {
2758 3379
 			return $error;
2759
-		} elseif ($globalDebug) echo "Done\n";
3380
+		} elseif ($globalDebug) {
3381
+			echo "Done\n";
3382
+		}
2760 3383
 		return '';
2761 3384
 	}
2762 3385
 	
@@ -2781,7 +3404,9 @@  discard block
 block discarded – undo
2781 3404
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2782 3405
 		$airspace_json = json_decode($airspace_lst,true);
2783 3406
 		foreach ($airspace_json['records'] as $airspace) {
2784
-			if ($globalDebug) echo $airspace['name']."...\n";
3407
+			if ($globalDebug) {
3408
+				echo $airspace['name']."...\n";
3409
+			}
2785 3410
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2786 3411
 			if (file_exists($tmp_dir.$airspace['name'])) {
2787 3412
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2825,8 +3450,11 @@  discard block
 block discarded – undo
2825 3450
                         return "error : ".$e->getMessage();
2826 3451
                 }
2827 3452
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2828
-                if ($row['nb'] > 0) return false;
2829
-                else return true;
3453
+                if ($row['nb'] > 0) {
3454
+                	return false;
3455
+                } else {
3456
+                	return true;
3457
+                }
2830 3458
 	}
2831 3459
 
2832 3460
 	public static function insert_last_update() {
@@ -2851,8 +3479,11 @@  discard block
 block discarded – undo
2851 3479
                         return "error : ".$e->getMessage();
2852 3480
                 }
2853 3481
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2854
-                if ($row['nb'] > 0) return true;
2855
-                else return false;
3482
+                if ($row['nb'] > 0) {
3483
+                	return true;
3484
+                } else {
3485
+                	return false;
3486
+                }
2856 3487
 	}
2857 3488
 
2858 3489
 	public static function check_geoid_version($version) {
@@ -2865,8 +3496,11 @@  discard block
 block discarded – undo
2865 3496
                         return "error : ".$e->getMessage();
2866 3497
                 }
2867 3498
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2868
-                if ($row['nb'] > 0) return true;
2869
-                else return false;
3499
+                if ($row['nb'] > 0) {
3500
+                	return true;
3501
+                } else {
3502
+                	return false;
3503
+                }
2870 3504
 	}
2871 3505
 
2872 3506
 	public static function check_marine_identity_version($version) {
@@ -2879,8 +3513,11 @@  discard block
 block discarded – undo
2879 3513
 			return "error : ".$e->getMessage();
2880 3514
 		}
2881 3515
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2882
-		if ($row['nb'] > 0) return true;
2883
-		else return false;
3516
+		if ($row['nb'] > 0) {
3517
+			return true;
3518
+		} else {
3519
+			return false;
3520
+		}
2884 3521
 	}
2885 3522
 
2886 3523
 	public static function check_satellite_version($version) {
@@ -2893,8 +3530,11 @@  discard block
 block discarded – undo
2893 3530
 			return "error : ".$e->getMessage();
2894 3531
 		}
2895 3532
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2896
-		if ($row['nb'] > 0) return true;
2897
-		else return false;
3533
+		if ($row['nb'] > 0) {
3534
+			return true;
3535
+		} else {
3536
+			return false;
3537
+		}
2898 3538
 	}
2899 3539
 
2900 3540
 
@@ -2961,8 +3601,11 @@  discard block
 block discarded – undo
2961 3601
                         return "error : ".$e->getMessage();
2962 3602
                 }
2963 3603
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2964
-                if ($row['nb'] > 0) return false;
2965
-                else return true;
3604
+                if ($row['nb'] > 0) {
3605
+                	return false;
3606
+                } else {
3607
+                	return true;
3608
+                }
2966 3609
 	}
2967 3610
 
2968 3611
 	public static function insert_last_notam_update() {
@@ -2992,8 +3635,11 @@  discard block
 block discarded – undo
2992 3635
                         return "error : ".$e->getMessage();
2993 3636
                 }
2994 3637
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2995
-                if ($row['nb'] > 0) return false;
2996
-                else return true;
3638
+                if ($row['nb'] > 0) {
3639
+                	return false;
3640
+                } else {
3641
+                	return true;
3642
+                }
2997 3643
 	}
2998 3644
 
2999 3645
 	public static function insert_last_airspace_update() {
@@ -3023,8 +3669,11 @@  discard block
 block discarded – undo
3023 3669
                         return "error : ".$e->getMessage();
3024 3670
                 }
3025 3671
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3026
-                if ($row['nb'] > 0) return false;
3027
-                else return true;
3672
+                if ($row['nb'] > 0) {
3673
+                	return false;
3674
+                } else {
3675
+                	return true;
3676
+                }
3028 3677
 	}
3029 3678
 
3030 3679
 	public static function insert_last_geoid_update() {
@@ -3054,8 +3703,11 @@  discard block
 block discarded – undo
3054 3703
                         return "error : ".$e->getMessage();
3055 3704
                 }
3056 3705
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3057
-                if ($row['nb'] > 0) return false;
3058
-                else return true;
3706
+                if ($row['nb'] > 0) {
3707
+                	return false;
3708
+                } else {
3709
+                	return true;
3710
+                }
3059 3711
 	}
3060 3712
 
3061 3713
 	public static function insert_last_owner_update() {
@@ -3084,8 +3736,11 @@  discard block
 block discarded – undo
3084 3736
                         return "error : ".$e->getMessage();
3085 3737
                 }
3086 3738
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3087
-                if ($row['nb'] > 0) return false;
3088
-                else return true;
3739
+                if ($row['nb'] > 0) {
3740
+                	return false;
3741
+                } else {
3742
+                	return true;
3743
+                }
3089 3744
 	}
3090 3745
 
3091 3746
 	public static function insert_last_schedules_update() {
@@ -3115,8 +3770,11 @@  discard block
 block discarded – undo
3115 3770
 			return "error : ".$e->getMessage();
3116 3771
 		}
3117 3772
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3118
-		if ($row['nb'] > 0) return false;
3119
-		else return true;
3773
+		if ($row['nb'] > 0) {
3774
+			return false;
3775
+		} else {
3776
+			return true;
3777
+		}
3120 3778
 	}
3121 3779
 
3122 3780
 	public static function insert_last_tle_update() {
@@ -3146,8 +3804,11 @@  discard block
 block discarded – undo
3146 3804
 			return "error : ".$e->getMessage();
3147 3805
 		}
3148 3806
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3149
-		if ($row['nb'] > 0) return false;
3150
-		else return true;
3807
+		if ($row['nb'] > 0) {
3808
+			return false;
3809
+		} else {
3810
+			return true;
3811
+		}
3151 3812
 	}
3152 3813
 
3153 3814
 	public static function insert_last_ucsdb_update() {
@@ -3177,8 +3838,11 @@  discard block
 block discarded – undo
3177 3838
 			return "error : ".$e->getMessage();
3178 3839
 		}
3179 3840
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3180
-		if ($row['nb'] > 0) return false;
3181
-		else return true;
3841
+		if ($row['nb'] > 0) {
3842
+			return false;
3843
+		} else {
3844
+			return true;
3845
+		}
3182 3846
 	}
3183 3847
 
3184 3848
 	public static function insert_last_celestrak_update() {
@@ -3208,8 +3872,11 @@  discard block
 block discarded – undo
3208 3872
 			return "error : ".$e->getMessage();
3209 3873
 		}
3210 3874
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3211
-		if ($row['nb'] > 0) return false;
3212
-		else return true;
3875
+		if ($row['nb'] > 0) {
3876
+			return false;
3877
+		} else {
3878
+			return true;
3879
+		}
3213 3880
 	}
3214 3881
 
3215 3882
 	public static function check_last_satellite_update() {
@@ -3227,8 +3894,11 @@  discard block
 block discarded – undo
3227 3894
 			return "error : ".$e->getMessage();
3228 3895
 		}
3229 3896
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3230
-		if ($row['nb'] > 0) return false;
3231
-		else return true;
3897
+		if ($row['nb'] > 0) {
3898
+			return false;
3899
+		} else {
3900
+			return true;
3901
+		}
3232 3902
 	}
3233 3903
 
3234 3904
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.