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 2 patches
Spacing   +417 added lines, -417 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		$ch = curl_init();
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
19
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
19
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
20 20
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
21 21
 			}
22 22
 		}
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
 		fclose($fp);
35 35
 	}
36 36
 
37
-	public static function gunzip($in_file,$out_file_name = '') {
37
+	public static function gunzip($in_file, $out_file_name = '') {
38 38
 		//echo $in_file.' -> '.$out_file_name."\n";
39 39
 		$buffer_size = 4096; // read 4kb at a time
40 40
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
41 41
 		if ($in_file != '' && file_exists($in_file)) {
42 42
 			// 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');
43
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
44
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
45 45
 			else {
46 46
 				echo 'gzopen not available';
47 47
 				die;
48 48
 			}
49 49
 			$out_file = fopen($out_file_name, 'wb'); 
50
-			while(!gzeof($file)) {
50
+			while (!gzeof($file)) {
51 51
 				fwrite($out_file, gzread($file, $buffer_size));
52 52
 			}  
53 53
 			fclose($out_file);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		try {
72 72
 			self::$db_sqlite = new PDO('sqlite:'.$database);
73 73
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
74
-		} catch(PDOException $e) {
74
+		} catch (PDOException $e) {
75 75
 			return "error : ".$e->getMessage();
76 76
 		}
77 77
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88 88
                         $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
89
+                } catch (PDOException $e) {
90 90
                         return "error : ".$e->getMessage();
91 91
                 }
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		try {
98 98
                         $sth = update_db::$db_sqlite->prepare($query);
99 99
                         $sth->execute();
100
-                } catch(PDOException $e) {
100
+                } catch (PDOException $e) {
101 101
                         return "error : ".$e->getMessage();
102 102
                 }
103 103
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109 109
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$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
-				$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);
111
+				$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 112
 				$sth_dest->execute($query_dest_values);
113 113
             		}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115
-		} catch(PDOException $e) {
115
+		} catch (PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
@@ -128,26 +128,26 @@  discard block
 block discarded – undo
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130 130
                         $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
131
+                } catch (PDOException $e) {
132 132
                         return "error : ".$e->getMessage();
133 133
                 }
134 134
 
135 135
     		if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138
-		if ($fh = fopen($database_file,"r")) {
138
+		if ($fh = fopen($database_file, "r")) {
139 139
 			$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 140
 			$Connection = new Connection();
141 141
 			$sth_dest = $Connection->db->prepare($query_dest);
142 142
 			if ($globalTransaction) $Connection->db->beginTransaction();
143 143
 			while (!feof($fh)) {
144
-				$line = fgetcsv($fh,9999,',');
144
+				$line = fgetcsv($fh, 9999, ',');
145 145
 				if ($line[0] != '') {
146 146
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
147 147
 						try {
148
-							$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');
148
+							$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 149
 							$sth_dest->execute($query_dest_values);
150
-						} catch(PDOException $e) {
150
+						} catch (PDOException $e) {
151 151
 							if ($globalTransaction) $Connection->db->rollBack(); 
152 152
 							return "error : ".$e->getMessage();
153 153
 						}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171 171
                         $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
172
+                } catch (PDOException $e) {
173 173
                         return "error : ".$e->getMessage();
174 174
                 }
175 175
 
@@ -177,24 +177,24 @@  discard block
 block discarded – undo
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
180
-		if ($fh = fopen($database_file,"r")) {
180
+		if ($fh = fopen($database_file, "r")) {
181 181
 			$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)';
182 182
 			$Connection = new Connection();
183 183
 			$sth_dest = $Connection->db->prepare($query_dest);
184 184
 			try {
185 185
 				if ($globalTransaction) $Connection->db->beginTransaction();
186 186
 				while (!feof($fh)) {
187
-					$line = fgetcsv($fh,9999,',');
187
+					$line = fgetcsv($fh, 9999, ',');
188 188
 					if ($line[0] != '') {
189
-						$datebe = explode('  -  ',$line[2]);
189
+						$datebe = explode('  -  ', $line[2]);
190 190
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
191
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
191
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
192 192
 							$sth_dest->execute($query_dest_values);
193 193
 						}
194 194
 					}
195 195
 				}
196 196
 				if ($globalTransaction) $Connection->db->commit();
197
-			} catch(PDOException $e) {
197
+			} catch (PDOException $e) {
198 198
 				if ($globalTransaction) $Connection->db->rollBack(); 
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211 211
                         $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
212
+                } catch (PDOException $e) {
213 213
                         return "error : ".$e->getMessage();
214 214
                 }
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219 219
                         $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		try {
227 227
                         $sth = update_db::$db_sqlite->prepare($query);
228 228
                         $sth->execute();
229
-                } catch(PDOException $e) {
229
+                } catch (PDOException $e) {
230 230
                         return "error : ".$e->getMessage();
231 231
                 }
232 232
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 			//$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 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
246
+				$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 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
249
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
250 250
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252 252
             		}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254
-		} catch(PDOException $e) {
254
+		} catch (PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
256 256
 		}
257 257
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263 263
                         $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
264
+                } catch (PDOException $e) {
265 265
                         return "error : ".$e->getMessage();
266 266
                 }
267 267
 		return '';
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278 278
                         $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
279
+                } catch (PDOException $e) {
280 280
                         return "error : ".$e->getMessage();
281 281
                 }
282 282
 		
283
-		if ($fh = fopen($database_file,"r")) {
283
+		if ($fh = fopen($database_file, "r")) {
284 284
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
285 285
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
286 286
 		
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291 291
             			while (!feof($fh)) {
292 292
             				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
293
+            				$line = $Common->hex2str(fgets($fh, 9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
295
+            				$values['ModeS'] = substr($line, 0, 6);
296
+            				$values['Registration'] = trim(substr($line, 69, 6));
297
+            				$aircraft_name = trim(substr($line, 48, 6));
298 298
             				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
299
+            				$aircraft_name_split = explode(' ', $aircraft_name);
300 300
             				$search_more = '';
301 301
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302 302
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	            				if (isset($result['icao']) && $result['icao'] != '') {
309 309
 	            				    $values['ICAOTypeCode'] = $result['icao'];
310 310
 	            				} 
311
-					} catch(PDOException $e) {
311
+					} catch (PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
314 314
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
315 315
 					// Add data to db
316 316
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 317
 						//$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']);
318
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
318
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
319 319
 						//print_r($query_dest_values);
320 320
 						$sth_dest->execute($query_dest_values);
321 321
 					}
322 322
 				}
323 323
 				if ($globalTransaction) $Connection->db->commit();
324
-			} catch(PDOException $e) {
324
+			} catch (PDOException $e) {
325 325
 				return "error : ".$e->getMessage();
326 326
 			}
327 327
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333 333
                         $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
334
+                } catch (PDOException $e) {
335 335
                         return "error : ".$e->getMessage();
336 336
                 }
337 337
 		return '';
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347 347
                         $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
348
+                } catch (PDOException $e) {
349 349
                         return "error : ".$e->getMessage();
350 350
                 }
351 351
 		
352
-		if ($fh = fopen($database_file,"r")) {
352
+		if ($fh = fopen($database_file, "r")) {
353 353
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
354 354
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
355 355
 		
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 			$sth_dest = $Connection->db->prepare($query_dest);
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360
-				$tmp = fgetcsv($fh,9999,',',"'");
360
+				$tmp = fgetcsv($fh, 9999, ',', "'");
361 361
             			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
362
+            				$line = fgetcsv($fh, 9999, ',', "'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
             				$values['ICAOTypeCode'] = '';
369 369
             				$aircraft_name = $line[2];
370 370
             				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
371
+            				$aircraft_name_split = explode(' ', $aircraft_name);
372 372
             				$search_more = '';
373 373
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374 374
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -377,20 +377,20 @@  discard block
 block discarded – undo
377 377
                                     		$sth_search->execute();
378 378
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379 379
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380
-					} catch(PDOException $e) {
380
+					} catch (PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
383 383
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
384 384
 					// Add data to db
385 385
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
386 386
 						//$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']);
387
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
387
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
388 388
 						//print_r($query_dest_values);
389 389
 						$sth_dest->execute($query_dest_values);
390 390
 					}
391 391
 				}
392 392
 				if ($globalTransaction) $Connection->db->commit();
393
-			} catch(PDOException $e) {
393
+			} catch (PDOException $e) {
394 394
 				return "error : ".$e->getMessage();
395 395
 			}
396 396
 		}
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402 402
                         $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
403
+                } catch (PDOException $e) {
404 404
                         return "error : ".$e->getMessage();
405 405
                 }
406 406
 		return '';
407 407
 	}
408 408
 
409
-	public static function retrieve_owner($database_file,$country = 'F') {
409
+	public static function retrieve_owner($database_file, $country = 'F') {
410 410
 		global $globalTransaction, $globalMasterSource;
411 411
 		//$query = 'TRUNCATE TABLE aircraft_modes';
412 412
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416 416
                         $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
417
+                } catch (PDOException $e) {
418 418
                         return "error : ".$e->getMessage();
419 419
                 }
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422
-		if ($fh = fopen($database_file,"r")) {
422
+		if ($fh = fopen($database_file, "r")) {
423 423
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425 425
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 			$sth_modes = $Connection->db->prepare($query_modes);
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432
-				$tmp = fgetcsv($fh,9999,',','"');
432
+				$tmp = fgetcsv($fh, 9999, ',', '"');
433 433
             			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
434
+            				$line = fgetcsv($fh, 9999, ',', '"');
435 435
             				$values = array();
436 436
             				//print_r($line);
437 437
             				if ($country == 'F') {
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             				    $values['base'] = $line[4];
440 440
             				    $values['owner'] = $line[5];
441 441
             				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
442
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
443 443
 					    $values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445 445
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             				    $values['base'] = $line[3];
448 448
             				    $values['owner'] = $line[2];
449 449
             				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
450
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
451 451
 					    $values['cancel'] = '';
452 452
 					    $values['modes'] = $line[7];
453 453
 					    $values['icao'] = $line[8];
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             				    $values['base'] = null;
468 468
             				    $values['owner'] = $line[5];
469 469
             				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
470
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
471 471
 					    $values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473 473
 					    // TODO : add modeS & reg to aircraft_modes
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
             				    $values['base'] = null;
476 476
             				    $values['owner'] = $line[12];
477 477
             				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
478
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
479 479
 
480 480
 					    $values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -495,28 +495,28 @@  discard block
 block discarded – undo
495 495
             				    $values['base'] = null;
496 496
             				    $values['owner'] = $line[8];
497 497
             				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
498
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
499 499
 					    $values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501 501
             				    $values['registration'] = $line[0];
502 502
             				    $values['base'] = null;
503 503
             				    $values['owner'] = $line[4];
504 504
             				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
505
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
506 506
 					    $values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508 508
             				    $values['registration'] = $line[0];
509 509
             				    $values['base'] = null;
510 510
             				    $values['owner'] = $line[4];
511 511
             				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
512
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
513 513
 					    $values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515 515
             				    $values['registration'] = $line[0];
516 516
             				    $values['base'] = null;
517 517
             				    $values['owner'] = $line[3];
518 518
             				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
519
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
520 520
 					    $values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522 522
             				    $values['registration'] = $line[0];
@@ -530,18 +530,18 @@  discard block
 block discarded – undo
530 530
             				    $values['registration'] = $line[0];
531 531
             				    $values['base'] = null;
532 532
             				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
533
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
534
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
535 535
 					    $values['modes'] = $line[4];
536 536
 					    $values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538 538
             				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
539
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
540 540
 					    $values['modes'] = $line[5];
541 541
 					    $values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543 543
             				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
544
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
545 545
 					    $values['modes'] = $line[4];
546 546
 					    $values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -552,17 +552,17 @@  discard block
 block discarded – undo
552 552
 					    $values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
555
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
556 556
 						$sth_dest->execute($query_dest_values);
557 557
 					}
558 558
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
559 559
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
560
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
560
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
561 561
 						$sth_modes->execute($query_modes_values);
562 562
 					}
563 563
 				}
564 564
 				if ($globalTransaction) $Connection->db->commit();
565
-			} catch(PDOException $e) {
565
+			} catch (PDOException $e) {
566 566
 				return "error : ".$e->getMessage();
567 567
 			}
