Completed
Push — master ( 5e46c3...387cf9 )
by Yannick
47:50 queued 16:30
created
scripts/update_db.php 1 patch
Braces   +30 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,7 +11,9 @@  discard block
 block discarded – undo
11 11
 	if(function_exists('exec')) {
12 12
 		exec("ps ux", $output, $result);
13 13
 		$j = 0;
14
-		foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
14
+		foreach ($output as $line) {
15
+			if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
16
+		}
15 17
 		if ($j > 1) {
16 18
 			echo "Script is already runnning...";
17 19
 			die();
@@ -30,14 +32,18 @@  discard block
 block discarded – undo
30 32
 			$update_db->update_notam();
31 33
 		}
32 34
 		$update_db->insert_last_notam_update();
33
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
35
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
36
+		echo "NOTAM are only updated once a day.\n";
37
+	}
34 38
 	if ((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft)) && ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS))) {
35 39
 		$update_db->update_all();
36 40
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
37 41
 	//	$Spotter = new Spotter();
38 42
 	//	$Spotter->updateFieldsFromOtherTables();
39 43
 		$update_db->insert_last_update();
40
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
44
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
45
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
46
+	}
41 47
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
42 48
 		echo "Check if new airspace version exist...";
43 49
 		echo $update_db->update_airspace_fam();
@@ -46,8 +52,11 @@  discard block
 block discarded – undo
46 52
 	if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) {
47 53
 		echo "Check if new geoid version exist...";
48 54
 		$error = $update_db->update_geoid_fam();
49
-		if ($error == '') $update_db->insert_last_geoid_update();
50
-		else echo $error;
55
+		if ($error == '') {
56
+			$update_db->insert_last_geoid_update();
57
+		} else {
58
+			echo $error;
59
+		}
51 60
 	}
52 61
 	if (isset($globalMarine) && $globalMarine && (!isset($globalVM) || $globalVM === FALSE) && $update_db->check_last_marine_identity_update()) {
53 62
 		echo "Check if new marine identity version exist...";
@@ -65,13 +74,17 @@  discard block
 block discarded – undo
65 74
 			//echo "Done";
66 75
 		}
67 76
 		$update_db->insert_last_owner_update();
68
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
77
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
78
+		echo "Owner are only updated every 15 days.\n";
79
+	}
69 80
 
70 81
 	if ((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft)) && ($update_db->check_last_airlines_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS))) {
71 82
 		echo "Updating airlines...\n";
72 83
 		echo $update_db->update_airlines_fam();
73 84
 		$update_db->insert_last_airlines_update();
74
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Airlines are only updated every 15 days.\n";
85
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
86
+		echo "Airlines are only updated every 15 days.\n";
87
+	}
75 88
 
76 89
 	if ((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft)) && (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS))) {
77 90
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -80,7 +93,9 @@  discard block
 block discarded – undo
80 93
 		if ($Accident->check_last_accidents_update()) {
81 94
 			$Accident->download_update();
82 95
 			$Accident->insert_last_accidents_update();
83
-		} else echo "Accidents are updated once a day.\n";
96
+		} else {
97
+			echo "Accidents are updated once a day.\n";
98
+		}
84 99
 	}
85 100
   
86 101
 }
@@ -93,7 +108,9 @@  discard block
 block discarded – undo
93 108
 		if ($METAR->check_last_update()) {
94 109
 			$METAR->addMETARCycle();
95 110
 			$METAR->insert_last_update();
96
-		} else echo "METAR are only updated every 30 minutes.\n";
111
+		} else {
112
+			echo "METAR are only updated every 30 minutes.\n";
113
+		}
97 114
 	}
98 115
 
99 116
 	if ((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft)) && (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS))) {
@@ -101,8 +118,10 @@  discard block
 block discarded – undo
101 118
 		//$update_db->update_oneworld();
102 119
 		$update_db->update_skyteam();
103 120
 		$update_db->insert_last_schedules_update();
104
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
105
-}
121
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
122
+		echo "Schedules are only updated every 15 days.\n";
123
+	}
124
+	}
106 125
 
107 126
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
108 127
 	echo "Updating statistics and archive old data...\n";
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +1220 added lines, -422 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 27
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28 28
 		curl_setopt($ch, CURLOPT_TIMEOUT, 200);
29
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
29
+		if ($referer != '') {
30
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
31
+		}
30 32
 		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');
31 33
 		curl_setopt($ch, CURLOPT_FILE, $fp);
32 34
 		curl_exec($ch);
@@ -37,12 +39,16 @@  discard block
 block discarded – undo
37 39
 	public static function gunzip($in_file,$out_file_name = '') {
38 40
 		//echo $in_file.' -> '.$out_file_name."\n";
39 41
 		$buffer_size = 4096; // read 4kb at a time
40
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
42
+		if ($out_file_name == '') {
43
+			$out_file_name = str_replace('.gz', '', $in_file);
44
+		}
41 45
 		if ($in_file != '' && file_exists($in_file)) {
42 46
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
45
-			else {
47
+			if (function_exists('gzopen')) {
48
+				$file = gzopen($in_file,'rb');
49
+			} elseif (function_exists('gzopen64')) {
50
+				$file = gzopen64($in_file,'rb');
51
+			} else {
46 52
 				echo 'gzopen not available';
47 53
 				die;
48 54
 			}
@@ -63,8 +69,12 @@  discard block
 block discarded – undo
63 69
 			if ($res === TRUE) {
64 70
 				$zip->extractTo($path);
65 71
 				$zip->close();
66
-			} else return false;
67
-		} else return false;
72
+			} else {
73
+				return false;
74
+			}
75
+		} else {
76
+			return false;
77
+		}
68 78
 	}
69 79
 	
70 80
 	public static function connect_sqlite($database) {
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 90
 		global $globalDebug, $globalTransaction;
81 91
 		//$query = 'TRUNCATE TABLE routes';
82
-		if ($globalDebug) echo " - Delete previous routes from DB -";
92
+		if ($globalDebug) {
93
+			echo " - Delete previous routes from DB -";
94
+		}
83 95
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
84 96
 		$Connection = new Connection();
85 97
 		try {
@@ -90,7 +102,9 @@  discard block
 block discarded – undo
90 102
                         return "error : ".$e->getMessage();
91 103
                 }
92 104
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
105
+    		if ($globalDebug) {
106
+    			echo " - Add routes to DB -";
107
+    		}
94 108
     		update_db::connect_sqlite($database_file);
95 109
 		//$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';
96 110
 		$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";
@@ -105,15 +119,21 @@  discard block
 block discarded – undo
105 119
 		$Connection = new Connection();
106 120
 		$sth_dest = $Connection->db->prepare($query_dest);
107 121
 		try {
108
-			if ($globalTransaction) $Connection->db->beginTransaction();
122
+			if ($globalTransaction) {
123
+				$Connection->db->beginTransaction();
124
+			}
109 125
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 126
 				//$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);
111 127
 				$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);
112 128
 				$sth_dest->execute($query_dest_values);
113 129
             		}
114
-			if ($globalTransaction) $Connection->db->commit();
130
+			if ($globalTransaction) {
131
+				$Connection->db->commit();
132
+			}
115 133
 		} catch(PDOException $e) {
116
-			if ($globalTransaction) $Connection->db->rollBack(); 
134
+			if ($globalTransaction) {
135
+				$Connection->db->rollBack();
136
+			}
117 137
 			return "error : ".$e->getMessage();
118 138
 		}
119 139
                 return '';
@@ -121,7 +141,9 @@  discard block
 block discarded – undo
121 141
 	public static function retrieve_route_oneworld($database_file) {
122 142
 		global $globalDebug, $globalTransaction;
123 143
 		//$query = 'TRUNCATE TABLE routes';
124
-		if ($globalDebug) echo " - Delete previous routes from DB -";
144
+		if ($globalDebug) {
145
+			echo " - Delete previous routes from DB -";
146
+		}
125 147
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
126 148
 		$Connection = new Connection();
127 149
 		try {
@@ -132,14 +154,18 @@  discard block
 block discarded – undo
132 154
                         return "error : ".$e->getMessage();
133 155
                 }
134 156
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
157
+    		if ($globalDebug) {
158
+    			echo " - Add routes to DB -";
159
+    		}
136 160
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 161
 		$Spotter = new Spotter();
138 162
 		if ($fh = fopen($database_file,"r")) {
139 163
 			$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)';
140 164
 			$Connection = new Connection();
141 165
 			$sth_dest = $Connection->db->prepare($query_dest);
142
-			if ($globalTransaction) $Connection->db->beginTransaction();
166
+			if ($globalTransaction) {
167
+				$Connection->db->beginTransaction();
168
+			}
143 169
 			while (!feof($fh)) {
144 170
 				$line = fgetcsv($fh,9999,',');
145 171
 				if ($line[0] != '') {
@@ -148,13 +174,17 @@  discard block
 block discarded – undo
148 174
 							$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');
149 175
 							$sth_dest->execute($query_dest_values);
150 176
 						} catch(PDOException $e) {
151
-							if ($globalTransaction) $Connection->db->rollBack(); 
177
+							if ($globalTransaction) {
178
+								$Connection->db->rollBack();
179
+							}
152 180
 							return "error : ".$e->getMessage();
153 181
 						}
154 182
 					}
155 183
 				}
156 184
 			}
157
-			if ($globalTransaction) $Connection->db->commit();
185
+			if ($globalTransaction) {
186
+				$Connection->db->commit();
187
+			}
158 188
 		}
159 189
                 return '';
160 190
 	}
@@ -162,7 +192,9 @@  discard block
 block discarded – undo
162 192
 	public static function retrieve_route_skyteam($database_file) {
163 193
 		global $globalDebug, $globalTransaction;
164 194
 		//$query = 'TRUNCATE TABLE routes';
165
-		if ($globalDebug) echo " - Delete previous routes from DB -";
195
+		if ($globalDebug) {
196
+			echo " - Delete previous routes from DB -";
197
+		}
166 198
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
167 199
 		$Connection = new Connection();
168 200
 		try {
@@ -173,7 +205,9 @@  discard block
 block discarded – undo
173 205
                         return "error : ".$e->getMessage();
174 206
                 }
175 207
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
208
+    		if ($globalDebug) {
209
+    			echo " - Add routes to DB -";
210
+    		}
177 211
 
178 212
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 213
 		$Spotter = new Spotter();
@@ -182,7 +216,9 @@  discard block
 block discarded – undo
182 216
 			$Connection = new Connection();
183 217
 			$sth_dest = $Connection->db->prepare($query_dest);
184 218
 			try {
185
-				if ($globalTransaction) $Connection->db->beginTransaction();
219
+				if ($globalTransaction) {
220
+					$Connection->db->beginTransaction();
221
+				}
186 222
 				while (!feof($fh)) {
187 223
 					$line = fgetcsv($fh,9999,',');
188 224
 					if ($line[0] != '') {
@@ -193,9 +229,13 @@  discard block
 block discarded – undo
193 229
 						}
194 230
 					}
195 231
 				}
196
-				if ($globalTransaction) $Connection->db->commit();
232
+				if ($globalTransaction) {
233
+					$Connection->db->commit();
234
+				}
197 235
 			} catch(PDOException $e) {
198
-				if ($globalTransaction) $Connection->db->rollBack(); 
236
+				if ($globalTransaction) {
237
+					$Connection->db->rollBack();
238
+				}
199 239
 				return "error : ".$e->getMessage();
200 240
 			}
201 241
 		}
@@ -238,11 +278,16 @@  discard block
 block discarded – undo
238 278
 		$sth_dest = $Connection->db->prepare($query_dest);
239 279
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 280
 		try {
241
-			if ($globalTransaction) $Connection->db->beginTransaction();
281
+			if ($globalTransaction) {
282
+				$Connection->db->beginTransaction();
283
+			}
242 284
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 285
 			//$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']);
244
-				if ($values['UserString4'] == 'M') $type = 'military';
245
-				else $type = null;
286
+				if ($values['UserString4'] == 'M') {
287
+					$type = 'military';
288
+				} else {
289
+					$type = null;
290
+				}
246 291
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 292
 				$sth_dest->execute($query_dest_values);
248 293
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -250,7 +295,9 @@  discard block
 block discarded – undo
250 295
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 296
 				}
252 297
             		}
253
-			if ($globalTransaction) $Connection->db->commit();
298
+			if ($globalTransaction) {
299
+				$Connection->db->commit();
300
+			}
254 301
 		} catch(PDOException $e) {
255 302
 			return "error : ".$e->getMessage();
256 303
 		}
@@ -287,7 +334,9 @@  discard block
 block discarded – undo
287 334
 			$Connection = new Connection();
288 335
 			$sth_dest = $Connection->db->prepare($query_dest);
289 336
 			try {
290
-				if ($globalTransaction) $Connection->db->beginTransaction();
337
+				if ($globalTransaction) {
338
+					$Connection->db->beginTransaction();
339
+				}
291 340
             			while (!feof($fh)) {
292 341
             				$values = array();
293 342
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -298,7 +347,9 @@  discard block
 block discarded – undo
298 347
             				// Check if we can find ICAO, else set it to GLID
299 348
             				$aircraft_name_split = explode(' ',$aircraft_name);
300 349
             				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
350
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
351
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
352
+            				}
302 353
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303 354
             				$sth_search = $Connection->db->prepare($query_search);
304 355
 					try {
@@ -311,7 +362,9 @@  discard block
 block discarded – undo
311 362
 					} catch(PDOException $e) {
312 363
 						return "error : ".$e->getMessage();
313 364
 					}
314
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
365
+					if (!isset($values['ICAOTypeCode'])) {
366
+						$values['ICAOTypeCode'] = 'GLID';
367
+					}
315 368
 					// Add data to db
316 369
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 370
 						//$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']);
@@ -320,7 +373,9 @@  discard block
 block discarded – undo
320 373
 						$sth_dest->execute($query_dest_values);
321 374
 					}
322 375
 				}
323
-				if ($globalTransaction) $Connection->db->commit();
376
+				if ($globalTransaction) {
377
+					$Connection->db->commit();
378
+				}
324 379
 			} catch(PDOException $e) {
325 380
 				return "error : ".$e->getMessage();
326 381
 			}
@@ -356,7 +411,9 @@  discard block
 block discarded – undo
356 411
 			$Connection = new Connection();
357 412
 			$sth_dest = $Connection->db->prepare($query_dest);
358 413
 			try {
359
-				if ($globalTransaction) $Connection->db->beginTransaction();
414
+				if ($globalTransaction) {
415
+					$Connection->db->beginTransaction();
416
+				}
360 417
 				$tmp = fgetcsv($fh,9999,',',"'");
361 418
             			while (!feof($fh)) {
362 419
             				$line = fgetcsv($fh,9999,',',"'");
@@ -370,13 +427,17 @@  discard block
 block discarded – undo
370 427
             				// Check if we can find ICAO, else set it to GLID
371 428
             				$aircraft_name_split = explode(' ',$aircraft_name);
372 429
             				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
430
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
431
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
432
+            				}
374 433
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375 434
             				$sth_search = $Connection->db->prepare($query_search);
376 435
 					try {
377 436
                                     		$sth_search->execute();
378 437
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
438
+	            				if (isset($result['icao']) && $result['icao'] != '') {
439
+	            					$values['ICAOTypeCode'] = $result['icao'];
440
+	            				}
380 441
 					} catch(PDOException $e) {
381 442
 						return "error : ".$e->getMessage();
382 443
 					}
@@ -389,7 +450,9 @@  discard block
 block discarded – undo
389 450
 						$sth_dest->execute($query_dest_values);
390 451
 					}
391 452
 				}
392
-				if ($globalTransaction) $Connection->db->commit();
453
+				if ($globalTransaction) {
454
+					$Connection->db->commit();
455
+				}
393 456
 			} catch(PDOException $e) {
394 457
 				return "error : ".$e->getMessage();
395 458
 			}
@@ -428,7 +491,9 @@  discard block
 block discarded – undo
428 491
 			$sth_dest = $Connection->db->prepare($query_dest);
429 492
 			$sth_modes = $Connection->db->prepare($query_modes);
430 493
 			try {
431
-				if ($globalTransaction) $Connection->db->beginTransaction();
494
+				if ($globalTransaction) {
495
+					$Connection->db->beginTransaction();
496
+				}
432 497
 				$tmp = fgetcsv($fh,9999,',','"');
433 498
             			while (!feof($fh)) {
434 499
             				$line = fgetcsv($fh,9999,',','"');
@@ -438,16 +503,22 @@  discard block
 block discarded – undo
438 503
             				    $values['registration'] = $line[0];
439 504
             				    $values['base'] = $line[4];
440 505
             				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+            				    if ($line[6] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
510
+					    }
443 511
 					    $values['cancel'] = $line[7];
444 512
 					} elseif ($country == 'EI') {
445 513
 					    // TODO : add modeS & reg to aircraft_modes
446 514
             				    $values['registration'] = $line[0];
447 515
             				    $values['base'] = $line[3];
448 516
             				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
517
+            				    if ($line[1] == '') {
518
+            				    	$values['date_first_reg'] = null;
519
+            				    } else {
520
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
521
+					    }
451 522
 					    $values['cancel'] = '';
452 523
 					    $values['modes'] = $line[7];
453 524
 					    $values['icao'] = $line[8];
@@ -466,16 +537,22 @@  discard block
 block discarded – undo
466 537
             				    $values['registration'] = $line[3];
467 538
             				    $values['base'] = null;
468 539
             				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
540
+            				    if ($line[18] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
544
+					    }
471 545
 					    $values['cancel'] = '';
472 546
 					} elseif ($country == 'VH') {
473 547
 					    // TODO : add modeS & reg to aircraft_modes
474 548
             				    $values['registration'] = $line[0];
475 549
             				    $values['base'] = null;
476 550
             				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
551
+            				    if ($line[28] == '') {
552
+            				    	$values['date_first_reg'] = null;
553
+            				    } else {
554
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
555
+					    }
479 556
 
480 557
 					    $values['cancel'] = $line[39];
481 558
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -494,29 +571,41 @@  discard block
 block discarded – undo
494 571
             				    $values['registration'] = $line[0];
495 572
             				    $values['base'] = null;
496 573
             				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
574
+            				    if ($line[7] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
578
+					    }
499 579
 					    $values['cancel'] = '';
500 580
 					} elseif ($country == 'PP') {
501 581
             				    $values['registration'] = $line[0];
502 582
             				    $values['base'] = null;
503 583
             				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
584
+            				    if ($line[6] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
588
+					    }
506 589
 					    $values['cancel'] = $line[7];
507 590
 					} elseif ($country == 'E7') {
508 591
             				    $values['registration'] = $line[0];
509 592
             				    $values['base'] = null;
510 593
             				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
594
+            				    if ($line[5] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
598
+					    }
513 599
 					    $values['cancel'] = '';
514 600
 					} elseif ($country == '8Q') {
515 601
             				    $values['registration'] = $line[0];
516 602
             				    $values['base'] = null;
517 603
             				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
604
+            				    if ($line[7] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
608
+					    }
520 609
 					    $values['cancel'] = '';
521 610
 					} elseif ($country == 'ZK') {
522 611
             				    $values['registration'] = $line[0];
@@ -561,7 +650,9 @@  discard block
 block discarded – undo
561 650
 						$sth_modes->execute($query_modes_values);
562 651
 					}
563 652
 				}
564
-				if ($globalTransaction) $Connection->db->commit();
653
+				if ($globalTransaction) {
654
+					$Connection->db->commit();
655
+				}
565 656
 			} catch(PDOException $e) {
566 657
 				return "error : ".$e->getMessage();
567 658
 			}
@@ -697,25 +788,45 @@  discard block
 block discarded – undo
697 788
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
698 789
 		$Connection = new Connection();
699 790
 		$sth_dest = $Connection->db->prepare($query_dest);
700
-		if ($globalTransaction) $Connection->db->beginTransaction();
791
+		if ($globalTransaction) {
792
+			$Connection->db->beginTransaction();
793
+		}
701 794
   
702 795
 		$i = 0;
703 796
 		while($row = sparql_fetch_array($result))