568 568
 		}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		if ($globalTransaction) $Connection->db->beginTransaction();
701 701
   
702 702
 		$i = 0;
703
-		while($row = sparql_fetch_array($result))
703
+		while ($row = sparql_fetch_array($result))
704 704
 		{
705 705
 			if ($i >= 1) {
706 706
 			//print_r($row);
@@ -720,33 +720,33 @@  discard block
 block discarded – undo
720 720
 				$row['image'] = '';
721 721
 				$row['image_thumb'] = '';
722 722
 			} else {
723
-				$image = str_replace(' ','_',$row['image']);
723
+				$image = str_replace(' ', '_', $row['image']);
724 724
 				$digest = md5($image);
725
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
726
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
727
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
728
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
725
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
726
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
727
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
728
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
729 729
 			}
730 730
 			
731
-			$country = explode('-',$row['country']);
731
+			$country = explode('-', $row['country']);
732 732
 			$row['country'] = $country[0];
733 733
 			
734 734
 			$row['type'] = trim($row['type']);
735
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
735
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
736 736
 				$row['type'] = 'military';
737 737
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
738 738
 				$row['type'] = 'small_airport';
739 739
 			}
740 740
 			
741
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
742
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
741
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
742
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
743 743
 			//print_r($query_dest_values);
744 744
 			
745 745
 			if ($row['icao'] != '') {
746 746
 				try {
747 747
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
748 748
 					$sth->execute(array(':icao' => $row['icao']));
749
-				} catch(PDOException $e) {
749
+				} catch (PDOException $e) {
750 750
 					return "error : ".$e->getMessage();
751 751
 				}
752 752
 					if ($sth->fetchColumn() > 0) {
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
755 755
 						try {
756 756
 							$sth = $Connection->db->prepare($query);
757
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
758
-						} catch(PDOException $e) {
757
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
758
+						} catch (PDOException $e) {
759 759
 							return "error : ".$e->getMessage();
760 760
 						}
761 761
 						echo $row['icao'].' : '.$row['type']."\n";
762 762
 					} else {
763 763
 						try {
764 764
 							$sth_dest->execute($query_dest_values);
765
-						} catch(PDOException $e) {
765
+						} catch (PDOException $e) {
766 766
 							return "error : ".$e->getMessage();
767 767
 						}
768 768
 					}
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		echo "Download data from ourairports.com...\n";
814 814
 		$delimiter = ',';
815 815
 		$out_file = $tmp_dir.'airports.csv';
816
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
816
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
817 817
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
818 818
 		echo "Add data from ourairports.com...\n";
819 819
 
@@ -824,33 +824,33 @@  discard block
 block discarded – undo
824 824
 			//$Connection->db->beginTransaction();
825 825
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 826
 			{
827
-				if(!$header) $header = $row;
827
+				if (!$header) $header = $row;
828 828
 				else {
829 829
 					$data = array();
830 830
 					$data = array_combine($header, $row);
831 831
 					try {
832 832
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
833 833
 						$sth->execute(array(':icao' => $data['ident']));
834
-					} catch(PDOException $e) {
834
+					} catch (PDOException $e) {
835 835
 						return "error : ".$e->getMessage();
836 836
 					}
837 837
 					if ($sth->fetchColumn() > 0) {
838 838
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
839 839
 						try {
840 840
 							$sth = $Connection->db->prepare($query);
841
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
842
-						} catch(PDOException $e) {
841
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
842
+						} catch (PDOException $e) {
843 843
 							return "error : ".$e->getMessage();
844 844
 						}
845 845
 					} else {
846 846
 						if ($data['gps_code'] == $data['ident']) {
847 847
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
848 848
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
849
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
849
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
850 850
 						try {
851 851
 							$sth = $Connection->db->prepare($query);
852 852
 							$sth->execute($query_values);
853
-						} catch(PDOException $e) {
853
+						} catch (PDOException $e) {
854 854
 							return "error : ".$e->getMessage();
855 855
 						}
856 856
 						$i++;
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		
866 866
 		echo "Download data from another free database...\n";
867 867
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
868
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
869 869
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
870 870
 		update_db::unzip($out_file);
871 871
 		$header = NULL;
@@ -877,15 +877,15 @@  discard block
 block discarded – undo
877 877
 			//$Connection->db->beginTransaction();
878 878
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 879
 			{
880
-				if(!$header) $header = $row;
880
+				if (!$header) $header = $row;
881 881
 				else {
882 882
 					$data = $row;
883 883
 
884 884
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
885 885
 					try {
886 886
 						$sth = $Connection->db->prepare($query);
887
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
888
-					} catch(PDOException $e) {
887
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
888
+					} catch (PDOException $e) {
889 889
 						return "error : ".$e->getMessage();
890 890
 					}
891 891
 				}
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 		try {
900 900
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
901 901
 			$sth->execute();
902
-		} catch(PDOException $e) {
902
+		} catch (PDOException $e) {
903 903
 			return "error : ".$e->getMessage();
904 904
 		}
905 905
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
906 906
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
907 907
 			try {
908 908
 				$sth2 = $Connection->db->prepare($query2);
909
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
910
-			} catch(PDOException $e) {
909
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
910
+			} catch (PDOException $e) {
911 911
 				return "error : ".$e->getMessage();
912 912
 			}
913 913
 		}
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930 930
                         $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
931
+                } catch (PDOException $e) {
932 932
                         return "error : ".$e->getMessage();
933 933
                 }
934 934
 
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
946 946
 			{
947 947
 				$i++;
948
-				if($i > 12) {
948
+				if ($i > 12) {
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
                                                 //echo substr($operator, 0, 2)."\n";;
954 954
                                                 if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956
-							$operator = $airline_array[0]['icao'].substr($operator,2);
956
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
957 957
                                                 }
958 958
                                         }
959 959
 					
@@ -961,14 +961,14 @@  discard block
 block discarded – undo
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962 962
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963 963
                                                 if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
964
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
965 965
                                             	}
966 966
                                         }
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
970
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
-					} catch(PDOException $e) {
970
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
+					} catch (PDOException $e) {
972 972
 						return "error : ".$e->getMessage();
973 973
 					}
974 974
 				}
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 			$Connection = new Connection();
987 987
 			$sth = $Connection->db->prepare($query);
988 988
 			$sth->execute(array(':source' => 'website_fam'));
989
-		} catch(PDOException $e) {
989
+		} catch (PDOException $e) {
990 990
 			return "error : ".$e->getMessage();
991 991
 		}
992 992
 		//update_db::unzip($out_file);
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
1005 1005
 					try {
1006 1006
 						$sth = $Connection->db->prepare($query);
1007
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
-					} catch(PDOException $e) {
1007
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
+					} catch (PDOException $e) {
1009 1009
 						return "error : ".$e->getMessage();
1010 1010
 					}
1011 1011
 				}
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030 1030
                         $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1031
+                } catch (PDOException $e) {
1032 1032
                         return "error : ".$e->getMessage();
1033 1033
                 }
1034 1034
 
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039 1039
                         $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1040
+                } catch (PDOException $e) {
1041 1041
                         return "error : ".$e->getMessage();
1042 1042
                 }
1043 1043
 
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1055 1055
 					try {
1056 1056
 						$sths = $Connection->db->prepare($query_search);
1057
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1058
-					} catch(PDOException $e) {
1057
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1058
+					} catch (PDOException $e) {
1059 1059
 						return "error s : ".$e->getMessage();
1060 1060
 					}
1061 1061
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
 							//}
1069 1069
 						try {
1070 1070
 							$sthi = $Connection->db->prepare($queryi);
1071
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1072
-						} catch(PDOException $e) {
1071
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1072
+						} catch (PDOException $e) {
1073 1073
 							return "error u : ".$e->getMessage();
1074 1074
 						}
1075 1075
 					} else {
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 						try {
1078 1078
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1079 1079
 							$sthsm->execute(array(':mfr' => $data[2]));
1080
-						} catch(PDOException $e) {
1080
+						} catch (PDOException $e) {
1081 1081
 							return "error mfr : ".$e->getMessage();
1082 1082
 						}
1083 1083
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1088
 							try {
1089 1089
 								$sthf = $Connection->db->prepare($queryf);
1090
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1091
-							} catch(PDOException $e) {
1090
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1091
+							} catch (PDOException $e) {
1092 1092
 								return "error f : ".$e->getMessage();
1093 1093
 							}
1094 1094
 						}
@@ -1098,13 +1098,13 @@  discard block
 block discarded – undo
1098 1098
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1099
 						try {
1100 1100
 							$sth = $Connection->db->prepare($query);
1101
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1102
-						} catch(PDOException $e) {
1101
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1102
+						} catch (PDOException $e) {
1103 1103
 							return "error i : ".$e->getMessage();
1104 1104
 						}
1105 1105
 					}
1106 1106
 				}
1107
-				if ($i % 90 == 0) {
1107
+				if ($i%90 == 0) {
1108 1108
 					if ($globalTransaction) $Connection->db->commit();
1109 1109
 					if ($globalTransaction) $Connection->db->beginTransaction();
1110 1110
 				}
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			$Connection = new Connection();
1124 1124
 			$sth = $Connection->db->prepare($query);
1125 1125
 			$sth->execute(array(':source' => 'website_fam'));
1126
-		} catch(PDOException $e) {
1126
+		} catch (PDOException $e) {
1127 1127
 			return "error : ".$e->getMessage();
1128 1128
 		}
1129 1129
 		$delimiter = "\t";
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 					$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 1140
 					try {
1141 1141
 						$sth = $Connection->db->prepare($query);
1142
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1143
-					} catch(PDOException $e) {
1142
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1143
+					} catch (PDOException $e) {
1144 1144
 						return "error : ".$e->getMessage();
1145 1145
 					}
1146 1146
 				}
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
 		try {
1173 1173
 			$sth = $Connection->db->prepare($query);
1174 1174
 			$sth->execute();
1175
-		} catch(PDOException $e) {
1175
+		} catch (PDOException $e) {
1176 1176
 			return "error : ".$e->getMessage();
1177 1177
 		}
1178 1178
 		$delimiter = "\t";
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 					$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 1188
 					try {
1189 1189
 						$sth = $Connection->db->prepare($query);
1190
-						$sth->execute(array(':name' => $data[0],':alias' => $data[1],':iata' => $data[2],':icao' => $data[3], ':callsign' => $data[4],':country' => $data[5],':active' => $data[6],':type' => $data[7],':home' => $data[8],':wikipedia_link' => $data[9],':alliance' => $data[10],':ban_eu' => $data[11]));
1191
-					} catch(PDOException $e) {
1190
+						$sth->execute(array(':name' => $data[0], ':alias' => $data[1], ':iata' => $data[2], ':icao' => $data[3], ':callsign' => $data[4], ':country' => $data[5], ':active' => $data[6], ':type' => $data[7], ':home' => $data[8], ':wikipedia_link' => $data[9], ':alliance' => $data[10], ':ban_eu' => $data[11]));
1191
+					} catch (PDOException $e) {
1192 1192
 						return "error : ".$e->getMessage();
1193 1193
 					}