704 797
 		{
705 798
 			if ($i >= 1) {
706 799
 			//print_r($row);
707
-			if (!isset($row['iata'])) $row['iata'] = '';
708
-			if (!isset($row['icao'])) $row['icao'] = '';
709
-			if (!isset($row['type'])) $row['type'] = '';
710
-			if (!isset($row['altitude'])) $row['altitude'] = '';
800
+			if (!isset($row['iata'])) {
801
+				$row['iata'] = '';
802
+			}
803
+			if (!isset($row['icao'])) {
804
+				$row['icao'] = '';
805
+			}
806
+			if (!isset($row['type'])) {
807
+				$row['type'] = '';
808
+			}
809
+			if (!isset($row['altitude'])) {
810
+				$row['altitude'] = '';
811
+			}
711 812
 			if (isset($row['city_bis'])) {
712 813
 				$row['city'] = $row['city_bis'];
713 814
 			}
714
-			if (!isset($row['city'])) $row['city'] = '';
715
-			if (!isset($row['country'])) $row['country'] = '';
716
-			if (!isset($row['homepage'])) $row['homepage'] = '';
717
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
718
-			if (!isset($row['name'])) continue;
815
+			if (!isset($row['city'])) {
816
+				$row['city'] = '';
817
+			}
818
+			if (!isset($row['country'])) {
819
+				$row['country'] = '';
820
+			}
821
+			if (!isset($row['homepage'])) {
822
+				$row['homepage'] = '';
823
+			}
824
+			if (!isset($row['wikipedia_page'])) {
825
+				$row['wikipedia_page'] = '';
826
+			}
827
+			if (!isset($row['name'])) {
828
+				continue;
829
+			}
719 830
 			if (!isset($row['image'])) {
720 831
 				$row['image'] = '';
721 832
 				$row['image_thumb'] = '';
@@ -771,7 +882,9 @@  discard block
 block discarded – undo
771 882
 
772 883
 			$i++;
773 884
 		}
774
-		if ($globalTransaction) $Connection->db->commit();
885
+		if ($globalTransaction) {
886
+			$Connection->db->commit();
887
+		}
775 888
 		/*
776 889
 		echo "Delete duplicate rows...\n";
777 890
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -814,7 +927,9 @@  discard block
 block discarded – undo
814 927
 		$delimiter = ',';
815 928
 		$out_file = $tmp_dir.'airports.csv';
816 929
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
817
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
930
+		if (!file_exists($out_file) || !is_readable($out_file)) {
931
+			return FALSE;
932
+		}
818 933
 		echo "Add data from ourairports.com...\n";
819 934
 
820 935
 		$header = NULL;
@@ -824,8 +939,9 @@  discard block
 block discarded – undo
824 939
 			//$Connection->db->beginTransaction();
825 940
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 941
 			{
827
-				if(!$header) $header = $row;
828
-				else {
942
+				if(!$header) {
943
+					$header = $row;
944
+				} else {
829 945
 					$data = array();
830 946
 					$data = array_combine($header, $row);
831 947
 					try {
@@ -866,7 +982,9 @@  discard block
 block discarded – undo
866 982
 		echo "Download data from another free database...\n";
867 983
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868 984
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
869
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
985
+		if (!file_exists($out_file) || !is_readable($out_file)) {
986
+			return FALSE;
987
+		}
870 988
 		update_db::unzip($out_file);
871 989
 		$header = NULL;
872 990
 		echo "Add data from another free database...\n";
@@ -877,8 +995,9 @@  discard block
 block discarded – undo
877 995
 			//$Connection->db->beginTransaction();
878 996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 997
 			{
880
-				if(!$header) $header = $row;
881
-				else {
998
+				if(!$header) {
999
+					$header = $row;
1000
+				} else {
882 1001
 					$data = $row;
883 1002
 
884 1003
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1047,7 +1166,9 @@  discard block
 block discarded – undo
1047 1166
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1048 1167
 		{
1049 1168
 			$i = 0;
1050
-			if ($globalTransaction) $Connection->db->beginTransaction();
1169
+			if ($globalTransaction) {
1170
+				$Connection->db->beginTransaction();
1171
+			}
1051 1172
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1052 1173
 			{
1053 1174
 				if ($i > 0) {
@@ -1060,7 +1181,9 @@  discard block
 block discarded – undo
1060 1181
 					}
1061 1182
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1062 1183
 					if (!empty($result_search)) {
1063
-						if ($globalDebug) echo '.';
1184
+						if ($globalDebug) {
1185
+							echo '.';
1186
+						}
1064 1187
 							//if ($globalDBdriver == 'mysql') {
1065 1188
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1066 1189
 							//} else {
@@ -1082,8 +1205,12 @@  discard block
 block discarded – undo
1082 1205
 						}
1083 1206
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1084 1207
 						if (!empty($result_search_mfr)) {
1085
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1086
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1208
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1209
+								$data[16] = $data[23];
1210
+							}
1211
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1212
+								$data[16] = $data[15];
1213
+							}
1087 1214
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1215
 							try {
1089 1216
 								$sthf = $Connection->db->prepare($queryf);
@@ -1094,7 +1221,9 @@  discard block
 block discarded – undo
1094 1221
 						}
1095 1222
 					}
1096 1223
 					if (strtotime($data[29]) > time()) {
1097
-						if ($globalDebug) echo 'i';
1224
+						if ($globalDebug) {
1225
+							echo 'i';
1226
+						}
1098 1227
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1228
 						try {
1100 1229
 							$sth = $Connection->db->prepare($query);
@@ -1105,13 +1234,19 @@  discard block
 block discarded – undo
1105 1234
 					}
1106 1235
 				}
1107 1236
 				if ($i % 90 == 0) {
1108
-					if ($globalTransaction) $Connection->db->commit();
1109
-					if ($globalTransaction) $Connection->db->beginTransaction();
1237
+					if ($globalTransaction) {
1238
+						$Connection->db->commit();
1239
+					}
1240
+					if ($globalTransaction) {
1241
+						$Connection->db->beginTransaction();
1242
+					}
1110 1243
 				}
1111 1244
 				$i++;
1112 1245
 			}
1113 1246
 			fclose($handle);
1114
-			if ($globalTransaction) $Connection->db->commit();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->commit();
1249
+			}
1115 1250
 		}
1116 1251
 		return '';
1117 1252
 	}
@@ -1131,11 +1266,15 @@  discard block
 block discarded – undo
1131 1266
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1132 1267
 		{
1133 1268
 			$i = 0;
1134
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1135 1272
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1136 1273
 			{
1137 1274
 				if ($i > 0) {
1138
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1275
+					if ($data[1] == 'NULL') {
1276
+						$data[1] = $data[0];
1277
+					}
1139 1278
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1279
 					try {
1141 1280
 						$sth = $Connection->db->prepare($query);
@@ -1147,7 +1286,9 @@  discard block
 block discarded – undo
1147 1286
 				$i++;
1148 1287
 			}
1149 1288
 			fclose($handle);
1150
-			if ($globalTransaction) $Connection->db->commit();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->commit();
1291
+			}
1151 1292
 		}
1152 1293
 		return '';
1153 1294
 	}
@@ -1179,11 +1320,15 @@  discard block
 block discarded – undo
1179 1320
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1180 1321
 		{
1181 1322
 			$i = 0;
1182
-			if ($globalTransaction) $Connection->db->beginTransaction();
1323
+			if ($globalTransaction) {
1324
+				$Connection->db->beginTransaction();
1325
+			}
1183 1326
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1184 1327
 			{
1185 1328
 				if ($i > 0) {
1186
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1329
+					if ($data[1] == 'NULL') {
1330
+						$data[1] = $data[0];
1331
+					}
1187 1332
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1333
 					try {
1189 1334
 						$sth = $Connection->db->prepare($query);
@@ -1195,7 +1340,9 @@  discard block
 block discarded – undo
1195 1340
 				$i++;
1196 1341
 			}
1197 1342
 			fclose($handle);
1198
-			if ($globalTransaction) $Connection->db->commit();
1343
+			if ($globalTransaction) {
1344
+				$Connection->db->commit();
1345
+			}
1199 1346
 		}
1200 1347
 		/*
1201 1348
 		$query = "UNLOCK TABLES";
@@ -1225,7 +1372,9 @@  discard block
 block discarded – undo
1225 1372
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1226 1373
 		{
1227 1374
 			$i = 0;
1228
-			if ($globalTransaction) $Connection->db->beginTransaction();
1375
+			if ($globalTransaction) {
1376
+				$Connection->db->beginTransaction();
1377
+			}
1229 1378
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1230 1379
 			{
1231 1380
 				if ($i > 0) {
@@ -1241,7 +1390,9 @@  discard block
 block discarded – undo
1241 1390
 				$i++;
1242 1391
 			}
1243 1392
 			fclose($handle);
1244
-			if ($globalTransaction) $Connection->db->commit();
1393
+			if ($globalTransaction) {
1394
+				$Connection->db->commit();
1395
+			}
1245 1396
 		}
1246 1397
 		return '';
1247 1398
         }
@@ -1261,7 +1412,9 @@  discard block
 block discarded – undo
1261 1412
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1262 1413
 		{
1263 1414
 			$i = 0;
1264
-			if ($globalTransaction) $Connection->db->beginTransaction();
1415
+			if ($globalTransaction) {
1416
+				$Connection->db->beginTransaction();
1417
+			}
1265 1418
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1266 1419
 			{
1267 1420
 				if ($i > 0) {
@@ -1271,19 +1424,25 @@  discard block
 block discarded – undo
1271 1424
 						$sth = $Connection->db->prepare($query);
1272 1425
 						$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'));
1273 1426
 					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1427
+						if ($globalDebug) {
1428
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1429
+						}
1275 1430
 						die();
1276 1431
 					}
1277 1432
 				}
1278 1433
 				if ($globalTransaction && $i % 2000 == 0) {
1279 1434
 					$Connection->db->commit();
1280
-					if ($globalDebug) echo '.';
1435
+					if ($globalDebug) {
1436
+						echo '.';
1437
+					}
1281 1438
 					$Connection->db->beginTransaction();
1282 1439
 				}
1283 1440
 				$i++;
1284 1441
 			}
1285 1442
 			fclose($handle);
1286
-			if ($globalTransaction) $Connection->db->commit();
1443
+			if ($globalTransaction) {
1444
+				$Connection->db->commit();
1445
+			}
1287 1446
 		}
1288 1447
 		return '';
1289 1448
 	}
@@ -1302,7 +1461,9 @@  discard block
 block discarded – undo
1302 1461
 		if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE)
1303 1462
 		{
1304 1463
 			$i = 0;
1305
-			if ($globalTransaction) $Connection->db->beginTransaction();
1464
+			if ($globalTransaction) {
1465
+				$Connection->db->beginTransaction();
1466
+			}
1306 1467
 			while (($data = fgets($handle, 1000)) !== FALSE)
1307 1468
 			{
1308 1469
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
@@ -1310,18 +1471,24 @@  discard block
 block discarded – undo
1310 1471
 					$sth = $Connection->db->prepare($query);
1311 1472
 					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1312 1473
 				} catch(PDOException $e) {
1313
-					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1474
+					if ($globalDebug) {
1475
+						echo "error: ".$e->getMessage()." - data: ".$data;
1476
+					}
1314 1477
 					die();
1315 1478
 				}
1316 1479
 				if ($globalTransaction && $i % 2000 == 0) {
1317 1480
 					$Connection->db->commit();
1318
-					if ($globalDebug) echo '.';
1481
+					if ($globalDebug) {
1482
+						echo '.';
1483
+					}
1319 1484
 					$Connection->db->beginTransaction();
1320 1485
 				}
1321 1486
 				$i++;
1322 1487
 			}
1323 1488
 			fclose($handle);
1324
-			if ($globalTransaction) $Connection->db->commit();
1489
+			if ($globalTransaction) {
1490
+				$Connection->db->commit();
1491
+			}
1325 1492
 		}
1326 1493
 		return '';
1327 1494
         }
@@ -1346,7 +1513,9 @@  discard block
 block discarded – undo
1346 1513
 			$i = 0;
1347 1514
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1348 1515
 			//$Connection->db->beginTransaction();
1349
-			if ($globalTransaction) $Connection->db->beginTransaction();
1516
+			if ($globalTransaction) {
1517
+				$Connection->db->beginTransaction();
1518
+			}
1350 1519
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1351 1520
 			{
1352 1521
 				if ($i > 0) {
@@ -1362,7 +1531,9 @@  discard block
 block discarded – undo
1362 1531
 				$i++;
1363 1532
 			}
1364 1533
 			fclose($handle);
1365
-			if ($globalTransaction) $Connection->db->commit();
1534
+			if ($globalTransaction) {
1535
+				$Connection->db->commit();
1536
+			}
1366 1537
 		}
1367 1538
 		return '';
1368 1539
         }
@@ -1382,7 +1553,9 @@  discard block
 block discarded – undo
1382 1553
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1383 1554
 		{
1384 1555
 			$i = 0;
1385
-			if ($globalTransaction) $Connection->db->beginTransaction();
1556
+			if ($globalTransaction) {
1557
+				$Connection->db->beginTransaction();
1558
+			}
1386 1559
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1387 1560
 			{
1388 1561
 				if ($i > 0) {
@@ -1399,7 +1572,9 @@  discard block
 block discarded – undo
1399 1572
 				$i++;
1400 1573
 			}
1401 1574
 			fclose($handle);
1402
-			if ($globalTransaction) $Connection->db->commit();
1575
+			if ($globalTransaction) {
1576
+				$Connection->db->commit();
1577
+			}
1403 1578
 		}
1404 1579
 		return '';
1405 1580
 	}
@@ -1418,7 +1593,9 @@  discard block
 block discarded – undo
1418 1593
 		$Connection = new Connection();
1419 1594
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1420 1595
 		{
1421
-			if ($globalTransaction) $Connection->db->beginTransaction();
1596
+			if ($globalTransaction) {
1597
+				$Connection->db->beginTransaction();
1598
+			}
1422 1599
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1423 1600
 			{
1424 1601
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1433,7 +1610,9 @@  discard block
 block discarded – undo
1433 1610
 				}
1434 1611
 			}
1435 1612
 			fclose($handle);
1436
-			if ($globalTransaction) $Connection->db->commit();
1613
+			if ($globalTransaction) {
1614
+				$Connection->db->commit();
1615
+			}
1437 1616
 		}
1438 1617
 		return '';
1439 1618
         }
@@ -1511,9 +1690,14 @@  discard block
 block discarded – undo
1511 1690
 				if ($i > 0 && $data[0] != '') {
1512 1691
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1513 1692
 					$period = str_replace(',','',$data[14]);
1514
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1515
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1516
-					else $launch_date = NULL;
1693
+					if (!empty($period) && strpos($period,'days')) {
1694
+						$period = str_replace(' days','',$period)*24*60;
1695
+					}
1696
+					if ($data[18] != '') {
1697
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1698
+					} else {
1699
+						$launch_date = NULL;
1700
+					}
1517 1701
 					$data = array_map(function($value) {
1518 1702
 						return trim($value) === '' ? null : $value;
1519 1703
 					}, $data);
@@ -1876,7 +2060,9 @@  discard block
 block discarded – undo
1876 2060
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1877 2061
 		{
1878 2062
 			$i = 0;
1879
-			if ($globalTransaction) $Connection->db->beginTransaction();
2063
+			if ($globalTransaction) {
2064
+				$Connection->db->beginTransaction();
2065
+			}
1880 2066
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1881 2067
 			{
1882 2068
 				$i++;
@@ -1904,7 +2090,9 @@  discard block
 block discarded – undo
1904 2090
 				}
1905 2091
 			}
1906 2092
 			fclose($handle);
1907
-			if ($globalTransaction) $Connection->db->commit();
2093
+			if ($globalTransaction) {
2094
+				$Connection->db->commit();
2095
+			}
1908 2096
 		}
1909 2097
 		return '';
1910 2098
 	}
@@ -1947,7 +2135,9 @@  discard block
 block discarded – undo
1947 2135
 		$Connection = new Connection();
1948 2136
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1949 2137
 		{
1950
-			if ($globalTransaction) $Connection->db->beginTransaction();
2138
+			if ($globalTransaction) {
2139
+				$Connection->db->beginTransaction();
2140
+			}
1951 2141
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1952 2142
 			{
1953 2143
 				if(count($row) > 1) {
@@ -1961,7 +2151,9 @@  discard block
 block discarded – undo
1961 2151
 				}
1962 2152
 			}
1963 2153
 			fclose($handle);
1964
-			if ($globalTransaction) $Connection->db->commit();
2154
+			if ($globalTransaction) {
2155
+				$Connection->db->commit();
2156
+			}
1965 2157
 		}
1966 2158
 		return '';
1967 2159
         }
@@ -1981,8 +2173,9 @@  discard block
 block discarded – undo
1981 2173
 	        }
1982 2174
 
1983 2175
 
1984
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1985
-		else {
2176
+		if ($globalDBdriver == 'mysql') {
2177
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2178
+		} else {
1986 2179
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1987 2180
 			$query = "CREATE EXTENSION postgis";
1988 2181
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -2001,7 +2194,9 @@  discard block
 block discarded – undo
2001 2194
 		global $tmp_dir, $globalDebug;
2002 2195
 		include_once('class.create_db.php');
2003 2196
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2004
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2197
+		if ($globalDebug) {
2198
+			echo "NOTAM from FlightAirMap website : Download...";
2199
+		}
2005 2200
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2006 2201
 		$error = '';
2007 2202
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -2011,20 +2206,34 @@  discard block
 block discarded – undo
2011 2206
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2012 2207
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2013 2208
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2014
-						if ($globalDebug) echo "Gunzip...";
2209
+						if ($globalDebug) {
2210
+							echo "Gunzip...";
2211
+						}
2015 2212
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
2016
-						if ($globalDebug) echo "Add to DB...";
2213
+						if ($globalDebug) {
2214
+							echo "Add to DB...";
2215
+						}
2017 2216
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
2018 2217
 						$NOTAM = new NOTAM();
2019 2218
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
2020 2219
 						update_db::insert_notam_version($notam_md5);
2021
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2022
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2023
-			} elseif ($globalDebug) echo "No new version.";
2024
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2220
+					} else {
2221
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2222
+					}
2223
+				} else {
2224
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2225
+				}
2226
+			} elseif ($globalDebug) {
2227
+				echo "No new version.";
2228
+			}
2229
+		} else {
2230
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2231
+		}
2025 2232
 		if ($error != '') {
2026 2233
 			return $error;
2027
-		} elseif ($globalDebug) echo "Done\n";
2234
+		} elseif ($globalDebug) {
2235
+			echo "Done\n";
2236
+		}
2028 2237
 		return '';
2029 2238
 	}
2030 2239
 
@@ -2079,68 +2288,114 @@  discard block
 block discarded – undo
2079 2288
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
2080 2289
 		if (extension_loaded('zip')) {
2081 2290
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
2082
-				if ($globalDebug) echo "Unzip...";
2291
+				if ($globalDebug) {
2292
+					echo "Unzip...";
2293
+				}
2083 2294
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
2084
-				if ($globalDebug) echo "Add to DB...";
2295
+				if ($globalDebug) {
2296
+					echo "Add to DB...";
2297
+				}
2085 2298
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2086
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2299
+				if ($globalDebug) {
2300
+					echo "Copy airlines logos to airlines images directory...";
2301
+				}
2087 2302
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2088
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2089
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2090
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2091
-		} else $error = "ZIP module not loaded but required for IVAO.";
2303
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2304
+						$error = "Failed to copy airlines logo.";
2305
+					}
2306
+				} else {
2307
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2308
+				}
2309
+			} else {
2310
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2311
+			}
2312
+		} else {
2313
+			$error = "ZIP module not loaded but required for IVAO.";
2314
+		}
2092 2315
 		if ($error != '') {
2093 2316
 			return $error;
2094
-		} elseif ($globalDebug) echo "Done\n";
2317
+		} elseif ($globalDebug) {
2318
+			echo "Done\n";
2319
+		}
2095 2320
 		return '';
2096 2321
 	}
2097 2322
 
2098 2323
 	public static function update_routes() {
2099 2324
 		global $tmp_dir, $globalDebug;
2100 2325
 		$error = '';
2101
-		if ($globalDebug) echo "Routes : Download...";
2326
+		if ($globalDebug) {
2327
+			echo "Routes : Download...";
2328
+		}
2102 2329
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2103 2330
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2104
-			if ($globalDebug) echo "Gunzip...";
2331
+			if ($globalDebug) {
2332
+				echo "Gunzip...";
2333
+			}
2105 2334
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2106
-			if ($globalDebug) echo "Add to DB...";
2335
+			if ($globalDebug) {
2336
+				echo "Add to DB...";
2337
+			}
2107 2338
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2108
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2339
+		} else {
2340
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2341
+		}
2109 2342
 		if ($error != '') {
2110 2343
 			return $error;
2111
-		} elseif ($globalDebug) echo "Done\n";
2344
+		} elseif ($globalDebug) {
2345
+			echo "Done\n";
2346
+		}
2112 2347
 		return '';
2113 2348
 	}
2114 2349
 	public static function update_oneworld() {
2115 2350
 		global $tmp_dir, $globalDebug;
2116 2351
 		$error = '';
2117
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2352
+		if ($globalDebug) {
2353
+			echo "Schedules Oneworld : Download...";
2354
+		}
2118 2355
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2119 2356
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2120
-			if ($globalDebug) echo "Gunzip...";
2357
+			if ($globalDebug) {
2358
+				echo "Gunzip...";
2359
+			}
2121 2360
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2122
-			if ($globalDebug) echo "Add to DB...";
2361
+			if ($globalDebug) {
2362
+				echo "Add to DB...";
2363
+			}
2123 2364
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2124
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2365
+		} else {
2366
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2367
+		}
2125 2368
 		if ($error != '') {
2126 2369
 			return $error;
2127
-		} elseif ($globalDebug) echo "Done\n";
2370
+		} elseif ($globalDebug) {
2371
+			echo "Done\n";
2372
+		}
2128 2373
 		return '';
2129 2374
 	}
2130 2375
 	public static function update_skyteam() {
2131 2376
 		global $tmp_dir, $globalDebug;
2132 2377
 		$error = '';
2133
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2378
+		if ($globalDebug) {
2379
+			echo "Schedules Skyteam : Download...";
2380
+		}
2134 2381
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2135 2382
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2136
-			if ($globalDebug) echo "Gunzip...";
2383
+			if ($globalDebug) {
2384
+				echo "Gunzip...";
2385
+			}
2137 2386
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2138
-			if ($globalDebug) echo "Add to DB...";
2387
+			if ($globalDebug) {
2388
+				echo "Add to DB...";
2389
+			}
2139 2390
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2140
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2391
+		} else {
2392
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2393
+		}
2141 2394
 		if ($error != '') {
2142 2395
 			return $error;
2143
-		} elseif ($globalDebug) echo "Done\n";
2396
+		} elseif ($globalDebug) {
2397
+			echo "Done\n";
2398
+		}
2144 2399
 		return '';
2145 2400
 	}
2146 2401
 	public static function update_ModeS() {
@@ -2157,340 +2412,590 @@  discard block
 block discarded – undo
2157 2412
 			exit;
2158 2413
 		} elseif ($globalDebug) echo "Done\n";
2159 2414
 */
2160
-		if ($globalDebug) echo "Modes : Download...";
2161
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2415
+		if ($globalDebug) {
2416
+			echo "Modes : Download...";
2417
+		}
2418
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2162 2419
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2163 2420
 
2164 2421
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2165 2422
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2166
-			if ($globalDebug) echo "Unzip...";
2167
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2423
+			if ($globalDebug) {
2424
+				echo "Unzip...";
2425
+			}
2426
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2168 2427
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2169
-			if ($globalDebug) echo "Add to DB...";
2428
+			if ($globalDebug) {
2429
+				echo "Add to DB...";
2430
+			}
2170 2431
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2171 2432
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2172
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2433
+		} else {
2434
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2435
+		}
2173 2436
 		if ($error != '') {
2174 2437
 			return $error;
2175
-		} elseif ($globalDebug) echo "Done\n";
2438
+		} elseif ($globalDebug) {
2439
+			echo "Done\n";
2440
+		}
2176 2441
 		return '';