1194 1194
 				}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 			$Connection = new Connection();
1217 1217
 			$sth = $Connection->db->prepare($query);
1218 1218
                         $sth->execute(array(':source' => 'website_fam'));
1219
-                } catch(PDOException $e) {
1219
+                } catch (PDOException $e) {
1220 1220
                         return "error : ".$e->getMessage();
1221 1221
                 }
1222 1222
 
@@ -1232,8 +1232,8 @@  discard block
 block discarded – undo
1232 1232
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1233 1233
 					try {
1234 1234
 						$sth = $Connection->db->prepare($query);
1235
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1236
-					} catch(PDOException $e) {
1235
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1236
+					} catch (PDOException $e) {
1237 1237
 						//print_r($data);
1238 1238
 						return "error : ".$e->getMessage();
1239 1239
 					}
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 			$Connection = new Connection();
1254 1254
 			$sth = $Connection->db->prepare($query);
1255 1255
 			$sth->execute(array(':source' => 'website_fam'));
1256
-		} catch(PDOException $e) {
1256
+		} catch (PDOException $e) {
1257 1257
 			return "error : ".$e->getMessage();
1258 1258
 		}
1259 1259
 		$delimiter = "\t";
@@ -1269,13 +1269,13 @@  discard block
 block discarded – undo
1269 1269
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1270 1270
 					try {
1271 1271
 						$sth = $Connection->db->prepare($query);
1272
-						$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
-					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1272
+						$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
+					} catch (PDOException $e) {
1274
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1275 1275
 						die();
1276 1276
 					}
1277 1277
 				}
1278
-				if ($globalTransaction && $i % 2000 == 0) {
1278
+				if ($globalTransaction && $i%2000 == 0) {
1279 1279
 					$Connection->db->commit();
1280 1280
 					if ($globalDebug) echo '.';
1281 1281
 					$Connection->db->beginTransaction();
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 			$Connection = new Connection();
1296 1296
 			$sth = $Connection->db->prepare($query);
1297 1297
 			$sth->execute(array(':source' => 'website_fam'));
1298
-		} catch(PDOException $e) {
1298
+		} catch (PDOException $e) {
1299 1299
 			return "error : ".$e->getMessage();
1300 1300
 		}
1301 1301
 		$Connection = new Connection();
@@ -1308,12 +1308,12 @@  discard block
 block discarded – undo
1308 1308
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
1309 1309
 				try {
1310 1310
 					$sth = $Connection->db->prepare($query);
1311
-					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1312
-				} catch(PDOException $e) {
1311
+					$sth->execute(array(':callSign' => trim($data), ':source' => 'website_fam'));
1312
+				} catch (PDOException $e) {
1313 1313
 					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1314 1314
 					die();
1315 1315
 				}
1316
-				if ($globalTransaction && $i % 2000 == 0) {
1316
+				if ($globalTransaction && $i%2000 == 0) {
1317 1317
 					$Connection->db->commit();
1318 1318
 					if ($globalDebug) echo '.';
1319 1319
 					$Connection->db->beginTransaction();
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 			$Connection = new Connection();
1334 1334
 			$sth = $Connection->db->prepare($query);
1335 1335
                         $sth->execute();
1336
-                } catch(PDOException $e) {
1336
+                } catch (PDOException $e) {
1337 1337
                         return "error : ".$e->getMessage();
1338 1338
                 }
1339 1339
 
@@ -1354,8 +1354,8 @@  discard block
 block discarded – undo
1354 1354
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1355 1355
 					try {
1356 1356
 						$sth = $Connection->db->prepare($query);
1357
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1358
-					} catch(PDOException $e) {
1357
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1358
+					} catch (PDOException $e) {
1359 1359
 						return "error : ".$e->getMessage();
1360 1360
 					}
1361 1361
 				}
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 			$Connection = new Connection();
1375 1375
 			$sth = $Connection->db->prepare($query);
1376 1376
 			$sth->execute();
1377
-		} catch(PDOException $e) {
1377
+		} catch (PDOException $e) {
1378 1378
 			return "error : ".$e->getMessage();
1379 1379
 		}
1380 1380
 		$delimiter = "\t";
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1392 1392
 					try {
1393 1393
 						$sth = $Connection->db->prepare($query);
1394
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1395
-					} catch(PDOException $e) {
1394
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1395
+					} catch (PDOException $e) {
1396 1396
 						return "error : ".$e->getMessage();
1397 1397
 					}
1398 1398
 				}
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 			$Connection = new Connection();
1412 1412
 			$sth = $Connection->db->prepare($query);
1413 1413
 			$sth->execute();
1414
-		} catch(PDOException $e) {
1414
+		} catch (PDOException $e) {
1415 1415
 			return "error : ".$e->getMessage();
1416 1416
 		}
1417 1417
 
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 					try {
1428 1428
 						$sth = $Connection->db->prepare($query);
1429 1429
 						$sth->execute(array(':icao' => $icao));
1430
-					} catch(PDOException $e) {
1430
+					} catch (PDOException $e) {
1431 1431
 						return "error : ".$e->getMessage();
1432 1432
 					}
1433 1433
 				}
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
 		return '';
1439 1439
         }
1440 1440
 
1441
-	public static function tle($filename,$tletype) {
1441
+	public static function tle($filename, $tletype) {
1442 1442
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1443 1443
 		global $tmp_dir, $globalTransaction;
1444 1444
 		//$Spotter = new Spotter();
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 			$Connection = new Connection();
1449 1449
 			$sth = $Connection->db->prepare($query);
1450 1450
                         $sth->execute(array(':source' => $filename));
1451
-                } catch(PDOException $e) {
1451
+                } catch (PDOException $e) {
1452 1452
                         return "error : ".$e->getMessage();
1453 1453
                 }
1454 1454
 		
@@ -1473,8 +1473,8 @@  discard block
 block discarded – undo
1473 1473
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1474 1474
 					try {
1475 1475
 						$sth = $Connection->db->prepare($query);
1476
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1477
-					} catch(PDOException $e) {
1476
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1477
+					} catch (PDOException $e) {
1478 1478
 						return "error : ".$e->getMessage();
1479 1479
 					}
1480 1480
 
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 			$Connection = new Connection();
1496 1496
 			$sth = $Connection->db->prepare($query);
1497 1497
 			$sth->execute(array(':source' => $filename));
1498
-		} catch(PDOException $e) {
1498
+		} catch (PDOException $e) {
1499 1499
 			return "error : ".$e->getMessage();
1500 1500
 		}
1501 1501
 		
@@ -1506,13 +1506,13 @@  discard block
 block discarded – undo
1506 1506
 			$i = 0;
1507 1507
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1508 1508
 			//$Connection->db->beginTransaction();
1509
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1509
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1510 1510
 			{
1511 1511
 				if ($i > 0 && $data[0] != '') {
1512 1512
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1513
-					$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]));
1513
+					$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 1516
 					else $launch_date = NULL;
1517 1517
 					$data = array_map(function($value) {
1518 1518
 						return trim($value) === '' ? null : $value;
@@ -1522,8 +1522,8 @@  discard block
 block discarded – undo
1522 1522
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1523 1523
 					try {
1524 1524
 						$sth = $Connection->db->prepare($query);
1525
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',','',$data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',','',$data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+',','),'',$data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',','-1900',' (BOL)',' (EOL)'),'',$data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',',' (BOL)',' (EOL)'),'',$data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20],':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1526
-					} catch(PDOException $e) {
1525
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',', '', $data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',', '', $data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+', ','), '', $data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',', '-1900', ' (BOL)', ' (EOL)'), '', $data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',', ' (BOL)', ' (EOL)'), '', $data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20], ':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1526
+					} catch (PDOException $e) {
1527 1527
 						return "error : ".$e->getMessage();
1528 1528
 					}
1529 1529
 				}
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1564 1564
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1565 1565
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1566
-			'EST' => array('country' => 'Estonia','owner' => ''),
1566
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1567 1567
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1568 1568
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1569 1569
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1687,10 +1687,10 @@  discard block
 block discarded – undo
1687 1687
 			{
1688 1688
 				if ($data != '') {
1689 1689
 				$result = array();
1690
-				$result['cospar'] = trim(substr($data,0,11));
1691
-				$result['norad'] = trim(substr($data,13,6));
1692
-				$result['operational'] = trim(substr($data,21,1));
1693
-				$result['name'] = trim(substr($data,23,24));
1690
+				$result['cospar'] = trim(substr($data, 0, 11));
1691
+				$result['norad'] = trim(substr($data, 13, 6));
1692
+				$result['operational'] = trim(substr($data, 21, 1));
1693
+				$result['name'] = trim(substr($data, 23, 24));
1694 1694
 				/*
1695 1695
 				    * R/B(1) = Rocket body, first stage
1696 1696
 				    * R/B(2) = Rocket body, second stage
@@ -1702,29 +1702,29 @@  discard block
 block discarded – undo
1702 1702
 				    * An ampersand (&) indicates two or more objects are attached
1703 1703
 				*/
1704 1704
 				
1705
-				$owner_code = trim(substr($data,49,5));
1705
+				$owner_code = trim(substr($data, 49, 5));
1706 1706
 				
1707 1707
 				if (!isset($satcat_sources[$owner_code])) {
1708 1708
 					echo $data;
1709 1709
 					echo 'owner_code: '.$owner_code."\n";
1710 1710
 				}
1711
-				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1712
-					echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1711
+				if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1712
+					echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n";
1713 1713
 				}
1714 1714
 				
1715
-				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
1715
+				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1716 1716
 					$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1717 1717
 					$result['owner'] = $satcat_sources[$owner_code]['owner'];
1718
-					$result['launch_date'] = trim(substr($data,56,10));
1719
-					$launch_site_code = trim(substr($data,68,5));
1718
+					$result['launch_date'] = trim(substr($data, 56, 10));
1719
+					$launch_site_code = trim(substr($data, 68, 5));
1720 1720
 					$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1721
-					$result['lifetime'] = trim(substr($data,75,10));
1722
-					$result['period'] = trim(substr($data,87,7));
1723
-					$result['inclination'] = trim(substr($data,96,5));
1724
-					$result['apogee'] = trim(substr($data,103,6));
1725
-					$result['perigee'] = trim(substr($data,111,6));
1721
+					$result['lifetime'] = trim(substr($data, 75, 10));
1722
+					$result['period'] = trim(substr($data, 87, 7));
1723
+					$result['inclination'] = trim(substr($data, 96, 5));
1724
+					$result['apogee'] = trim(substr($data, 103, 6));
1725
+					$result['perigee'] = trim(substr($data, 111, 6));
1726 1726
 					//$result['radarcross'] = trim(substr($data,119,8));
1727
-					$result['status'] = trim(substr($data,129,3));
1727
+					$result['status'] = trim(substr($data, 129, 3));
1728 1728
 					//print_r($result);
1729 1729
 					$result = array_map(function($value) {
1730 1730
 						return trim($value) === '' ? null : $value;
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
 							$sth = $Connection->db->prepare($query);
1738 1738
 							$sth->execute(array(':cospar' => $result['cospar']));
1739 1739
 							$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1740
-						} catch(PDOException $e) {
1740
+						} catch (PDOException $e) {
1741 1741
 							return "error : ".$e->getMessage();
1742 1742
 						}
1743 1743
 						if (empty($exist)) {
@@ -1749,10 +1749,10 @@  discard block
 block discarded – undo
1749 1749
 								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1750 1750
 								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1751 1751
 								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1752
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1752
+								    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1753 1753
 								    )
1754 1754
 								);
1755
-							} catch(PDOException $e) {
1755
+							} catch (PDOException $e) {
1756 1756
 								return "error : ".$e->getMessage();
1757 1757
 							}
1758 1758
 						} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1760,8 +1760,8 @@  discard block
 block discarded – undo