2177 2442
 	}
2178 2443
 
2179 2444
 	public static function update_ModeS_faa() {
2180 2445
 		global $tmp_dir, $globalDebug;
2181
-		if ($globalDebug) echo "Modes FAA: Download...";
2446
+		if ($globalDebug) {
2447
+			echo "Modes FAA: Download...";
2448
+		}
2182 2449
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2183 2450
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2184
-			if ($globalDebug) echo "Unzip...";
2451
+			if ($globalDebug) {
2452
+				echo "Unzip...";
2453
+			}
2185 2454
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2186
-			if ($globalDebug) echo "Add to DB...";
2455
+			if ($globalDebug) {
2456
+				echo "Add to DB...";
2457
+			}
2187 2458
 			$error = update_db::modes_faa();
2188
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2459
+		} else {
2460
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2461
+		}
2189 2462
 		if ($error != '') {
2190 2463
 			return $error;
2191
-		} elseif ($globalDebug) echo "Done\n";
2464
+		} elseif ($globalDebug) {
2465
+			echo "Done\n";
2466
+		}
2192 2467
 		return '';
2193 2468
 	}
2194 2469
 
2195 2470
 	public static function update_ModeS_flarm() {
2196 2471
 		global $tmp_dir, $globalDebug;
2197
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2472
+		if ($globalDebug) {
2473
+			echo "Modes Flarmnet: Download...";
2474
+		}
2198 2475
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2199 2476
 		if (file_exists($tmp_dir.'data.fln')) {
2200
-			if ($globalDebug) echo "Add to DB...";
2477
+			if ($globalDebug) {
2478
+				echo "Add to DB...";
2479
+			}
2201 2480
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2202
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2481
+		} else {
2482
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2483
+		}
2203 2484
 		if ($error != '') {
2204 2485
 			return $error;
2205
-		} elseif ($globalDebug) echo "Done\n";
2486
+		} elseif ($globalDebug) {
2487
+			echo "Done\n";
2488
+		}
2206 2489
 		return '';
2207 2490
 	}
2208 2491
 
2209 2492
 	public static function update_ModeS_ogn() {
2210 2493
 		global $tmp_dir, $globalDebug;
2211
-		if ($globalDebug) echo "Modes OGN: Download...";
2494
+		if ($globalDebug) {
2495
+			echo "Modes OGN: Download...";
2496
+		}
2212 2497
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2213 2498
 		if (file_exists($tmp_dir.'ogn.csv')) {
2214
-			if ($globalDebug) echo "Add to DB...";
2499
+			if ($globalDebug) {
2500
+				echo "Add to DB...";
2501
+			}
2215 2502
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2216
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2503
+		} else {
2504
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2505
+		}
2217 2506
 		if ($error != '') {
2218 2507
 			return $error;
2219
-		} elseif ($globalDebug) echo "Done\n";
2508
+		} elseif ($globalDebug) {
2509
+			echo "Done\n";
2510
+		}
2220 2511
 		return '';
2221 2512
 	}
2222 2513
 
2223 2514
 	public static function update_owner() {
2224 2515
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2225 2516
 		
2226
-		if ($globalDebug) echo "Owner France: Download...";
2517
+		if ($globalDebug) {
2518
+			echo "Owner France: Download...";
2519
+		}
2227 2520
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2228 2521
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2229
-			if ($globalDebug) echo "Add to DB...";
2522
+			if ($globalDebug) {
2523
+				echo "Add to DB...";
2524
+			}
2230 2525
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2231
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2526
+		} else {
2527
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2528
+		}
2232 2529
 		if ($error != '') {
2233 2530
 			return $error;
2234
-		} elseif ($globalDebug) echo "Done\n";
2531
+		} elseif ($globalDebug) {
2532
+			echo "Done\n";
2533
+		}
2235 2534
 		