1760 1760
 							try {
1761 1761
 								$Connection = new Connection();
1762 1762
 								$sth = $Connection->db->prepare($query);
1763
-								$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1764
-							} catch(PDOException $e) {
1763
+								$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1764
+							} catch (PDOException $e) {
1765 1765
 								return "error : ".$e->getMessage();
1766 1766
 							}
1767 1767
 						}
@@ -1880,13 +1880,13 @@  discard block
 block discarded – undo
1880 1880
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1881 1881
 			{
1882 1882
 				$i++;
1883
-				if($i > 3 && count($row) > 2) {
1883
+				if ($i > 3 && count($row) > 2) {
1884 1884
 					$data = array_values(array_filter($row));
1885 1885
 					$cntdata = count($data);
1886 1886
 					if ($cntdata > 10) {
1887 1887
 						$value = $data[9];
1888 1888
 						
1889
-						for ($i =10;$i < $cntdata;$i++) {
1889
+						for ($i = 10; $i < $cntdata; $i++) {
1890 1890
 							$value .= ' '.$data[$i];
1891 1891
 						}
1892 1892
 						$data[9] = $value;
@@ -1896,8 +1896,8 @@  discard block
 block discarded – undo
1896 1896
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1897 1897
 						try {
1898 1898
 							$sth = $Connection->db->prepare($query);
1899
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1900
-						} catch(PDOException $e) {
1899
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1900
+						} catch (PDOException $e) {
1901 1901
 							return "error : ".$e->getMessage();
1902 1902
 						}
1903 1903
 					}
@@ -1914,16 +1914,16 @@  discard block
 block discarded – undo
1914 1914
 		require_once(dirname(__FILE__).'/../require/class.Source.php');
1915 1915
 		$delimiter = ',';
1916 1916
 		$Common = new Common();
1917
-		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv');
1917
+		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv');
1918 1918
 		$Connection = new Connection();
1919 1919
 		$Source = new Source();
1920 1920
 		$Source->deleteLocationByType('fires');
1921 1921
 		$i = 0;
1922
-		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1923
-			while (($row = fgetcsv($handle,1000)) !== false) {
1922
+		if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) {
1923
+			while (($row = fgetcsv($handle, 1000)) !== false) {
1924 1924
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1925
-					$description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]);
1926
-					$Source->addLocation('',$row[0],$row[1],null,'','','fires','fire.png','fires',0,0,$row[5].' '.substr($row[6],0,2).':'.substr($row[6],2,2),json_encode($description));
1925
+					$description = array('bright_t14' => $row[2], 'scan' => $row[3], 'track' => $row[4], 'sat' => $row[7], 'confidence' => $row[8], 'version' => $row[9], 'bright_t15' => $row[10], 'frp' => $row[11], 'daynight' => $row[12]);
1926
+					$Source->addLocation('', $row[0], $row[1], null, '', '', 'fires', 'fire.png', 'fires', 0, 0, $row[5].' '.substr($row[6], 0, 2).':'.substr($row[6], 2, 2), json_encode($description));
1927 1927
 				}
1928 1928
 				$i++;
1929 1929
 			}
@@ -1939,7 +1939,7 @@  discard block
 block discarded – undo
1939 1939
 			$Connection = new Connection();
1940 1940
 			$sth = $Connection->db->prepare($query);
1941 1941
 			$sth->execute();
1942
-		} catch(PDOException $e) {
1942
+		} catch (PDOException $e) {
1943 1943
 			return "error : ".$e->getMessage();
1944 1944
 		}
1945 1945
 		$header = NULL;
@@ -1950,12 +1950,12 @@  discard block
 block discarded – undo
1950 1950
 			if ($globalTransaction) $Connection->db->beginTransaction();
1951 1951
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1952 1952
 			{
1953
-				if(count($row) > 1) {
1953
+				if (count($row) > 1) {
1954 1954
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1955 1955
 					try {
1956 1956
 						$sth = $Connection->db->prepare($query);
1957
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1958
-					} catch(PDOException $e) {
1957
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1958
+					} catch (PDOException $e) {
1959 1959
 						return "error : ".$e->getMessage();
1960 1960
 					}
1961 1961
 				}
@@ -1975,21 +1975,21 @@  discard block
 block discarded – undo
1975 1975
 			try {
1976 1976
 				$sth = $Connection->db->prepare($query);
1977 1977
                     		$sth->execute();
1978
-	                } catch(PDOException $e) {
1978
+	                } catch (PDOException $e) {
1979 1979
 				return "error : ".$e->getMessage();
1980 1980
 	                }
1981 1981
 	        }
1982 1982
 
1983 1983
 
1984
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1984
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1985 1985
 		else {
1986
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1986
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1987 1987
 			$query = "CREATE EXTENSION postgis";
1988
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1988
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1989 1989
 			try {
1990 1990
 				$sth = $Connection->db->prepare($query);
1991 1991
 				$sth->execute();
1992
-			} catch(PDOException $e) {
1992
+			} catch (PDOException $e) {
1993 1993
 				return "error : ".$e->getMessage();
1994 1994
 			}
1995 1995
 		}
@@ -2002,13 +2002,13 @@  discard block
 block discarded – undo
2002 2002
 		include_once('class.create_db.php');
2003 2003
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2004 2004
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2005
-		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2005
+		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5');
2006 2006
 		$error = '';
2007 2007
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
2008
-			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
2008
+			$notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5'));
2009 2009
 			$notam_md5 = $notam_md5_file[0];
2010 2010
 			if (!update_db::check_notam_version($notam_md5)) {
2011
-				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2011
+				update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
2012 2012
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2013 2013
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2014 2014
 						if ($globalDebug) echo "Gunzip...";
@@ -2044,14 +2044,14 @@  discard block
 block discarded – undo
2044 2044
 			try {
2045 2045
 				$sth = $Connection->db->prepare($query);
2046 2046
             	        	$sth->execute();
2047
-	                } catch(PDOException $e) {
2047
+	                } catch (PDOException $e) {
2048 2048
     	                	echo "error : ".$e->getMessage();
2049 2049
 	                }
2050 2050
 		}
2051 2051
 		if ($globalDBdriver == 'mysql') {
2052
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
2052
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
2053 2053
 		} else {
2054
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
2054
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
2055 2055
 		}
2056 2056
 		$error = create_db::import_file($tmp_dir.'countries.sql');
2057 2057
 		return $error;
@@ -2064,7 +2064,7 @@  discard block
 block discarded – undo
2064 2064
 //		update_db::unzip($tmp_dir.'AptNav.zip');
2065 2065
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
2066 2066
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
2067
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
2067
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
2068 2068
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
2069 2069
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
2070 2070
 		return $error;
@@ -2085,7 +2085,7 @@  discard block
 block discarded – undo
2085 2085
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2086 2086
 				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2087 2087
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2088
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2088
+					if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2089 2089
 				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2090 2090
 			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2091 2091
 		} else $error = "ZIP module not loaded but required for IVAO.";
@@ -2099,7 +2099,7 @@  discard block
 block discarded – undo
2099 2099
 		global $tmp_dir, $globalDebug;
2100 2100
 		$error = '';
2101 2101
 		if ($globalDebug) echo "Routes : Download...";
2102
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2102
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
2103 2103
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2104 2104
 			if ($globalDebug) echo "Gunzip...";
2105 2105
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
 		global $tmp_dir, $globalDebug;
2116 2116
 		$error = '';
2117 2117
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
2118
-		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2118
+		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
2119 2119
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2120 2120
 			if ($globalDebug) echo "Gunzip...";
2121 2121
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
 		global $tmp_dir, $globalDebug;
2132 2132
 		$error = '';
2133 2133
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
2134
-		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2134
+		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
2135 2135
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2136 2136
 			if ($globalDebug) echo "Gunzip...";
2137 2137
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2159,7 +2159,7 @@  discard block
 block discarded – undo
2159 2159
 */
2160 2160
 		if ($globalDebug) echo "Modes : Download...";
2161 2161
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2162
-		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2162
+		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2163 2163
 
2164 2164
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2165 2165
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
 	public static function update_ModeS_faa() {
2180 2180
 		global $tmp_dir, $globalDebug;
2181 2181
 		if ($globalDebug) echo "Modes FAA: Download...";
2182
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2182
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2183 2183
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2184 2184
 			if ($globalDebug) echo "Unzip...";
2185 2185
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
 	public static function update_ModeS_flarm() {
2196 2196
 		global $tmp_dir, $globalDebug;
2197 2197
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2198
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2198
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2199 2199
 		if (file_exists($tmp_dir.'data.fln')) {
2200 2200
 			if ($globalDebug) echo "Add to DB...";
2201 2201
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 	public static function update_ModeS_ogn() {
2210 2210
 		global $tmp_dir, $globalDebug;
2211 2211
 		if ($globalDebug) echo "Modes OGN: Download...";
2212
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2212
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2213 2213
 		if (file_exists($tmp_dir.'ogn.csv')) {
2214 2214
 			if ($globalDebug) echo "Add to DB...";
2215 2215
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2224,201 +2224,201 @@  discard block
 block discarded – undo
2224 2224
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2225 2225
 		
2226 2226
 		if ($globalDebug) echo "Owner France: Download...";
2227
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2227
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2228 2228
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2229 2229
 			if ($globalDebug) echo "Add to DB...";
2230
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2230
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2231 2231
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2232 2232
 		if ($error != '') {
2233 2233
 			return $error;
2234 2234
 		} elseif ($globalDebug) echo "Done\n";
2235 2235
 		
2236 2236
 		if ($globalDebug) echo "Owner Ireland: Download...";
2237
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2237
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2238 2238
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2239 2239
 			if ($globalDebug) echo "Add to DB...";
2240
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2240
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2241 2241
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2242 2242
 		if ($error != '') {
2243 2243
 			return $error;
2244 2244
 		} elseif ($globalDebug) echo "Done\n";
2245 2245
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2246
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2246
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2247 2247
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2248 2248
 			if ($globalDebug) echo "Add to DB...";
2249
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2249
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2250 2250
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2251 2251
 		if ($error != '') {
2252 2252
 			return $error;
2253 2253
 		} elseif ($globalDebug) echo "Done\n";
2254 2254
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2255
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2255
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2256 2256
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2257 2257
 			if ($globalDebug) echo "Add to DB...";
2258
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2258
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2259 2259
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2260 2260
 		if ($error != '') {
2261 2261
 			return $error;
2262 2262
 		} elseif ($globalDebug) echo "Done\n";
2263 2263
 		if ($globalDebug) echo "Owner Australia: Download...";
2264
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2264
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2265 2265
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2266 2266
 			if ($globalDebug) echo "Add to DB...";
2267
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2267
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2268 2268
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2269 2269
 		if ($error != '') {
2270 2270
 			return $error;
2271 2271
 		} elseif ($globalDebug) echo "Done\n";
2272 2272
 		if ($globalDebug) echo "Owner Austria: Download...";
2273
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2273
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2274 2274
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2275 2275
 			if ($globalDebug) echo "Add to DB...";
2276
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2276
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2277 2277
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2278 2278
 		if ($error != '') {
2279 2279
 			return $error;
2280 2280
 		} elseif ($globalDebug) echo "Done\n";
2281 2281
 		if ($globalDebug) echo "Owner Chile: Download...";
2282
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2282
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2283 2283
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2284 2284
 			if ($globalDebug) echo "Add to DB...";
2285
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2285
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2286 2286
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2287 2287
 		if ($error != '') {
2288 2288
 			return $error;
2289 2289
 		} elseif ($globalDebug) echo "Done\n";
2290 2290
 		if ($globalDebug) echo "Owner Colombia: Download...";
2291
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2291
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2292 2292
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2293 2293
 			if ($globalDebug) echo "Add to DB...";
2294
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2294
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2295 2295
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2296 2296
 		if ($error != '') {
2297 2297
 			return $error;
2298 2298
 		} elseif ($globalDebug) echo "Done\n";
2299 2299
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2300
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2300
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2301 2301
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2302 2302
 			if ($globalDebug) echo "Add to DB...";
2303
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2303
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2304 2304
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2305 2305
 		if ($error != '') {
2306 2306
 			return $error;
2307 2307
 		} elseif ($globalDebug) echo "Done\n";
2308 2308
 		if ($globalDebug) echo "Owner Brazil: Download...";
2309
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2309
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2310 2310
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2311 2311
 			if ($globalDebug) echo "Add to DB...";
2312
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2312
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2313 2313
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2314 2314
 		if ($error != '') {
2315 2315
 			return $error;
2316 2316
 		} elseif ($globalDebug) echo "Done\n";
2317 2317
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2318
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2318
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2319 2319
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2320 2320
 			if ($globalDebug) echo "Add to DB...";
2321
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2321
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2322 2322
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2323 2323
 		if ($error != '') {
2324 2324
 			return $error;
2325 2325
 		} elseif ($globalDebug) echo "Done\n";
2326 2326
 		if ($globalDebug) echo "Owner Croatia: Download...";
2327
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2327
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2328 2328
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2329 2329
 			if ($globalDebug) echo "Add to DB...";
2330
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2330
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2331 2331
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2332 2332
 		if ($error != '') {
2333 2333
 			return $error;
2334 2334
 		} elseif ($globalDebug) echo "Done\n";
2335 2335
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2336
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2336
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2337 2337
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2338 2338
 			if ($globalDebug) echo "Add to DB...";
2339
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2339
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2340 2340
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2341 2341
 		if ($error != '') {
2342 2342
 			return $error;
2343 2343
 		} elseif ($globalDebug) echo "Done\n";
2344 2344
 		if ($globalDebug) echo "Owner Maldives: Download...";
2345
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2345
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2346 2346
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2347 2347
 			if ($globalDebug) echo "Add to DB...";
2348
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2348
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2349 2349
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2350 2350
 		if ($error != '') {
2351 2351
 			return $error;
2352 2352
 		} elseif ($globalDebug) echo "Done\n";
2353 2353
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2354
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2354
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2355 2355
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2356 2356
 			if ($globalDebug) echo "Add to DB...";
2357
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2357
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2358 2358
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2359 2359
 		if ($error != '') {
2360 2360
 			return $error;
2361 2361
 		} elseif ($globalDebug) echo "Done\n";
2362 2362
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2363
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2363
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2364 2364
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2365 2365
 			if ($globalDebug) echo "Add to DB...";
2366
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2366
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2367 2367
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2368 2368
 		if ($error != '') {
2369 2369
 			return $error;
2370 2370
 		} elseif ($globalDebug) echo "Done\n";
2371 2371
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2372
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2372
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2373 2373
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2374 2374
 			if ($globalDebug) echo "Add to DB...";
2375
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2375
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2376 2376
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2377 2377
 		if ($error != '') {
2378 2378
 			return $error;
2379 2379
 		} elseif ($globalDebug) echo "Done\n";
2380 2380
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2381
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2381
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2382 2382
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2383 2383
 			if ($globalDebug) echo "Add to DB...";
2384
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2384
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2385 2385
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2386 2386
 		if ($error != '') {
2387 2387
 			return $error;
2388 2388
 		} elseif ($globalDebug) echo "Done\n";
2389 2389
 		if ($globalDebug) echo "Owner Iceland: Download...";
2390
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2390
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2391 2391
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2392 2392
 			if ($globalDebug) echo "Add to DB...";
2393
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2393
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2394 2394
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2395 2395
 		if ($error != '') {
2396 2396
 			return $error;
2397 2397
 		} elseif ($globalDebug) echo "Done\n";
2398 2398
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2399
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2399
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2400 2400
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2401 2401
 			if ($globalDebug) echo "Add to DB...";
2402
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2402
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2403 2403
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2404 2404
 		if ($error != '') {
2405 2405
 			return $error;
2406 2406
 		} elseif ($globalDebug) echo "Done\n";
2407 2407
 		if ($globalMasterSource) {
2408 2408
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2409
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2409
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2410 2410
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2411 2411
 				if ($globalDebug) echo "Add to DB...";
2412
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2412
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2413 2413
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2414 2414
 			if ($error != '') {
2415 2415
 				return $error;
2416 2416
 			} elseif ($globalDebug) echo "Done\n";
2417 2417
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2418
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2418
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2419 2419
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2420 2420
 				if ($globalDebug) echo "Add to DB...";
2421
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2421
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2422 2422
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2423 2423
 			if ($error != '') {
2424 2424
 				return $error;
@@ -2431,7 +2431,7 @@  discard block
 block discarded – undo
2431 2431
 		global $tmp_dir, $globalDebug;
2432 2432
 		$error = '';
2433 2433
 		if ($globalDebug) echo "Translation : Download...";
2434
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2434
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2435 2435
 		if (file_exists($tmp_dir.'translation.zip')) {
2436 2436
 			if ($globalDebug) echo "Unzip...";
2437 2437
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2448,10 +2448,10 @@  discard block
 block discarded – undo
2448 2448
 		global $tmp_dir, $globalDebug;
2449 2449
 		$error = '';
2450 2450
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2451
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2452
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2451
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2452
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5');
2453 2453
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2454
-			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2454
+			$translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2455 2455
 			$translation_md5 = $translation_md5_file[0];
2456 2456
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2457 2457
 				if ($globalDebug) echo "Gunzip...";
@@ -2469,10 +2469,10 @@  discard block
 block discarded – undo
2469 2469
 		global $tmp_dir, $globalDebug;
2470 2470
 		$error = '';
2471 2471
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2472
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2473
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2472
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2473
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5');
2474 2474
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2475
-			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2475
+			$modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2476 2476
 			$modes_md5 = $modes_md5_file[0];
2477 2477
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2478 2478
 				if ($globalDebug) echo "Gunzip...";
@@ -2491,12 +2491,12 @@  discard block
 block discarded – undo
2491 2491
 		global $tmp_dir, $globalDebug;
2492 2492
 		$error = '';
2493 2493
 		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2494
-		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2494
+		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5');
2495 2495
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2496
-			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2496
+			$airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2497 2497
 			$airlines_md5 = $airlines_md5_file[0];
2498 2498
 			if (!update_db::check_airlines_version($airlines_md5)) {
2499
-				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2499
+				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz');
2500 2500
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2501 2501
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2502 2502
 						if ($globalDebug) echo "Gunzip...";
@@ -2521,14 +2521,14 @@  discard block
 block discarded – undo
2521 2521
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2522 2522
 		$error = '';
2523 2523
 		if ($globalOwner === TRUE) {
2524
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2525
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2524
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2525
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2526 2526
 		} else {
2527
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2528
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2527
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2528
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2529 2529
 		}
2530 2530
 		if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) {
2531
-			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2531
+			$owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2532 2532
 			$owners_md5 = $owners_md5_file[0];
2533 2533
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2534 2534
 				if ($globalDebug) echo "Gunzip...";
@@ -2545,10 +2545,10 @@  discard block
 block discarded – undo
2545 2545
 	public static function update_routes_fam() {
2546 2546
 		global $tmp_dir, $globalDebug;
2547 2547
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2548
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2549
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2548
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2549
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5');
2550 2550
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2551
-			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2551
+			$routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2552 2552
 			$routes_md5 = $routes_md5_file[0];
2553 2553
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2554 2554
 				if ($globalDebug) echo "Gunzip...";
@@ -2565,10 +2565,10 @@  discard block
 block discarded – undo
2565 2565
 	public static function update_block_fam() {
2566 2566
 		global $tmp_dir, $globalDebug;
2567 2567
 		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
2568
-		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2569
-		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2568
+		update_db::download('http://data.flightairmap.com/data/block.tsv.gz', $tmp_dir.'block.tsv.gz');
2569
+		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5', $tmp_dir.'block.tsv.gz.md5');
2570 2570
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2571
-			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2571
+			$block_md5_file = explode(' ', file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2572 2572
 			$block_md5 = $block_md5_file[0];
2573 2573
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2574 2574
 				if ($globalDebug) echo "Gunzip...";
@@ -2584,13 +2584,13 @@  discard block
 block discarded – undo
2584 2584
 	}
2585 2585
 	public static function update_marine_identity_fam() {
2586 2586
 		global $tmp_dir, $globalDebug;
2587
-		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2587
+		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2588 2588
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2589
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2589
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2590 2590
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2591 2591
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2592 2592
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2593
-				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2593
+				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2594 2594
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2595 2595
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2596 2596
 						if ($globalDebug) echo "Gunzip...";
@@ -2612,13 +2612,13 @@  discard block
 block discarded – undo
2612 2612
 
2613 2613
 	public static function update_satellite_fam() {
2614 2614
 		global $tmp_dir, $globalDebug;
2615
-		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2615
+		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2616 2616
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2617
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2617
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2618 2618
 			$satellite_md5 = $satellite_md5_file[0];
2619 2619
 			if (!update_db::check_satellite_version($satellite_md5)) {
2620 2620
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2621
-				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2621
+				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2622 2622
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2623 2623
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2624 2624
 						if ($globalDebug) echo "Gunzip...";
@@ -2640,7 +2640,7 @@  discard block
 block discarded – undo
2640 2640
 	public static function update_banned_fam() {
2641 2641
 		global $tmp_dir, $globalDebug;
2642 2642
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2643
-		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2643
+		update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2644 2644
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2645 2645
 			//if ($globalDebug) echo "Gunzip...";
2646 2646
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2659,18 +2659,18 @@  discard block
 block discarded – undo
2659 2659
 		$error = '';
2660 2660
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2661 2661
 		if ($globalDBdriver == 'mysql') {
2662
-			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2662
+			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2663 2663
 		} else {
2664
-			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2664
+			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2665 2665
 		}
2666 2666
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2667
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2667
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2668 2668
 			$airspace_md5 = $airspace_md5_file[0];
2669 2669
 			if (!update_db::check_airspace_version($airspace_md5)) {
2670 2670
 				if ($globalDBdriver == 'mysql') {
2671
-					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2671
+					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2672 2672
 				} else {
2673
-					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2673
+					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2674 2674
 				}
2675 2675
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2676 2676
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
@@ -2683,7 +2683,7 @@  discard block
 block discarded – undo
2683 2683
 							try {
2684 2684
 								$sth = $Connection->db->prepare($query);
2685 2685
 								$sth->execute();
2686
-							} catch(PDOException $e) {
2686
+							} catch (PDOException $e) {
2687 2687
 								return "error : ".$e->getMessage();
2688 2688
 							}
2689 2689
 						}
@@ -2703,16 +2703,16 @@  discard block
 block discarded – undo
2703 2703
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2704 2704
 		$error = '';
2705 2705
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2706
-		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2706
+		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2707 2707
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2708
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2708
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2709 2709
 			$geoid_md5 = $geoid_md5_file[0];
2710 2710
 			if (!update_db::check_geoid_version($geoid_md5)) {
2711
-				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2711
+				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2712 2712
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2713 2713
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2714 2714
 						if ($globalDebug) echo "Gunzip...";
2715
-						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2715
+						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2716 2716
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2717 2717
 							update_db::insert_geoid_version($geoid_md5);
2718 2718
 						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
@@ -2729,15 +2729,15 @@  discard block
 block discarded – undo
2729 2729
 	public static function update_tle() {
2730 2730
 		global $tmp_dir, $globalDebug;
2731 2731
 		if ($globalDebug) echo "Download TLE : Download...";
2732
-		$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
-		'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
-		'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');
2732
+		$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
+		'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
+		'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 2735
 		foreach ($alltle as $filename) {
2736 2736
 			if ($globalDebug) echo "downloading ".$filename.'...';
2737
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2737
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2738 2738
 			if (file_exists($tmp_dir.$filename)) {
2739 2739
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2740
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2740
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2741 2741
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2742 2742
 			if ($error != '') {
2743 2743
 				echo $error."\n";
@@ -2749,7 +2749,7 @@  discard block
 block discarded – undo
2749 2749
 	public static function update_ucsdb() {
2750 2750
 		global $tmp_dir, $globalDebug;
2751 2751
 		if ($globalDebug) echo "Download UCS DB : Download...";
2752
-		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');
2752
+		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 2753
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2754 2754
 			if ($globalDebug) echo "Add to DB...";
2755 2755
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
@@ -2763,7 +2763,7 @@  discard block
 block discarded – undo
2763 2763
 	public static function update_celestrak() {
2764 2764
 		global $tmp_dir, $globalDebug;
2765 2765
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2766
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2766
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2767 2767
 		if (file_exists($tmp_dir.'satcat.txt')) {
2768 2768
 			if ($globalDebug) echo "Add to DB...";
2769 2769
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2782,62 +2782,62 @@  discard block
 block discarded – undo
2782 2782
 			if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !';
2783 2783
 			return '';
2784 2784
 		}
2785
-		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2785
+		update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2786 2786
 		if (file_exists($tmp_dir.'models.md5sum')) {
2787 2787
 			if ($globalDebug) echo "Check files...\n";
2788 2788
 			$newmodelsdb = array();
2789
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2790
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2789
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2790
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2791 2791
 					$model = trim($row[2]);
2792 2792
 					$newmodelsdb[$model] = trim($row[0]);
2793 2793
 				}
2794 2794
 			}
2795 2795
 			$modelsdb = array();
2796 2796
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2797
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2798
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2797
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2798
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2799 2799
 						$model = trim($row[2]);
2800 2800
 						$modelsdb[$model] = trim($row[0]);
2801 2801
 					}
2802 2802
 				}
2803 2803
 			}
2804
-			$diff = array_diff($newmodelsdb,$modelsdb);
2804
+			$diff = array_diff($newmodelsdb, $modelsdb);
2805 2805
 			foreach ($diff as $key => $value) {
2806 2806
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2807
-				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2807
+				update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2808 2808
 			}
2809
-			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2809
+			update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2810 2810
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2811 2811
 		if ($error != '') {
2812 2812
 			return $error;
2813 2813
 		} elseif ($globalDebug) echo "Done\n";
2814 2814
 		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
2815
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2815
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum');
2816 2816
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2817 2817
 			if ($globalDebug) echo "Check files...\n";
2818 2818
 			$newmodelsdb = array();
2819
-			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2820
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2819
+			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) {
2820
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2821 2821
 					$model = trim($row[2]);
2822 2822
 					$newmodelsdb[$model] = trim($row[0]);
2823 2823
 				}
2824 2824
 			}
2825 2825
 			$modelsdb = array();
2826 2826
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) {
2827
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) {
2828
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2827
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) {
2828
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2829 2829
 						$model = trim($row[2]);
2830 2830
 						$modelsdb[$model] = trim($row[0]);
2831 2831
 					}
2832 2832
 				}
2833 2833
 			}
2834
-			$diff = array_diff($newmodelsdb,$modelsdb);
2834
+			$diff = array_diff($newmodelsdb, $modelsdb);
2835 2835
 			foreach ($diff as $key => $value) {
2836 2836
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2837
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2837
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key);
2838 2838
 				
2839 2839
 			}
2840
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2840
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum');
2841 2841
 		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
2842 2842
 		if ($error != '') {
2843 2843
 			return $error;
@@ -2853,32 +2853,32 @@  discard block
 block discarded – undo
2853 2853
 			return '';
2854 2854
 		}
2855 2855
 		if ($globalDebug) echo "Weather Models from FlightAirMap website : Download...";
2856
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum');
2856
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', $tmp_dir.'modelsweather.md5sum');
2857 2857
 		if (file_exists($tmp_dir.'modelsweather.md5sum')) {
2858 2858
 			if ($globalDebug) echo "Check files...\n";
2859 2859
 			$newmodelsdb = array();
2860
-			if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) {
2861
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2860
+			if (($handle = fopen($tmp_dir.'modelsweather.md5sum', 'r')) !== FALSE) {
2861
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2862 2862
 					$model = trim($row[2]);
2863 2863
 					$newmodelsdb[$model] = trim($row[0]);
2864 2864
 				}
2865 2865
 			}
2866 2866
 			$modelsdb = array();
2867 2867
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum')) {
2868
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum','r')) !== FALSE) {
2869
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2868
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum', 'r')) !== FALSE) {
2869
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2870 2870
 						$model = trim($row[2]);
2871 2871
 						$modelsdb[$model] = trim($row[0]);
2872 2872
 					}
2873 2873
 				}
2874 2874
 			}
2875
-			$diff = array_diff($newmodelsdb,$modelsdb);
2875
+			$diff = array_diff($newmodelsdb, $modelsdb);
2876 2876
 			foreach ($diff as $key => $value) {
2877 2877
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2878
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2878
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key, dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2879 2879
 				
2880 2880
 			}
2881
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2881
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2882 2882
 		} else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
2883 2883
 		if ($error != '') {
2884 2884
 			return $error;
@@ -2890,32 +2890,32 @@  discard block
 block discarded – undo
2890 2890
 		global $tmp_dir, $globalDebug;
2891 2891
 		$error = '';
2892 2892
 		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
2893
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2893
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum');
2894 2894
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2895 2895
 			if ($globalDebug) echo "Check files...\n";
2896 2896
 			$newmodelsdb = array();
2897
-			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2898
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2897
+			if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) {
2898
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2899 2899
 					$model = trim($row[2]);
2900 2900
 					$newmodelsdb[$model] = trim($row[0]);
2901 2901
 				}
2902 2902
 			}
2903 2903
 			$modelsdb = array();
2904 2904
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) {
2905
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) {
2906
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2905
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) {
2906
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2907 2907
 						$model = trim($row[2]);
2908 2908
 						$modelsdb[$model] = trim($row[0]);
2909 2909
 					}
2910 2910
 				}
2911 2911
 			}
2912
-			$diff = array_diff($newmodelsdb,$modelsdb);
2912
+			$diff = array_diff($newmodelsdb, $modelsdb);
2913 2913
 			foreach ($diff as $key => $value) {
2914 2914
 				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
2915
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2915
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2916 2916
 				
2917 2917
 			}
2918
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2918
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2919 2919
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2920 2920
 		if ($error != '') {
2921 2921
 			return $error;
@@ -2931,32 +2931,32 @@  discard block
 block discarded – undo
2931 2931
 			return '';
2932 2932
 		}
2933 2933
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2934
-		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2934
+		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2935 2935
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2936 2936
 			if ($globalDebug) echo "Check files...\n";
2937 2937
 			$newmodelsdb = array();
2938
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2939
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2938
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2939
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2940 2940
 					$model = trim($row[2]);
2941 2941
 					$newmodelsdb[$model] = trim($row[0]);
2942 2942
 				}
2943 2943
 			}
2944 2944
 			$modelsdb = array();
2945 2945
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2946
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2947
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2946
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2947
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2948 2948
 						$model = trim($row[2]);
2949 2949
 						$modelsdb[$model] = trim($row[0]);
2950 2950
 					}
2951 2951
 				}