2236
-		if ($globalDebug) echo "Owner Ireland: Download...";
2535
+		if ($globalDebug) {
2536
+			echo "Owner Ireland: Download...";
2537
+		}
2237 2538
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2238 2539
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2239
-			if ($globalDebug) echo "Add to DB...";
2540
+			if ($globalDebug) {
2541
+				echo "Add to DB...";
2542
+			}
2240 2543
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2241
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2544
+		} else {
2545
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2546
+		}
2242 2547
 		if ($error != '') {
2243 2548
 			return $error;
2244
-		} elseif ($globalDebug) echo "Done\n";
2245
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2549
+		} elseif ($globalDebug) {
2550
+			echo "Done\n";
2551
+		}
2552
+		if ($globalDebug) {
2553
+			echo "Owner Switzerland: Download...";
2554
+		}
2246 2555
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2247 2556
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2248
-			if ($globalDebug) echo "Add to DB...";
2557
+			if ($globalDebug) {
2558
+				echo "Add to DB...";
2559
+			}
2249 2560
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2250
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2561
+		} else {
2562
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2563
+		}
2251 2564
 		if ($error != '') {
2252 2565
 			return $error;
2253
-		} elseif ($globalDebug) echo "Done\n";
2254
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2566
+		} elseif ($globalDebug) {
2567
+			echo "Done\n";
2568
+		}
2569
+		if ($globalDebug) {
2570
+			echo "Owner Czech Republic: Download...";
2571
+		}
2255 2572
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2256 2573
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2257
-			if ($globalDebug) echo "Add to DB...";
2574
+			if ($globalDebug) {
2575
+				echo "Add to DB...";
2576
+			}
2258 2577
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2259
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2578
+		} else {
2579
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2580
+		}
2260 2581
 		if ($error != '') {
2261 2582
 			return $error;
2262
-		} elseif ($globalDebug) echo "Done\n";
2263
-		if ($globalDebug) echo "Owner Australia: Download...";
2583
+		} elseif ($globalDebug) {
2584
+			echo "Done\n";
2585
+		}
2586
+		if ($globalDebug) {
2587
+			echo "Owner Australia: Download...";
2588
+		}
2264 2589
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2265 2590
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2266
-			if ($globalDebug) echo "Add to DB...";
2591
+			if ($globalDebug) {
2592
+				echo "Add to DB...";
2593
+			}
2267 2594
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2268
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2595
+		} else {
2596
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2597
+		}
2269 2598
 		if ($error != '') {
2270 2599
 			return $error;
2271
-		} elseif ($globalDebug) echo "Done\n";
2272
-		if ($globalDebug) echo "Owner Austria: Download...";
2600
+		} elseif ($globalDebug) {
2601
+			echo "Done\n";
2602
+		}
2603
+		if ($globalDebug) {
2604
+			echo "Owner Austria: Download...";
2605
+		}
2273 2606
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2274 2607
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2275
-			if ($globalDebug) echo "Add to DB...";
2608
+			if ($globalDebug) {
2609
+				echo "Add to DB...";
2610
+			}
2276 2611
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2277
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2612
+		} else {
2613
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2614
+		}
2278 2615
 		if ($error != '') {
2279 2616
 			return $error;
2280
-		} elseif ($globalDebug) echo "Done\n";
2281
-		if ($globalDebug) echo "Owner Chile: Download...";
2617
+		} elseif ($globalDebug) {
2618
+			echo "Done\n";
2619
+		}
2620
+		if ($globalDebug) {
2621
+			echo "Owner Chile: Download...";
2622
+		}
2282 2623
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2283 2624
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2284
-			if ($globalDebug) echo "Add to DB...";
2625
+			if ($globalDebug) {
2626
+				echo "Add to DB...";
2627
+			}
2285 2628
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2286
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2629
+		} else {
2630
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2631
+		}
2287 2632
 		if ($error != '') {
2288 2633
 			return $error;
2289
-		} elseif ($globalDebug) echo "Done\n";
2290
-		if ($globalDebug) echo "Owner Colombia: Download...";
2634
+		} elseif ($globalDebug) {
2635
+			echo "Done\n";
2636
+		}
2637
+		if ($globalDebug) {
2638
+			echo "Owner Colombia: Download...";
2639
+		}
2291 2640
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2292 2641
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2293
-			if ($globalDebug) echo "Add to DB...";
2642
+			if ($globalDebug) {
2643
+				echo "Add to DB...";
2644
+			}
2294 2645
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2295
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2646
+		} else {
2647
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2648
+		}
2296 2649
 		if ($error != '') {
2297 2650
 			return $error;
2298
-		} elseif ($globalDebug) echo "Done\n";
2299
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2651
+		} elseif ($globalDebug) {
2652
+			echo "Done\n";
2653
+		}
2654
+		if ($globalDebug) {
2655
+			echo "Owner Bosnia Herzegobina: Download...";
2656
+		}
2300 2657
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2301 2658
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2302
-			if ($globalDebug) echo "Add to DB...";
2659
+			if ($globalDebug) {
2660
+				echo "Add to DB...";
2661
+			}
2303 2662
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2304
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2663
+		} else {
2664
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2665
+		}
2305 2666
 		if ($error != '') {
2306 2667
 			return $error;
2307
-		} elseif ($globalDebug) echo "Done\n";
2308
-		if ($globalDebug) echo "Owner Brazil: Download...";
2668
+		} elseif ($globalDebug) {
2669
+			echo "Done\n";
2670
+		}
2671
+		if ($globalDebug) {
2672
+			echo "Owner Brazil: Download...";
2673
+		}
2309 2674
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2310 2675
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2311
-			if ($globalDebug) echo "Add to DB...";
2676
+			if ($globalDebug) {
2677
+				echo "Add to DB...";
2678
+			}
2312 2679
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2313
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2680
+		} else {
2681
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2682
+		}
2314 2683
 		if ($error != '') {
2315 2684
 			return $error;
2316
-		} elseif ($globalDebug) echo "Done\n";
2317
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2685
+		} elseif ($globalDebug) {
2686
+			echo "Done\n";
2687
+		}
2688
+		if ($globalDebug) {
2689
+			echo "Owner Cayman Islands: Download...";
2690
+		}
2318 2691
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2319 2692
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2320
-			if ($globalDebug) echo "Add to DB...";
2693
+			if ($globalDebug) {
2694
+				echo "Add to DB...";
2695
+			}
2321 2696
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2322
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2697
+		} else {
2698
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2699
+		}
2323 2700
 		if ($error != '') {
2324 2701
 			return $error;
2325
-		} elseif ($globalDebug) echo "Done\n";
2326
-		if ($globalDebug) echo "Owner Croatia: Download...";
2702
+		} elseif ($globalDebug) {
2703
+			echo "Done\n";
2704
+		}
2705
+		if ($globalDebug) {
2706
+			echo "Owner Croatia: Download...";
2707
+		}
2327 2708
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2328 2709
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2329
-			if ($globalDebug) echo "Add to DB...";
2710
+			if ($globalDebug) {
2711
+				echo "Add to DB...";
2712
+			}
2330 2713
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2331
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2714
+		} else {
2715
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2716
+		}
2332 2717
 		if ($error != '') {
2333 2718
 			return $error;
2334
-		} elseif ($globalDebug) echo "Done\n";
2335
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2719
+		} elseif ($globalDebug) {
2720
+			echo "Done\n";
2721
+		}
2722
+		if ($globalDebug) {
2723
+			echo "Owner Luxembourg: Download...";
2724
+		}
2336 2725
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2337 2726
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2338
-			if ($globalDebug) echo "Add to DB...";
2727
+			if ($globalDebug) {
2728
+				echo "Add to DB...";
2729
+			}
2339 2730
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2340
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2731
+		} else {
2732
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2733
+		}
2341 2734
 		if ($error != '') {
2342 2735
 			return $error;
2343
-		} elseif ($globalDebug) echo "Done\n";
2344
-		if ($globalDebug) echo "Owner Maldives: Download...";
2736
+		} elseif ($globalDebug) {
2737
+			echo "Done\n";
2738
+		}
2739
+		if ($globalDebug) {
2740
+			echo "Owner Maldives: Download...";
2741
+		}
2345 2742
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2346 2743
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2347
-			if ($globalDebug) echo "Add to DB...";
2744
+			if ($globalDebug) {
2745
+				echo "Add to DB...";
2746
+			}
2348 2747
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2349
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2748
+		} else {
2749
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2750
+		}
2350 2751
 		if ($error != '') {
2351 2752
 			return $error;
2352
-		} elseif ($globalDebug) echo "Done\n";
2353
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2753
+		} elseif ($globalDebug) {
2754
+			echo "Done\n";
2755
+		}
2756
+		if ($globalDebug) {
2757
+			echo "Owner New Zealand: Download...";
2758
+		}
2354 2759
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2355 2760
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2356
-			if ($globalDebug) echo "Add to DB...";
2761
+			if ($globalDebug) {
2762
+				echo "Add to DB...";
2763
+			}
2357 2764
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2358
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2765
+		} else {
2766
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2767
+		}
2359 2768
 		if ($error != '') {
2360 2769
 			return $error;
2361
-		} elseif ($globalDebug) echo "Done\n";
2362
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2770
+		} elseif ($globalDebug) {
2771
+			echo "Done\n";
2772
+		}
2773
+		if ($globalDebug) {
2774
+			echo "Owner Papua New Guinea: Download...";
2775
+		}
2363 2776
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2364 2777
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2365
-			if ($globalDebug) echo "Add to DB...";
2778
+			if ($globalDebug) {
2779
+				echo "Add to DB...";
2780
+			}
2366 2781
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2367
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2782
+		} else {
2783
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2784
+		}
2368 2785
 		if ($error != '') {
2369 2786
 			return $error;
2370
-		} elseif ($globalDebug) echo "Done\n";
2371
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2787
+		} elseif ($globalDebug) {
2788
+			echo "Done\n";
2789
+		}
2790
+		if ($globalDebug) {
2791
+			echo "Owner Slovakia: Download...";
2792
+		}
2372 2793
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2373 2794
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2374
-			if ($globalDebug) echo "Add to DB...";
2795
+			if ($globalDebug) {
2796
+				echo "Add to DB...";
2797
+			}
2375 2798
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2376
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2799
+		} else {
2800
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2801
+		}
2377 2802
 		if ($error != '') {
2378 2803
 			return $error;
2379
-		} elseif ($globalDebug) echo "Done\n";
2380
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2804
+		} elseif ($globalDebug) {
2805
+			echo "Done\n";
2806
+		}
2807
+		if ($globalDebug) {
2808
+			echo "Owner Ecuador: Download...";
2809
+		}
2381 2810
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2382 2811
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2383
-			if ($globalDebug) echo "Add to DB...";
2812
+			if ($globalDebug) {
2813
+				echo "Add to DB...";
2814
+			}
2384 2815
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2385
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2816
+		} else {
2817
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2818
+		}
2386 2819
 		if ($error != '') {
2387 2820
 			return $error;
2388
-		} elseif ($globalDebug) echo "Done\n";
2389
-		if ($globalDebug) echo "Owner Iceland: Download...";
2821
+		} elseif ($globalDebug) {
2822
+			echo "Done\n";
2823
+		}
2824
+		if ($globalDebug) {
2825
+			echo "Owner Iceland: Download...";
2826
+		}
2390 2827
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2391 2828
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2392
-			if ($globalDebug) echo "Add to DB...";
2829
+			if ($globalDebug) {
2830
+				echo "Add to DB...";
2831
+			}
2393 2832
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2394
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2833
+		} else {
2834
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2835
+		}
2395 2836
 		if ($error != '') {
2396 2837
 			return $error;
2397
-		} elseif ($globalDebug) echo "Done\n";
2398
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2838
+		} elseif ($globalDebug) {
2839
+			echo "Done\n";
2840
+		}
2841
+		if ($globalDebug) {
2842
+			echo "Owner Isle of Man: Download...";
2843
+		}
2399 2844
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2400 2845
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2401
-			if ($globalDebug) echo "Add to DB...";
2846
+			if ($globalDebug) {
2847
+				echo "Add to DB...";
2848
+			}
2402 2849
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2403
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2850
+		} else {
2851
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2852
+		}
2404 2853
 		if ($error != '') {
2405 2854
 			return $error;
2406
-		} elseif ($globalDebug) echo "Done\n";
2855
+		} elseif ($globalDebug) {
2856
+			echo "Done\n";
2857
+		}
2407 2858
 		if ($globalMasterSource) {
2408
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2859
+			if ($globalDebug) {
2860
+				echo "ModeS Netherlands: Download...";
2861
+			}
2409 2862
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2410 2863
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2411
-				if ($globalDebug) echo "Add to DB...";
2864
+				if ($globalDebug) {
2865
+					echo "Add to DB...";
2866
+				}
2412 2867
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2413
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2868
+			} else {
2869
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2870
+			}
2414 2871
 			if ($error != '') {
2415 2872
 				return $error;
2416
-			} elseif ($globalDebug) echo "Done\n";
2417
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2873
+			} elseif ($globalDebug) {
2874
+				echo "Done\n";
2875
+			}
2876
+			if ($globalDebug) {
2877
+				echo "ModeS Denmark: Download...";
2878
+			}
2418 2879
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2419 2880
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2420
-				if ($globalDebug) echo "Add to DB...";
2881
+				if ($globalDebug) {
2882
+					echo "Add to DB...";
2883
+				}
2421 2884
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2422
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2885
+			} else {
2886
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2887
+			}
2423 2888
 			if ($error != '') {
2424 2889
 				return $error;
2425
-			} elseif ($globalDebug) echo "Done\n";
2426
-		} elseif ($globalDebug) echo "Done\n";
2890
+			} elseif ($globalDebug) {
2891
+				echo "Done\n";
2892
+			}
2893
+		} elseif ($globalDebug) {
2894
+			echo "Done\n";
2895
+		}
2427 2896
 		return '';
2428 2897
 	}
2429 2898
 
2430 2899
 	public static function update_translation() {
2431 2900
 		global $tmp_dir, $globalDebug;
2432 2901
 		$error = '';
2433
-		if ($globalDebug) echo "Translation : Download...";
2902
+		if ($globalDebug) {
2903
+			echo "Translation : Download...";
2904
+		}
2434 2905
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2435 2906
 		if (file_exists($tmp_dir.'translation.zip')) {
2436
-			if ($globalDebug) echo "Unzip...";
2907
+			if ($globalDebug) {
2908
+				echo "Unzip...";
2909
+			}
2437 2910
 			update_db::unzip($tmp_dir.'translation.zip');
2438
-			if ($globalDebug) echo "Add to DB...";
2911
+			if ($globalDebug) {
2912
+				echo "Add to DB...";
2913
+			}
2439 2914
 			$error = update_db::translation();
2440
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2915
+		} else {
2916
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2917
+		}
2441 2918
 		if ($error != '') {
2442 2919
 			return $error;
2443
-		} elseif ($globalDebug) echo "Done\n";
2920
+		} elseif ($globalDebug) {
2921
+			echo "Done\n";
2922
+		}
2444 2923
 		return '';
2445 2924
 	}
2446 2925
 
2447 2926
 	public static function update_translation_fam() {
2448 2927
 		global $tmp_dir, $globalDebug;
2449 2928
 		$error = '';
2450
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2929
+		if ($globalDebug) {
2930
+			echo "Translation from FlightAirMap website : Download...";
2931
+		}
2451 2932
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2452 2933
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2453 2934
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2454 2935
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2455 2936
 			$translation_md5 = $translation_md5_file[0];
2456 2937
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2457
-				if ($globalDebug) echo "Gunzip...";
2938
+				if ($globalDebug) {
2939
+					echo "Gunzip...";
2940
+				}
2458 2941
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2459
-				if ($globalDebug) echo "Add to DB...";
2942
+				if ($globalDebug) {
2943
+					echo "Add to DB...";
2944
+				}
2460 2945
 				$error = update_db::translation_fam();
2461
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2462
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2946
+			} else {
2947
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2948
+			}
2949
+		} else {
2950
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2951
+		}
2463 2952
 		if ($error != '') {
2464 2953
 			return $error;
2465
-		} elseif ($globalDebug) echo "Done\n";
2954
+		} elseif ($globalDebug) {
2955
+			echo "Done\n";
2956
+		}
2466 2957
 		return '';
2467 2958
 	}
2468 2959
 	public static function update_ModeS_fam() {
2469 2960
 		global $tmp_dir, $globalDebug;
2470 2961
 		$error = '';
2471
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2962
+		if ($globalDebug) {
2963
+			echo "ModeS from FlightAirMap website : Download...";
2964
+		}
2472 2965
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2473 2966
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2474 2967
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2475 2968
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2476 2969
 			$modes_md5 = $modes_md5_file[0];
2477 2970
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2478
-				if ($globalDebug) echo "Gunzip...";
2971
+				if ($globalDebug) {
2972
+					echo "Gunzip...";
2973
+				}
2479 2974
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2480
-				if ($globalDebug) echo "Add to DB...";
2975
+				if ($globalDebug) {
2976
+					echo "Add to DB...";
2977
+				}
2481 2978
 				$error = update_db::modes_fam();
2482
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2483
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2979
+			} else {
2980
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2981
+			}
2982
+		} else {
2983
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2984
+		}
2484 2985
 		if ($error != '') {
2485 2986
 			return $error;
2486
-		} elseif ($globalDebug) echo "Done\n";
2987
+		} elseif ($globalDebug) {
2988
+			echo "Done\n";
2989
+		}
2487 2990
 		return '';
2488 2991
 	}
2489 2992
 
2490 2993
 	public static function update_airlines_fam() {
2491 2994
 		global $tmp_dir, $globalDebug;
2492 2995
 		$error = '';
2493
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2996
+		if ($globalDebug) {
2997
+			echo "Airlines from FlightAirMap website : Download...";
2998
+		}
2494 2999
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2495 3000
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2496 3001
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2499,26 +3004,42 @@  discard block
 block discarded – undo
2499 3004
 				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2500 3005
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2501 3006
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2502
-						if ($globalDebug) echo "Gunzip...";
3007
+						if ($globalDebug) {
3008
+							echo "Gunzip...";
3009
+						}
2503 3010
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2504
-						if ($globalDebug) echo "Add to DB...";
3011
+						if ($globalDebug) {
3012
+							echo "Add to DB...";
3013
+						}
2505 3014
 						$error = update_db::airlines_fam();
2506 3015
 						update_db::insert_airlines_version($airlines_md5);
2507
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2508
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2509
-			} elseif ($globalDebug) echo "No update.";
2510
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3016
+					} else {
3017
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
3018
+					}
3019
+			    } else {
3020
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
3021
+			    }
3022
+			} elseif ($globalDebug) {
3023
+				echo "No update.";
3024
+			}
3025
+		} else {
3026
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3027
+		}
2511 3028
 		if ($error != '') {
2512 3029
 			return $error;
2513 3030
 		} else {
2514
-			if ($globalDebug) echo "Done\n";
3031
+			if ($globalDebug) {
3032
+				echo "Done\n";
3033
+			}
2515 3034
 		}
2516 3035
 		return '';
2517 3036
 	}
2518 3037
 
2519 3038
 	public static function update_owner_fam() {
2520 3039
 		global $tmp_dir, $globalDebug, $globalOwner;
2521
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
3040
+		if ($globalDebug) {
3041
+			echo "owner from FlightAirMap website : Download...";
3042
+		}
2522 3043
 		$error = '';
2523 3044
 		if ($globalOwner === TRUE) {
2524 3045
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
@@ -2531,55 +3052,89 @@  discard block
 block discarded – undo
2531 3052
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2532 3053
 			$owners_md5 = $owners_md5_file[0];
2533 3054
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2534
-				if ($globalDebug) echo "Gunzip...";
3055
+				if ($globalDebug) {
3056
+					echo "Gunzip...";
3057
+				}
2535 3058
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2536
-				if ($globalDebug) echo "Add to DB...";
3059
+				if ($globalDebug) {
3060
+					echo "Add to DB...";
3061
+				}
2537 3062
 				$error = update_db::owner_fam();
2538
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2539
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3063
+			} else {
3064
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
3065
+			}
3066
+		} else {
3067
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3068
+		}
2540 3069
 		if ($error != '') {
2541 3070
 			return $error;
2542
-		} elseif ($globalDebug) echo "Done\n";
3071
+		} elseif ($globalDebug) {
3072
+			echo "Done\n";
3073
+		}
2543 3074
 		return '';
2544 3075
 	}
2545 3076
 	public static function update_routes_fam() {
2546 3077
 		global $tmp_dir, $globalDebug;
2547
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
3078
+		if ($globalDebug) {
3079
+			echo "Routes from FlightAirMap website : Download...";
3080
+		}
2548 3081
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2549 3082
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2550 3083
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2551 3084
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2552 3085
 			$routes_md5 = $routes_md5_file[0];
2553 3086
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2554
-				if ($globalDebug) echo "Gunzip...";
3087
+				if ($globalDebug) {
3088
+					echo "Gunzip...";
3089
+				}
2555 3090
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2556
-				if ($globalDebug) echo "Add to DB...";
3091
+				if ($globalDebug) {
3092
+					echo "Add to DB...";
3093
+				}
2557 3094
 				$error = update_db::routes_fam();
2558
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2559
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3095
+			} else {
3096
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
3097
+			}
3098
+		} else {
3099
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3100
+		}
2560 3101
 		if ($error != '') {
2561 3102
 			return $error;
2562
-		} elseif ($globalDebug) echo "Done\n";
3103
+		} elseif ($globalDebug) {
3104
+			echo "Done\n";
3105
+		}
2563 3106
 		return '';
2564 3107
 	}
2565 3108
 	public static function update_block_fam() {
2566 3109
 		global $tmp_dir, $globalDebug;
2567
-		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
3110
+		if ($globalDebug) {
3111
+			echo "Blocked aircraft from FlightAirMap website : Download...";
3112
+		}
2568 3113
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2569 3114
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2570 3115
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2571 3116
 			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2572 3117
 			$block_md5 = $block_md5_file[0];
2573 3118
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2574
-				if ($globalDebug) echo "Gunzip...";
3119
+				if ($globalDebug) {
3120
+					echo "Gunzip...";
3121
+				}
2575 3122
 				update_db::gunzip($tmp_dir.'block.tsv.gz');
2576
-				if ($globalDebug) echo "Add to DB...";
3123
+				if ($globalDebug) {
3124
+					echo "Add to DB...";
3125
+				}
2577 3126
 				$error = update_db::block_fam();
2578
-			} else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
2579
-		} else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3127
+			} else {
3128
+				$error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
3129
+			}
3130
+		} else {
3131
+			$error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3132
+		}
2580 3133
 		if ($error != '') {
2581 3134
 			return $error;
2582
-		} elseif ($globalDebug) echo "Done\n";
3135
+		} elseif ($globalDebug) {
3136
+			echo "Done\n";
3137
+		}
2583 3138
 		return '';
2584 3139
 	}
2585 3140
 	public static function update_marine_identity_fam() {
@@ -2589,21 +3144,33 @@  discard block
 block discarded – undo
2589 3144
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2590 3145
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2591 3146
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2592
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3147
+				if ($globalDebug) {
3148
+					echo "Marine identity from FlightAirMap website : Download...";
3149
+				}
2593 3150
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2594 3151
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2595 3152
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2596
-						if ($globalDebug) echo "Gunzip...";
3153
+						if ($globalDebug) {
3154
+							echo "Gunzip...";
3155
+						}
2597 3156
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2598
-						if ($globalDebug) echo "Add to DB...";
3157
+						if ($globalDebug) {
3158
+							echo "Add to DB...";
3159
+						}
2599 3160
 						$error = update_db::marine_identity_fam();
2600
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2601
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3161
+					} else {
3162
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3163
+					}
3164
+				} else {
3165
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3166
+				}
2602 3167
 				if ($error != '') {
2603 3168
 					return $error;
2604 3169
 				} else {
2605 3170
 					update_db::insert_marine_identity_version($marine_identity_md5);
2606
-					if ($globalDebug) echo "Done\n";
3171
+					if ($globalDebug) {
3172
+						echo "Done\n";
3173
+					}
2607 3174
 				}
2608 3175
 			}
2609 3176
 		}
@@ -2617,21 +3184,33 @@  discard block
 block discarded – undo
2617 3184
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2618 3185
 			$satellite_md5 = $satellite_md5_file[0];
2619 3186
 			if (!update_db::check_satellite_version($satellite_md5)) {
2620
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3187
+				if ($globalDebug) {
3188
+					echo "Satellite from FlightAirMap website : Download...";
3189
+				}
2621 3190
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2622 3191
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2623 3192
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2624
-						if ($globalDebug) echo "Gunzip...";
3193
+						if ($globalDebug) {
3194
+							echo "Gunzip...";
3195
+						}
2625 3196
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2626
-						if ($globalDebug) echo "Add to DB...";
3197
+						if ($globalDebug) {
3198
+							echo "Add to DB...";
3199
+						}
2627 3200
 						$error = update_db::satellite_fam();
2628
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2629
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3201
+					} else {
3202
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3203
+					}
3204
+				} else {
3205
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3206
+				}
2630 3207
 				if ($error != '') {
2631 3208
 					return $error;
2632 3209
 				} else {
2633 3210
 					update_db::insert_satellite_version($satellite_md5);
2634
-					if ($globalDebug) echo "Done\n";
3211
+					if ($globalDebug) {
3212
+						echo "Done\n";
3213
+					}
2635 3214
 				}
2636 3215
 			}
2637 3216
 		}
@@ -2639,17 +3218,25 @@  discard block
 block discarded – undo
2639 3218
 	}
2640 3219
 	public static function update_banned_fam() {
2641 3220
 		global $tmp_dir, $globalDebug;
2642
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3221
+		if ($globalDebug) {
3222
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3223
+		}
2643 3224
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2644 3225
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2645 3226
 			//if ($globalDebug) echo "Gunzip...";
2646 3227
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2647
-			if ($globalDebug) echo "Add to DB...";
3228
+			if ($globalDebug) {
3229
+				echo "Add to DB...";
3230
+			}
2648 3231
 			$error = update_db::banned_fam();
2649
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3232
+		} else {
3233
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3234
+		}
2650 3235
 		if ($error != '') {
2651 3236
 			return $error;
2652
-		} elseif ($globalDebug) echo "Done\n";
3237
+		} elseif ($globalDebug) {
3238
+			echo "Done\n";
3239
+		}
2653 3240
 		return '';
2654 3241
 	}
2655 3242
 
@@ -2657,7 +3244,9 @@  discard block
 block discarded – undo
2657 3244
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2658 3245
 		include_once('class.create_db.php');
2659 3246
 		$error = '';
2660
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3247
+		if ($globalDebug) {
3248
+			echo "Airspace from FlightAirMap website : Download...";
3249
+		}
2661 3250
 		if ($globalDBdriver == 'mysql') {
2662 3251
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2663 3252
 		} else {
@@ -2674,9 +3263,13 @@  discard block
 block discarded – undo
2674 3263
 				}
2675 3264
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2676 3265
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2677
-						if ($globalDebug) echo "Gunzip...";
3266
+						if ($globalDebug) {
3267
+							echo "Gunzip...";
3268
+						}
2678 3269
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2679
-						if ($globalDebug) echo "Add to DB...";
3270
+						if ($globalDebug) {
3271
+							echo "Add to DB...";
3272
+						}
2680 3273
 						$Connection = new Connection();
2681 3274
 						if ($Connection->tableExists('airspace')) {
2682 3275
 							$query = 'DROP TABLE airspace';
@@ -2689,20 +3282,30 @@  discard block
 block discarded – undo
2689 3282
 						}
2690 3283
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2691 3284
 						update_db::insert_airspace_version($airspace_md5);
2692
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2693
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3285
+					} else {
3286
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3287
+					}
3288
+				} else {
3289
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3290
+				}
2694 3291
 			}
2695
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3292
+		} else {
3293
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3294
+		}
2696 3295
 		if ($error != '') {
2697 3296
 			return $error;
2698
-		} elseif ($globalDebug) echo "Done\n";
3297
+		} elseif ($globalDebug) {
3298
+			echo "Done\n";
3299
+		}
2699 3300
 		return '';
2700 3301
 	}
2701 3302
 
2702 3303
 	public static function update_geoid_fam() {
2703 3304
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2704 3305
 		$error = '';
2705
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3306
+		if ($globalDebug) {
3307
+			echo "Geoid from FlightAirMap website : Download...";
3308
+		}
2706 3309
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2707 3310
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2708 3311
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2711,80 +3314,126 @@  discard block
 block discarded – undo
2711 3314
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2712 3315
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2713 3316
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2714
-						if ($globalDebug) echo "Gunzip...";
3317
+						if ($globalDebug) {
3318
+							echo "Gunzip...";
3319
+						}
2715 3320
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2716 3321
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2717 3322
 							update_db::insert_geoid_version($geoid_md5);
2718
-						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
2719
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2720
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2721
-			} elseif ($globalDebug) echo 'No new version'."\n";
2722
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3323
+						} else {
3324
+							$error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
3325
+						}
3326
+					} else {
3327
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3328
+					}
3329
+				} else {
3330
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3331
+				}
3332
+			} elseif ($globalDebug) {
3333
+				echo 'No new version'."\n";
3334
+			}
3335
+		} else {
3336
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3337
+		}
2723 3338
 		if ($error != '') {
2724 3339
 			return $error;
2725
-		} elseif ($globalDebug) echo "Done\n";
3340
+		} elseif ($globalDebug) {
3341
+			echo "Done\n";
3342
+		}
2726 3343
 		return '';