2952 2952
 			}
2953
-			$diff = array_diff($newmodelsdb,$modelsdb);
2953
+			$diff = array_diff($newmodelsdb, $modelsdb);
2954 2954
 			foreach ($diff as $key => $value) {
2955 2955
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2956
-				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2956
+				update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2957 2957
 				
2958 2958
 			}
2959
-			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2959
+			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2960 2960
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2961 2961
 		if ($error != '') {
2962 2962
 			return $error;
@@ -2972,32 +2972,32 @@  discard block
 block discarded – undo
2972 2972
 			return '';
2973 2973
 		}
2974 2974
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2975
-		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2975
+		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2976 2976
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2977 2977
 			if ($globalDebug) echo "Check files...\n";
2978 2978
 			$newmodelsdb = array();
2979
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2980
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2979
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2980
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2981 2981
 					$model = trim($row[2]);
2982 2982
 					$newmodelsdb[$model] = trim($row[0]);
2983 2983
 				}
2984 2984
 			}
2985 2985
 			$modelsdb = array();
2986 2986
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2987
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2988
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2987
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2988
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2989 2989
 						$model = trim($row[2]);
2990 2990
 						$modelsdb[$model] = trim($row[0]);
2991 2991
 					}
2992 2992
 				}
2993 2993
 			}
2994
-			$diff = array_diff($newmodelsdb,$modelsdb);
2994
+			$diff = array_diff($newmodelsdb, $modelsdb);
2995 2995
 			foreach ($diff as $key => $value) {
2996 2996
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2997
-				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2997
+				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2998 2998
 				
2999 2999
 			}
3000
-			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3000
+			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
3001 3001
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3002 3002
 		if ($error != '') {
3003 3003
 			return $error;
@@ -3009,8 +3009,8 @@  discard block
 block discarded – undo
3009 3009
 		global $tmp_dir, $globalDebug;
3010 3010
 		date_default_timezone_set('UTC');
3011 3011
 		$Common = new Common();
3012
-		$data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes','post',array('X-Requested-With: XMLHttpRequest','Accept: application/json, text/javascript, */*; q=0.01','Host: www4.icao.int','Origin: https://www.icao.int','Content-Length: 0'),'','','https://www.icao.int/publications/DOC8643/Pages/Search.aspx',60);
3013
-		$all = json_decode($data,true);
3012
+		$data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes', 'post', array('X-Requested-With: XMLHttpRequest', 'Accept: application/json, text/javascript, */*; q=0.01', 'Host: www4.icao.int', 'Origin: https://www.icao.int', 'Content-Length: 0'), '', '', 'https://www.icao.int/publications/DOC8643/Pages/Search.aspx', 60);
3013
+		$all = json_decode($data, true);
3014 3014
 		$Connection = new Connection();
3015 3015
 		$querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao";
3016 3016
 		$sth = $Connection->db->prepare($querychk);
@@ -3022,8 +3022,8 @@  discard block
 block discarded – undo
3022 3022
 		foreach ($all as $model) {
3023 3023
 			$icao = $model['Designator'];
3024 3024
 			if (!isset($allicao[$icao])) {
3025
-				$aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png';
3026
-				$allicao[$icao] = array(':icao' => $icao,':type' => $model['ModelFullName'],':manufacturer' => $model['ManufacturerCode'],':aircraft_shadow' => $aircraft_shadow,':aircraft_description' => $model['AircraftDescription'],':engine_type' => $model['EngineType'],':engine_count' => $model['EngineCount'],':wake_category' => $model['WTC']);
3025
+				$aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png';
3026
+				$allicao[$icao] = array(':icao' => $icao, ':type' => $model['ModelFullName'], ':manufacturer' => $model['ManufacturerCode'], ':aircraft_shadow' => $aircraft_shadow, ':aircraft_description' => $model['AircraftDescription'], ':engine_type' => $model['EngineType'], ':engine_count' => $model['EngineCount'], ':wake_category' => $model['WTC']);
3027 3027
 			} else {
3028 3028
 				$allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName'];
3029 3029
 			}
@@ -3035,9 +3035,9 @@  discard block
 block discarded – undo
3035 3035
 				if ($exist[0]['nb'] == 0) {
3036 3036
 					$sthins->execute($airdata);
3037 3037
 				} else {
3038
-					$sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao));
3038
+					$sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao));
3039 3039
 				}