2727 3344
 	}
2728 3345
 
2729 3346
 	public static function update_tle() {
2730 3347
 		global $tmp_dir, $globalDebug;
2731
-		if ($globalDebug) echo "Download TLE : Download...";
3348
+		if ($globalDebug) {
3349
+			echo "Download TLE : Download...";
3350
+		}
2732 3351
 		$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',
2733 3352
 		'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',
2734 3353
 		'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');
2735 3354
 		foreach ($alltle as $filename) {
2736
-			if ($globalDebug) echo "downloading ".$filename.'...';
3355
+			if ($globalDebug) {
3356
+				echo "downloading ".$filename.'...';
3357
+			}
2737 3358
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2738 3359
 			if (file_exists($tmp_dir.$filename)) {
2739
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3360
+				if ($globalDebug) {
3361
+					echo "Add to DB ".$filename."...";
3362
+				}
2740 3363
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2741
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3364
+			} else {
3365
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3366
+			}
2742 3367
 			if ($error != '') {
2743 3368
 				echo $error."\n";
2744
-			} elseif ($globalDebug) echo "Done\n";
3369
+			} elseif ($globalDebug) {
3370
+				echo "Done\n";
3371
+			}
2745 3372
 		}
2746 3373
 		return '';
2747 3374
 	}
2748 3375
 
2749 3376
 	public static function update_ucsdb() {
2750 3377
 		global $tmp_dir, $globalDebug;
2751
-		if ($globalDebug) echo "Download UCS DB : Download...";
3378
+		if ($globalDebug) {
3379
+			echo "Download UCS DB : Download...";
3380
+		}
2752 3381
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt',$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2753 3382
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2754
-			if ($globalDebug) echo "Add to DB...";
3383
+			if ($globalDebug) {
3384
+				echo "Add to DB...";
3385
+			}
2755 3386
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2756
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed.";
3387
+		} else {
3388
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed.";
3389
+		}
2757 3390
 		if ($error != '') {
2758 3391
 			echo $error."\n";
2759
-		} elseif ($globalDebug) echo "Done\n";
3392
+		} elseif ($globalDebug) {
3393
+			echo "Done\n";
3394
+		}
2760 3395
 		return '';
2761 3396
 	}
2762 3397
 
2763 3398
 	public static function update_celestrak() {
2764 3399
 		global $tmp_dir, $globalDebug;
2765
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3400
+		if ($globalDebug) {
3401
+			echo "Download Celestrak DB : Download...";
3402
+		}
2766 3403
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2767 3404
 		if (file_exists($tmp_dir.'satcat.txt')) {
2768
-			if ($globalDebug) echo "Add to DB...";
3405
+			if ($globalDebug) {
3406
+				echo "Add to DB...";
3407
+			}
2769 3408
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2770
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3409
+		} else {
3410
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3411
+		}
2771 3412
 		if ($error != '') {
2772 3413
 			echo $error."\n";
2773
-		} elseif ($globalDebug) echo "Done\n";
3414
+		} elseif ($globalDebug) {
3415
+			echo "Done\n";
3416
+		}
2774 3417
 		return '';
2775 3418
 	}
2776 3419
 
2777 3420
 	public static function update_models() {
2778 3421
 		global $tmp_dir, $globalDebug;
2779 3422
 		$error = '';
2780
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3423
+		if ($globalDebug) {
3424
+			echo "Models from FlightAirMap website : Download...";
3425
+		}
2781 3426
 		if (!is_writable(dirname(__FILE__).'/../models')) {
2782
-			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
3427
+			if ($globalDebug) {
3428
+				echo dirname(__FILE__).'/../models'.' is not writable !';
3429
+			}
2783 3430
 			return '';
2784 3431
 		}
2785 3432
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2786 3433
 		if (file_exists($tmp_dir.'models.md5sum')) {
2787
-			if ($globalDebug) echo "Check files...\n";
3434
+			if ($globalDebug) {
3435
+				echo "Check files...\n";
3436
+			}
2788 3437
 			$newmodelsdb = array();
2789 3438
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2790 3439
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2803,18 +3452,28 @@  discard block
 block discarded – undo
2803 3452
 			}
2804 3453
 			$diff = array_diff($newmodelsdb,$modelsdb);
2805 3454
 			foreach ($diff as $key => $value) {
2806
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3455
+				if ($globalDebug) {
3456
+					echo 'Downloading model '.$key.' ...'."\n";
3457
+				}
2807 3458
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2808 3459
 			}
2809 3460
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2810
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3461
+		} else {
3462
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3463
+		}
2811 3464
 		if ($error != '') {
2812 3465
 			return $error;
2813
-		} elseif ($globalDebug) echo "Done\n";
2814
-		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
3466
+		} elseif ($globalDebug) {
3467
+			echo "Done\n";
3468
+		}
3469
+		if ($globalDebug) {
3470
+			echo "glTF 2.0 Models from FlightAirMap website : Download...";
3471
+		}
2815 3472
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2816 3473
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2817
-			if ($globalDebug) echo "Check files...\n";
3474
+			if ($globalDebug) {
3475
+				echo "Check files...\n";
3476
+			}
2818 3477
 			$newmodelsdb = array();
2819 3478
 			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2820 3479
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2833,29 +3492,43 @@  discard block
 block discarded – undo
2833 3492
 			}
2834 3493
 			$diff = array_diff($newmodelsdb,$modelsdb);
2835 3494
 			foreach ($diff as $key => $value) {
2836
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3495
+				if ($globalDebug) {
3496
+					echo 'Downloading model '.$key.' ...'."\n";
3497
+				}
2837 3498
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2838 3499
 				
2839 3500
 			}
2840 3501
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2841
-		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3502
+		} else {
3503
+			$error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3504
+		}
2842 3505
 		if ($error != '') {
2843 3506
 			return $error;
2844
-		} elseif ($globalDebug) echo "Done\n";
3507
+		} elseif ($globalDebug) {
3508
+			echo "Done\n";
3509
+		}
2845 3510
 		return '';
2846 3511
 	}
2847 3512
 	public static function update_weather_models() {
2848 3513
 		global $tmp_dir, $globalDebug;
2849 3514
 		$error = '';
2850
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3515
+		if ($globalDebug) {
3516
+			echo "Models from FlightAirMap website : Download...";
3517
+		}
2851 3518
 		if (!is_writable(dirname(__FILE__).'/../models/gltf2/weather')) {
2852
-			if ($globalDebug) echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !';
3519
+			if ($globalDebug) {
3520
+				echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !';
3521
+			}
2853 3522
 			return '';
2854 3523
 		}
2855
-		if ($globalDebug) echo "Weather Models from FlightAirMap website : Download...";
3524
+		if ($globalDebug) {
3525
+			echo "Weather Models from FlightAirMap website : Download...";
3526
+		}
2856 3527
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum');
2857 3528
 		if (file_exists($tmp_dir.'modelsweather.md5sum')) {
2858
-			if ($globalDebug) echo "Check files...\n";
3529
+			if ($globalDebug) {
3530
+				echo "Check files...\n";
3531
+			}
2859 3532
 			$newmodelsdb = array();
2860 3533
 			if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) {
2861 3534
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2874,25 +3547,35 @@  discard block
 block discarded – undo
2874 3547
 			}
2875 3548
 			$diff = array_diff($newmodelsdb,$modelsdb);
2876 3549
 			foreach ($diff as $key => $value) {
2877
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3550
+				if ($globalDebug) {
3551
+					echo 'Downloading model '.$key.' ...'."\n";
3552
+				}
2878 3553
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2879 3554
 				
2880 3555
 			}
2881 3556
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2882
-		} else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
3557
+		} else {
3558
+			$error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
3559
+		}
2883 3560
 		if ($error != '') {
2884 3561
 			return $error;
2885
-		} elseif ($globalDebug) echo "Done\n";
3562
+		} elseif ($globalDebug) {
3563
+			echo "Done\n";
3564
+		}
2886 3565
 		return '';
2887 3566
 	}
2888 3567
 
2889 3568
 	public static function update_liveries() {
2890 3569
 		global $tmp_dir, $globalDebug;
2891 3570
 		$error = '';
2892
-		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
3571
+		if ($globalDebug) {
3572
+			echo "Liveries from FlightAirMap website : Download...";
3573
+		}
2893 3574
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2894 3575
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2895
-			if ($globalDebug) echo "Check files...\n";
3576
+			if ($globalDebug) {
3577
+				echo "Check files...\n";
3578
+			}
2896 3579
 			$newmodelsdb = array();
2897 3580
 			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2898 3581
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2911,15 +3594,21 @@  discard block
 block discarded – undo
2911 3594
 			}
2912 3595
 			$diff = array_diff($newmodelsdb,$modelsdb);
2913 3596
 			foreach ($diff as $key => $value) {
2914
-				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
3597
+				if ($globalDebug) {
3598
+					echo 'Downloading liveries '.$key.' ...'."\n";
3599
+				}
2915 3600
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2916 3601
 				
2917 3602
 			}
2918 3603
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2919
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3604
+		} else {
3605
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3606
+		}
2920 3607
 		if ($error != '') {
2921 3608
 			return $error;
2922
-		} elseif ($globalDebug) echo "Done\n";
3609
+		} elseif ($globalDebug) {
3610
+			echo "Done\n";
3611
+		}
2923 3612
 		return '';
2924 3613
 	}
2925 3614
 
@@ -2927,13 +3616,19 @@  discard block
 block discarded – undo
2927 3616
 		global $tmp_dir, $globalDebug;
2928 3617
 		$error = '';
2929 3618
 		if (!is_writable(dirname(__FILE__).'/../models')) {
2930
-			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
3619
+			if ($globalDebug) {
3620
+				echo dirname(__FILE__).'/../models'.' is not writable !';
3621
+			}
2931 3622
 			return '';
2932 3623
 		}
2933
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3624
+		if ($globalDebug) {
3625
+			echo "Space models from FlightAirMap website : Download...";
3626
+		}
2934 3627
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2935 3628
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2936
-			if ($globalDebug) echo "Check files...\n";
3629
+			if ($globalDebug) {
3630
+				echo "Check files...\n";
3631
+			}
2937 3632
 			$newmodelsdb = array();
2938 3633
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2939 3634
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2952,15 +3647,21 @@  discard block
 block discarded – undo
2952 3647
 			}
2953 3648
 			$diff = array_diff($newmodelsdb,$modelsdb);
2954 3649
 			foreach ($diff as $key => $value) {
2955
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3650
+				if ($globalDebug) {
3651
+					echo 'Downloading space model '.$key.' ...'."\n";
3652
+				}
2956 3653
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2957 3654
 				
2958 3655
 			}
2959 3656
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2960
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3657
+		} else {
3658
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3659
+		}
2961 3660
 		if ($error != '') {
2962 3661
 			return $error;
2963
-		} elseif ($globalDebug) echo "Done\n";
3662
+		} elseif ($globalDebug) {
3663
+			echo "Done\n";
3664
+		}
2964 3665
 		return '';
2965 3666
 	}
2966 3667
 
@@ -2968,13 +3669,19 @@  discard block
 block discarded – undo
2968 3669
 		global $tmp_dir, $globalDebug;
2969 3670
 		$error = '';
2970 3671
 		if (!is_writable(dirname(__FILE__).'/../models/vehicules')) {
2971
-			if ($globalDebug) echo dirname(__FILE__).'/../models/vehicules'.' is not writable !';
3672
+			if ($globalDebug) {
3673
+				echo dirname(__FILE__).'/../models/vehicules'.' is not writable !';
3674
+			}
2972 3675
 			return '';
2973 3676
 		}
2974
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3677
+		if ($globalDebug) {
3678
+			echo "Vehicules models from FlightAirMap website : Download...";
3679
+		}
2975 3680
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2976 3681
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2977
-			if ($globalDebug) echo "Check files...\n";
3682
+			if ($globalDebug) {
3683
+				echo "Check files...\n";
3684
+			}
2978 3685
 			$newmodelsdb = array();
2979 3686
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2980 3687
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2993,15 +3700,21 @@  discard block
 block discarded – undo
2993 3700
 			}
2994 3701
 			$diff = array_diff($newmodelsdb,$modelsdb);
2995 3702
 			foreach ($diff as $key => $value) {
2996
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3703
+				if ($globalDebug) {
3704
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3705
+				}
2997 3706
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2998 3707
 				
2999 3708
 			}
3000 3709
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3001
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3710
+		} else {
3711
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3712
+		}
3002 3713
 		if ($error != '') {
3003 3714
 			return $error;
3004
-		} elseif ($globalDebug) echo "Done\n";
3715
+		} elseif ($globalDebug) {
3716
+			echo "Done\n";
3717
+		}
3005 3718
 		return '';
3006 3719
 	}
3007 3720
 
@@ -3074,7 +3787,9 @@  discard block
 block discarded – undo
3074 3787
                 }
3075 3788
 
3076 3789
 		$error = '';
3077
-		if ($globalDebug) echo "Notam : Download...";
3790
+		if ($globalDebug) {
3791
+			echo "Notam : Download...";
3792
+		}
3078 3793
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3079 3794
 		if (file_exists($tmp_dir.'notam.rss')) {
3080 3795
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -3089,14 +3804,30 @@  discard block
 block discarded – undo
3089 3804
 				$data['fir'] = $q[0];
3090 3805
 				$data['code'] = $q[1];
3091 3806
 				$ifrvfr = $q[2];
3092
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
3093
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
3094
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
3095
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
3096
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
3097
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
3098
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
3099
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3807
+				if ($ifrvfr == 'IV') {
3808
+					$data['rules'] = 'IFR/VFR';
3809
+				}
3810
+				if ($ifrvfr == 'I') {
3811
+					$data['rules'] = 'IFR';
3812
+				}
3813
+				if ($ifrvfr == 'V') {
3814
+					$data['rules'] = 'VFR';
3815
+				}
3816
+				if ($q[4] == 'A') {
3817
+					$data['scope'] = 'Airport warning';
3818
+				}
3819
+				if ($q[4] == 'E') {
3820
+					$data['scope'] = 'Enroute warning';
3821
+				}
3822
+				if ($q[4] == 'W') {
3823
+					$data['scope'] = 'Navigation warning';
3824
+				}
3825
+				if ($q[4] == 'AE') {
3826
+					$data['scope'] = 'Airport/Enroute warning';
3827
+				}
3828
+				if ($q[4] == 'AW') {
3829
+					$data['scope'] = 'Airport/Navigation warning';
3830
+				}
3100 3831
 				//$data['scope'] = $q[4];
3101 3832
 				$data['lower_limit'] = $q[5];
3102 3833
 				$data['upper_limit'] = $q[6];
@@ -3104,8 +3835,12 @@  discard block
 block discarded – undo
3104 3835
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3105 3836
 				$latitude = $Common->convertDec($las,'latitude');
3106 3837
 				$longitude = $Common->convertDec($lns,'longitude');
3107
-				if ($lac == 'S') $latitude = '-'.$latitude;
3108
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3838
+				if ($lac == 'S') {
3839
+					$latitude = '-'.$latitude;
3840
+				}
3841
+				if ($lnc == 'W') {
3842
+					$longitude = '-'.$longitude;
3843
+				}
3109 3844
 				$data['center_latitude'] = $latitude;
3110 3845
 				$data['center_longitude'] = $longitude;
3111 3846
 				$data['radius'] = intval($radius);
@@ -3135,10 +3870,14 @@  discard block
 block discarded – undo
3135 3870
 				$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']);
3136 3871
 				unset($data);
3137 3872
 			} 
3138
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3873
+		} else {
3874
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3875
+		}
3139 3876
 		if ($error != '') {
3140 3877
 			return $error;
3141
-		} elseif ($globalDebug) echo "Done\n";
3878
+		} elseif ($globalDebug) {
3879
+			echo "Done\n";
3880
+		}
3142 3881
 		return '';
3143 3882
 	}
3144 3883
 	
@@ -3163,7 +3902,9 @@  discard block
 block discarded – undo
3163 3902
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3164 3903
 		$airspace_json = json_decode($airspace_lst,true);
3165 3904
 		foreach ($airspace_json['records'] as $airspace) {
3166
-			if ($globalDebug) echo $airspace['name']."...\n";
3905
+			if ($globalDebug) {
3906
+				echo $airspace['name']."...\n";
3907
+			}
3167 3908
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3168 3909
 			if (file_exists($tmp_dir.$airspace['name'])) {
3169 3910
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -3207,8 +3948,11 @@  discard block
 block discarded – undo
3207 3948
                         return "error : ".$e->getMessage();
3208 3949
                 }
3209 3950
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3210
-                if ($row['nb'] > 0) return false;
3211
-                else return true;
3951
+                if ($row['nb'] > 0) {
3952
+                	return false;
3953
+                } else {
3954
+                	return true;
3955
+                }
3212 3956
 	}
3213 3957
 
3214 3958
 	public static function insert_last_update() {
@@ -3233,8 +3977,11 @@  discard block
 block discarded – undo
3233 3977
                         return "error : ".$e->getMessage();
3234 3978
                 }
3235 3979
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3236
-                if ($row['nb'] > 0) return true;
3237
-                else return false;
3980
+                if ($row['nb'] > 0) {
3981
+                	return true;
3982
+                } else {
3983
+                	return false;
3984
+                }
3238 3985
 	}
3239 3986
 
3240 3987
 	public static function check_geoid_version($version) {
@@ -3247,8 +3994,11 @@  discard block
 block discarded – undo
3247 3994
                         return "error : ".$e->getMessage();
3248 3995
                 }
3249 3996
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3250
-                if ($row['nb'] > 0) return true;
3251
-                else return false;
3997
+                if ($row['nb'] > 0) {
3998
+                	return true;
3999
+                } else {
4000
+                	return false;
4001
+                }
3252 4002
 	}
3253 4003
 
3254 4004
 	public static function check_marine_identity_version($version) {
@@ -3261,8 +4011,11 @@  discard block
 block discarded – undo
3261 4011
 			return "error : ".$e->getMessage();
3262 4012
 		}
3263 4013
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3264
-		if ($row['nb'] > 0) return true;
3265
-		else return false;
4014
+		if ($row['nb'] > 0) {
4015
+			return true;
4016
+		} else {
4017
+			return false;
4018
+		}
3266 4019
 	}
3267 4020
 
3268 4021
 	public static function check_satellite_version($version) {
@@ -3275,8 +4028,11 @@  discard block
 block discarded – undo
3275 4028
 			return "error : ".$e->getMessage();
3276 4029
 		}
3277 4030
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3278
-		if ($row['nb'] > 0) return true;
3279
-		else return false;
4031
+		if ($row['nb'] > 0) {
4032
+			return true;
4033
+		} else {
4034
+			return false;
4035
+		}
3280 4036
 	}
3281 4037
 
3282 4038
 	public static function check_airlines_version($version) {
@@ -3289,8 +4045,11 @@  discard block
 block discarded – undo
3289 4045
 			return "error : ".$e->getMessage();
3290 4046
 		}
3291 4047
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3292
-		if ($row['nb'] > 0) return true;
3293
-		else return false;
4048
+		if ($row['nb'] > 0) {
4049
+			return true;
4050
+		} else {
4051
+			return false;
4052
+		}
3294 4053
 	}
3295 4054
 
3296 4055
 	public static function check_notam_version($version) {
@@ -3303,8 +4062,11 @@  discard block
 block discarded – undo
3303 4062
 			return "error : ".$e->getMessage();
3304 4063
 		}
3305 4064
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3306
-		if ($row['nb'] > 0) return true;
3307
-		else return false;
4065
+		if ($row['nb'] > 0) {
4066
+			return true;
4067
+		} else {
4068
+			return false;
4069
+		}
3308 4070
 	}
3309 4071
 
3310 4072
 	public static function insert_airlines_version($version) {
@@ -3394,8 +4156,11 @@  discard block
 block discarded – undo
3394 4156
                         return "error : ".$e->getMessage();
3395 4157
                 }
3396 4158
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3397
-                if ($row['nb'] > 0) return false;
3398
-                else return true;
4159
+                if ($row['nb'] > 0) {
4160
+                	return false;
4161
+                } else {
4162
+                	return true;
4163
+                }
3399 4164
 	}
3400 4165
 
3401 4166
 	public static function insert_last_notam_update() {
@@ -3425,8 +4190,11 @@  discard block
 block discarded – undo
3425 4190
                         return "error : ".$e->getMessage();
3426 4191
                 }
3427 4192
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3428
-                if ($row['nb'] > 0) return false;
3429
-                else return true;
4193
+                if ($row['nb'] > 0) {
4194
+                	return false;
4195
+                } else {
4196
+                	return true;
4197
+                }
3430 4198
 	}
3431 4199
 
3432 4200
 	public static function insert_last_airspace_update() {
@@ -3456,8 +4224,11 @@  discard block
 block discarded – undo
3456 4224
                         return "error : ".$e->getMessage();
3457 4225
                 }
3458 4226
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3459
-                if ($row['nb'] > 0) return false;
3460
-                else return true;
4227
+                if ($row['nb'] > 0) {
4228
+                	return false;
4229
+                } else {
4230
+                	return true;
4231
+                }
3461 4232
 	}
3462 4233
 
3463 4234
 	public static function insert_last_geoid_update() {
@@ -3487,8 +4258,11 @@  discard block
 block discarded – undo
3487 4258
 			return "error : ".$e->getMessage();
3488 4259
 		}
3489 4260
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3490
-		if ($row['nb'] > 0) return false;
3491
-		else return true;
4261
+		if ($row['nb'] > 0) {
4262
+			return false;
4263
+		} else {
4264
+			return true;
4265
+		}
3492 4266
 	}
3493 4267
 
3494 4268
 	public static function insert_last_owner_update() {
@@ -3518,8 +4292,11 @@  discard block
 block discarded – undo
3518 4292
 			return "error : ".$e->getMessage();
3519 4293
 		}
3520 4294
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3521
-		if ($row['nb'] > 0) return false;
3522
-		else return true;
4295
+		if ($row['nb'] > 0) {
4296
+			return false;
4297
+		} else {
4298
+			return true;
4299
+		}
3523 4300
 	}
3524 4301
 
3525 4302
 	public static function insert_last_fires_update() {
@@ -3549,8 +4326,11 @@  discard block
 block discarded – undo
3549 4326
 			return "error : ".$e->getMessage();
3550 4327
 		}
3551 4328
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3552
-		if ($row['nb'] > 0) return false;
3553
-		else return true;
4329
+		if ($row['nb'] > 0) {
4330
+			return false;
4331
+		} else {
4332
+			return true;
4333
+		}
3554 4334
 	}
3555 4335
 
3556 4336
 	public static function insert_last_airlines_update() {
@@ -3580,8 +4360,11 @@  discard block
 block discarded – undo
3580 4360
                         return "error : ".$e->getMessage();
3581 4361
                 }
3582 4362
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3583
-                if ($row['nb'] > 0) return false;
3584
-                else return true;
4363
+                if ($row['nb'] > 0) {
4364
+                	return false;
4365
+                } else {
4366
+                	return true;
4367
+                }
3585 4368
 	}
3586 4369
 
3587 4370
 	public static function insert_last_schedules_update() {
@@ -3611,8 +4394,11 @@  discard block
 block discarded – undo
3611 4394
 			return "error : ".$e->getMessage();
3612 4395
 		}
3613 4396
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3614
-		if ($row['nb'] > 0) return false;
3615
-		else return true;
4397
+		if ($row['nb'] > 0) {
4398
+			return false;
4399
+		} else {
4400
+			return true;
4401
+		}
3616 4402
 	}
3617 4403
 
3618 4404
 	public static function insert_last_tle_update() {
@@ -3642,8 +4428,11 @@  discard block
 block discarded – undo
3642 4428
 			return "error : ".$e->getMessage();
3643 4429
 		}
3644 4430
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3645
-		if ($row['nb'] > 0) return false;
3646
-		else return true;
4431
+		if ($row['nb'] > 0) {
4432
+			return false;
4433
+		} else {
4434
+			return true;
4435
+		}
3647 4436
 	}
3648 4437
 
3649 4438
 	public static function insert_last_ucsdb_update() {
@@ -3673,8 +4462,11 @@  discard block
 block discarded – undo
3673 4462
 			return "error : ".$e->getMessage();
3674 4463
 		}
3675 4464
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3676
-		if ($row['nb'] > 0) return false;
3677
-		else return true;
4465
+		if ($row['nb'] > 0) {
4466
+			return false;
4467
+		} else {
4468
+			return true;
4469
+		}
3678 4470
 	}
3679 4471
 
3680 4472
 	public static function insert_last_celestrak_update() {
@@ -3704,8 +4496,11 @@  discard block
 block discarded – undo
3704 4496
 			return "error : ".$e->getMessage();
3705 4497
 		}
3706 4498
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3707
-		if ($row['nb'] > 0) return false;
3708
-		else return true;
4499
+		if ($row['nb'] > 0) {
4500
+			return false;
4501
+		} else {
4502
+			return true;
4503
+		}
3709 4504
 	}
3710 4505
 
3711 4506
 	public static function check_last_satellite_update() {
@@ -3723,8 +4518,11 @@  discard block
 block discarded – undo
3723 4518
 			return "error : ".$e->getMessage();
3724 4519
 		}
3725 4520
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3726
-		if ($row['nb'] > 0) return false;
3727
-		else return true;
4521
+		if ($row['nb'] > 0) {
4522
+			return false;
4523
+		} else {
4524
+			return true;
4525
+		}
3728 4526
 	}
3729 4527
 
3730 4528
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.