3040
-			} catch(PDOException $e) {
3040
+			} catch (PDOException $e) {
3041 3041
 				return "error : ".$e->getMessage();
3042 3042
 			}
3043 3043
 		}
@@ -3069,23 +3069,23 @@  discard block
 block discarded – undo
3069 3069
 			$Connection = new Connection();
3070 3070
 			$sth = $Connection->db->prepare($query);
3071 3071
                         $sth->execute();
3072
-                } catch(PDOException $e) {
3072
+                } catch (PDOException $e) {
3073 3073
                         return "error : ".$e->getMessage();
3074 3074
                 }
3075 3075
 
3076 3076
 		$error = '';
3077 3077
 		if ($globalDebug) echo "Notam : Download...";
3078
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3078
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
3079 3079
 		if (file_exists($tmp_dir.'notam.rss')) {
3080
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
3080
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
3081 3081
 			foreach ($notams['channel']['item'] as $notam) {
3082
-				$title = explode(':',$notam['title']);
3082
+				$title = explode(':', $notam['title']);
3083 3083
 				$data['ref'] = trim($title[0]);
3084 3084
 				unset($title[0]);
3085
-				$data['title'] = trim(implode(':',$title));
3086
-				$description = strip_tags($notam['description'],'<pre>');
3087
-				preg_match(':^(.*?)<pre>:',$description,$match);
3088
-				$q = explode('/',$match[1]);
3085
+				$data['title'] = trim(implode(':', $title));
3086
+				$description = strip_tags($notam['description'], '<pre>');
3087
+				preg_match(':^(.*?)<pre>:', $description, $match);
3088
+				$q = explode('/', $match[1]);
3089 3089
 				$data['fir'] = $q[0];
3090 3090
 				$data['code'] = $q[1];
3091 3091
 				$ifrvfr = $q[2];
@@ -3101,30 +3101,30 @@  discard block
 block discarded – undo
3101 3101
 				$data['lower_limit'] = $q[5];
3102 3102
 				$data['upper_limit'] = $q[6];
3103 3103
 				$latlonrad = $q[7];
3104
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3105
-				$latitude = $Common->convertDec($las,'latitude');
3106
-				$longitude = $Common->convertDec($lns,'longitude');
3104
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
3105
+				$latitude = $Common->convertDec($las, 'latitude');
3106
+				$longitude = $Common->convertDec($lns, 'longitude');
3107 3107
 				if ($lac == 'S') $latitude = '-'.$latitude;
3108 3108
 				if ($lnc == 'W') $longitude = '-'.$longitude;
3109 3109
 				$data['center_latitude'] = $latitude;
3110 3110
 				$data['center_longitude'] = $longitude;
3111 3111
 				$data['radius'] = intval($radius);
3112 3112
 				
3113
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
3113
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
3114 3114
 				$data['text'] = $match[1];
3115
-				preg_match(':</pre>(.*?)$:',$description,$match);
3115
+				preg_match(':</pre>(.*?)$:', $description, $match);
3116 3116
 				$fromto = $match[1];
3117
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
3117
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
3118 3118
 				$fromall = trim($match[1]);
3119
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
3119
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
3120 3120
 				$from = trim($match[1]);
3121
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
3122
-				preg_match('#TO:(.*?)$#',$fromto,$match);
3121
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
3122
+				preg_match('#TO:(.*?)$#', $fromto, $match);
3123 3123
 				$toall = trim($match[1]);
3124
-				if (!preg_match(':Permanent:',$toall)) {
3125
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
3124
+				if (!preg_match(':Permanent:', $toall)) {
3125
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
3126 3126
 					$to = trim($match[1]);
3127
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3127
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
3128 3128
 					$data['permanent'] = 0;
3129 3129
 				} else {
3130 3130
 				    $data['date_end'] = NULL;
@@ -3132,7 +3132,7 @@  discard block
 block discarded – undo
3132 3132
 				}
3133 3133
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3134 3134
 				$NOTAM = new NOTAM();
3135
-				$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']);
3135
+				$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 3136
 				unset($data);
3137 3137
 			} 
3138 3138
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -3155,16 +3155,16 @@  discard block
 block discarded – undo
3155 3155
 				$Connection = new Connection();
3156 3156
 				$sth = $Connection->db->prepare($query);
3157 3157
 				$sth->execute();
3158
-			} catch(PDOException $e) {
3158
+			} catch (PDOException $e) {
3159 3159
 				return "error : ".$e->getMessage();
3160 3160
 			}
3161 3161
 		}
3162 3162
 		$Common = new Common();
3163 3163
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3164
-		$airspace_json = json_decode($airspace_lst,true);
3164
+		$airspace_json = json_decode($airspace_lst, true);
3165 3165
 		foreach ($airspace_json['records'] as $airspace) {
3166 3166
 			if ($globalDebug) echo $airspace['name']."...\n";
3167
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3167
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
3168 3168
 			if (file_exists($tmp_dir.$airspace['name'])) {
3169 3169
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
3170 3170
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -3186,7 +3186,7 @@  discard block
 block discarded – undo
3186 3186
 				$Connection = new Connection();
3187 3187
 				$sth = $Connection->db->prepare($query);
3188 3188
 				$sth->execute(array(':new' => $new, ':old' => $old));
3189
-			} catch(PDOException $e) {
3189
+			} catch (PDOException $e) {
3190 3190
 				return "error : ".$e->getMessage();
3191 3191
 			}
3192 3192
 		}
@@ -3203,7 +3203,7 @@  discard block
 block discarded – undo
3203 3203
 			$Connection = new Connection();
3204 3204
 			$sth = $Connection->db->prepare($query);
3205 3205
                         $sth->execute();
3206
-                } catch(PDOException $e) {
3206
+                } catch (PDOException $e) {
3207 3207
                         return "error : ".$e->getMessage();
3208 3208
                 }
3209 3209
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3218,7 +3218,7 @@  discard block
 block discarded – undo
3218 3218
 			$Connection = new Connection();
3219 3219
 			$sth = $Connection->db->prepare($query);
3220 3220
                         $sth->execute();
3221
-                } catch(PDOException $e) {
3221
+                } catch (PDOException $e) {
3222 3222
                         return "error : ".$e->getMessage();
3223 3223
                 }
3224 3224
 	}
@@ -3229,7 +3229,7 @@  discard block
 block discarded – undo
3229 3229
 			$Connection = new Connection();
3230 3230
 			$sth = $Connection->db->prepare($query);
3231 3231
                         $sth->execute(array(':version' => $version));
3232
-                } catch(PDOException $e) {
3232
+                } catch (PDOException $e) {
3233 3233
                         return "error : ".$e->getMessage();
3234 3234
                 }
3235 3235
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3243,7 +3243,7 @@  discard block
 block discarded – undo
3243 3243
 			$Connection = new Connection();
3244 3244
 			$sth = $Connection->db->prepare($query);
3245 3245
                         $sth->execute(array(':version' => $version));
3246
-                } catch(PDOException $e) {
3246
+                } catch (PDOException $e) {
3247 3247
                         return "error : ".$e->getMessage();
3248 3248
                 }
3249 3249
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3257,7 +3257,7 @@  discard block
 block discarded – undo
3257 3257
 			$Connection = new Connection();
3258 3258
 			$sth = $Connection->db->prepare($query);
3259 3259
 			$sth->execute(array(':version' => $version));
3260
-		} catch(PDOException $e) {
3260
+		} catch (PDOException $e) {
3261 3261
 			return "error : ".$e->getMessage();
3262 3262
 		}
3263 3263
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3271,7 +3271,7 @@  discard block
 block discarded – undo
3271 3271
 			$Connection = new Connection();
3272 3272
 			$sth = $Connection->db->prepare($query);
3273 3273
 			$sth->execute(array(':version' => $version));
3274
-		} catch(PDOException $e) {
3274
+		} catch (PDOException $e) {
3275 3275
 			return "error : ".$e->getMessage();
3276 3276
 		}
3277 3277
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3285,7 +3285,7 @@  discard block
 block discarded – undo
3285 3285
 			$Connection = new Connection();
3286 3286
 			$sth = $Connection->db->prepare($query);
3287 3287
 			$sth->execute(array(':version' => $version));
3288
-		} catch(PDOException $e) {
3288
+		} catch (PDOException $e) {
3289 3289
 			return "error : ".$e->getMessage();
3290 3290
 		}
3291 3291
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3299,7 +3299,7 @@  discard block
 block discarded – undo
3299 3299
 			$Connection = new Connection();
3300 3300
 			$sth = $Connection->db->prepare($query);
3301 3301
 			$sth->execute(array(':version' => $version));
3302
-		} catch(PDOException $e) {
3302
+		} catch (PDOException $e) {
3303 3303
 			return "error : ".$e->getMessage();
3304 3304
 		}
3305 3305
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3314,7 +3314,7 @@  discard block
 block discarded – undo
3314 3314
 			$Connection = new Connection();
3315 3315
 			$sth = $Connection->db->prepare($query);
3316 3316
 			$sth->execute(array(':version' => $version));
3317
-		} catch(PDOException $e) {
3317
+		} catch (PDOException $e) {
3318 3318
 			return "error : ".$e->getMessage();
3319 3319
 		}
3320 3320
 	}
@@ -3326,7 +3326,7 @@  discard block
 block discarded – undo
3326 3326
 			$Connection = new Connection();
3327 3327
 			$sth = $Connection->db->prepare($query);
3328 3328
 			$sth->execute(array(':version' => $version));
3329
-		} catch(PDOException $e) {
3329
+		} catch (PDOException $e) {
3330 3330
 			return "error : ".$e->getMessage();
3331 3331
 		}
3332 3332
 	}
@@ -3338,7 +3338,7 @@  discard block
 block discarded – undo
3338 3338
 			$Connection = new Connection();
3339 3339
 			$sth = $Connection->db->prepare($query);
3340 3340
 			$sth->execute(array(':version' => $version));
3341
-		} catch(PDOException $e) {
3341
+		} catch (PDOException $e) {
3342 3342
 			return "error : ".$e->getMessage();
3343 3343
 		}
3344 3344
 	}
@@ -3350,7 +3350,7 @@  discard block
 block discarded – undo
3350 3350
 			$Connection = new Connection();
3351 3351
 			$sth = $Connection->db->prepare($query);
3352 3352
                         $sth->execute(array(':version' => $version));
3353
-                } catch(PDOException $e) {
3353
+                } catch (PDOException $e) {
3354 3354
                         return "error : ".$e->getMessage();
3355 3355
                 }
3356 3356
 	}
@@ -3362,7 +3362,7 @@  discard block
 block discarded – undo
3362 3362
 			$Connection = new Connection();
3363 3363
 			$sth = $Connection->db->prepare($query);
3364 3364
 			$sth->execute(array(':version' => $version));
3365
-		} catch(PDOException $e) {
3365
+		} catch (PDOException $e) {
3366 3366
 			return "error : ".$e->getMessage();
3367 3367
 		}
3368 3368
 	}
@@ -3374,7 +3374,7 @@  discard block
 block discarded – undo
3374 3374
 			$Connection = new Connection();
3375 3375
 			$sth = $Connection->db->prepare($query);
3376 3376
 			$sth->execute(array(':version' => $version));
3377
-		} catch(PDOException $e) {
3377
+		} catch (PDOException $e) {
3378 3378
 			return "error : ".$e->getMessage();
3379 3379
 		}
3380 3380
 	}
@@ -3390,7 +3390,7 @@  discard block
 block discarded – undo
3390 3390
 			$Connection = new Connection();
3391 3391
 			$sth = $Connection->db->prepare($query);
3392 3392
                         $sth->execute();
3393
-                } catch(PDOException $e) {
3393
+                } catch (PDOException $e) {
3394 3394
                         return "error : ".$e->getMessage();
3395 3395
                 }
3396 3396
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3405,7 +3405,7 @@  discard block
 block discarded – undo
3405 3405
 			$Connection = new Connection();
3406 3406
 			$sth = $Connection->db->prepare($query);
3407 3407
                         $sth->execute();
3408
-                } catch(PDOException $e) {
3408
+                } catch (PDOException $e) {
3409 3409
                         return "error : ".$e->getMessage();
3410 3410
                 }
3411 3411
 	}
@@ -3421,7 +3421,7 @@  discard block
 block discarded – undo
3421 3421
 			$Connection = new Connection();
3422 3422
 			$sth = $Connection->db->prepare($query);
3423 3423
                         $sth->execute();
3424
-                } catch(PDOException $e) {
3424
+                } catch (PDOException $e) {
3425 3425
                         return "error : ".$e->getMessage();
3426 3426
                 }
3427 3427
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3436,7 +3436,7 @@  discard block
 block discarded – undo
3436 3436
 			$Connection = new Connection();
3437 3437
 			$sth = $Connection->db->prepare($query);
3438 3438
                         $sth->execute();
3439
-                } catch(PDOException $e) {
3439
+                } catch (PDOException $e) {
3440 3440
                         return "error : ".$e->getMessage();
3441 3441
                 }
3442 3442
 	}
@@ -3452,7 +3452,7 @@  discard block
 block discarded – undo
3452 3452
 			$Connection = new Connection();
3453 3453
 			$sth = $Connection->db->prepare($query);
3454 3454
                         $sth->execute();
3455
-                } catch(PDOException $e) {
3455
+                } catch (PDOException $e) {
3456 3456
                         return "error : ".$e->getMessage();
3457 3457
                 }
3458 3458
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3467,7 +3467,7 @@  discard block
 block discarded – undo
3467 3467
 			$Connection = new Connection();
3468 3468
 			$sth = $Connection->db->prepare($query);
3469 3469
                         $sth->execute();
3470
-                } catch(PDOException $e) {
3470
+                } catch (PDOException $e) {
3471 3471
                         return "error : ".$e->getMessage();
3472 3472
                 }
3473 3473
 	}
@@ -3483,7 +3483,7 @@  discard block
 block discarded – undo
3483 3483
 			$Connection = new Connection();
3484 3484
 			$sth = $Connection->db->prepare($query);
3485 3485
 			$sth->execute();
3486
-		} catch(PDOException $e) {
3486
+		} catch (PDOException $e) {
3487 3487
 			return "error : ".$e->getMessage();
3488 3488
 		}
3489 3489
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3498,7 +3498,7 @@  discard block
 block discarded – undo
3498 3498
 			$Connection = new Connection();
3499 3499
 			$sth = $Connection->db->prepare($query);
3500 3500
 			$sth->execute();
3501
-		} catch(PDOException $e) {
3501
+		} catch (PDOException $e) {
3502 3502
 			return "error : ".$e->getMessage();
3503 3503
 		}
3504 3504
 	}
@@ -3514,7 +3514,7 @@  discard block
 block discarded – undo
3514 3514
 			$Connection = new Connection();
3515 3515
 			$sth = $Connection->db->prepare($query);
3516 3516
 			$sth->execute();
3517
-		} catch(PDOException $e) {
3517
+		} catch (PDOException $e) {
3518 3518
 			return "error : ".$e->getMessage();
3519 3519
 		}
3520 3520
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3529,7 +3529,7 @@  discard block
 block discarded – undo
3529 3529
 			$Connection = new Connection();
3530 3530
 			$sth = $Connection->db->prepare($query);
3531 3531
 			$sth->execute();
3532
-		} catch(PDOException $e) {
3532
+		} catch (PDOException $e) {
3533 3533
 			return "error : ".$e->getMessage();
3534 3534
 		}
3535 3535
 	}
@@ -3545,7 +3545,7 @@  discard block
 block discarded – undo
3545 3545
 			$Connection = new Connection();
3546 3546
 			$sth = $Connection->db->prepare($query);
3547 3547
 			$sth->execute();
3548
-		} catch(PDOException $e) {
3548
+		} catch (PDOException $e) {
3549 3549
 			return "error : ".$e->getMessage();
3550 3550
 		}
3551 3551
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3560,7 +3560,7 @@  discard block
 block discarded – undo
3560 3560
 			$Connection = new Connection();
3561 3561
 			$sth = $Connection->db->prepare($query);
3562 3562
 			$sth->execute();
3563
-		} catch(PDOException $e) {
3563
+		} catch (PDOException $e) {
3564 3564
 			return "error : ".$e->getMessage();
3565 3565
 		}
3566 3566
 	}
@@ -3576,7 +3576,7 @@  discard block
 block discarded – undo
3576 3576
 			$Connection = new Connection();
3577 3577
 			$sth = $Connection->db->prepare($query);
3578 3578
                         $sth->execute();
3579
-                } catch(PDOException $e) {
3579
+                } catch (PDOException $e) {
3580 3580
                         return "error : ".$e->getMessage();
3581 3581
                 }
3582 3582
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3591,7 +3591,7 @@  discard block
 block discarded – undo
3591 3591
 			$Connection = new Connection();
3592 3592
 			$sth = $Connection->db->prepare($query);
3593 3593
 			$sth->execute();
3594
-		} catch(PDOException $e) {
3594
+		} catch (PDOException $e) {
3595 3595
 			return "error : ".$e->getMessage();
3596 3596
 		}
3597 3597
 	}
@@ -3607,7 +3607,7 @@  discard block
 block discarded – undo
3607 3607
 			$Connection = new Connection();
3608 3608
 			$sth = $Connection->db->prepare($query);
3609 3609
 			$sth->execute();
3610
-		} catch(PDOException $e) {
3610
+		} catch (PDOException $e) {
3611 3611
 			return "error : ".$e->getMessage();
3612 3612
 		}
3613 3613
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3622,7 +3622,7 @@  discard block
 block discarded – undo
3622 3622
 			$Connection = new Connection();
3623 3623
 			$sth = $Connection->db->prepare($query);
3624 3624
 			$sth->execute();
3625
-		} catch(PDOException $e) {
3625
+		} catch (PDOException $e) {
3626 3626
 			return "error : ".$e->getMessage();
3627 3627
 		}
3628 3628
 	}
@@ -3638,7 +3638,7 @@  discard block
 block discarded – undo
3638 3638
 			$Connection = new Connection();
3639 3639
 			$sth = $Connection->db->prepare($query);
3640 3640
 			$sth->execute();
3641
-		} catch(PDOException $e) {
3641
+		} catch (PDOException $e) {
3642 3642
 			return "error : ".$e->getMessage();
3643 3643
 		}
3644 3644
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3653,7 +3653,7 @@  discard block
 block discarded – undo
3653 3653
 			$Connection = new Connection();
3654 3654
 			$sth = $Connection->db->prepare($query);
3655 3655
 			$sth->execute();
3656
-		} catch(PDOException $e) {
3656
+		} catch (PDOException $e) {
3657 3657
 			return "error : ".$e->getMessage();
3658 3658
 		}
3659 3659
 	}
@@ -3669,7 +3669,7 @@  discard block
 block discarded – undo
3669 3669
 			$Connection = new Connection();
3670 3670
 			$sth = $Connection->db->prepare($query);
3671 3671
 			$sth->execute();
3672
-		} catch(PDOException $e) {
3672
+		} catch (PDOException $e) {
3673 3673
 			return "error : ".$e->getMessage();
3674 3674
 		}
3675 3675
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3684,7 +3684,7 @@  discard block
 block discarded – undo
3684 3684
 			$Connection = new Connection();
3685 3685
 			$sth = $Connection->db->prepare($query);
3686 3686
 			$sth->execute();
3687
-		} catch(PDOException $e) {
3687
+		} catch (PDOException $e) {
3688 3688
 			return "error : ".$e->getMessage();
3689 3689
 		}
3690 3690
 	}
@@ -3700,7 +3700,7 @@  discard block
 block discarded – undo
3700 3700
 			$Connection = new Connection();
3701 3701
 			$sth = $Connection->db->prepare($query);
3702 3702
 			$sth->execute();
3703
-		} catch(PDOException $e) {
3703
+		} catch (PDOException $e) {
3704 3704
 			return "error : ".$e->getMessage();
3705 3705
 		}
3706 3706
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3719,7 +3719,7 @@  discard block
 block discarded – undo
3719 3719
 			$Connection = new Connection();
3720 3720
 			$sth = $Connection->db->prepare($query);
3721 3721
 			$sth->execute();
3722
-		} catch(PDOException $e) {
3722
+		} catch (PDOException $e) {
3723 3723
 			return "error : ".$e->getMessage();
3724 3724
 		}
3725 3725
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3734,7 +3734,7 @@  discard block
 block discarded – undo
3734 3734
 			$Connection = new Connection();
3735 3735
 			$sth = $Connection->db->prepare($query);
3736 3736
 			$sth->execute();
3737
-		} catch(PDOException $e) {
3737
+		} catch (PDOException $e) {
3738 3738
 			return "error : ".$e->getMessage();
3739 3739
 		}
3740 3740
 	}
@@ -3746,7 +3746,7 @@  discard block
 block discarded – undo
3746 3746
 			$Connection = new Connection();
3747 3747
 			$sth = $Connection->db->prepare($query);
3748 3748
 			$sth->execute();
3749
-		} catch(PDOException $e) {
3749
+		} catch (PDOException $e) {
3750 3750
 			return "error : ".$e->getMessage();
3751 3751
 		}
3752 3752
 	}
@@ -3762,7 +3762,7 @@  discard block
 block discarded – undo
3762 3762
 			$Connection = new Connection();
3763 3763
 			$sth = $Connection->db->prepare($query);
3764 3764
                         $sth->execute();
3765
-                } catch(PDOException $e) {
3765
+                } catch (PDOException $e) {
3766 3766
                         return "error : ".$e->getMessage();
3767 3767
                 }
3768 3768
 	}
@@ -3777,7 +3777,7 @@  discard block
 block discarded – undo
3777 3777
 			$Connection = new Connection();
3778 3778
 			$sth = $Connection->db->prepare($query);
3779 3779
                         $sth->execute();
3780
-                } catch(PDOException $e) {
3780
+                } catch (PDOException $e) {
3781 3781
                         return "error : ".$e->getMessage();
3782 3782
                 }
3783 3783
 	}
Please login to merge, or discard this 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.