Completed
Push — master ( 81ed4a...f9d220 )
by Yannick
97:00 queued 67:59
created
install/class.update_db.php 2 patches
Spacing   +347 added lines, -347 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		fclose($fp);
26 26
 	}
27 27
 
28
-	public static function gunzip($in_file,$out_file_name = '') {
28
+	public static function gunzip($in_file, $out_file_name = '') {
29 29
 		//echo $in_file.' -> '.$out_file_name."\n";
30 30
 		$buffer_size = 4096; // read 4kb at a time
31 31
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32 32
 		if ($in_file != '' && file_exists($in_file)) {
33 33
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
34
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
35
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
36 36
 			else {
37 37
 				echo 'gzopen not available';
38 38
 				die;
39 39
 			}
40 40
 			$out_file = fopen($out_file_name, 'wb'); 
41
-			while(!gzeof($file)) {
41
+			while (!gzeof($file)) {
42 42
 				fwrite($out_file, gzread($file, $buffer_size));
43 43
 			}  
44 44
 			fclose($out_file);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			self::$db_sqlite = new PDO('sqlite:'.$database);
64 64
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79 79
                         $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         return "error : ".$e->getMessage();
82 82
                 }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		try {
89 89
                         $sth = update_db::$db_sqlite->prepare($query);
90 90
                         $sth->execute();
91
-                } catch(PDOException $e) {
91
+                } catch (PDOException $e) {
92 92
                         return "error : ".$e->getMessage();
93 93
                 }
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100 100
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104 104
             		}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
126 126
     		if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129
-		if ($fh = fopen($database_file,"r")) {
129
+		if ($fh = fopen($database_file, "r")) {
130 130
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 131
 			$Connection = new Connection();
132 132
 			$sth_dest = $Connection->db->prepare($query_dest);
133 133
 			if ($globalTransaction) $Connection->db->beginTransaction();
134 134
 			while (!feof($fh)) {
135
-				$line = fgetcsv($fh,9999,',');
135
+				$line = fgetcsv($fh, 9999, ',');
136 136
 				if ($line[0] != '') {
137 137
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
138 138
 						try {
139
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
140 140
 							$sth_dest->execute($query_dest_values);
141
-						} catch(PDOException $e) {
141
+						} catch (PDOException $e) {
142 142
 							if ($globalTransaction) $Connection->db->rollBack(); 
143 143
 							return "error : ".$e->getMessage();
144 144
 						}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162 162
                         $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         return "error : ".$e->getMessage();
165 165
                 }
166 166
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
171
-		if ($fh = fopen($database_file,"r")) {
171
+		if ($fh = fopen($database_file, "r")) {
172 172
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
173 173
 			$Connection = new Connection();
174 174
 			$sth_dest = $Connection->db->prepare($query_dest);
175 175
 			try {
176 176
 				if ($globalTransaction) $Connection->db->beginTransaction();
177 177
 				while (!feof($fh)) {
178
-					$line = fgetcsv($fh,9999,',');
178
+					$line = fgetcsv($fh, 9999, ',');
179 179
 					if ($line[0] != '') {
180
-						$datebe = explode('  -  ',$line[2]);
180
+						$datebe = explode('  -  ', $line[2]);
181 181
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
182
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
182
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
183 183
 							$sth_dest->execute($query_dest_values);
184 184
 						}
185 185
 					}
186 186
 				}
187 187
 				if ($globalTransaction) $Connection->db->commit();
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				if ($globalTransaction) $Connection->db->rollBack(); 
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202 202
                         $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         return "error : ".$e->getMessage();
205 205
                 }
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210 210
                         $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         return "error : ".$e->getMessage();
213 213
                 }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		try {
218 218
                         $sth = update_db::$db_sqlite->prepare($query);
219 219
                         $sth->execute();
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
241 241
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243 243
             		}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245
-		} catch(PDOException $e) {
245
+		} catch (PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
247 247
 		}
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254 254
                         $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
255
+                } catch (PDOException $e) {
256 256
                         return "error : ".$e->getMessage();
257 257
                 }
258 258
 		return '';
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269 269
                         $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
270
+                } catch (PDOException $e) {
271 271
                         return "error : ".$e->getMessage();
272 272
                 }
273 273
 		
274
-		if ($fh = fopen($database_file,"r")) {
274
+		if ($fh = fopen($database_file, "r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
276 276
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
277 277
 		
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282 282
             			while (!feof($fh)) {
283 283
             				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
284
+            				$line = $Common->hex2str(fgets($fh, 9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
286
+            				$values['ModeS'] = substr($line, 0, 6);
287
+            				$values['Registration'] = trim(substr($line, 69, 6));
288
+            				$aircraft_name = trim(substr($line, 48, 6));
289 289
             				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
+            				$aircraft_name_split = explode(' ', $aircraft_name);
291 291
             				$search_more = '';
292 292
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293 293
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	            				if (isset($result['icao']) && $result['icao'] != '') {
300 300
 	            				    $values['ICAOTypeCode'] = $result['icao'];
301 301
 	            				} 
302
-					} catch(PDOException $e) {
302
+					} catch (PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
305 305
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
306 306
 					// Add data to db
307 307
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 308
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
309
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
309
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
310 310
 						//print_r($query_dest_values);
311 311
 						$sth_dest->execute($query_dest_values);
312 312
 					}
313 313
 				}
314 314
 				if ($globalTransaction) $Connection->db->commit();
315
-			} catch(PDOException $e) {
315
+			} catch (PDOException $e) {
316 316
 				return "error : ".$e->getMessage();
317 317
 			}
318 318
 		}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324 324
                         $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
325
+                } catch (PDOException $e) {
326 326
                         return "error : ".$e->getMessage();
327 327
                 }
328 328
 		return '';
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338 338
                         $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
339
+                } catch (PDOException $e) {
340 340
                         return "error : ".$e->getMessage();
341 341
                 }
342 342
 		
343
-		if ($fh = fopen($database_file,"r")) {
343
+		if ($fh = fopen($database_file, "r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
345 345
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
346 346
 		
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 			$sth_dest = $Connection->db->prepare($query_dest);
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351
-				$tmp = fgetcsv($fh,9999,',',"'");
351
+				$tmp = fgetcsv($fh, 9999, ',', "'");
352 352
             			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
353
+            				$line = fgetcsv($fh, 9999, ',', "'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             				$values['ICAOTypeCode'] = '';
360 360
             				$aircraft_name = $line[2];
361 361
             				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
362
+            				$aircraft_name_split = explode(' ', $aircraft_name);
363 363
             				$search_more = '';
364 364
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365 365
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
                                     		$sth_search->execute();
369 369
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370 370
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371
-					} catch(PDOException $e) {
371
+					} catch (PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
374 374
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375 375
 					// Add data to db
376 376
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
377 377
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
378
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
378
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
379 379
 						//print_r($query_dest_values);
380 380
 						$sth_dest->execute($query_dest_values);
381 381
 					}
382 382
 				}
383 383
 				if ($globalTransaction) $Connection->db->commit();
384
-			} catch(PDOException $e) {
384
+			} catch (PDOException $e) {
385 385
 				return "error : ".$e->getMessage();
386 386
 			}
387 387
 		}
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
                         $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
394
+                } catch (PDOException $e) {
395 395
                         return "error : ".$e->getMessage();
396 396
                 }
397 397
 		return '';
398 398
 	}
399 399
 
400
-	public static function retrieve_owner($database_file,$country = 'F') {
400
+	public static function retrieve_owner($database_file, $country = 'F') {
401 401
 		global $globalTransaction, $globalMasterSource;
402 402
 		//$query = 'TRUNCATE TABLE aircraft_modes';
403 403
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407 407
                         $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
408
+                } catch (PDOException $e) {
409 409
                         return "error : ".$e->getMessage();
410 410
                 }
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413
-		if ($fh = fopen($database_file,"r")) {
413
+		if ($fh = fopen($database_file, "r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416 416
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 			$sth_modes = $Connection->db->prepare($query_modes);
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423
-				$tmp = fgetcsv($fh,9999,',','"');
423
+				$tmp = fgetcsv($fh, 9999, ',', '"');
424 424
             			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
425
+            				$line = fgetcsv($fh, 9999, ',', '"');
426 426
             				$values = array();
427 427
             				//print_r($line);
428 428
             				if ($country == 'F') {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             				    $values['base'] = $line[4];
431 431
             				    $values['owner'] = $line[5];
432 432
             				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
433
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
434 434
 					    $values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436 436
 					    // TODO : add modeS & reg to aircraft_modes
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             				    $values['base'] = $line[3];
439 439
             				    $values['owner'] = $line[2];
440 440
             				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
441
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
442 442
 					    $values['cancel'] = '';
443 443
 					    $values['modes'] = $line[7];
444 444
 					    $values['icao'] = $line[8];
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             				    $values['base'] = null;
459 459
             				    $values['owner'] = $line[5];
460 460
             				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
461
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
462 462
 					    $values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464 464
 					    // TODO : add modeS & reg to aircraft_modes
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             				    $values['base'] = null;
467 467
             				    $values['owner'] = $line[12];
468 468
             				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
469
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
470 470
 
471 471
 					    $values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -486,28 +486,28 @@  discard block
 block discarded – undo
486 486
             				    $values['base'] = null;
487 487
             				    $values['owner'] = $line[8];
488 488
             				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
489
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
490 490
 					    $values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492 492
             				    $values['registration'] = $line[0];
493 493
             				    $values['base'] = null;
494 494
             				    $values['owner'] = $line[4];
495 495
             				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
497 497
 					    $values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499 499
             				    $values['registration'] = $line[0];
500 500
             				    $values['base'] = null;
501 501
             				    $values['owner'] = $line[4];
502 502
             				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
503
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
504 504
 					    $values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506 506
             				    $values['registration'] = $line[0];
507 507
             				    $values['base'] = null;
508 508
             				    $values['owner'] = $line[3];
509 509
             				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
510
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
511 511
 					    $values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513 513
             				    $values['registration'] = $line[0];
@@ -521,18 +521,18 @@  discard block
 block discarded – undo
521 521
             				    $values['registration'] = $line[0];
522 522
             				    $values['base'] = null;
523 523
             				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
525
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
526 526
 					    $values['modes'] = $line[4];
527 527
 					    $values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529 529
             				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
530
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
531 531
 					    $values['modes'] = $line[5];
532 532
 					    $values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534 534
             				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
535
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
536 536
 					    $values['modes'] = $line[4];
537 537
 					    $values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
 					    $values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
546
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
547 547
 						$sth_dest->execute($query_dest_values);
548 548
 					}
549 549
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
550 550
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
551
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
551
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
552 552
 						$sth_modes->execute($query_modes_values);
553 553
 					}
554 554
 				}
555 555
 				if ($globalTransaction) $Connection->db->commit();
556
-			} catch(PDOException $e) {
556
+			} catch (PDOException $e) {
557 557
 				return "error : ".$e->getMessage();
558 558
 			}
559 559
 		}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		if ($globalTransaction) $Connection->db->beginTransaction();
692 692
   
693 693
 		$i = 0;
694
-		while($row = sparql_fetch_array($result))
694
+		while ($row = sparql_fetch_array($result))
695 695
 		{
696 696
 			if ($i >= 1) {
697 697
 			//print_r($row);
@@ -711,33 +711,33 @@  discard block
 block discarded – undo
711 711
 				$row['image'] = '';
712 712
 				$row['image_thumb'] = '';
713 713
 			} else {
714
-				$image = str_replace(' ','_',$row['image']);
714
+				$image = str_replace(' ', '_', $row['image']);
715 715
 				$digest = md5($image);
716
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
717
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
718
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
719
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
716
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
717
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
718
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
719
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
720 720
 			}
721 721
 			
722
-			$country = explode('-',$row['country']);
722
+			$country = explode('-', $row['country']);
723 723
 			$row['country'] = $country[0];
724 724
 			
725 725
 			$row['type'] = trim($row['type']);
726
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
726
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
727 727
 				$row['type'] = 'military';
728 728
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
729 729
 				$row['type'] = 'small_airport';
730 730
 			}
731 731
 			
732
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
733
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
732
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
733
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
734 734
 			//print_r($query_dest_values);
735 735
 			
736 736
 			if ($row['icao'] != '') {
737 737
 				try {
738 738
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
739 739
 					$sth->execute(array(':icao' => $row['icao']));
740
-				} catch(PDOException $e) {
740
+				} catch (PDOException $e) {
741 741
 					return "error : ".$e->getMessage();
742 742
 				}
743 743
 					if ($sth->fetchColumn() > 0) {
@@ -745,15 +745,15 @@  discard block
 block discarded – undo
745 745
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
746 746
 						try {
747 747
 							$sth = $Connection->db->prepare($query);
748
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
749
-						} catch(PDOException $e) {
748
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
749
+						} catch (PDOException $e) {
750 750
 							return "error : ".$e->getMessage();
751 751
 						}
752 752
 						echo $row['icao'].' : '.$row['type']."\n";
753 753
 					} else {
754 754
 						try {
755 755
 							$sth_dest->execute($query_dest_values);
756
-						} catch(PDOException $e) {
756
+						} catch (PDOException $e) {
757 757
 							return "error : ".$e->getMessage();
758 758
 						}
759 759
 					}
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		echo "Download data from ourairports.com...\n";
805 805
 		$delimiter = ',';
806 806
 		$out_file = $tmp_dir.'airports.csv';
807
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
807
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
808 808
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
809 809
 		echo "Add data from ourairports.com...\n";
810 810
 
@@ -815,33 +815,33 @@  discard block
 block discarded – undo
815 815
 			//$Connection->db->beginTransaction();
816 816
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 817
 			{
818
-				if(!$header) $header = $row;
818
+				if (!$header) $header = $row;
819 819
 				else {
820 820
 					$data = array();
821 821
 					$data = array_combine($header, $row);
822 822
 					try {
823 823
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
824 824
 						$sth->execute(array(':icao' => $data['ident']));
825
-					} catch(PDOException $e) {
825
+					} catch (PDOException $e) {
826 826
 						return "error : ".$e->getMessage();
827 827
 					}
828 828
 					if ($sth->fetchColumn() > 0) {
829 829
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
830 830
 						try {
831 831
 							$sth = $Connection->db->prepare($query);
832
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
833
-						} catch(PDOException $e) {
832
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
833
+						} catch (PDOException $e) {
834 834
 							return "error : ".$e->getMessage();
835 835
 						}
836 836
 					} else {
837 837
 						if ($data['gps_code'] == $data['ident']) {
838 838
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
839 839
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
840
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
840
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
841 841
 						try {
842 842
 							$sth = $Connection->db->prepare($query);
843 843
 							$sth->execute($query_values);
844
-						} catch(PDOException $e) {
844
+						} catch (PDOException $e) {
845 845
 							return "error : ".$e->getMessage();
846 846
 						}
847 847
 						$i++;
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		
857 857
 		echo "Download data from another free database...\n";
858 858
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
859
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
860 860
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
861 861
 		update_db::unzip($out_file);
862 862
 		$header = NULL;
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 			//$Connection->db->beginTransaction();
869 869
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 870
 			{
871
-				if(!$header) $header = $row;
871
+				if (!$header) $header = $row;
872 872
 				else {
873 873
 					$data = $row;
874 874
 
875 875
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
876 876
 					try {
877 877
 						$sth = $Connection->db->prepare($query);
878
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
879
-					} catch(PDOException $e) {
878
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
879
+					} catch (PDOException $e) {
880 880
 						return "error : ".$e->getMessage();
881 881
 					}
882 882
 				}
@@ -890,15 +890,15 @@  discard block
 block discarded – undo
890 890
 		try {
891 891
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
892 892
 			$sth->execute();
893
-		} catch(PDOException $e) {
893
+		} catch (PDOException $e) {
894 894
 			return "error : ".$e->getMessage();
895 895
 		}
896 896
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
897 897
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
898 898
 			try {
899 899
 				$sth2 = $Connection->db->prepare($query2);
900
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
901
-			} catch(PDOException $e) {
900
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
901
+			} catch (PDOException $e) {
902 902
 				return "error : ".$e->getMessage();
903 903
 			}
904 904
 		}
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921 921
                         $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
922
+                } catch (PDOException $e) {
923 923
                         return "error : ".$e->getMessage();
924 924
                 }
925 925
 
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
937 937
 			{
938 938
 				$i++;
939
-				if($i > 12) {
939
+				if ($i > 12) {
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
                                                 //echo substr($operator, 0, 2)."\n";;
945 945
                                                 if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947
-							$operator = $airline_array[0]['icao'].substr($operator,2);
947
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
948 948
                                                 }
949 949
                                         }
950 950
 					
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953 953
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954 954
                                                 if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
955
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
956 956
                                             	}
957 957
                                         }
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
961
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
-					} catch(PDOException $e) {
961
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
+					} catch (PDOException $e) {
963 963
 						return "error : ".$e->getMessage();
964 964
 					}
965 965
 				}
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 			$Connection = new Connection();
978 978
 			$sth = $Connection->db->prepare($query);
979 979
 			$sth->execute(array(':source' => 'website_fam'));
980
-		} catch(PDOException $e) {
980
+		} catch (PDOException $e) {
981 981
 			return "error : ".$e->getMessage();
982 982
 		}
983 983
 		//update_db::unzip($out_file);
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
996 996
 					try {
997 997
 						$sth = $Connection->db->prepare($query);
998
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
999
-					} catch(PDOException $e) {
998
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
999
+					} catch (PDOException $e) {
1000 1000
 						return "error : ".$e->getMessage();
1001 1001
 					}
1002 1002
 				}
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 			$Connection = new Connection();
1020 1020
 			$sth = $Connection->db->prepare($query);
1021 1021
                         $sth->execute(array(':source' => 'website_faa'));
1022
-                } catch(PDOException $e) {
1022
+                } catch (PDOException $e) {
1023 1023
                         return "error : ".$e->getMessage();
1024 1024
                 }
1025 1025
 
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030 1030
                         $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1031
+                } catch (PDOException $e) {
1032 1032
                         return "error : ".$e->getMessage();
1033 1033
                 }
1034 1034
 
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1046 1046
 					try {
1047 1047
 						$sths = $Connection->db->prepare($query_search);
1048
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1049
-					} catch(PDOException $e) {
1048
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1049
+					} catch (PDOException $e) {
1050 1050
 						return "error s : ".$e->getMessage();
1051 1051
 					}
1052 1052
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 							//}
1060 1060
 						try {
1061 1061
 							$sthi = $Connection->db->prepare($queryi);
1062
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1063
-						} catch(PDOException $e) {
1062
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1063
+						} catch (PDOException $e) {
1064 1064
 							return "error u : ".$e->getMessage();
1065 1065
 						}
1066 1066
 					} else {
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 						try {
1069 1069
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1070 1070
 							$sthsm->execute(array(':mfr' => $data[2]));
1071
-						} catch(PDOException $e) {
1071
+						} catch (PDOException $e) {
1072 1072
 							return "error mfr : ".$e->getMessage();
1073 1073
 						}
1074 1074
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1079 1079
 							try {
1080 1080
 								$sthf = $Connection->db->prepare($queryf);
1081
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1082
-							} catch(PDOException $e) {
1081
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1082
+							} catch (PDOException $e) {
1083 1083
 								return "error f : ".$e->getMessage();
1084 1084
 							}
1085 1085
 						}
@@ -1089,13 +1089,13 @@  discard block
 block discarded – undo
1089 1089
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1090 1090
 						try {
1091 1091
 							$sth = $Connection->db->prepare($query);
1092
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1093
-						} catch(PDOException $e) {
1092
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1093
+						} catch (PDOException $e) {
1094 1094
 							return "error i : ".$e->getMessage();
1095 1095
 						}
1096 1096
 					}
1097 1097
 				}
1098
-				if ($i % 90 == 0) {
1098
+				if ($i%90 == 0) {
1099 1099
 					if ($globalTransaction) $Connection->db->commit();
1100 1100
 					if ($globalTransaction) $Connection->db->beginTransaction();
1101 1101
 				}
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 			$Connection = new Connection();
1115 1115
 			$sth = $Connection->db->prepare($query);
1116 1116
                         $sth->execute(array(':source' => 'website_fam'));
1117
-                } catch(PDOException $e) {
1117
+                } catch (PDOException $e) {
1118 1118
                         return "error : ".$e->getMessage();
1119 1119
                 }
1120 1120
 
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1136 1136
 					try {
1137 1137
 						$sth = $Connection->db->prepare($query);
1138
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1139
-					} catch(PDOException $e) {
1138
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1139
+					} catch (PDOException $e) {
1140 1140
 						return "error : ".$e->getMessage();
1141 1141
 					}
1142 1142
 				}
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			$Connection = new Connection();
1156 1156
 			$sth = $Connection->db->prepare($query);
1157 1157
                         $sth->execute(array(':source' => 'website_fam'));
1158
-                } catch(PDOException $e) {
1158
+                } catch (PDOException $e) {
1159 1159
                         return "error : ".$e->getMessage();
1160 1160
                 }
1161 1161
 
@@ -1171,8 +1171,8 @@  discard block
 block discarded – undo
1171 1171
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1172 1172
 					try {
1173 1173
 						$sth = $Connection->db->prepare($query);
1174
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1175
-					} catch(PDOException $e) {
1174
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1175
+					} catch (PDOException $e) {
1176 1176
 						//print_r($data);
1177 1177
 						return "error : ".$e->getMessage();
1178 1178
 					}
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 			$Connection = new Connection();
1193 1193
 			$sth = $Connection->db->prepare($query);
1194 1194
 			$sth->execute(array(':source' => 'website_fam'));
1195
-		} catch(PDOException $e) {
1195
+		} catch (PDOException $e) {
1196 1196
 			return "error : ".$e->getMessage();
1197 1197
 		}
1198 1198
 		$delimiter = "\t";
@@ -1207,9 +1207,9 @@  discard block
 block discarded – undo
1207 1207
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1208 1208
 					try {
1209 1209
 						$sth = $Connection->db->prepare($query);
1210
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1211
-					} catch(PDOException $e) {
1212
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1210
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1211
+					} catch (PDOException $e) {
1212
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1213 1213
 					}
1214 1214
 				}
1215 1215
 				$i++;
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			$Connection = new Connection();
1228 1228
 			$sth = $Connection->db->prepare($query);
1229 1229
                         $sth->execute();
1230
-                } catch(PDOException $e) {
1230
+                } catch (PDOException $e) {
1231 1231
                         return "error : ".$e->getMessage();
1232 1232
                 }
1233 1233
 
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1249 1249
 					try {
1250 1250
 						$sth = $Connection->db->prepare($query);
1251
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1252
-					} catch(PDOException $e) {
1251
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1252
+					} catch (PDOException $e) {
1253 1253
 						return "error : ".$e->getMessage();
1254 1254
 					}
1255 1255
 				}
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 			$Connection = new Connection();
1269 1269
 			$sth = $Connection->db->prepare($query);
1270 1270
 			$sth->execute();
1271
-		} catch(PDOException $e) {
1271
+		} catch (PDOException $e) {
1272 1272
 			return "error : ".$e->getMessage();
1273 1273
 		}
1274 1274
 		$delimiter = "\t";
@@ -1285,8 +1285,8 @@  discard block
 block discarded – undo
1285 1285
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1286 1286
 					try {
1287 1287
 						$sth = $Connection->db->prepare($query);
1288
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1289
-					} catch(PDOException $e) {
1288
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1289
+					} catch (PDOException $e) {
1290 1290
 						return "error : ".$e->getMessage();
1291 1291
 					}
1292 1292
 				}
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 			$Connection = new Connection();
1306 1306
 			$sth = $Connection->db->prepare($query);
1307 1307
 			$sth->execute();
1308
-		} catch(PDOException $e) {
1308
+		} catch (PDOException $e) {
1309 1309
 			return "error : ".$e->getMessage();
1310 1310
 		}
1311 1311
 
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 					try {
1322 1322
 						$sth = $Connection->db->prepare($query);
1323 1323
 						$sth->execute(array(':icao' => $icao));
1324
-					} catch(PDOException $e) {
1324
+					} catch (PDOException $e) {
1325 1325
 						return "error : ".$e->getMessage();
1326 1326
 					}
1327 1327
 				}
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 		return '';
1333 1333
         }
1334 1334
 
1335
-	public static function tle($filename,$tletype) {
1335
+	public static function tle($filename, $tletype) {
1336 1336
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1337 1337
 		global $tmp_dir, $globalTransaction;
1338 1338
 		//$Spotter = new Spotter();
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 			$Connection = new Connection();
1343 1343
 			$sth = $Connection->db->prepare($query);
1344 1344
                         $sth->execute(array(':source' => $filename));
1345
-                } catch(PDOException $e) {
1345
+                } catch (PDOException $e) {
1346 1346
                         return "error : ".$e->getMessage();
1347 1347
                 }
1348 1348
 		
@@ -1367,8 +1367,8 @@  discard block
 block discarded – undo
1367 1367
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1368 1368
 					try {
1369 1369
 						$sth = $Connection->db->prepare($query);
1370
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1371
-					} catch(PDOException $e) {
1370
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1371
+					} catch (PDOException $e) {
1372 1372
 						return "error : ".$e->getMessage();
1373 1373
 					}
1374 1374
 
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 			$Connection = new Connection();
1389 1389
 			$sth = $Connection->db->prepare($query);
1390 1390
 			$sth->execute(array(':source' => $filename));
1391
-		} catch(PDOException $e) {
1391
+		} catch (PDOException $e) {
1392 1392
 			return "error : ".$e->getMessage();
1393 1393
 		}
1394 1394
 		
@@ -1398,13 +1398,13 @@  discard block
 block discarded – undo
1398 1398
 			$i = 0;
1399 1399
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1400 1400
 			//$Connection->db->beginTransaction();
1401
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1401
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1402 1402
 			{
1403 1403
 				if ($i > 0 && $data[0] != '') {
1404 1404
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1405
-					$period = str_replace(',','',$data[14]);
1406
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1407
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1405
+					$period = str_replace(',', '', $data[14]);
1406
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1407
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1408 1408
 					else $launch_date = NULL;
1409 1409
 					$data = array_map(function($value) {
1410 1410
 						return trim($value) === '' ? null : $value;
@@ -1414,8 +1414,8 @@  discard block
 block discarded – undo
1414 1414
 					    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)';
1415 1415
 					try {
1416 1416
 						$sth = $Connection->db->prepare($query);
1417
-						$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));
1418
-					} catch(PDOException $e) {
1417
+						$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));
1418
+					} catch (PDOException $e) {
1419 1419
 						return "error : ".$e->getMessage();
1420 1420
 					}
1421 1421
 				}
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1455 1455
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1456 1456
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1457
-			'EST' => array('country' => 'Estonia','owner' => ''),
1457
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1458 1458
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1459 1459
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1460 1460
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1577,10 +1577,10 @@  discard block
 block discarded – undo
1577 1577
 			while (($data = fgets($handle, 1000)) !== FALSE)
1578 1578
 			{
1579 1579
 				$result = array();
1580
-				$result['cospar'] = trim(substr($data,0,11));
1581
-				$result['norad'] = trim(substr($data,13,6));
1582
-				$result['operational'] = trim(substr($data,21,1));
1583
-				$result['name'] = trim(substr($data,23,24));
1580
+				$result['cospar'] = trim(substr($data, 0, 11));
1581
+				$result['norad'] = trim(substr($data, 13, 6));
1582
+				$result['operational'] = trim(substr($data, 21, 1));
1583
+				$result['name'] = trim(substr($data, 23, 24));
1584 1584
 				/*
1585 1585
 				    * R/B(1) = Rocket body, first stage
1586 1586
 				    * R/B(2) = Rocket body, second stage
@@ -1592,19 +1592,19 @@  discard block
 block discarded – undo
1592 1592
 				    * An ampersand (&) indicates two or more objects are attached
1593 1593
 				*/
1594 1594
 				
1595
-				$owner_code = trim(substr($data,49,5));
1595
+				$owner_code = trim(substr($data, 49, 5));
1596 1596
 				$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1597 1597
 				$result['owner'] = $satcat_sources[$owner_code]['owner'];
1598
-				$result['launch_date'] = trim(substr($data,56,10));
1599
-				$launch_site_code = trim(substr($data,68,5));
1598
+				$result['launch_date'] = trim(substr($data, 56, 10));
1599
+				$launch_site_code = trim(substr($data, 68, 5));
1600 1600
 				$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1601
-				$result['lifetime'] = trim(substr($data,75,10));
1602
-				$result['period'] = trim(substr($data,87,7));
1603
-				$result['inclination'] = trim(substr($data,96,5));
1604
-				$result['apogee'] = trim(substr($data,103,6));
1605
-				$result['perigee'] = trim(substr($data,111,6));
1601
+				$result['lifetime'] = trim(substr($data, 75, 10));
1602
+				$result['period'] = trim(substr($data, 87, 7));
1603
+				$result['inclination'] = trim(substr($data, 96, 5));
1604
+				$result['apogee'] = trim(substr($data, 103, 6));
1605
+				$result['perigee'] = trim(substr($data, 111, 6));
1606 1606
 				//$result['radarcross'] = trim(substr($data,119,8));
1607
-				$result['status'] = trim(substr($data,129,3));
1607
+				$result['status'] = trim(substr($data, 129, 3));
1608 1608
 				//print_r($result);
1609 1609
 				$result = array_map(function($value) {
1610 1610
 					return trim($value) === '' ? null : $value;
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
 						$sth = $Connection->db->prepare($query);
1618 1618
 						$sth->execute(array(':cospar' => $result['cospar']));
1619 1619
 						$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1620
-					} catch(PDOException $e) {
1620
+					} catch (PDOException $e) {
1621 1621
 						return "error : ".$e->getMessage();
1622 1622
 					}
1623 1623
 					if (empty($exist)) {
@@ -1629,10 +1629,10 @@  discard block
 block discarded – undo
1629 1629
 							    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1630 1630
 							    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1631 1631
 							    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1632
-							    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1632
+							    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1633 1633
 							    )
1634 1634
 							);
1635
-						} catch(PDOException $e) {
1635
+						} catch (PDOException $e) {
1636 1636
 							return "error : ".$e->getMessage();
1637 1637
 						}
1638 1638
 					} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1640,8 +1640,8 @@  discard block
 block discarded – undo
1640 1640
 						try {
1641 1641
 							$Connection = new Connection();
1642 1642
 							$sth = $Connection->db->prepare($query);
1643
-							$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1644
-						} catch(PDOException $e) {
1643
+							$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1644
+						} catch (PDOException $e) {
1645 1645
 							return "error : ".$e->getMessage();
1646 1646
 						}
1647 1647
 					}
@@ -1759,13 +1759,13 @@  discard block
 block discarded – undo
1759 1759
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1760 1760
 			{
1761 1761
 				$i++;
1762
-				if($i > 3 && count($row) > 2) {
1762
+				if ($i > 3 && count($row) > 2) {
1763 1763
 					$data = array_values(array_filter($row));
1764 1764
 					$cntdata = count($data);
1765 1765
 					if ($cntdata > 10) {
1766 1766
 						$value = $data[9];
1767 1767
 						
1768
-						for ($i =10;$i < $cntdata;$i++) {
1768
+						for ($i = 10; $i < $cntdata; $i++) {
1769 1769
 							$value .= ' '.$data[$i];
1770 1770
 						}
1771 1771
 						$data[9] = $value;
@@ -1775,8 +1775,8 @@  discard block
 block discarded – undo
1775 1775
 						$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)';
1776 1776
 						try {
1777 1777
 							$sth = $Connection->db->prepare($query);
1778
-							$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]));
1779
-						} catch(PDOException $e) {
1778
+							$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]));
1779
+						} catch (PDOException $e) {
1780 1780
 							return "error : ".$e->getMessage();
1781 1781
 						}
1782 1782
 					}
@@ -1797,7 +1797,7 @@  discard block
 block discarded – undo
1797 1797
 			$Connection = new Connection();
1798 1798
 			$sth = $Connection->db->prepare($query);
1799 1799
                         $sth->execute();
1800
-                } catch(PDOException $e) {
1800
+                } catch (PDOException $e) {
1801 1801
                         return "error : ".$e->getMessage();
1802 1802
                 }
1803 1803
 
@@ -1809,12 +1809,12 @@  discard block
 block discarded – undo
1809 1809
 			if ($globalTransaction) $Connection->db->beginTransaction();
1810 1810
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1811 1811
 			{
1812
-				if(count($row) > 1) {
1812
+				if (count($row) > 1) {
1813 1813
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1814 1814
 					try {
1815 1815
 						$sth = $Connection->db->prepare($query);
1816
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1817
-					} catch(PDOException $e) {
1816
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1817
+					} catch (PDOException $e) {
1818 1818
 						return "error : ".$e->getMessage();
1819 1819
 					}
1820 1820
 				}
@@ -1834,21 +1834,21 @@  discard block
 block discarded – undo
1834 1834
 			try {
1835 1835
 				$sth = $Connection->db->prepare($query);
1836 1836
                     		$sth->execute();
1837
-	                } catch(PDOException $e) {
1837
+	                } catch (PDOException $e) {
1838 1838
 				return "error : ".$e->getMessage();
1839 1839
 	                }
1840 1840
 	        }
1841 1841
 
1842 1842
 
1843
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1843
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1844 1844
 		else {
1845
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1845
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1846 1846
 			$query = "CREATE EXTENSION postgis";
1847
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1847
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1848 1848
 			try {
1849 1849
 				$sth = $Connection->db->prepare($query);
1850 1850
 				$sth->execute();
1851
-			} catch(PDOException $e) {
1851
+			} catch (PDOException $e) {
1852 1852
 				return "error : ".$e->getMessage();
1853 1853
 			}
1854 1854
 		}
@@ -1861,7 +1861,7 @@  discard block
 block discarded – undo
1861 1861
 		include_once('class.create_db.php');
1862 1862
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1863 1863
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1864
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1864
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1865 1865
 		$error = '';
1866 1866
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1867 1867
 			if ($globalDebug) echo "Gunzip...";
@@ -1893,14 +1893,14 @@  discard block
 block discarded – undo
1893 1893
 			try {
1894 1894
 				$sth = $Connection->db->prepare($query);
1895 1895
             	        	$sth->execute();
1896
-	                } catch(PDOException $e) {
1896
+	                } catch (PDOException $e) {
1897 1897
     	                	echo "error : ".$e->getMessage();
1898 1898
 	                }
1899 1899
 		}
1900 1900
 		if ($globalDBdriver == 'mysql') {
1901
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1901
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1902 1902
 		} else {
1903
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1903
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1904 1904
 		}
1905 1905
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1906 1906
 		return $error;
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1914 1914
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1915 1915
 //		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');
1916
-		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');
1916
+		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');
1917 1917
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1918 1918
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1919 1919
 		return $error;
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1934 1934
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1935 1935
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1936
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1936
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1937 1937
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1938 1938
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1939 1939
 		if ($error != '') {
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
 		global $tmp_dir, $globalDebug;
1947 1947
 		$error = '';
1948 1948
 		if ($globalDebug) echo "Routes : Download...";
1949
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1949
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1950 1950
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1951 1951
 			if ($globalDebug) echo "Gunzip...";
1952 1952
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1962,7 +1962,7 @@  discard block
 block discarded – undo
1962 1962
 		global $tmp_dir, $globalDebug;
1963 1963
 		$error = '';
1964 1964
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1965
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1965
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1966 1966
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1967 1967
 			if ($globalDebug) echo "Gunzip...";
1968 1968
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1978,7 +1978,7 @@  discard block
 block discarded – undo
1978 1978
 		global $tmp_dir, $globalDebug;
1979 1979
 		$error = '';
1980 1980
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1981
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1981
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1982 1982
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1983 1983
 			if ($globalDebug) echo "Gunzip...";
1984 1984
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2006,7 +2006,7 @@  discard block
 block discarded – undo
2006 2006
 */
2007 2007
 		if ($globalDebug) echo "Modes : Download...";
2008 2008
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2009
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2009
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2010 2010
 
2011 2011
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2012 2012
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
 	public static function update_ModeS_faa() {
2027 2027
 		global $tmp_dir, $globalDebug;
2028 2028
 		if ($globalDebug) echo "Modes FAA: Download...";
2029
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2029
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2030 2030
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2031 2031
 			if ($globalDebug) echo "Unzip...";
2032 2032
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2042,7 +2042,7 @@  discard block
 block discarded – undo
2042 2042
 	public static function update_ModeS_flarm() {
2043 2043
 		global $tmp_dir, $globalDebug;
2044 2044
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2045
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2045
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2046 2046
 		if (file_exists($tmp_dir.'data.fln')) {
2047 2047
 			if ($globalDebug) echo "Add to DB...";
2048 2048
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
 	public static function update_ModeS_ogn() {
2057 2057
 		global $tmp_dir, $globalDebug;
2058 2058
 		if ($globalDebug) echo "Modes OGN: Download...";
2059
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2059
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2060 2060
 		if (file_exists($tmp_dir.'ogn.csv')) {
2061 2061
 			if ($globalDebug) echo "Add to DB...";
2062 2062
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2071,201 +2071,201 @@  discard block
 block discarded – undo
2071 2071
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2072 2072
 		
2073 2073
 		if ($globalDebug) echo "Owner France: Download...";
2074
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2074
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2075 2075
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2076 2076
 			if ($globalDebug) echo "Add to DB...";
2077
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2077
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2078 2078
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2079 2079
 		if ($error != '') {
2080 2080
 			return $error;
2081 2081
 		} elseif ($globalDebug) echo "Done\n";
2082 2082
 		
2083 2083
 		if ($globalDebug) echo "Owner Ireland: Download...";
2084
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2084
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2085 2085
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2086 2086
 			if ($globalDebug) echo "Add to DB...";
2087
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2087
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2088 2088
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2089 2089
 		if ($error != '') {
2090 2090
 			return $error;
2091 2091
 		} elseif ($globalDebug) echo "Done\n";
2092 2092
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2093
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2093
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2094 2094
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2095 2095
 			if ($globalDebug) echo "Add to DB...";
2096
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2096
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2097 2097
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2098 2098
 		if ($error != '') {
2099 2099
 			return $error;
2100 2100
 		} elseif ($globalDebug) echo "Done\n";
2101 2101
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2102
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2102
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2103 2103
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2104 2104
 			if ($globalDebug) echo "Add to DB...";
2105
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2105
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2106 2106
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2107 2107
 		if ($error != '') {
2108 2108
 			return $error;
2109 2109
 		} elseif ($globalDebug) echo "Done\n";
2110 2110
 		if ($globalDebug) echo "Owner Australia: Download...";
2111
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2111
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2112 2112
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2113 2113
 			if ($globalDebug) echo "Add to DB...";
2114
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2114
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2115 2115
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2116 2116
 		if ($error != '') {
2117 2117
 			return $error;
2118 2118
 		} elseif ($globalDebug) echo "Done\n";
2119 2119
 		if ($globalDebug) echo "Owner Austria: Download...";
2120
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2120
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2121 2121
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2122 2122
 			if ($globalDebug) echo "Add to DB...";
2123
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2123
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2124 2124
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2125 2125
 		if ($error != '') {
2126 2126
 			return $error;
2127 2127
 		} elseif ($globalDebug) echo "Done\n";
2128 2128
 		if ($globalDebug) echo "Owner Chile: Download...";
2129
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2129
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2130 2130
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2131 2131
 			if ($globalDebug) echo "Add to DB...";
2132
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2132
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2133 2133
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2134 2134
 		if ($error != '') {
2135 2135
 			return $error;
2136 2136
 		} elseif ($globalDebug) echo "Done\n";
2137 2137
 		if ($globalDebug) echo "Owner Colombia: Download...";
2138
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2138
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2139 2139
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2140 2140
 			if ($globalDebug) echo "Add to DB...";
2141
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2141
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2142 2142
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2143 2143
 		if ($error != '') {
2144 2144
 			return $error;
2145 2145
 		} elseif ($globalDebug) echo "Done\n";
2146 2146
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2147
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2147
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2148 2148
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2149 2149
 			if ($globalDebug) echo "Add to DB...";
2150
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2150
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2151 2151
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2152 2152
 		if ($error != '') {
2153 2153
 			return $error;
2154 2154
 		} elseif ($globalDebug) echo "Done\n";
2155 2155
 		if ($globalDebug) echo "Owner Brazil: Download...";
2156
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2156
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2157 2157
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2158 2158
 			if ($globalDebug) echo "Add to DB...";
2159
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2159
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2160 2160
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2161 2161
 		if ($error != '') {
2162 2162
 			return $error;
2163 2163
 		} elseif ($globalDebug) echo "Done\n";
2164 2164
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2165
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2165
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2166 2166
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2167 2167
 			if ($globalDebug) echo "Add to DB...";
2168
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2168
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2169 2169
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2170 2170
 		if ($error != '') {
2171 2171
 			return $error;
2172 2172
 		} elseif ($globalDebug) echo "Done\n";
2173 2173
 		if ($globalDebug) echo "Owner Croatia: Download...";
2174
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2174
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2175 2175
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2176 2176
 			if ($globalDebug) echo "Add to DB...";
2177
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2177
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2178 2178
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2179 2179
 		if ($error != '') {
2180 2180
 			return $error;
2181 2181
 		} elseif ($globalDebug) echo "Done\n";
2182 2182
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2183
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2183
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2184 2184
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2185 2185
 			if ($globalDebug) echo "Add to DB...";
2186
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2186
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2187 2187
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2188 2188
 		if ($error != '') {
2189 2189
 			return $error;
2190 2190
 		} elseif ($globalDebug) echo "Done\n";
2191 2191
 		if ($globalDebug) echo "Owner Maldives: Download...";
2192
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2192
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2193 2193
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2194 2194
 			if ($globalDebug) echo "Add to DB...";
2195
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2195
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2196 2196
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2197 2197
 		if ($error != '') {
2198 2198
 			return $error;
2199 2199
 		} elseif ($globalDebug) echo "Done\n";
2200 2200
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2201
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2201
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2202 2202
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2203 2203
 			if ($globalDebug) echo "Add to DB...";
2204
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2204
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2205 2205
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2206 2206
 		if ($error != '') {
2207 2207
 			return $error;
2208 2208
 		} elseif ($globalDebug) echo "Done\n";
2209 2209
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2210
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2210
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2211 2211
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2212 2212
 			if ($globalDebug) echo "Add to DB...";
2213
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2213
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2214 2214
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2215 2215
 		if ($error != '') {
2216 2216
 			return $error;
2217 2217
 		} elseif ($globalDebug) echo "Done\n";
2218 2218
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2219
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2219
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2220 2220
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2221 2221
 			if ($globalDebug) echo "Add to DB...";
2222
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2222
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2223 2223
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2224 2224
 		if ($error != '') {
2225 2225
 			return $error;
2226 2226
 		} elseif ($globalDebug) echo "Done\n";
2227 2227
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2228
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2228
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2229 2229
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2230 2230
 			if ($globalDebug) echo "Add to DB...";
2231
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2231
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2232 2232
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2233 2233
 		if ($error != '') {
2234 2234
 			return $error;
2235 2235
 		} elseif ($globalDebug) echo "Done\n";
2236 2236
 		if ($globalDebug) echo "Owner Iceland: Download...";
2237
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2237
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2238 2238
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2239 2239
 			if ($globalDebug) echo "Add to DB...";
2240
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2240
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2241 2241
 		} else $error = "File ".$tmp_dir.'owner_tf.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 Isle of Man: Download...";
2246
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2246
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2247 2247
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2248 2248
 			if ($globalDebug) echo "Add to DB...";
2249
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2249
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2250 2250
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2251 2251
 		if ($error != '') {
2252 2252
 			return $error;
2253 2253
 		} elseif ($globalDebug) echo "Done\n";
2254 2254
 		if ($globalMasterSource) {
2255 2255
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2256
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2256
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2257 2257
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2258 2258
 				if ($globalDebug) echo "Add to DB...";
2259
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2259
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2260 2260
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2261 2261
 			if ($error != '') {
2262 2262
 				return $error;
2263 2263
 			} elseif ($globalDebug) echo "Done\n";
2264 2264
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2265
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2265
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2266 2266
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2267 2267
 				if ($globalDebug) echo "Add to DB...";
2268
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2268
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2269 2269
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2270 2270
 			if ($error != '') {
2271 2271
 				return $error;
@@ -2278,7 +2278,7 @@  discard block
 block discarded – undo
2278 2278
 		global $tmp_dir, $globalDebug;
2279 2279
 		$error = '';
2280 2280
 		if ($globalDebug) echo "Translation : Download...";
2281
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2281
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2282 2282
 		if (file_exists($tmp_dir.'translation.zip')) {
2283 2283
 			if ($globalDebug) echo "Unzip...";
2284 2284
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2294,7 +2294,7 @@  discard block
 block discarded – undo
2294 2294
 	public static function update_translation_fam() {
2295 2295
 		global $tmp_dir, $globalDebug;
2296 2296
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2297
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2297
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2298 2298
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
2299 2299
 			if ($globalDebug) echo "Gunzip...";
2300 2300
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -2309,7 +2309,7 @@  discard block
 block discarded – undo
2309 2309
 	public static function update_ModeS_fam() {
2310 2310
 		global $tmp_dir, $globalDebug;
2311 2311
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2312
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2312
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2313 2313
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2314 2314
 			if ($globalDebug) echo "Gunzip...";
2315 2315
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -2325,9 +2325,9 @@  discard block
 block discarded – undo
2325 2325
 		global $tmp_dir, $globalDebug, $globalOwner;
2326 2326
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2327 2327
 		if ($globalOwner === TRUE) {
2328
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2328
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2329 2329
 		} else {
2330
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2330
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2331 2331
 		}
2332 2332
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2333 2333
 			if ($globalDebug) echo "Gunzip...";
@@ -2343,7 +2343,7 @@  discard block
 block discarded – undo
2343 2343
 	public static function update_routes_fam() {
2344 2344
 		global $tmp_dir, $globalDebug;
2345 2345
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2346
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2346
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2347 2347
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2348 2348
 			if ($globalDebug) echo "Gunzip...";
2349 2349
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2357,13 +2357,13 @@  discard block
 block discarded – undo
2357 2357
 	}
2358 2358
 	public static function update_marine_identity_fam() {
2359 2359
 		global $tmp_dir, $globalDebug;
2360
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2360
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2361 2361
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2362
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2362
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2363 2363
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2364 2364
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2365 2365
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2366
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2366
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2367 2367
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2368 2368
 					if ($globalDebug) echo "Gunzip...";
2369 2369
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2383,13 +2383,13 @@  discard block
 block discarded – undo
2383 2383
 
2384 2384
 	public static function update_satellite_fam() {
2385 2385
 		global $tmp_dir, $globalDebug;
2386
-		update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2386
+		update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2387 2387
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2388
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2388
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2389 2389
 			$satellite_md5 = $satellite_md5_file[0];
2390 2390
 			if (!update_db::check_satellite_version($satellite_md5)) {
2391 2391
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2392
-				update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2392
+				update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2393 2393
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2394 2394
 					if ($globalDebug) echo "Gunzip...";
2395 2395
 					update_db::gunzip($tmp_dir.'satellite.tsv.gz');
@@ -2409,7 +2409,7 @@  discard block
 block discarded – undo
2409 2409
 	public static function update_banned_fam() {
2410 2410
 		global $tmp_dir, $globalDebug;
2411 2411
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2412
-		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2412
+		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2413 2413
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2414 2414
 			//if ($globalDebug) echo "Gunzip...";
2415 2415
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2428,18 +2428,18 @@  discard block
 block discarded – undo
2428 2428
 		$error = '';
2429 2429
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2430 2430
 		if ($globalDBdriver == 'mysql') {
2431
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2431
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2432 2432
 		} else {
2433
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2433
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2434 2434
 		}
2435 2435
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2436
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2436
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2437 2437
 			$airspace_md5 = $airspace_md5_file[0];
2438 2438
 			if (!update_db::check_airspace_version($airspace_md5)) {
2439 2439
 				if ($globalDBdriver == 'mysql') {
2440
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2440
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2441 2441
 				} else {
2442
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2442
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2443 2443
 				}
2444 2444
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2445 2445
 					if ($globalDebug) echo "Gunzip...";
@@ -2451,7 +2451,7 @@  discard block
 block discarded – undo
2451 2451
 						try {
2452 2452
 							$sth = $Connection->db->prepare($query);
2453 2453
     	    	    					$sth->execute();
2454
-			            		} catch(PDOException $e) {
2454
+			            		} catch (PDOException $e) {
2455 2455
 							return "error : ".$e->getMessage();
2456 2456
 		            			}
2457 2457
 		    			}
@@ -2470,15 +2470,15 @@  discard block
 block discarded – undo
2470 2470
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2471 2471
 		$error = '';
2472 2472
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2473
-		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2473
+		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2474 2474
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2475
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2475
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2476 2476
 			$geoid_md5 = $geoid_md5_file[0];
2477 2477
 			if (!update_db::check_geoid_version($geoid_md5)) {
2478
-				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2478
+				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2479 2479
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2480 2480
 					if ($globalDebug) echo "Gunzip...";
2481
-					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2481
+					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2482 2482
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2483 2483
 						update_db::insert_geoid_version($geoid_md5);
2484 2484
 					}
@@ -2494,15 +2494,15 @@  discard block
 block discarded – undo
2494 2494
 	public static function update_tle() {
2495 2495
 		global $tmp_dir, $globalDebug;
2496 2496
 		if ($globalDebug) echo "Download TLE : Download...";
2497
-		$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',
2498
-		'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',
2499
-		'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');
2497
+		$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',
2498
+		'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',
2499
+		'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');
2500 2500
 		foreach ($alltle as $filename) {
2501 2501
 			if ($globalDebug) echo "downloading ".$filename.'...';
2502
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2502
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2503 2503
 			if (file_exists($tmp_dir.$filename)) {
2504 2504
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2505
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2505
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2506 2506
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2507 2507
 			if ($error != '') {
2508 2508
 				echo $error."\n";
@@ -2514,7 +2514,7 @@  discard block
 block discarded – undo
2514 2514
 	public static function update_ucsdb() {
2515 2515
 		global $tmp_dir, $globalDebug;
2516 2516
 		if ($globalDebug) echo "Download UCS DB : Download...";
2517
-		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2517
+		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt', $tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2518 2518
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2519 2519
 			if ($globalDebug) echo "Add to DB...";
2520 2520
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
@@ -2528,7 +2528,7 @@  discard block
 block discarded – undo
2528 2528
 	public static function update_celestrak() {
2529 2529
 		global $tmp_dir, $globalDebug;
2530 2530
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2531
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2531
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2532 2532
 		if (file_exists($tmp_dir.'satcat.txt')) {
2533 2533
 			if ($globalDebug) echo "Add to DB...";
2534 2534
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2543,32 +2543,32 @@  discard block
 block discarded – undo
2543 2543
 		global $tmp_dir, $globalDebug;
2544 2544
 		$error = '';
2545 2545
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2546
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2546
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2547 2547
 		if (file_exists($tmp_dir.'models.md5sum')) {
2548 2548
 			if ($globalDebug) echo "Check files...\n";
2549 2549
 			$newmodelsdb = array();
2550
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2551
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2550
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2551
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2552 2552
 					$model = trim($row[2]);
2553 2553
 					$newmodelsdb[$model] = trim($row[0]);
2554 2554
 				}
2555 2555
 			}
2556 2556
 			$modelsdb = array();
2557 2557
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2558
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2559
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2558
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2559
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2560 2560
 						$model = trim($row[2]);
2561 2561
 						$modelsdb[$model] = trim($row[0]);
2562 2562
 					}
2563 2563
 				}
2564 2564
 			}
2565
-			$diff = array_diff($newmodelsdb,$modelsdb);
2565
+			$diff = array_diff($newmodelsdb, $modelsdb);
2566 2566
 			foreach ($diff as $key => $value) {
2567 2567
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2568
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2568
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2569 2569
 				
2570 2570
 			}
2571
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2571
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2572 2572
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2573 2573
 		if ($error != '') {
2574 2574
 			return $error;
@@ -2580,32 +2580,32 @@  discard block
 block discarded – undo
2580 2580
 		global $tmp_dir, $globalDebug;
2581 2581
 		$error = '';
2582 2582
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2583
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2583
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2584 2584
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2585 2585
 			if ($globalDebug) echo "Check files...\n";
2586 2586
 			$newmodelsdb = array();
2587
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2588
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2587
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2588
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2589 2589
 					$model = trim($row[2]);
2590 2590
 					$newmodelsdb[$model] = trim($row[0]);
2591 2591
 				}
2592 2592
 			}
2593 2593
 			$modelsdb = array();
2594 2594
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2595
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2596
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2595
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2596
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2597 2597
 						$model = trim($row[2]);
2598 2598
 						$modelsdb[$model] = trim($row[0]);
2599 2599
 					}
2600 2600
 				}
2601 2601
 			}
2602
-			$diff = array_diff($newmodelsdb,$modelsdb);
2602
+			$diff = array_diff($newmodelsdb, $modelsdb);
2603 2603
 			foreach ($diff as $key => $value) {
2604 2604
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2605
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2605
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2606 2606
 				
2607 2607
 			}
2608
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2608
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2609 2609
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2610 2610
 		if ($error != '') {
2611 2611
 			return $error;
@@ -2617,32 +2617,32 @@  discard block
 block discarded – undo
2617 2617
 		global $tmp_dir, $globalDebug;
2618 2618
 		$error = '';
2619 2619
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2620
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2620
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2621 2621
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2622 2622
 			if ($globalDebug) echo "Check files...\n";
2623 2623
 			$newmodelsdb = array();
2624
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2625
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2624
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2625
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2626 2626
 					$model = trim($row[2]);
2627 2627
 					$newmodelsdb[$model] = trim($row[0]);
2628 2628
 				}
2629 2629
 			}
2630 2630
 			$modelsdb = array();
2631 2631
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2632
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2633
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2632
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2633
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2634 2634
 						$model = trim($row[2]);
2635 2635
 						$modelsdb[$model] = trim($row[0]);
2636 2636
 					}
2637 2637
 				}
2638 2638
 			}
2639
-			$diff = array_diff($newmodelsdb,$modelsdb);
2639
+			$diff = array_diff($newmodelsdb, $modelsdb);
2640 2640
 			foreach ($diff as $key => $value) {
2641 2641
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2642
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2642
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2643 2643
 				
2644 2644
 			}
2645
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2645
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2646 2646
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2647 2647
 		if ($error != '') {
2648 2648
 			return $error;
@@ -2665,8 +2665,8 @@  discard block
 block discarded – undo
2665 2665
 		*/
2666 2666
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2667 2667
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2668
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2669
-		    $result = fread($fh,100000000);
2668
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2669
+		    $result = fread($fh, 100000000);
2670 2670
 		    //echo $result;
2671 2671
 		    //var_dump(str_get_html($result));
2672 2672
 		    //print_r(self::table2array($result));
@@ -2684,23 +2684,23 @@  discard block
 block discarded – undo
2684 2684
 			$Connection = new Connection();
2685 2685
 			$sth = $Connection->db->prepare($query);
2686 2686
                         $sth->execute();
2687
-                } catch(PDOException $e) {
2687
+                } catch (PDOException $e) {
2688 2688
                         return "error : ".$e->getMessage();
2689 2689
                 }
2690 2690
 
2691 2691
 		$error = '';
2692 2692
 		if ($globalDebug) echo "Notam : Download...";
2693
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2693
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2694 2694
 		if (file_exists($tmp_dir.'notam.rss')) {
2695
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2695
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2696 2696
 			foreach ($notams['channel']['item'] as $notam) {
2697
-				$title = explode(':',$notam['title']);
2697
+				$title = explode(':', $notam['title']);
2698 2698
 				$data['ref'] = trim($title[0]);
2699 2699
 				unset($title[0]);
2700
-				$data['title'] = trim(implode(':',$title));
2701
-				$description = strip_tags($notam['description'],'<pre>');
2702
-				preg_match(':^(.*?)<pre>:',$description,$match);
2703
-				$q = explode('/',$match[1]);
2700
+				$data['title'] = trim(implode(':', $title));
2701
+				$description = strip_tags($notam['description'], '<pre>');
2702
+				preg_match(':^(.*?)<pre>:', $description, $match);
2703
+				$q = explode('/', $match[1]);
2704 2704
 				$data['fir'] = $q[0];
2705 2705
 				$data['code'] = $q[1];
2706 2706
 				$ifrvfr = $q[2];
@@ -2716,30 +2716,30 @@  discard block
 block discarded – undo
2716 2716
 				$data['lower_limit'] = $q[5];
2717 2717
 				$data['upper_limit'] = $q[6];
2718 2718
 				$latlonrad = $q[7];
2719
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2720
-				$latitude = $Common->convertDec($las,'latitude');
2721
-				$longitude = $Common->convertDec($lns,'longitude');
2719
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2720
+				$latitude = $Common->convertDec($las, 'latitude');
2721
+				$longitude = $Common->convertDec($lns, 'longitude');
2722 2722
 				if ($lac == 'S') $latitude = '-'.$latitude;
2723 2723
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2724 2724
 				$data['center_latitude'] = $latitude;
2725 2725
 				$data['center_longitude'] = $longitude;
2726 2726
 				$data['radius'] = intval($radius);
2727 2727
 				
2728
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2728
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2729 2729
 				$data['text'] = $match[1];
2730
-				preg_match(':</pre>(.*?)$:',$description,$match);
2730
+				preg_match(':</pre>(.*?)$:', $description, $match);
2731 2731
 				$fromto = $match[1];
2732
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2732
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2733 2733
 				$fromall = trim($match[1]);
2734
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2734
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2735 2735
 				$from = trim($match[1]);
2736
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2737
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2736
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2737
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2738 2738
 				$toall = trim($match[1]);
2739
-				if (!preg_match(':Permanent:',$toall)) {
2740
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2739
+				if (!preg_match(':Permanent:', $toall)) {
2740
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2741 2741
 					$to = trim($match[1]);
2742
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2742
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2743 2743
 					$data['permanent'] = 0;
2744 2744
 				} else {
2745 2745
 				    $data['date_end'] = NULL;
@@ -2747,7 +2747,7 @@  discard block
 block discarded – undo
2747 2747
 				}
2748 2748
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2749 2749
 				$NOTAM = new NOTAM();
2750
-				$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']);
2750
+				$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']);
2751 2751
 				unset($data);
2752 2752
 			} 
2753 2753
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2770,16 +2770,16 @@  discard block
 block discarded – undo
2770 2770
 				$Connection = new Connection();
2771 2771
 				$sth = $Connection->db->prepare($query);
2772 2772
 				$sth->execute();
2773
-			} catch(PDOException $e) {
2773
+			} catch (PDOException $e) {
2774 2774
 				return "error : ".$e->getMessage();
2775 2775
 			}
2776 2776
 		}
2777 2777
 		$Common = new Common();
2778 2778
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2779
-		$airspace_json = json_decode($airspace_lst,true);
2779
+		$airspace_json = json_decode($airspace_lst, true);
2780 2780
 		foreach ($airspace_json['records'] as $airspace) {
2781 2781
 			if ($globalDebug) echo $airspace['name']."...\n";
2782
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2782
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2783 2783
 			if (file_exists($tmp_dir.$airspace['name'])) {
2784 2784
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2785 2785
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2801,7 +2801,7 @@  discard block
 block discarded – undo
2801 2801
 				$Connection = new Connection();
2802 2802
 				$sth = $Connection->db->prepare($query);
2803 2803
 				$sth->execute(array(':new' => $new, ':old' => $old));
2804
-			} catch(PDOException $e) {
2804
+			} catch (PDOException $e) {
2805 2805
 				return "error : ".$e->getMessage();
2806 2806
 			}
2807 2807
 		}
@@ -2818,7 +2818,7 @@  discard block
 block discarded – undo
2818 2818
 			$Connection = new Connection();
2819 2819
 			$sth = $Connection->db->prepare($query);
2820 2820
                         $sth->execute();
2821
-                } catch(PDOException $e) {
2821
+                } catch (PDOException $e) {
2822 2822
                         return "error : ".$e->getMessage();
2823 2823
                 }
2824 2824
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2833,7 +2833,7 @@  discard block
 block discarded – undo
2833 2833
 			$Connection = new Connection();
2834 2834
 			$sth = $Connection->db->prepare($query);
2835 2835
                         $sth->execute();
2836
-                } catch(PDOException $e) {
2836
+                } catch (PDOException $e) {
2837 2837
                         return "error : ".$e->getMessage();
2838 2838
                 }
2839 2839
 	}
@@ -2844,7 +2844,7 @@  discard block
 block discarded – undo
2844 2844
 			$Connection = new Connection();
2845 2845
 			$sth = $Connection->db->prepare($query);
2846 2846
                         $sth->execute(array(':version' => $version));
2847
-                } catch(PDOException $e) {
2847
+                } catch (PDOException $e) {
2848 2848
                         return "error : ".$e->getMessage();
2849 2849
                 }
2850 2850
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2858,7 +2858,7 @@  discard block
 block discarded – undo
2858 2858
 			$Connection = new Connection();
2859 2859
 			$sth = $Connection->db->prepare($query);
2860 2860
                         $sth->execute(array(':version' => $version));
2861
-                } catch(PDOException $e) {
2861
+                } catch (PDOException $e) {
2862 2862
                         return "error : ".$e->getMessage();
2863 2863
                 }
2864 2864
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2872,7 +2872,7 @@  discard block
 block discarded – undo
2872 2872
 			$Connection = new Connection();
2873 2873
 			$sth = $Connection->db->prepare($query);
2874 2874
 			$sth->execute(array(':version' => $version));
2875
-		} catch(PDOException $e) {
2875
+		} catch (PDOException $e) {
2876 2876
 			return "error : ".$e->getMessage();
2877 2877
 		}
2878 2878
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2886,7 +2886,7 @@  discard block
 block discarded – undo
2886 2886
 			$Connection = new Connection();
2887 2887
 			$sth = $Connection->db->prepare($query);
2888 2888
 			$sth->execute(array(':version' => $version));
2889
-		} catch(PDOException $e) {
2889
+		} catch (PDOException $e) {
2890 2890
 			return "error : ".$e->getMessage();
2891 2891
 		}
2892 2892
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2902,7 +2902,7 @@  discard block
 block discarded – undo
2902 2902
 			$Connection = new Connection();
2903 2903
 			$sth = $Connection->db->prepare($query);
2904 2904
 			$sth->execute(array(':version' => $version));
2905
-		} catch(PDOException $e) {
2905
+		} catch (PDOException $e) {
2906 2906
 			return "error : ".$e->getMessage();
2907 2907
 		}
2908 2908
 	}
@@ -2914,7 +2914,7 @@  discard block
 block discarded – undo
2914 2914
 			$Connection = new Connection();
2915 2915
 			$sth = $Connection->db->prepare($query);
2916 2916
                         $sth->execute(array(':version' => $version));
2917
-                } catch(PDOException $e) {
2917
+                } catch (PDOException $e) {
2918 2918
                         return "error : ".$e->getMessage();
2919 2919
                 }
2920 2920
 	}
@@ -2926,7 +2926,7 @@  discard block
 block discarded – undo
2926 2926
 			$Connection = new Connection();
2927 2927
 			$sth = $Connection->db->prepare($query);
2928 2928
 			$sth->execute(array(':version' => $version));
2929
-		} catch(PDOException $e) {
2929
+		} catch (PDOException $e) {
2930 2930
 			return "error : ".$e->getMessage();
2931 2931
 		}
2932 2932
 	}
@@ -2938,7 +2938,7 @@  discard block
 block discarded – undo
2938 2938
 			$Connection = new Connection();
2939 2939
 			$sth = $Connection->db->prepare($query);
2940 2940
 			$sth->execute(array(':version' => $version));
2941
-		} catch(PDOException $e) {
2941
+		} catch (PDOException $e) {
2942 2942
 			return "error : ".$e->getMessage();
2943 2943
 		}
2944 2944
 	}
@@ -2954,7 +2954,7 @@  discard block
 block discarded – undo
2954 2954
 			$Connection = new Connection();
2955 2955
 			$sth = $Connection->db->prepare($query);
2956 2956
                         $sth->execute();
2957
-                } catch(PDOException $e) {
2957
+                } catch (PDOException $e) {
2958 2958
                         return "error : ".$e->getMessage();
2959 2959
                 }
2960 2960
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2969,7 +2969,7 @@  discard block
 block discarded – undo
2969 2969
 			$Connection = new Connection();
2970 2970
 			$sth = $Connection->db->prepare($query);
2971 2971
                         $sth->execute();
2972
-                } catch(PDOException $e) {
2972
+                } catch (PDOException $e) {
2973 2973
                         return "error : ".$e->getMessage();
2974 2974
                 }
2975 2975
 	}
@@ -2985,7 +2985,7 @@  discard block
 block discarded – undo
2985 2985
 			$Connection = new Connection();
2986 2986
 			$sth = $Connection->db->prepare($query);
2987 2987
                         $sth->execute();
2988
-                } catch(PDOException $e) {
2988
+                } catch (PDOException $e) {
2989 2989
                         return "error : ".$e->getMessage();
2990 2990
                 }
2991 2991
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3000,7 +3000,7 @@  discard block
 block discarded – undo
3000 3000
 			$Connection = new Connection();
3001 3001
 			$sth = $Connection->db->prepare($query);
3002 3002
                         $sth->execute();
3003
-                } catch(PDOException $e) {
3003
+                } catch (PDOException $e) {
3004 3004
                         return "error : ".$e->getMessage();
3005 3005
                 }
3006 3006
 	}
@@ -3016,7 +3016,7 @@  discard block
 block discarded – undo
3016 3016
 			$Connection = new Connection();
3017 3017
 			$sth = $Connection->db->prepare($query);
3018 3018
                         $sth->execute();
3019
-                } catch(PDOException $e) {
3019
+                } catch (PDOException $e) {
3020 3020
                         return "error : ".$e->getMessage();
3021 3021
                 }
3022 3022
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3031,7 +3031,7 @@  discard block
 block discarded – undo
3031 3031
 			$Connection = new Connection();
3032 3032
 			$sth = $Connection->db->prepare($query);
3033 3033
                         $sth->execute();
3034
-                } catch(PDOException $e) {
3034
+                } catch (PDOException $e) {
3035 3035
                         return "error : ".$e->getMessage();
3036 3036
                 }
3037 3037
 	}
@@ -3047,7 +3047,7 @@  discard block
 block discarded – undo
3047 3047
 			$Connection = new Connection();
3048 3048
 			$sth = $Connection->db->prepare($query);
3049 3049
                         $sth->execute();
3050
-                } catch(PDOException $e) {
3050
+                } catch (PDOException $e) {
3051 3051
                         return "error : ".$e->getMessage();
3052 3052
                 }
3053 3053
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3062,7 +3062,7 @@  discard block
 block discarded – undo
3062 3062
 			$Connection = new Connection();
3063 3063
 			$sth = $Connection->db->prepare($query);
3064 3064
                         $sth->execute();
3065
-                } catch(PDOException $e) {
3065
+                } catch (PDOException $e) {
3066 3066
                         return "error : ".$e->getMessage();
3067 3067
                 }
3068 3068
 	}
@@ -3077,7 +3077,7 @@  discard block
 block discarded – undo
3077 3077
 			$Connection = new Connection();
3078 3078
 			$sth = $Connection->db->prepare($query);
3079 3079
                         $sth->execute();
3080
-                } catch(PDOException $e) {
3080
+                } catch (PDOException $e) {
3081 3081
                         return "error : ".$e->getMessage();
3082 3082
                 }
3083 3083
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3092,7 +3092,7 @@  discard block
 block discarded – undo
3092 3092
 			$Connection = new Connection();
3093 3093
 			$sth = $Connection->db->prepare($query);
3094 3094
 			$sth->execute();
3095
-		} catch(PDOException $e) {
3095
+		} catch (PDOException $e) {
3096 3096
 			return "error : ".$e->getMessage();
3097 3097
 		}
3098 3098
 	}
@@ -3108,7 +3108,7 @@  discard block
 block discarded – undo
3108 3108
 			$Connection = new Connection();
3109 3109
 			$sth = $Connection->db->prepare($query);
3110 3110
 			$sth->execute();
3111
-		} catch(PDOException $e) {
3111
+		} catch (PDOException $e) {
3112 3112
 			return "error : ".$e->getMessage();
3113 3113
 		}
3114 3114
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3123,7 +3123,7 @@  discard block
 block discarded – undo
3123 3123
 			$Connection = new Connection();
3124 3124
 			$sth = $Connection->db->prepare($query);
3125 3125
 			$sth->execute();
3126
-		} catch(PDOException $e) {
3126
+		} catch (PDOException $e) {
3127 3127
 			return "error : ".$e->getMessage();
3128 3128
 		}
3129 3129
 	}
@@ -3139,7 +3139,7 @@  discard block
 block discarded – undo
3139 3139
 			$Connection = new Connection();
3140 3140
 			$sth = $Connection->db->prepare($query);
3141 3141
 			$sth->execute();
3142
-		} catch(PDOException $e) {
3142
+		} catch (PDOException $e) {
3143 3143
 			return "error : ".$e->getMessage();
3144 3144
 		}
3145 3145
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3154,7 +3154,7 @@  discard block
 block discarded – undo
3154 3154
 			$Connection = new Connection();
3155 3155
 			$sth = $Connection->db->prepare($query);
3156 3156
 			$sth->execute();
3157
-		} catch(PDOException $e) {
3157
+		} catch (PDOException $e) {
3158 3158
 			return "error : ".$e->getMessage();
3159 3159
 		}
3160 3160
 	}
@@ -3170,7 +3170,7 @@  discard block
 block discarded – undo
3170 3170
 			$Connection = new Connection();
3171 3171
 			$sth = $Connection->db->prepare($query);
3172 3172
 			$sth->execute();
3173
-		} catch(PDOException $e) {
3173
+		} catch (PDOException $e) {
3174 3174
 			return "error : ".$e->getMessage();
3175 3175
 		}
3176 3176
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3185,7 +3185,7 @@  discard block
 block discarded – undo
3185 3185
 			$Connection = new Connection();
3186 3186
 			$sth = $Connection->db->prepare($query);
3187 3187
 			$sth->execute();
3188
-		} catch(PDOException $e) {
3188
+		} catch (PDOException $e) {
3189 3189
 			return "error : ".$e->getMessage();
3190 3190
 		}
3191 3191
 	}
@@ -3201,7 +3201,7 @@  discard block
 block discarded – undo
3201 3201
 			$Connection = new Connection();
3202 3202
 			$sth = $Connection->db->prepare($query);
3203 3203
 			$sth->execute();
3204
-		} catch(PDOException $e) {
3204
+		} catch (PDOException $e) {
3205 3205
 			return "error : ".$e->getMessage();
3206 3206
 		}
3207 3207
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3220,7 +3220,7 @@  discard block
 block discarded – undo
3220 3220
 			$Connection = new Connection();
3221 3221
 			$sth = $Connection->db->prepare($query);
3222 3222
 			$sth->execute();
3223
-		} catch(PDOException $e) {
3223
+		} catch (PDOException $e) {
3224 3224
 			return "error : ".$e->getMessage();
3225 3225
 		}
3226 3226
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3235,7 +3235,7 @@  discard block
 block discarded – undo
3235 3235
 			$Connection = new Connection();
3236 3236
 			$sth = $Connection->db->prepare($query);
3237 3237
 			$sth->execute();
3238
-		} catch(PDOException $e) {
3238
+		} catch (PDOException $e) {
3239 3239
 			return "error : ".$e->getMessage();
3240 3240
 		}
3241 3241
 	}
@@ -3247,7 +3247,7 @@  discard block
 block discarded – undo
3247 3247
 			$Connection = new Connection();
3248 3248
 			$sth = $Connection->db->prepare($query);
3249 3249
 			$sth->execute();
3250
-		} catch(PDOException $e) {
3250
+		} catch (PDOException $e) {
3251 3251
 			return "error : ".$e->getMessage();
3252 3252
 		}
3253 3253
 	}
@@ -3263,7 +3263,7 @@  discard block
 block discarded – undo
3263 3263
 			$Connection = new Connection();
3264 3264
 			$sth = $Connection->db->prepare($query);
3265 3265
                         $sth->execute();
3266
-                } catch(PDOException $e) {
3266
+                } catch (PDOException $e) {
3267 3267
                         return "error : ".$e->getMessage();
3268 3268
                 }
3269 3269
 	}
@@ -3278,7 +3278,7 @@  discard block
 block discarded – undo
3278 3278
 			$Connection = new Connection();
3279 3279
 			$sth = $Connection->db->prepare($query);
3280 3280
                         $sth->execute();
3281
-                } catch(PDOException $e) {
3281
+                } catch (PDOException $e) {
3282 3282
                         return "error : ".$e->getMessage();
3283 3283
                 }
3284 3284
 	}
Please login to merge, or discard this patch.
Braces   +1026 added lines, -356 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19 19
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
20
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
20
+		if ($referer != '') {
21
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
22
+		}
21 23
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
22 24
 		curl_setopt($ch, CURLOPT_FILE, $fp);
23 25
 		curl_exec($ch);
@@ -28,12 +30,16 @@  discard block
 block discarded – undo
28 30
 	public static function gunzip($in_file,$out_file_name = '') {
29 31
 		//echo $in_file.' -> '.$out_file_name."\n";
30 32
 		$buffer_size = 4096; // read 4kb at a time
31
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
33
+		if ($out_file_name == '') {
34
+			$out_file_name = str_replace('.gz', '', $in_file);
35
+		}
32 36
 		if ($in_file != '' && file_exists($in_file)) {
33 37
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
36
-			else {
38
+			if (function_exists('gzopen')) {
39
+				$file = gzopen($in_file,'rb');
40
+			} elseif (function_exists('gzopen64')) {
41
+				$file = gzopen64($in_file,'rb');
42
+			} else {
37 43
 				echo 'gzopen not available';
38 44
 				die;
39 45
 			}
@@ -54,8 +60,12 @@  discard block
 block discarded – undo
54 60
 			if ($res === TRUE) {
55 61
 				$zip->extractTo($path);
56 62
 				$zip->close();
57
-			} else return false;
58
-		} else return false;
63
+			} else {
64
+				return false;
65
+			}
66
+		} else {
67
+			return false;
68
+		}
59 69
 	}
60 70
 	
61 71
 	public static function connect_sqlite($database) {
@@ -70,7 +80,9 @@  discard block
 block discarded – undo
70 80
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 81
 		global $globalDebug, $globalTransaction;
72 82
 		//$query = 'TRUNCATE TABLE routes';
73
-		if ($globalDebug) echo " - Delete previous routes from DB -";
83
+		if ($globalDebug) {
84
+			echo " - Delete previous routes from DB -";
85
+		}
74 86
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
75 87
 		$Connection = new Connection();
76 88
 		try {
@@ -81,7 +93,9 @@  discard block
 block discarded – undo
81 93
                         return "error : ".$e->getMessage();
82 94
                 }
83 95
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
96
+    		if ($globalDebug) {
97
+    			echo " - Add routes to DB -";
98
+    		}
85 99
     		update_db::connect_sqlite($database_file);
86 100
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 101
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -96,15 +110,21 @@  discard block
 block discarded – undo
96 110
 		$Connection = new Connection();
97 111
 		$sth_dest = $Connection->db->prepare($query_dest);
98 112
 		try {
99
-			if ($globalTransaction) $Connection->db->beginTransaction();
113
+			if ($globalTransaction) {
114
+				$Connection->db->beginTransaction();
115
+			}
100 116
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 117
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 119
 				$sth_dest->execute($query_dest_values);
104 120
             		}
105
-			if ($globalTransaction) $Connection->db->commit();
121
+			if ($globalTransaction) {
122
+				$Connection->db->commit();
123
+			}
106 124
 		} catch(PDOException $e) {
107
-			if ($globalTransaction) $Connection->db->rollBack(); 
125
+			if ($globalTransaction) {
126
+				$Connection->db->rollBack();
127
+			}
108 128
 			return "error : ".$e->getMessage();
109 129
 		}
110 130
                 return '';
@@ -112,7 +132,9 @@  discard block
 block discarded – undo
112 132
 	public static function retrieve_route_oneworld($database_file) {
113 133
 		global $globalDebug, $globalTransaction;
114 134
 		//$query = 'TRUNCATE TABLE routes';
115
-		if ($globalDebug) echo " - Delete previous routes from DB -";
135
+		if ($globalDebug) {
136
+			echo " - Delete previous routes from DB -";
137
+		}
116 138
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
117 139
 		$Connection = new Connection();
118 140
 		try {
@@ -123,14 +145,18 @@  discard block
 block discarded – undo
123 145
                         return "error : ".$e->getMessage();
124 146
                 }
125 147
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
148
+    		if ($globalDebug) {
149
+    			echo " - Add routes to DB -";
150
+    		}
127 151
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 152
 		$Spotter = new Spotter();
129 153
 		if ($fh = fopen($database_file,"r")) {
130 154
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 155
 			$Connection = new Connection();
132 156
 			$sth_dest = $Connection->db->prepare($query_dest);
133
-			if ($globalTransaction) $Connection->db->beginTransaction();
157
+			if ($globalTransaction) {
158
+				$Connection->db->beginTransaction();
159
+			}
134 160
 			while (!feof($fh)) {
135 161
 				$line = fgetcsv($fh,9999,',');
136 162
 				if ($line[0] != '') {
@@ -139,13 +165,17 @@  discard block
 block discarded – undo
139 165
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
140 166
 							$sth_dest->execute($query_dest_values);
141 167
 						} catch(PDOException $e) {
142
-							if ($globalTransaction) $Connection->db->rollBack(); 
168
+							if ($globalTransaction) {
169
+								$Connection->db->rollBack();
170
+							}
143 171
 							return "error : ".$e->getMessage();
144 172
 						}
145 173
 					}
146 174
 				}
147 175
 			}
148
-			if ($globalTransaction) $Connection->db->commit();
176
+			if ($globalTransaction) {
177
+				$Connection->db->commit();
178
+			}
149 179
 		}
150 180
                 return '';
151 181
 	}
@@ -153,7 +183,9 @@  discard block
 block discarded – undo
153 183
 	public static function retrieve_route_skyteam($database_file) {
154 184
 		global $globalDebug, $globalTransaction;
155 185
 		//$query = 'TRUNCATE TABLE routes';
156
-		if ($globalDebug) echo " - Delete previous routes from DB -";
186
+		if ($globalDebug) {
187
+			echo " - Delete previous routes from DB -";
188
+		}
157 189
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
158 190
 		$Connection = new Connection();
159 191
 		try {
@@ -164,7 +196,9 @@  discard block
 block discarded – undo
164 196
                         return "error : ".$e->getMessage();
165 197
                 }
166 198
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
199
+    		if ($globalDebug) {
200
+    			echo " - Add routes to DB -";
201
+    		}
168 202
 
169 203
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 204
 		$Spotter = new Spotter();
@@ -173,7 +207,9 @@  discard block
 block discarded – undo
173 207
 			$Connection = new Connection();
174 208
 			$sth_dest = $Connection->db->prepare($query_dest);
175 209
 			try {
176
-				if ($globalTransaction) $Connection->db->beginTransaction();
210
+				if ($globalTransaction) {
211
+					$Connection->db->beginTransaction();
212
+				}
177 213
 				while (!feof($fh)) {
178 214
 					$line = fgetcsv($fh,9999,',');
179 215
 					if ($line[0] != '') {
@@ -184,9 +220,13 @@  discard block
 block discarded – undo
184 220
 						}
185 221
 					}
186 222
 				}
187
-				if ($globalTransaction) $Connection->db->commit();
223
+				if ($globalTransaction) {
224
+					$Connection->db->commit();
225
+				}
188 226
 			} catch(PDOException $e) {
189
-				if ($globalTransaction) $Connection->db->rollBack(); 
227
+				if ($globalTransaction) {
228
+					$Connection->db->rollBack();
229
+				}
190 230
 				return "error : ".$e->getMessage();
191 231
 			}
192 232
 		}
@@ -229,11 +269,16 @@  discard block
 block discarded – undo
229 269
 		$sth_dest = $Connection->db->prepare($query_dest);
230 270
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 271
 		try {
232
-			if ($globalTransaction) $Connection->db->beginTransaction();
272
+			if ($globalTransaction) {
273
+				$Connection->db->beginTransaction();
274
+			}
233 275
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 276
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235
-				if ($values['UserString4'] == 'M') $type = 'military';
236
-				else $type = null;
277
+				if ($values['UserString4'] == 'M') {
278
+					$type = 'military';
279
+				} else {
280
+					$type = null;
281
+				}
237 282
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 283
 				$sth_dest->execute($query_dest_values);
239 284
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -241,7 +286,9 @@  discard block
 block discarded – undo
241 286
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 287
 				}
243 288
             		}
244
-			if ($globalTransaction) $Connection->db->commit();
289
+			if ($globalTransaction) {
290
+				$Connection->db->commit();
291
+			}
245 292
 		} catch(PDOException $e) {
246 293
 			return "error : ".$e->getMessage();
247 294
 		}
@@ -278,7 +325,9 @@  discard block
 block discarded – undo
278 325
 			$Connection = new Connection();
279 326
 			$sth_dest = $Connection->db->prepare($query_dest);
280 327
 			try {
281
-				if ($globalTransaction) $Connection->db->beginTransaction();
328
+				if ($globalTransaction) {
329
+					$Connection->db->beginTransaction();
330
+				}
282 331
             			while (!feof($fh)) {
283 332
             				$values = array();
284 333
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -289,7 +338,9 @@  discard block
 block discarded – undo
289 338
             				// Check if we can find ICAO, else set it to GLID
290 339
             				$aircraft_name_split = explode(' ',$aircraft_name);
291 340
             				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
342
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
343
+            				}
293 344
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294 345
             				$sth_search = $Connection->db->prepare($query_search);
295 346
 					try {
@@ -302,7 +353,9 @@  discard block
 block discarded – undo
302 353
 					} catch(PDOException $e) {
303 354
 						return "error : ".$e->getMessage();
304 355
 					}
305
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
356
+					if (!isset($values['ICAOTypeCode'])) {
357
+						$values['ICAOTypeCode'] = 'GLID';
358
+					}
306 359
 					// Add data to db
307 360
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 361
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -311,7 +364,9 @@  discard block
 block discarded – undo
311 364
 						$sth_dest->execute($query_dest_values);
312 365
 					}
313 366
 				}
314
-				if ($globalTransaction) $Connection->db->commit();
367
+				if ($globalTransaction) {
368
+					$Connection->db->commit();
369
+				}
315 370
 			} catch(PDOException $e) {
316 371
 				return "error : ".$e->getMessage();
317 372
 			}
@@ -347,7 +402,9 @@  discard block
 block discarded – undo
347 402
 			$Connection = new Connection();
348 403
 			$sth_dest = $Connection->db->prepare($query_dest);
349 404
 			try {
350
-				if ($globalTransaction) $Connection->db->beginTransaction();
405
+				if ($globalTransaction) {
406
+					$Connection->db->beginTransaction();
407
+				}
351 408
 				$tmp = fgetcsv($fh,9999,',',"'");
352 409
             			while (!feof($fh)) {
353 410
             				$line = fgetcsv($fh,9999,',',"'");
@@ -361,13 +418,17 @@  discard block
 block discarded – undo
361 418
             				// Check if we can find ICAO, else set it to GLID
362 419
             				$aircraft_name_split = explode(' ',$aircraft_name);
363 420
             				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
422
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
423
+            				}
365 424
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366 425
             				$sth_search = $Connection->db->prepare($query_search);
367 426
 					try {
368 427
                                     		$sth_search->execute();
369 428
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
429
+	            				if (isset($result['icao']) && $result['icao'] != '') {
430
+	            					$values['ICAOTypeCode'] = $result['icao'];
431
+	            				}
371 432
 					} catch(PDOException $e) {
372 433
 						return "error : ".$e->getMessage();
373 434
 					}
@@ -380,7 +441,9 @@  discard block
 block discarded – undo
380 441
 						$sth_dest->execute($query_dest_values);
381 442
 					}
382 443
 				}
383
-				if ($globalTransaction) $Connection->db->commit();
444
+				if ($globalTransaction) {
445
+					$Connection->db->commit();
446
+				}
384 447
 			} catch(PDOException $e) {
385 448
 				return "error : ".$e->getMessage();
386 449
 			}
@@ -419,7 +482,9 @@  discard block
 block discarded – undo
419 482
 			$sth_dest = $Connection->db->prepare($query_dest);
420 483
 			$sth_modes = $Connection->db->prepare($query_modes);
421 484
 			try {
422
-				if ($globalTransaction) $Connection->db->beginTransaction();
485
+				if ($globalTransaction) {
486
+					$Connection->db->beginTransaction();
487
+				}
423 488
 				$tmp = fgetcsv($fh,9999,',','"');
424 489
             			while (!feof($fh)) {
425 490
             				$line = fgetcsv($fh,9999,',','"');
@@ -429,16 +494,22 @@  discard block
 block discarded – undo
429 494
             				    $values['registration'] = $line[0];
430 495
             				    $values['base'] = $line[4];
431 496
             				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+            				    if ($line[6] == '') {
498
+            				    	$values['date_first_reg'] = null;
499
+            				    } else {
500
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
501
+					    }
434 502
 					    $values['cancel'] = $line[7];
435 503
 					} elseif ($country == 'EI') {
436 504
 					    // TODO : add modeS & reg to aircraft_modes
437 505
             				    $values['registration'] = $line[0];
438 506
             				    $values['base'] = $line[3];
439 507
             				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
508
+            				    if ($line[1] == '') {
509
+            				    	$values['date_first_reg'] = null;
510
+            				    } else {
511
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
512
+					    }
442 513
 					    $values['cancel'] = '';
443 514
 					    $values['modes'] = $line[7];
444 515
 					    $values['icao'] = $line[8];
@@ -457,16 +528,22 @@  discard block
 block discarded – undo
457 528
             				    $values['registration'] = $line[3];
458 529
             				    $values['base'] = null;
459 530
             				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
531
+            				    if ($line[18] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
535
+					    }
462 536
 					    $values['cancel'] = '';
463 537
 					} elseif ($country == 'VH') {
464 538
 					    // TODO : add modeS & reg to aircraft_modes
465 539
             				    $values['registration'] = $line[0];
466 540
             				    $values['base'] = null;
467 541
             				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
542
+            				    if ($line[28] == '') {
543
+            				    	$values['date_first_reg'] = null;
544
+            				    } else {
545
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
546
+					    }
470 547
 
471 548
 					    $values['cancel'] = $line[39];
472 549
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -485,29 +562,41 @@  discard block
 block discarded – undo
485 562
             				    $values['registration'] = $line[0];
486 563
             				    $values['base'] = null;
487 564
             				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
565
+            				    if ($line[7] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
569
+					    }
490 570
 					    $values['cancel'] = '';
491 571
 					} elseif ($country == 'PP') {
492 572
             				    $values['registration'] = $line[0];
493 573
             				    $values['base'] = null;
494 574
             				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
575
+            				    if ($line[6] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
579
+					    }
497 580
 					    $values['cancel'] = $line[7];
498 581
 					} elseif ($country == 'E7') {
499 582
             				    $values['registration'] = $line[0];
500 583
             				    $values['base'] = null;
501 584
             				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
585
+            				    if ($line[5] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
589
+					    }
504 590
 					    $values['cancel'] = '';
505 591
 					} elseif ($country == '8Q') {
506 592
             				    $values['registration'] = $line[0];
507 593
             				    $values['base'] = null;
508 594
             				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
595
+            				    if ($line[7] == '') {
596
+            				    	$values['date_first_reg'] = null;
597
+            				    } else {
598
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
599
+					    }
511 600
 					    $values['cancel'] = '';
512 601
 					} elseif ($country == 'ZK') {
513 602
             				    $values['registration'] = $line[0];
@@ -552,7 +641,9 @@  discard block
 block discarded – undo
552 641
 						$sth_modes->execute($query_modes_values);
553 642
 					}
554 643
 				}
555
-				if ($globalTransaction) $Connection->db->commit();
644
+				if ($globalTransaction) {
645
+					$Connection->db->commit();
646
+				}
556 647
 			} catch(PDOException $e) {
557 648
 				return "error : ".$e->getMessage();
558 649
 			}
@@ -688,25 +779,45 @@  discard block
 block discarded – undo
688 779
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
689 780
 		$Connection = new Connection();
690 781
 		$sth_dest = $Connection->db->prepare($query_dest);
691
-		if ($globalTransaction) $Connection->db->beginTransaction();
782
+		if ($globalTransaction) {
783
+			$Connection->db->beginTransaction();
784
+		}
692 785
   
693 786
 		$i = 0;
694 787
 		while($row = sparql_fetch_array($result))
695 788
 		{
696 789
 			if ($i >= 1) {
697 790
 			//print_r($row);
698
-			if (!isset($row['iata'])) $row['iata'] = '';
699
-			if (!isset($row['icao'])) $row['icao'] = '';
700
-			if (!isset($row['type'])) $row['type'] = '';
701
-			if (!isset($row['altitude'])) $row['altitude'] = '';
791
+			if (!isset($row['iata'])) {
792
+				$row['iata'] = '';
793
+			}
794
+			if (!isset($row['icao'])) {
795
+				$row['icao'] = '';
796
+			}
797
+			if (!isset($row['type'])) {
798
+				$row['type'] = '';
799
+			}
800
+			if (!isset($row['altitude'])) {
801
+				$row['altitude'] = '';
802
+			}
702 803
 			if (isset($row['city_bis'])) {
703 804
 				$row['city'] = $row['city_bis'];
704 805
 			}
705
-			if (!isset($row['city'])) $row['city'] = '';
706
-			if (!isset($row['country'])) $row['country'] = '';
707
-			if (!isset($row['homepage'])) $row['homepage'] = '';
708
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
709
-			if (!isset($row['name'])) continue;
806
+			if (!isset($row['city'])) {
807
+				$row['city'] = '';
808
+			}
809
+			if (!isset($row['country'])) {
810
+				$row['country'] = '';
811
+			}
812
+			if (!isset($row['homepage'])) {
813
+				$row['homepage'] = '';
814
+			}
815
+			if (!isset($row['wikipedia_page'])) {
816
+				$row['wikipedia_page'] = '';
817
+			}
818
+			if (!isset($row['name'])) {
819
+				continue;
820
+			}
710 821
 			if (!isset($row['image'])) {
711 822
 				$row['image'] = '';
712 823
 				$row['image_thumb'] = '';
@@ -762,7 +873,9 @@  discard block
 block discarded – undo
762 873
 
763 874
 			$i++;
764 875
 		}
765
-		if ($globalTransaction) $Connection->db->commit();
876
+		if ($globalTransaction) {
877
+			$Connection->db->commit();
878
+		}
766 879
 		/*
767 880
 		echo "Delete duplicate rows...\n";
768 881
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -805,7 +918,9 @@  discard block
 block discarded – undo
805 918
 		$delimiter = ',';
806 919
 		$out_file = $tmp_dir.'airports.csv';
807 920
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
808
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
921
+		if (!file_exists($out_file) || !is_readable($out_file)) {
922
+			return FALSE;
923
+		}
809 924
 		echo "Add data from ourairports.com...\n";
810 925
 
811 926
 		$header = NULL;
@@ -815,8 +930,9 @@  discard block
 block discarded – undo
815 930
 			//$Connection->db->beginTransaction();
816 931
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 932
 			{
818
-				if(!$header) $header = $row;
819
-				else {
933
+				if(!$header) {
934
+					$header = $row;
935
+				} else {
820 936
 					$data = array();
821 937
 					$data = array_combine($header, $row);
822 938
 					try {
@@ -857,7 +973,9 @@  discard block
 block discarded – undo
857 973
 		echo "Download data from another free database...\n";
858 974
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859 975
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
860
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
976
+		if (!file_exists($out_file) || !is_readable($out_file)) {
977
+			return FALSE;
978
+		}
861 979
 		update_db::unzip($out_file);
862 980
 		$header = NULL;
863 981
 		echo "Add data from another free database...\n";
@@ -868,8 +986,9 @@  discard block
 block discarded – undo
868 986
 			//$Connection->db->beginTransaction();
869 987
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 988
 			{
871
-				if(!$header) $header = $row;
872
-				else {
989
+				if(!$header) {
990
+					$header = $row;
991
+				} else {
873 992
 					$data = $row;
874 993
 
875 994
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1038,7 +1157,9 @@  discard block
 block discarded – undo
1038 1157
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1039 1158
 		{
1040 1159
 			$i = 0;
1041
-			if ($globalTransaction) $Connection->db->beginTransaction();
1160
+			if ($globalTransaction) {
1161
+				$Connection->db->beginTransaction();
1162
+			}
1042 1163
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1043 1164
 			{
1044 1165
 				if ($i > 0) {
@@ -1051,7 +1172,9 @@  discard block
 block discarded – undo
1051 1172
 					}
1052 1173
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1053 1174
 					if (!empty($result_search)) {
1054
-						if ($globalDebug) echo '.';
1175
+						if ($globalDebug) {
1176
+							echo '.';
1177
+						}
1055 1178
 							//if ($globalDBdriver == 'mysql') {
1056 1179
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1057 1180
 							//} else {
@@ -1073,8 +1196,12 @@  discard block
 block discarded – undo
1073 1196
 						}
1074 1197
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1075 1198
 						if (!empty($result_search_mfr)) {
1076
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1077
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1199
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1200
+								$data[16] = $data[23];
1201
+							}
1202
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1203
+								$data[16] = $data[15];
1204
+							}
1078 1205
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1079 1206
 							try {
1080 1207
 								$sthf = $Connection->db->prepare($queryf);
@@ -1085,7 +1212,9 @@  discard block
 block discarded – undo
1085 1212
 						}
1086 1213
 					}
1087 1214
 					if (strtotime($data[29]) > time()) {
1088
-						if ($globalDebug) echo 'i';
1215
+						if ($globalDebug) {
1216
+							echo 'i';
1217
+						}
1089 1218
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1090 1219
 						try {
1091 1220
 							$sth = $Connection->db->prepare($query);
@@ -1096,13 +1225,19 @@  discard block
 block discarded – undo
1096 1225
 					}
1097 1226
 				}
1098 1227
 				if ($i % 90 == 0) {
1099
-					if ($globalTransaction) $Connection->db->commit();
1100
-					if ($globalTransaction) $Connection->db->beginTransaction();
1228
+					if ($globalTransaction) {
1229
+						$Connection->db->commit();
1230
+					}
1231
+					if ($globalTransaction) {
1232
+						$Connection->db->beginTransaction();
1233
+					}
1101 1234
 				}
1102 1235
 				$i++;
1103 1236
 			}
1104 1237
 			fclose($handle);
1105
-			if ($globalTransaction) $Connection->db->commit();
1238
+			if ($globalTransaction) {
1239
+				$Connection->db->commit();
1240
+			}
1106 1241
 		}
1107 1242
 		//print_r($mfr);
1108 1243
 		return '';
@@ -1127,11 +1262,15 @@  discard block
 block discarded – undo
1127 1262
 			$i = 0;
1128 1263
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1129 1264
 			//$Connection->db->beginTransaction();
1130
-			if ($globalTransaction) $Connection->db->beginTransaction();
1265
+			if ($globalTransaction) {
1266
+				$Connection->db->beginTransaction();
1267
+			}
1131 1268
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1132 1269
 			{
1133 1270
 				if ($i > 0) {
1134
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1271
+					if ($data[1] == 'NULL') {
1272
+						$data[1] = $data[0];
1273
+					}
1135 1274
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1136 1275
 					try {
1137 1276
 						$sth = $Connection->db->prepare($query);
@@ -1143,7 +1282,9 @@  discard block
 block discarded – undo
1143 1282
 				$i++;
1144 1283
 			}
1145 1284
 			fclose($handle);
1146
-			if ($globalTransaction) $Connection->db->commit();
1285
+			if ($globalTransaction) {
1286
+				$Connection->db->commit();
1287
+			}
1147 1288
 		}
1148 1289
 		return '';
1149 1290
         }
@@ -1164,7 +1305,9 @@  discard block
 block discarded – undo
1164 1305
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1165 1306
 		{
1166 1307
 			$i = 0;
1167
-			if ($globalTransaction) $Connection->db->beginTransaction();
1308
+			if ($globalTransaction) {
1309
+				$Connection->db->beginTransaction();
1310
+			}
1168 1311
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1169 1312
 			{
1170 1313
 				if ($i > 0) {
@@ -1180,7 +1323,9 @@  discard block
 block discarded – undo
1180 1323
 				$i++;
1181 1324
 			}
1182 1325
 			fclose($handle);
1183
-			if ($globalTransaction) $Connection->db->commit();
1326
+			if ($globalTransaction) {
1327
+				$Connection->db->commit();
1328
+			}
1184 1329
 		}
1185 1330
 		return '';
1186 1331
         }
@@ -1200,7 +1345,9 @@  discard block
 block discarded – undo
1200 1345
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1201 1346
 		{
1202 1347
 			$i = 0;
1203
-			if ($globalTransaction) $Connection->db->beginTransaction();
1348
+			if ($globalTransaction) {
1349
+				$Connection->db->beginTransaction();
1350
+			}
1204 1351
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1205 1352
 			{
1206 1353
 				if ($i > 0) {
@@ -1209,13 +1356,17 @@  discard block
 block discarded – undo
1209 1356
 						$sth = $Connection->db->prepare($query);
1210 1357
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1211 1358
 					} catch(PDOException $e) {
1212
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1359
+						if ($globalDebug) {
1360
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1361
+						}
1213 1362
 					}
1214 1363
 				}
1215 1364
 				$i++;
1216 1365
 			}
1217 1366
 			fclose($handle);
1218
-			if ($globalTransaction) $Connection->db->commit();
1367
+			if ($globalTransaction) {
1368
+				$Connection->db->commit();
1369
+			}
1219 1370
 		}
1220 1371
 		return '';
1221 1372
         }
@@ -1240,7 +1391,9 @@  discard block
 block discarded – undo
1240 1391
 			$i = 0;
1241 1392
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1242 1393
 			//$Connection->db->beginTransaction();
1243
-			if ($globalTransaction) $Connection->db->beginTransaction();
1394
+			if ($globalTransaction) {
1395
+				$Connection->db->beginTransaction();
1396
+			}
1244 1397
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1245 1398
 			{
1246 1399
 				if ($i > 0) {
@@ -1256,7 +1409,9 @@  discard block
 block discarded – undo
1256 1409
 				$i++;
1257 1410
 			}
1258 1411
 			fclose($handle);
1259
-			if ($globalTransaction) $Connection->db->commit();
1412
+			if ($globalTransaction) {
1413
+				$Connection->db->commit();
1414
+			}
1260 1415
 		}
1261 1416
 		return '';
1262 1417
         }
@@ -1276,7 +1431,9 @@  discard block
 block discarded – undo
1276 1431
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1277 1432
 		{
1278 1433
 			$i = 0;
1279
-			if ($globalTransaction) $Connection->db->beginTransaction();
1434
+			if ($globalTransaction) {
1435
+				$Connection->db->beginTransaction();
1436
+			}
1280 1437
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1281 1438
 			{
1282 1439
 				if ($i > 0) {
@@ -1293,7 +1450,9 @@  discard block
 block discarded – undo
1293 1450
 				$i++;
1294 1451
 			}
1295 1452
 			fclose($handle);
1296
-			if ($globalTransaction) $Connection->db->commit();
1453
+			if ($globalTransaction) {
1454
+				$Connection->db->commit();
1455
+			}
1297 1456
 		}
1298 1457
 		return '';
1299 1458
 	}
@@ -1312,7 +1471,9 @@  discard block
 block discarded – undo
1312 1471
 		$Connection = new Connection();
1313 1472
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1314 1473
 		{
1315
-			if ($globalTransaction) $Connection->db->beginTransaction();
1474
+			if ($globalTransaction) {
1475
+				$Connection->db->beginTransaction();
1476
+			}
1316 1477
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1317 1478
 			{
1318 1479
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1327,7 +1488,9 @@  discard block
 block discarded – undo
1327 1488
 				}
1328 1489
 			}
1329 1490
 			fclose($handle);
1330
-			if ($globalTransaction) $Connection->db->commit();
1491
+			if ($globalTransaction) {
1492
+				$Connection->db->commit();
1493
+			}
1331 1494
 		}
1332 1495
 		return '';
1333 1496
         }
@@ -1403,9 +1566,14 @@  discard block
 block discarded – undo
1403 1566
 				if ($i > 0 && $data[0] != '') {
1404 1567
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1405 1568
 					$period = str_replace(',','',$data[14]);
1406
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1407
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1408
-					else $launch_date = NULL;
1569
+					if (!empty($period) && strpos($period,'days')) {
1570
+						$period = str_replace(' days','',$period)*24*60;
1571
+					}
1572
+					if ($data[18] != '') {
1573
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1574
+					} else {
1575
+						$launch_date = NULL;
1576
+					}
1409 1577
 					$data = array_map(function($value) {
1410 1578
 						return trim($value) === '' ? null : $value;
1411 1579
 					}, $data);
@@ -1755,7 +1923,9 @@  discard block
 block discarded – undo
1755 1923
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1756 1924
 		{
1757 1925
 			$i = 0;
1758
-			if ($globalTransaction) $Connection->db->beginTransaction();
1926
+			if ($globalTransaction) {
1927
+				$Connection->db->beginTransaction();
1928
+			}
1759 1929
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1760 1930
 			{
1761 1931
 				$i++;
@@ -1783,7 +1953,9 @@  discard block
 block discarded – undo
1783 1953
 				}
1784 1954
 			}
1785 1955
 			fclose($handle);
1786
-			if ($globalTransaction) $Connection->db->commit();
1956
+			if ($globalTransaction) {
1957
+				$Connection->db->commit();
1958
+			}
1787 1959
 		}
1788 1960
 		return '';
1789 1961
         }
@@ -1806,7 +1978,9 @@  discard block
 block discarded – undo
1806 1978
 		$Connection = new Connection();
1807 1979
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1808 1980
 		{
1809
-			if ($globalTransaction) $Connection->db->beginTransaction();
1981
+			if ($globalTransaction) {
1982
+				$Connection->db->beginTransaction();
1983
+			}
1810 1984
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1811 1985
 			{
1812 1986
 				if(count($row) > 1) {
@@ -1820,7 +1994,9 @@  discard block
 block discarded – undo
1820 1994
 				}
1821 1995
 			}
1822 1996
 			fclose($handle);
1823
-			if ($globalTransaction) $Connection->db->commit();
1997
+			if ($globalTransaction) {
1998
+				$Connection->db->commit();
1999
+			}
1824 2000
 		}
1825 2001
 		return '';
1826 2002
         }
@@ -1840,8 +2016,9 @@  discard block
 block discarded – undo
1840 2016
 	        }
1841 2017
 
1842 2018
 
1843
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1844
-		else {
2019
+		if ($globalDBdriver == 'mysql') {
2020
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2021
+		} else {
1845 2022
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1846 2023
 			$query = "CREATE EXTENSION postgis";
1847 2024
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1860,20 +2037,30 @@  discard block
 block discarded – undo
1860 2037
 		global $tmp_dir, $globalDebug;
1861 2038
 		include_once('class.create_db.php');
1862 2039
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1863
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2040
+		if ($globalDebug) {
2041
+			echo "NOTAM from FlightAirMap website : Download...";
2042
+		}
1864 2043
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1865 2044
 		$error = '';
1866 2045
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1867
-			if ($globalDebug) echo "Gunzip...";
2046
+			if ($globalDebug) {
2047
+				echo "Gunzip...";
2048
+			}
1868 2049
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1869
-			if ($globalDebug) echo "Add to DB...";
2050
+			if ($globalDebug) {
2051
+				echo "Add to DB...";
2052
+			}
1870 2053
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1871 2054
 			$NOTAM = new NOTAM();
1872 2055
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1873
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2056
+		} else {
2057
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2058
+		}
1874 2059
 		if ($error != '') {
1875 2060
 			return $error;
1876
-		} elseif ($globalDebug) echo "Done\n";
2061
+		} elseif ($globalDebug) {
2062
+			echo "Done\n";
2063
+		}
1877 2064
 		return '';
1878 2065
 	}
1879 2066
 
@@ -1927,67 +2114,111 @@  discard block
 block discarded – undo
1927 2114
 		//if ($globalDebug) echo "IVAO : Download...";
1928 2115
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1929 2116
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1930
-			if ($globalDebug) echo "Unzip...";
2117
+			if ($globalDebug) {
2118
+				echo "Unzip...";
2119
+			}
1931 2120
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1932
-			if ($globalDebug) echo "Add to DB...";
2121
+			if ($globalDebug) {
2122
+				echo "Add to DB...";
2123
+			}
1933 2124
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1934
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2125
+			if ($globalDebug) {
2126
+				echo "Copy airlines logos to airlines images directory...";
2127
+			}
1935 2128
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1936
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1937
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1938
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2129
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2130
+					$error = "Failed to copy airlines logo.";
2131
+				}
2132
+			} else {
2133
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2134
+			}
2135
+		} else {
2136
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2137
+		}
1939 2138
 		if ($error != '') {
1940 2139
 			return $error;
1941
-		} elseif ($globalDebug) echo "Done\n";
2140
+		} elseif ($globalDebug) {
2141
+			echo "Done\n";
2142
+		}
1942 2143
 		return '';
1943 2144
 	}
1944 2145
 
1945 2146
 	public static function update_routes() {
1946 2147
 		global $tmp_dir, $globalDebug;
1947 2148
 		$error = '';
1948
-		if ($globalDebug) echo "Routes : Download...";
2149
+		if ($globalDebug) {
2150
+			echo "Routes : Download...";
2151
+		}
1949 2152
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1950 2153
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1951
-			if ($globalDebug) echo "Gunzip...";
2154
+			if ($globalDebug) {
2155
+				echo "Gunzip...";
2156
+			}
1952 2157
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1953
-			if ($globalDebug) echo "Add to DB...";
2158
+			if ($globalDebug) {
2159
+				echo "Add to DB...";
2160
+			}
1954 2161
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1955
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2162
+		} else {
2163
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2164
+		}
1956 2165
 		if ($error != '') {
1957 2166
 			return $error;
1958
-		} elseif ($globalDebug) echo "Done\n";
2167
+		} elseif ($globalDebug) {
2168
+			echo "Done\n";
2169
+		}
1959 2170
 		return '';
1960 2171
 	}
1961 2172
 	public static function update_oneworld() {
1962 2173
 		global $tmp_dir, $globalDebug;
1963 2174
 		$error = '';
1964
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2175
+		if ($globalDebug) {
2176
+			echo "Schedules Oneworld : Download...";
2177
+		}
1965 2178
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1966 2179
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1967
-			if ($globalDebug) echo "Gunzip...";
2180
+			if ($globalDebug) {
2181
+				echo "Gunzip...";
2182
+			}
1968 2183
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1969
-			if ($globalDebug) echo "Add to DB...";
2184
+			if ($globalDebug) {
2185
+				echo "Add to DB...";
2186
+			}
1970 2187
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1971
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2188
+		} else {
2189
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2190
+		}
1972 2191
 		if ($error != '') {
1973 2192
 			return $error;
1974
-		} elseif ($globalDebug) echo "Done\n";
2193
+		} elseif ($globalDebug) {
2194
+			echo "Done\n";
2195
+		}
1975 2196
 		return '';
1976 2197
 	}
1977 2198
 	public static function update_skyteam() {
1978 2199
 		global $tmp_dir, $globalDebug;
1979 2200
 		$error = '';
1980
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2201
+		if ($globalDebug) {
2202
+			echo "Schedules Skyteam : Download...";
2203
+		}
1981 2204
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1982 2205
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1983
-			if ($globalDebug) echo "Gunzip...";
2206
+			if ($globalDebug) {
2207
+				echo "Gunzip...";
2208
+			}
1984 2209
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1985
-			if ($globalDebug) echo "Add to DB...";
2210
+			if ($globalDebug) {
2211
+				echo "Add to DB...";
2212
+			}
1986 2213
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1987
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2214
+		} else {
2215
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2216
+		}
1988 2217
 		if ($error != '') {
1989 2218
 			return $error;
1990
-		} elseif ($globalDebug) echo "Done\n";
2219
+		} elseif ($globalDebug) {
2220
+			echo "Done\n";
2221
+		}
1991 2222
 		return '';
1992 2223
 	}
1993 2224
 	public static function update_ModeS() {
@@ -2004,355 +2235,619 @@  discard block
 block discarded – undo
2004 2235
 			exit;
2005 2236
 		} elseif ($globalDebug) echo "Done\n";
2006 2237
 */
2007
-		if ($globalDebug) echo "Modes : Download...";
2008
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2238
+		if ($globalDebug) {
2239
+			echo "Modes : Download...";
2240
+		}
2241
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2009 2242
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2010 2243
 
2011 2244
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2012 2245
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2013
-			if ($globalDebug) echo "Unzip...";
2014
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2246
+			if ($globalDebug) {
2247
+				echo "Unzip...";
2248
+			}
2249
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2015 2250
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2016
-			if ($globalDebug) echo "Add to DB...";
2251
+			if ($globalDebug) {
2252
+				echo "Add to DB...";
2253
+			}
2017 2254
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2018 2255
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2019
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2256
+		} else {
2257
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2258
+		}
2020 2259
 		if ($error != '') {
2021 2260
 			return $error;
2022
-		} elseif ($globalDebug) echo "Done\n";
2261
+		} elseif ($globalDebug) {
2262
+			echo "Done\n";
2263
+		}
2023 2264
 		return '';
2024 2265
 	}
2025 2266
 
2026 2267
 	public static function update_ModeS_faa() {
2027 2268
 		global $tmp_dir, $globalDebug;
2028
-		if ($globalDebug) echo "Modes FAA: Download...";
2269
+		if ($globalDebug) {
2270
+			echo "Modes FAA: Download...";
2271
+		}
2029 2272
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2030 2273
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2031
-			if ($globalDebug) echo "Unzip...";
2274
+			if ($globalDebug) {
2275
+				echo "Unzip...";
2276
+			}
2032 2277
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2033
-			if ($globalDebug) echo "Add to DB...";
2278
+			if ($globalDebug) {
2279
+				echo "Add to DB...";
2280
+			}
2034 2281
 			$error = update_db::modes_faa();
2035
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2282
+		} else {
2283
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2284
+		}
2036 2285
 		if ($error != '') {
2037 2286
 			return $error;
2038
-		} elseif ($globalDebug) echo "Done\n";
2287
+		} elseif ($globalDebug) {
2288
+			echo "Done\n";
2289
+		}
2039 2290
 		return '';
2040 2291
 	}
2041 2292
 
2042 2293
 	public static function update_ModeS_flarm() {
2043 2294
 		global $tmp_dir, $globalDebug;
2044
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2295
+		if ($globalDebug) {
2296
+			echo "Modes Flarmnet: Download...";
2297
+		}
2045 2298
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2046 2299
 		if (file_exists($tmp_dir.'data.fln')) {
2047
-			if ($globalDebug) echo "Add to DB...";
2300
+			if ($globalDebug) {
2301
+				echo "Add to DB...";
2302
+			}
2048 2303
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2049
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2304
+		} else {
2305
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2306
+		}
2050 2307
 		if ($error != '') {
2051 2308
 			return $error;
2052
-		} elseif ($globalDebug) echo "Done\n";
2309
+		} elseif ($globalDebug) {
2310
+			echo "Done\n";
2311
+		}
2053 2312
 		return '';
2054 2313
 	}
2055 2314
 
2056 2315
 	public static function update_ModeS_ogn() {
2057 2316
 		global $tmp_dir, $globalDebug;
2058
-		if ($globalDebug) echo "Modes OGN: Download...";
2317
+		if ($globalDebug) {
2318
+			echo "Modes OGN: Download...";
2319
+		}
2059 2320
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2060 2321
 		if (file_exists($tmp_dir.'ogn.csv')) {
2061
-			if ($globalDebug) echo "Add to DB...";
2322
+			if ($globalDebug) {
2323
+				echo "Add to DB...";
2324
+			}
2062 2325
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2063
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2326
+		} else {
2327
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2328
+		}
2064 2329
 		if ($error != '') {
2065 2330
 			return $error;
2066
-		} elseif ($globalDebug) echo "Done\n";
2331
+		} elseif ($globalDebug) {
2332
+			echo "Done\n";
2333
+		}
2067 2334
 		return '';
2068 2335
 	}
2069 2336
 
2070 2337
 	public static function update_owner() {
2071 2338
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2072 2339
 		
2073
-		if ($globalDebug) echo "Owner France: Download...";
2340
+		if ($globalDebug) {
2341
+			echo "Owner France: Download...";
2342
+		}
2074 2343
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2075 2344
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2076
-			if ($globalDebug) echo "Add to DB...";
2345
+			if ($globalDebug) {
2346
+				echo "Add to DB...";
2347
+			}
2077 2348
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2078
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2349
+		} else {
2350
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2351
+		}
2079 2352
 		if ($error != '') {
2080 2353
 			return $error;
2081
-		} elseif ($globalDebug) echo "Done\n";
2354
+		} elseif ($globalDebug) {
2355
+			echo "Done\n";
2356
+		}
2082 2357
 		
2083
-		if ($globalDebug) echo "Owner Ireland: Download...";
2358
+		if ($globalDebug) {
2359
+			echo "Owner Ireland: Download...";
2360
+		}
2084 2361
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2085 2362
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2086
-			if ($globalDebug) echo "Add to DB...";
2363
+			if ($globalDebug) {
2364
+				echo "Add to DB...";
2365
+			}
2087 2366
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2088
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2367
+		} else {
2368
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2369
+		}
2089 2370
 		if ($error != '') {
2090 2371
 			return $error;
2091
-		} elseif ($globalDebug) echo "Done\n";
2092
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2372
+		} elseif ($globalDebug) {
2373
+			echo "Done\n";
2374
+		}
2375
+		if ($globalDebug) {
2376
+			echo "Owner Switzerland: Download...";
2377
+		}
2093 2378
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2094 2379
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2095
-			if ($globalDebug) echo "Add to DB...";
2380
+			if ($globalDebug) {
2381
+				echo "Add to DB...";
2382
+			}
2096 2383
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2097
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2384
+		} else {
2385
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2386
+		}
2098 2387
 		if ($error != '') {
2099 2388
 			return $error;
2100
-		} elseif ($globalDebug) echo "Done\n";
2101
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2389
+		} elseif ($globalDebug) {
2390
+			echo "Done\n";
2391
+		}
2392
+		if ($globalDebug) {
2393
+			echo "Owner Czech Republic: Download...";
2394
+		}
2102 2395
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2103 2396
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2104
-			if ($globalDebug) echo "Add to DB...";
2397
+			if ($globalDebug) {
2398
+				echo "Add to DB...";
2399
+			}
2105 2400
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2106
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2401
+		} else {
2402
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2403
+		}
2107 2404
 		if ($error != '') {
2108 2405
 			return $error;
2109
-		} elseif ($globalDebug) echo "Done\n";
2110
-		if ($globalDebug) echo "Owner Australia: Download...";
2406
+		} elseif ($globalDebug) {
2407
+			echo "Done\n";
2408
+		}
2409
+		if ($globalDebug) {
2410
+			echo "Owner Australia: Download...";
2411
+		}
2111 2412
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2112 2413
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2113
-			if ($globalDebug) echo "Add to DB...";
2414
+			if ($globalDebug) {
2415
+				echo "Add to DB...";
2416
+			}
2114 2417
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2115
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2418
+		} else {
2419
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2420
+		}
2116 2421
 		if ($error != '') {
2117 2422
 			return $error;
2118
-		} elseif ($globalDebug) echo "Done\n";
2119
-		if ($globalDebug) echo "Owner Austria: Download...";
2423
+		} elseif ($globalDebug) {
2424
+			echo "Done\n";
2425
+		}
2426
+		if ($globalDebug) {
2427
+			echo "Owner Austria: Download...";
2428
+		}
2120 2429
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2121 2430
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2122
-			if ($globalDebug) echo "Add to DB...";
2431
+			if ($globalDebug) {
2432
+				echo "Add to DB...";
2433
+			}
2123 2434
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2124
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2435
+		} else {
2436
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2437
+		}
2125 2438
 		if ($error != '') {
2126 2439
 			return $error;
2127
-		} elseif ($globalDebug) echo "Done\n";
2128
-		if ($globalDebug) echo "Owner Chile: Download...";
2440
+		} elseif ($globalDebug) {
2441
+			echo "Done\n";
2442
+		}
2443
+		if ($globalDebug) {
2444
+			echo "Owner Chile: Download...";
2445
+		}
2129 2446
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2130 2447
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2131
-			if ($globalDebug) echo "Add to DB...";
2448
+			if ($globalDebug) {
2449
+				echo "Add to DB...";
2450
+			}
2132 2451
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2133
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2452
+		} else {
2453
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2454
+		}
2134 2455
 		if ($error != '') {
2135 2456
 			return $error;
2136
-		} elseif ($globalDebug) echo "Done\n";
2137
-		if ($globalDebug) echo "Owner Colombia: Download...";
2457
+		} elseif ($globalDebug) {
2458
+			echo "Done\n";
2459
+		}
2460
+		if ($globalDebug) {
2461
+			echo "Owner Colombia: Download...";
2462
+		}
2138 2463
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2139 2464
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2140
-			if ($globalDebug) echo "Add to DB...";
2465
+			if ($globalDebug) {
2466
+				echo "Add to DB...";
2467
+			}
2141 2468
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2142
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2469
+		} else {
2470
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2471
+		}
2143 2472
 		if ($error != '') {
2144 2473
 			return $error;
2145
-		} elseif ($globalDebug) echo "Done\n";
2146
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2474
+		} elseif ($globalDebug) {
2475
+			echo "Done\n";
2476
+		}
2477
+		if ($globalDebug) {
2478
+			echo "Owner Bosnia Herzegobina: Download...";
2479
+		}
2147 2480
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2148 2481
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2149
-			if ($globalDebug) echo "Add to DB...";
2482
+			if ($globalDebug) {
2483
+				echo "Add to DB...";
2484
+			}
2150 2485
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2151
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2486
+		} else {
2487
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2488
+		}
2152 2489
 		if ($error != '') {
2153 2490
 			return $error;
2154
-		} elseif ($globalDebug) echo "Done\n";
2155
-		if ($globalDebug) echo "Owner Brazil: Download...";
2491
+		} elseif ($globalDebug) {
2492
+			echo "Done\n";
2493
+		}
2494
+		if ($globalDebug) {
2495
+			echo "Owner Brazil: Download...";
2496
+		}
2156 2497
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2157 2498
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2158
-			if ($globalDebug) echo "Add to DB...";
2499
+			if ($globalDebug) {
2500
+				echo "Add to DB...";
2501
+			}
2159 2502
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2160
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2503
+		} else {
2504
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2505
+		}
2161 2506
 		if ($error != '') {
2162 2507
 			return $error;
2163
-		} elseif ($globalDebug) echo "Done\n";
2164
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2508
+		} elseif ($globalDebug) {
2509
+			echo "Done\n";
2510
+		}
2511
+		if ($globalDebug) {
2512
+			echo "Owner Cayman Islands: Download...";
2513
+		}
2165 2514
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2166 2515
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2167
-			if ($globalDebug) echo "Add to DB...";
2516
+			if ($globalDebug) {
2517
+				echo "Add to DB...";
2518
+			}
2168 2519
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2169
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2520
+		} else {
2521
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2522
+		}
2170 2523
 		if ($error != '') {
2171 2524
 			return $error;
2172
-		} elseif ($globalDebug) echo "Done\n";
2173
-		if ($globalDebug) echo "Owner Croatia: Download...";
2525
+		} elseif ($globalDebug) {
2526
+			echo "Done\n";
2527
+		}
2528
+		if ($globalDebug) {
2529
+			echo "Owner Croatia: Download...";
2530
+		}
2174 2531
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2175 2532
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2176
-			if ($globalDebug) echo "Add to DB...";
2533
+			if ($globalDebug) {
2534
+				echo "Add to DB...";
2535
+			}
2177 2536
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2178
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2537
+		} else {
2538
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2539
+		}
2179 2540
 		if ($error != '') {
2180 2541
 			return $error;
2181
-		} elseif ($globalDebug) echo "Done\n";
2182
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2542
+		} elseif ($globalDebug) {
2543
+			echo "Done\n";
2544
+		}
2545
+		if ($globalDebug) {
2546
+			echo "Owner Luxembourg: Download...";
2547
+		}
2183 2548
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2184 2549
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2185
-			if ($globalDebug) echo "Add to DB...";
2550
+			if ($globalDebug) {
2551
+				echo "Add to DB...";
2552
+			}
2186 2553
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2187
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2554
+		} else {
2555
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2556
+		}
2188 2557
 		if ($error != '') {
2189 2558
 			return $error;
2190
-		} elseif ($globalDebug) echo "Done\n";
2191
-		if ($globalDebug) echo "Owner Maldives: Download...";
2559
+		} elseif ($globalDebug) {
2560
+			echo "Done\n";
2561
+		}
2562
+		if ($globalDebug) {
2563
+			echo "Owner Maldives: Download...";
2564
+		}
2192 2565
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2193 2566
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2194
-			if ($globalDebug) echo "Add to DB...";
2567
+			if ($globalDebug) {
2568
+				echo "Add to DB...";
2569
+			}
2195 2570
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2196
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2571
+		} else {
2572
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2573
+		}
2197 2574
 		if ($error != '') {
2198 2575
 			return $error;
2199
-		} elseif ($globalDebug) echo "Done\n";
2200
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2576
+		} elseif ($globalDebug) {
2577
+			echo "Done\n";
2578
+		}
2579
+		if ($globalDebug) {
2580
+			echo "Owner New Zealand: Download...";
2581
+		}
2201 2582
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2202 2583
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2203
-			if ($globalDebug) echo "Add to DB...";
2584
+			if ($globalDebug) {
2585
+				echo "Add to DB...";
2586
+			}
2204 2587
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2205
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2588
+		} else {
2589
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2590
+		}
2206 2591
 		if ($error != '') {
2207 2592
 			return $error;
2208
-		} elseif ($globalDebug) echo "Done\n";
2209
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2593
+		} elseif ($globalDebug) {
2594
+			echo "Done\n";
2595
+		}
2596
+		if ($globalDebug) {
2597
+			echo "Owner Papua New Guinea: Download...";
2598
+		}
2210 2599
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2211 2600
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2212
-			if ($globalDebug) echo "Add to DB...";
2601
+			if ($globalDebug) {
2602
+				echo "Add to DB...";
2603
+			}
2213 2604
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2214
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2605
+		} else {
2606
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2607
+		}
2215 2608
 		if ($error != '') {
2216 2609
 			return $error;
2217
-		} elseif ($globalDebug) echo "Done\n";
2218
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2610
+		} elseif ($globalDebug) {
2611
+			echo "Done\n";
2612
+		}
2613
+		if ($globalDebug) {
2614
+			echo "Owner Slovakia: Download...";
2615
+		}
2219 2616
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2220 2617
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2221
-			if ($globalDebug) echo "Add to DB...";
2618
+			if ($globalDebug) {
2619
+				echo "Add to DB...";
2620
+			}
2222 2621
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2223
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2622
+		} else {
2623
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2624
+		}
2224 2625
 		if ($error != '') {
2225 2626
 			return $error;
2226
-		} elseif ($globalDebug) echo "Done\n";
2227
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2627
+		} elseif ($globalDebug) {
2628
+			echo "Done\n";
2629
+		}
2630
+		if ($globalDebug) {
2631
+			echo "Owner Ecuador: Download...";
2632
+		}
2228 2633
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2229 2634
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2230
-			if ($globalDebug) echo "Add to DB...";
2635
+			if ($globalDebug) {
2636
+				echo "Add to DB...";
2637
+			}
2231 2638
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2232
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2639
+		} else {
2640
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2641
+		}
2233 2642
 		if ($error != '') {
2234 2643
 			return $error;
2235
-		} elseif ($globalDebug) echo "Done\n";
2236
-		if ($globalDebug) echo "Owner Iceland: Download...";
2644
+		} elseif ($globalDebug) {
2645
+			echo "Done\n";
2646
+		}
2647
+		if ($globalDebug) {
2648
+			echo "Owner Iceland: Download...";
2649
+		}
2237 2650
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2238 2651
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2239
-			if ($globalDebug) echo "Add to DB...";
2652
+			if ($globalDebug) {
2653
+				echo "Add to DB...";
2654
+			}
2240 2655
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2241
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2656
+		} else {
2657
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2658
+		}
2242 2659
 		if ($error != '') {
2243 2660
 			return $error;
2244
-		} elseif ($globalDebug) echo "Done\n";
2245
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2661
+		} elseif ($globalDebug) {
2662
+			echo "Done\n";
2663
+		}
2664
+		if ($globalDebug) {
2665
+			echo "Owner Isle of Man: Download...";
2666
+		}
2246 2667
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2247 2668
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2248
-			if ($globalDebug) echo "Add to DB...";
2669
+			if ($globalDebug) {
2670
+				echo "Add to DB...";
2671
+			}
2249 2672
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2250
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2673
+		} else {
2674
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2675
+		}
2251 2676
 		if ($error != '') {
2252 2677
 			return $error;
2253
-		} elseif ($globalDebug) echo "Done\n";
2678
+		} elseif ($globalDebug) {
2679
+			echo "Done\n";
2680
+		}
2254 2681
 		if ($globalMasterSource) {
2255
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2682
+			if ($globalDebug) {
2683
+				echo "ModeS Netherlands: Download...";
2684
+			}
2256 2685
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2257 2686
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2258
-				if ($globalDebug) echo "Add to DB...";
2687
+				if ($globalDebug) {
2688
+					echo "Add to DB...";
2689
+				}
2259 2690
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2260
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2691
+			} else {
2692
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2693
+			}
2261 2694
 			if ($error != '') {
2262 2695
 				return $error;
2263
-			} elseif ($globalDebug) echo "Done\n";
2264
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2696
+			} elseif ($globalDebug) {
2697
+				echo "Done\n";
2698
+			}
2699
+			if ($globalDebug) {
2700
+				echo "ModeS Denmark: Download...";
2701
+			}
2265 2702
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2266 2703
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2267
-				if ($globalDebug) echo "Add to DB...";
2704
+				if ($globalDebug) {
2705
+					echo "Add to DB...";
2706
+				}
2268 2707
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2269
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2708
+			} else {
2709
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2710
+			}
2270 2711
 			if ($error != '') {
2271 2712
 				return $error;
2272
-			} elseif ($globalDebug) echo "Done\n";
2273
-		} elseif ($globalDebug) echo "Done\n";
2713
+			} elseif ($globalDebug) {
2714
+				echo "Done\n";
2715
+			}
2716
+		} elseif ($globalDebug) {
2717
+			echo "Done\n";
2718
+		}
2274 2719
 		return '';
2275 2720
 	}
2276 2721
 
2277 2722
 	public static function update_translation() {
2278 2723
 		global $tmp_dir, $globalDebug;
2279 2724
 		$error = '';
2280
-		if ($globalDebug) echo "Translation : Download...";
2725
+		if ($globalDebug) {
2726
+			echo "Translation : Download...";
2727
+		}
2281 2728
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2282 2729
 		if (file_exists($tmp_dir.'translation.zip')) {
2283
-			if ($globalDebug) echo "Unzip...";
2730
+			if ($globalDebug) {
2731
+				echo "Unzip...";
2732
+			}
2284 2733
 			update_db::unzip($tmp_dir.'translation.zip');
2285
-			if ($globalDebug) echo "Add to DB...";
2734
+			if ($globalDebug) {
2735
+				echo "Add to DB...";
2736
+			}
2286 2737
 			$error = update_db::translation();
2287
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2738
+		} else {
2739
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2740
+		}
2288 2741
 		if ($error != '') {
2289 2742
 			return $error;
2290
-		} elseif ($globalDebug) echo "Done\n";
2743
+		} elseif ($globalDebug) {
2744
+			echo "Done\n";
2745
+		}
2291 2746
 		return '';
2292 2747
 	}
2293 2748
 
2294 2749
 	public static function update_translation_fam() {
2295 2750
 		global $tmp_dir, $globalDebug;
2296
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2751
+		if ($globalDebug) {
2752
+			echo "Translation from FlightAirMap website : Download...";
2753
+		}
2297 2754
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2298 2755
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
2299
-			if ($globalDebug) echo "Gunzip...";
2756
+			if ($globalDebug) {
2757
+				echo "Gunzip...";
2758
+			}
2300 2759
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
2301
-			if ($globalDebug) echo "Add to DB...";
2760
+			if ($globalDebug) {
2761
+				echo "Add to DB...";
2762
+			}
2302 2763
 			$error = update_db::translation_fam();
2303
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2764
+		} else {
2765
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2766
+		}
2304 2767
 		if ($error != '') {
2305 2768
 			return $error;
2306
-		} elseif ($globalDebug) echo "Done\n";
2769
+		} elseif ($globalDebug) {
2770
+			echo "Done\n";
2771
+		}
2307 2772
 		return '';
2308 2773
 	}
2309 2774
 	public static function update_ModeS_fam() {
2310 2775
 		global $tmp_dir, $globalDebug;
2311
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2776
+		if ($globalDebug) {
2777
+			echo "ModeS from FlightAirMap website : Download...";
2778
+		}
2312 2779
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2313 2780
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2314
-			if ($globalDebug) echo "Gunzip...";
2781
+			if ($globalDebug) {
2782
+				echo "Gunzip...";
2783
+			}
2315 2784
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
2316
-			if ($globalDebug) echo "Add to DB...";
2785
+			if ($globalDebug) {
2786
+				echo "Add to DB...";
2787
+			}
2317 2788
 			$error = update_db::modes_fam();
2318
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2789
+		} else {
2790
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2791
+		}
2319 2792
 		if ($error != '') {
2320 2793
 			return $error;
2321
-		} elseif ($globalDebug) echo "Done\n";
2794
+		} elseif ($globalDebug) {
2795
+			echo "Done\n";
2796
+		}
2322 2797
 		return '';
2323 2798
 	}
2324 2799
 	public static function update_owner_fam() {
2325 2800
 		global $tmp_dir, $globalDebug, $globalOwner;
2326
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2801
+		if ($globalDebug) {
2802
+			echo "owner from FlightAirMap website : Download...";
2803
+		}
2327 2804
 		if ($globalOwner === TRUE) {
2328 2805
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2329 2806
 		} else {
2330 2807
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2331 2808
 		}
2332 2809
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2333
-			if ($globalDebug) echo "Gunzip...";
2810
+			if ($globalDebug) {
2811
+				echo "Gunzip...";
2812
+			}
2334 2813
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2335
-			if ($globalDebug) echo "Add to DB...";
2814
+			if ($globalDebug) {
2815
+				echo "Add to DB...";
2816
+			}
2336 2817
 			$error = update_db::owner_fam();
2337
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2818
+		} else {
2819
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2820
+		}
2338 2821
 		if ($error != '') {
2339 2822
 			return $error;
2340
-		} elseif ($globalDebug) echo "Done\n";
2823
+		} elseif ($globalDebug) {
2824
+			echo "Done\n";
2825
+		}
2341 2826
 		return '';
2342 2827
 	}
2343 2828
 	public static function update_routes_fam() {
2344 2829
 		global $tmp_dir, $globalDebug;
2345
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2830
+		if ($globalDebug) {
2831
+			echo "Routes from FlightAirMap website : Download...";
2832
+		}
2346 2833
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2347 2834
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2348
-			if ($globalDebug) echo "Gunzip...";
2835
+			if ($globalDebug) {
2836
+				echo "Gunzip...";
2837
+			}
2349 2838
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2350
-			if ($globalDebug) echo "Add to DB...";
2839
+			if ($globalDebug) {
2840
+				echo "Add to DB...";
2841
+			}
2351 2842
 			$error = update_db::routes_fam();
2352
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2843
+		} else {
2844
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2845
+		}
2353 2846
 		if ($error != '') {
2354 2847
 			return $error;
2355
-		} elseif ($globalDebug) echo "Done\n";
2848
+		} elseif ($globalDebug) {
2849
+			echo "Done\n";
2850
+		}
2356 2851
 		return '';
2357 2852
 	}
2358 2853
 	public static function update_marine_identity_fam() {
@@ -2362,14 +2857,22 @@  discard block
 block discarded – undo
2362 2857
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2363 2858
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2364 2859
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2365
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2860
+				if ($globalDebug) {
2861
+					echo "Marine identity from FlightAirMap website : Download...";
2862
+				}
2366 2863
 				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2367 2864
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2368
-					if ($globalDebug) echo "Gunzip...";
2865
+					if ($globalDebug) {
2866
+						echo "Gunzip...";
2867
+					}
2369 2868
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2370
-					if ($globalDebug) echo "Add to DB...";
2869
+					if ($globalDebug) {
2870
+						echo "Add to DB...";
2871
+					}
2371 2872
 					$error = update_db::marine_identity_fam();
2372
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2873
+				} else {
2874
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2875
+				}
2373 2876
 				if ($error != '') {
2374 2877
 					return $error;
2375 2878
 				} elseif ($globalDebug) {
@@ -2388,14 +2891,22 @@  discard block
 block discarded – undo
2388 2891
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2389 2892
 			$satellite_md5 = $satellite_md5_file[0];
2390 2893
 			if (!update_db::check_satellite_version($satellite_md5)) {
2391
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2894
+				if ($globalDebug) {
2895
+					echo "Satellite from FlightAirMap website : Download...";
2896
+				}
2392 2897
 				update_db::download('http://data.flightairmap.fr/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2393 2898
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2394
-					if ($globalDebug) echo "Gunzip...";
2899
+					if ($globalDebug) {
2900
+						echo "Gunzip...";
2901
+					}
2395 2902
 					update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2396
-					if ($globalDebug) echo "Add to DB...";
2903
+					if ($globalDebug) {
2904
+						echo "Add to DB...";
2905
+					}
2397 2906
 					$error = update_db::satellite_fam();
2398
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2907
+				} else {
2908
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2909
+				}
2399 2910
 				if ($error != '') {
2400 2911
 					return $error;
2401 2912
 				} elseif ($globalDebug) {
@@ -2408,17 +2919,25 @@  discard block
 block discarded – undo
2408 2919
 	}
2409 2920
 	public static function update_banned_fam() {
2410 2921
 		global $tmp_dir, $globalDebug;
2411
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2922
+		if ($globalDebug) {
2923
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2924
+		}
2412 2925
 		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2413 2926
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2414 2927
 			//if ($globalDebug) echo "Gunzip...";
2415 2928
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2416
-			if ($globalDebug) echo "Add to DB...";
2929
+			if ($globalDebug) {
2930
+				echo "Add to DB...";
2931
+			}
2417 2932
 			$error = update_db::banned_fam();
2418
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2933
+		} else {
2934
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2935
+		}
2419 2936
 		if ($error != '') {
2420 2937
 			return $error;
2421
-		} elseif ($globalDebug) echo "Done\n";
2938
+		} elseif ($globalDebug) {
2939
+			echo "Done\n";
2940
+		}
2422 2941
 		return '';
2423 2942
 	}
2424 2943
 
@@ -2426,7 +2945,9 @@  discard block
 block discarded – undo
2426 2945
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2427 2946
 		include_once('class.create_db.php');
2428 2947
 		$error = '';
2429
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2948
+		if ($globalDebug) {
2949
+			echo "Airspace from FlightAirMap website : Download...";
2950
+		}
2430 2951
 		if ($globalDBdriver == 'mysql') {
2431 2952
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2432 2953
 		} else {
@@ -2442,9 +2963,13 @@  discard block
 block discarded – undo
2442 2963
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2443 2964
 				}
2444 2965
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2445
-					if ($globalDebug) echo "Gunzip...";
2966
+					if ($globalDebug) {
2967
+						echo "Gunzip...";
2968
+					}
2446 2969
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2447
-					if ($globalDebug) echo "Add to DB...";
2970
+					if ($globalDebug) {
2971
+						echo "Add to DB...";
2972
+					}
2448 2973
 					$Connection = new Connection();
2449 2974
 					if ($Connection->tableExists('airspace')) {
2450 2975
 						$query = 'DROP TABLE airspace';
@@ -2457,19 +2982,27 @@  discard block
 block discarded – undo
2457 2982
 		    			}
2458 2983
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2459 2984
 					update_db::insert_airspace_version($airspace_md5);
2460
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2985
+				} else {
2986
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2987
+				}
2461 2988
 			}
2462
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2989
+		} else {
2990
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2991
+		}
2463 2992
 		if ($error != '') {
2464 2993
 			return $error;
2465
-		} elseif ($globalDebug) echo "Done\n";
2994
+		} elseif ($globalDebug) {
2995
+			echo "Done\n";
2996
+		}
2466 2997
 		return '';
2467 2998
 	}
2468 2999
 
2469 3000
 	public static function update_geoid_fam() {
2470 3001
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2471 3002
 		$error = '';
2472
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3003
+		if ($globalDebug) {
3004
+			echo "Geoid from FlightAirMap website : Download...";
3005
+		}
2473 3006
 		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2474 3007
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2475 3008
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2477,75 +3010,113 @@  discard block
 block discarded – undo
2477 3010
 			if (!update_db::check_geoid_version($geoid_md5)) {
2478 3011
 				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2479 3012
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2480
-					if ($globalDebug) echo "Gunzip...";
3013
+					if ($globalDebug) {
3014
+						echo "Gunzip...";
3015
+					}
2481 3016
 					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2482 3017
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2483 3018
 						update_db::insert_geoid_version($geoid_md5);
2484 3019
 					}
2485
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3020
+				} else {
3021
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3022
+				}
2486 3023
 			}
2487
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3024
+		} else {
3025
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3026
+		}
2488 3027
 		if ($error != '') {
2489 3028
 			return $error;
2490
-		} elseif ($globalDebug) echo "Done\n";
3029
+		} elseif ($globalDebug) {
3030
+			echo "Done\n";
3031
+		}
2491 3032
 		return '';
2492 3033
 	}
2493 3034
 
2494 3035
 	public static function update_tle() {
2495 3036
 		global $tmp_dir, $globalDebug;
2496
-		if ($globalDebug) echo "Download TLE : Download...";
3037
+		if ($globalDebug) {
3038
+			echo "Download TLE : Download...";
3039
+		}
2497 3040
 		$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',
2498 3041
 		'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',
2499 3042
 		'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');
2500 3043
 		foreach ($alltle as $filename) {
2501
-			if ($globalDebug) echo "downloading ".$filename.'...';
3044
+			if ($globalDebug) {
3045
+				echo "downloading ".$filename.'...';
3046
+			}
2502 3047
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2503 3048
 			if (file_exists($tmp_dir.$filename)) {
2504
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3049
+				if ($globalDebug) {
3050
+					echo "Add to DB ".$filename."...";
3051
+				}
2505 3052
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2506
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3053
+			} else {
3054
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3055
+			}
2507 3056
 			if ($error != '') {
2508 3057
 				echo $error."\n";
2509
-			} elseif ($globalDebug) echo "Done\n";
3058
+			} elseif ($globalDebug) {
3059
+				echo "Done\n";
3060
+			}
2510 3061
 		}
2511 3062
 		return '';
2512 3063
 	}
2513 3064
 
2514 3065
 	public static function update_ucsdb() {
2515 3066
 		global $tmp_dir, $globalDebug;
2516
-		if ($globalDebug) echo "Download UCS DB : Download...";
3067
+		if ($globalDebug) {
3068
+			echo "Download UCS DB : Download...";
3069
+		}
2517 3070
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2518 3071
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2519
-			if ($globalDebug) echo "Add to DB...";
3072
+			if ($globalDebug) {
3073
+				echo "Add to DB...";
3074
+			}
2520 3075
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2521
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3076
+		} else {
3077
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3078
+		}
2522 3079
 		if ($error != '') {
2523 3080
 			echo $error."\n";
2524
-		} elseif ($globalDebug) echo "Done\n";
3081
+		} elseif ($globalDebug) {
3082
+			echo "Done\n";
3083
+		}
2525 3084
 		return '';
2526 3085
 	}
2527 3086
 
2528 3087
 	public static function update_celestrak() {
2529 3088
 		global $tmp_dir, $globalDebug;
2530
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3089
+		if ($globalDebug) {
3090
+			echo "Download Celestrak DB : Download...";
3091
+		}
2531 3092
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2532 3093
 		if (file_exists($tmp_dir.'satcat.txt')) {
2533
-			if ($globalDebug) echo "Add to DB...";
3094
+			if ($globalDebug) {
3095
+				echo "Add to DB...";
3096
+			}
2534 3097
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2535
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3098
+		} else {
3099
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3100
+		}
2536 3101
 		if ($error != '') {
2537 3102
 			echo $error."\n";
2538
-		} elseif ($globalDebug) echo "Done\n";
3103
+		} elseif ($globalDebug) {
3104
+			echo "Done\n";
3105
+		}
2539 3106
 		return '';
2540 3107
 	}
2541 3108
 
2542 3109
 	public static function update_models() {
2543 3110
 		global $tmp_dir, $globalDebug;
2544 3111
 		$error = '';
2545
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3112
+		if ($globalDebug) {
3113
+			echo "Models from FlightAirMap website : Download...";
3114
+		}
2546 3115
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2547 3116
 		if (file_exists($tmp_dir.'models.md5sum')) {
2548
-			if ($globalDebug) echo "Check files...\n";
3117
+			if ($globalDebug) {
3118
+				echo "Check files...\n";
3119
+			}
2549 3120
 			$newmodelsdb = array();
2550 3121
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2551 3122
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2564,25 +3135,35 @@  discard block
 block discarded – undo
2564 3135
 			}
2565 3136
 			$diff = array_diff($newmodelsdb,$modelsdb);
2566 3137
 			foreach ($diff as $key => $value) {
2567
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3138
+				if ($globalDebug) {
3139
+					echo 'Downloading model '.$key.' ...'."\n";
3140
+				}
2568 3141
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2569 3142
 				
2570 3143
 			}
2571 3144
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2572
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3145
+		} else {
3146
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3147
+		}
2573 3148
 		if ($error != '') {
2574 3149
 			return $error;
2575
-		} elseif ($globalDebug) echo "Done\n";
3150
+		} elseif ($globalDebug) {
3151
+			echo "Done\n";
3152
+		}
2576 3153
 		return '';
2577 3154
 	}
2578 3155
 
2579 3156
 	public static function update_space_models() {
2580 3157
 		global $tmp_dir, $globalDebug;
2581 3158
 		$error = '';
2582
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3159
+		if ($globalDebug) {
3160
+			echo "Space models from FlightAirMap website : Download...";
3161
+		}
2583 3162
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2584 3163
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2585
-			if ($globalDebug) echo "Check files...\n";
3164
+			if ($globalDebug) {
3165
+				echo "Check files...\n";
3166
+			}
2586 3167
 			$newmodelsdb = array();
2587 3168
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2588 3169
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2601,25 +3182,35 @@  discard block
 block discarded – undo
2601 3182
 			}
2602 3183
 			$diff = array_diff($newmodelsdb,$modelsdb);
2603 3184
 			foreach ($diff as $key => $value) {
2604
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3185
+				if ($globalDebug) {
3186
+					echo 'Downloading space model '.$key.' ...'."\n";
3187
+				}
2605 3188
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2606 3189
 				
2607 3190
 			}
2608 3191
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2609
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3192
+		} else {
3193
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3194
+		}
2610 3195
 		if ($error != '') {
2611 3196
 			return $error;
2612
-		} elseif ($globalDebug) echo "Done\n";
3197
+		} elseif ($globalDebug) {
3198
+			echo "Done\n";
3199
+		}
2613 3200
 		return '';
2614 3201
 	}
2615 3202
 
2616 3203
 	public static function update_vehicules_models() {
2617 3204
 		global $tmp_dir, $globalDebug;
2618 3205
 		$error = '';
2619
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3206
+		if ($globalDebug) {
3207
+			echo "Vehicules models from FlightAirMap website : Download...";
3208
+		}
2620 3209
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2621 3210
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2622
-			if ($globalDebug) echo "Check files...\n";
3211
+			if ($globalDebug) {
3212
+				echo "Check files...\n";
3213
+			}
2623 3214
 			$newmodelsdb = array();
2624 3215
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2625 3216
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2638,15 +3229,21 @@  discard block
 block discarded – undo
2638 3229
 			}
2639 3230
 			$diff = array_diff($newmodelsdb,$modelsdb);
2640 3231
 			foreach ($diff as $key => $value) {
2641
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3232
+				if ($globalDebug) {
3233
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3234
+				}
2642 3235
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2643 3236
 				
2644 3237
 			}
2645 3238
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2646
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3239
+		} else {
3240
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3241
+		}
2647 3242
 		if ($error != '') {
2648 3243
 			return $error;
2649
-		} elseif ($globalDebug) echo "Done\n";
3244
+		} elseif ($globalDebug) {
3245
+			echo "Done\n";
3246
+		}
2650 3247
 		return '';
2651 3248
 	}
2652 3249
 
@@ -2689,7 +3286,9 @@  discard block
 block discarded – undo
2689 3286
                 }
2690 3287
 
2691 3288
 		$error = '';
2692
-		if ($globalDebug) echo "Notam : Download...";
3289
+		if ($globalDebug) {
3290
+			echo "Notam : Download...";
3291
+		}
2693 3292
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2694 3293
 		if (file_exists($tmp_dir.'notam.rss')) {
2695 3294
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2704,14 +3303,30 @@  discard block
 block discarded – undo
2704 3303
 				$data['fir'] = $q[0];
2705 3304
 				$data['code'] = $q[1];
2706 3305
 				$ifrvfr = $q[2];
2707
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2708
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2709
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2710
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2711
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2712
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2713
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2714
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3306
+				if ($ifrvfr == 'IV') {
3307
+					$data['rules'] = 'IFR/VFR';
3308
+				}
3309
+				if ($ifrvfr == 'I') {
3310
+					$data['rules'] = 'IFR';
3311
+				}
3312
+				if ($ifrvfr == 'V') {
3313
+					$data['rules'] = 'VFR';
3314
+				}
3315
+				if ($q[4] == 'A') {
3316
+					$data['scope'] = 'Airport warning';
3317
+				}
3318
+				if ($q[4] == 'E') {
3319
+					$data['scope'] = 'Enroute warning';
3320
+				}
3321
+				if ($q[4] == 'W') {
3322
+					$data['scope'] = 'Navigation warning';
3323
+				}
3324
+				if ($q[4] == 'AE') {
3325
+					$data['scope'] = 'Airport/Enroute warning';
3326
+				}
3327
+				if ($q[4] == 'AW') {
3328
+					$data['scope'] = 'Airport/Navigation warning';
3329
+				}
2715 3330
 				//$data['scope'] = $q[4];
2716 3331
 				$data['lower_limit'] = $q[5];
2717 3332
 				$data['upper_limit'] = $q[6];
@@ -2719,8 +3334,12 @@  discard block
 block discarded – undo
2719 3334
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2720 3335
 				$latitude = $Common->convertDec($las,'latitude');
2721 3336
 				$longitude = $Common->convertDec($lns,'longitude');
2722
-				if ($lac == 'S') $latitude = '-'.$latitude;
2723
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3337
+				if ($lac == 'S') {
3338
+					$latitude = '-'.$latitude;
3339
+				}
3340
+				if ($lnc == 'W') {
3341
+					$longitude = '-'.$longitude;
3342
+				}
2724 3343
 				$data['center_latitude'] = $latitude;
2725 3344
 				$data['center_longitude'] = $longitude;
2726 3345
 				$data['radius'] = intval($radius);
@@ -2750,10 +3369,14 @@  discard block
 block discarded – undo
2750 3369
 				$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']);
2751 3370
 				unset($data);
2752 3371
 			} 
2753
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3372
+		} else {
3373
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3374
+		}
2754 3375
 		if ($error != '') {
2755 3376
 			return $error;
2756
-		} elseif ($globalDebug) echo "Done\n";
3377
+		} elseif ($globalDebug) {
3378
+			echo "Done\n";
3379
+		}
2757 3380
 		return '';
2758 3381
 	}
2759 3382
 	
@@ -2778,7 +3401,9 @@  discard block
 block discarded – undo
2778 3401
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2779 3402
 		$airspace_json = json_decode($airspace_lst,true);
2780 3403
 		foreach ($airspace_json['records'] as $airspace) {
2781
-			if ($globalDebug) echo $airspace['name']."...\n";
3404
+			if ($globalDebug) {
3405
+				echo $airspace['name']."...\n";
3406
+			}
2782 3407
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2783 3408
 			if (file_exists($tmp_dir.$airspace['name'])) {
2784 3409
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2822,8 +3447,11 @@  discard block
 block discarded – undo
2822 3447
                         return "error : ".$e->getMessage();
2823 3448
                 }
2824 3449
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2825
-                if ($row['nb'] > 0) return false;
2826
-                else return true;
3450
+                if ($row['nb'] > 0) {
3451
+                	return false;
3452
+                } else {
3453
+                	return true;
3454
+                }
2827 3455
 	}
2828 3456
 
2829 3457
 	public static function insert_last_update() {
@@ -2848,8 +3476,11 @@  discard block
 block discarded – undo
2848 3476
                         return "error : ".$e->getMessage();
2849 3477
                 }
2850 3478
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2851
-                if ($row['nb'] > 0) return true;
2852
-                else return false;
3479
+                if ($row['nb'] > 0) {
3480
+                	return true;
3481
+                } else {
3482
+                	return false;
3483
+                }
2853 3484
 	}
2854 3485
 
2855 3486
 	public static function check_geoid_version($version) {
@@ -2862,8 +3493,11 @@  discard block
 block discarded – undo
2862 3493
                         return "error : ".$e->getMessage();
2863 3494
                 }
2864 3495
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2865
-                if ($row['nb'] > 0) return true;
2866
-                else return false;
3496
+                if ($row['nb'] > 0) {
3497
+                	return true;
3498
+                } else {
3499
+                	return false;
3500
+                }
2867 3501
 	}
2868 3502
 
2869 3503
 	public static function check_marine_identity_version($version) {
@@ -2876,8 +3510,11 @@  discard block
 block discarded – undo
2876 3510
 			return "error : ".$e->getMessage();
2877 3511
 		}
2878 3512
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2879
-		if ($row['nb'] > 0) return true;
2880
-		else return false;
3513
+		if ($row['nb'] > 0) {
3514
+			return true;
3515
+		} else {
3516
+			return false;
3517
+		}
2881 3518
 	}
2882 3519
 
2883 3520
 	public static function check_satellite_version($version) {
@@ -2890,8 +3527,11 @@  discard block
 block discarded – undo
2890 3527
 			return "error : ".$e->getMessage();
2891 3528
 		}
2892 3529
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2893
-		if ($row['nb'] > 0) return true;
2894
-		else return false;
3530
+		if ($row['nb'] > 0) {
3531
+			return true;
3532
+		} else {
3533
+			return false;
3534
+		}
2895 3535
 	}
2896 3536
 
2897 3537
 
@@ -2958,8 +3598,11 @@  discard block
 block discarded – undo
2958 3598
                         return "error : ".$e->getMessage();
2959 3599
                 }
2960 3600
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2961
-                if ($row['nb'] > 0) return false;
2962
-                else return true;
3601
+                if ($row['nb'] > 0) {
3602
+                	return false;
3603
+                } else {
3604
+                	return true;
3605
+                }
2963 3606
 	}
2964 3607
 
2965 3608
 	public static function insert_last_notam_update() {
@@ -2989,8 +3632,11 @@  discard block
 block discarded – undo
2989 3632
                         return "error : ".$e->getMessage();
2990 3633
                 }
2991 3634
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2992
-                if ($row['nb'] > 0) return false;
2993
-                else return true;
3635
+                if ($row['nb'] > 0) {
3636
+                	return false;
3637
+                } else {
3638
+                	return true;
3639
+                }
2994 3640
 	}
2995 3641
 
2996 3642
 	public static function insert_last_airspace_update() {
@@ -3020,8 +3666,11 @@  discard block
 block discarded – undo
3020 3666
                         return "error : ".$e->getMessage();
3021 3667
                 }
3022 3668
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3023
-                if ($row['nb'] > 0) return false;
3024
-                else return true;
3669
+                if ($row['nb'] > 0) {
3670
+                	return false;
3671
+                } else {
3672
+                	return true;
3673
+                }
3025 3674
 	}
3026 3675
 
3027 3676
 	public static function insert_last_geoid_update() {
@@ -3051,8 +3700,11 @@  discard block
 block discarded – undo
3051 3700
                         return "error : ".$e->getMessage();
3052 3701
                 }
3053 3702
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3054
-                if ($row['nb'] > 0) return false;
3055
-                else return true;
3703
+                if ($row['nb'] > 0) {
3704
+                	return false;
3705
+                } else {
3706
+                	return true;
3707
+                }
3056 3708
 	}
3057 3709
 
3058 3710
 	public static function insert_last_owner_update() {
@@ -3081,8 +3733,11 @@  discard block
 block discarded – undo
3081 3733
                         return "error : ".$e->getMessage();
3082 3734
                 }
3083 3735
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3084
-                if ($row['nb'] > 0) return false;
3085
-                else return true;
3736
+                if ($row['nb'] > 0) {
3737
+                	return false;
3738
+                } else {
3739
+                	return true;
3740
+                }
3086 3741
 	}
3087 3742
 
3088 3743
 	public static function insert_last_schedules_update() {
@@ -3112,8 +3767,11 @@  discard block
 block discarded – undo
3112 3767
 			return "error : ".$e->getMessage();
3113 3768
 		}
3114 3769
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3115
-		if ($row['nb'] > 0) return false;
3116
-		else return true;
3770
+		if ($row['nb'] > 0) {
3771
+			return false;
3772
+		} else {
3773
+			return true;
3774
+		}
3117 3775
 	}
3118 3776
 
3119 3777
 	public static function insert_last_tle_update() {
@@ -3143,8 +3801,11 @@  discard block
 block discarded – undo
3143 3801
 			return "error : ".$e->getMessage();
3144 3802
 		}
3145 3803
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3146
-		if ($row['nb'] > 0) return false;
3147
-		else return true;
3804
+		if ($row['nb'] > 0) {
3805
+			return false;
3806
+		} else {
3807
+			return true;
3808
+		}
3148 3809
 	}
3149 3810
 
3150 3811
 	public static function insert_last_ucsdb_update() {
@@ -3174,8 +3835,11 @@  discard block
 block discarded – undo
3174 3835
 			return "error : ".$e->getMessage();
3175 3836
 		}
3176 3837
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3177
-		if ($row['nb'] > 0) return false;
3178
-		else return true;
3838
+		if ($row['nb'] > 0) {
3839
+			return false;
3840
+		} else {
3841
+			return true;
3842
+		}
3179 3843
 	}
3180 3844
 
3181 3845
 	public static function insert_last_celestrak_update() {
@@ -3205,8 +3869,11 @@  discard block
 block discarded – undo
3205 3869
 			return "error : ".$e->getMessage();
3206 3870
 		}
3207 3871
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3208
-		if ($row['nb'] > 0) return false;
3209
-		else return true;
3872
+		if ($row['nb'] > 0) {
3873
+			return false;
3874
+		} else {
3875
+			return true;
3876
+		}
3210 3877
 	}
3211 3878
 
3212 3879
 	public static function check_last_satellite_update() {
@@ -3224,8 +3891,11 @@  discard block
 block discarded – undo
3224 3891
 			return "error : ".$e->getMessage();
3225 3892
 		}
3226 3893
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3227
-		if ($row['nb'] > 0) return false;
3228
-		else return true;
3894
+		if ($row['nb'] > 0) {
3895
+			return false;
3896
+		} else {
3897
+			return true;
3898
+		}
3229 3899
 	}
3230 3900
 
3231 3901
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -69,7 +78,9 @@  discard block
 block discarded – undo
69 78
 	if (isset($last_update[0]['value'])) {
70 79
 		date_default_timezone_set('UTC');
71 80
 		$lastupdate = strtotime($last_update[0]['value']);
72
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
81
+		if (isset($globalTimezone) && $globalTimezone != '') {
82
+			date_default_timezone_set($globalTimezone);
83
+		}
73 84
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
74 85
 	}
75 86
 }
@@ -154,8 +165,11 @@  discard block
 block discarded – undo
154 165
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
155 166
 		$aircraft_data = '';
156 167
 		foreach($aircraft_array as $aircraft_item) {
157
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
158
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
168
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
169
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
170
+			} else {
171
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			}
159 173
 		}
160 174
 		$aircraft_data = substr($aircraft_data, 0, -1);
161 175
 		print 'var series = ['.$aircraft_data.'];';
@@ -172,11 +186,17 @@  discard block
 block discarded – undo
172 186
 <?php
173 187
 	if ($year != '' && $month != '') {
174 188
 ?>
175
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
189
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
190
+	echo '/'.$airline_icao;
191
+}
192
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
176 193
 <?php
177 194
 	} else {
178 195
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
196
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
197
+	echo '/'.$airline_icao;
198
+}
199
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 200
 <?php
181 201
 	}
182 202
 ?>
@@ -205,11 +225,15 @@  discard block
 block discarded – undo
205 225
 			print '</script>';
206 226
 			if ($year != '' && $month != '') {
207 227
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
208
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
228
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
229
+					echo '/'.$airline_icao;
230
+				}
209 231
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
210 232
 			} else {
211 233
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
234
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
235
+					echo '/'.$airline_icao;
236
+				}
213 237
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 238
 			}
215 239
 			print '</div>';
@@ -229,8 +253,9 @@  discard block
 block discarded – undo
229 253
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
230 254
 <?php
231 255
 	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
232
-	if (count($marine_array) == 0) print _("No data available");
233
-	else {
256
+	if (count($marine_array) == 0) {
257
+		print _("No data available");
258
+	} else {
234 259
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
235 260
 		$marine_data = '';
236 261
 		foreach($marine_array as $marine_item) {
@@ -274,8 +299,9 @@  discard block
 block discarded – undo
274 299
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
275 300
 <?php
276 301
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
277
-	if (count($tracker_array) == 0) print _("No data available");
278
-	else {
302
+	if (count($tracker_array) == 0) {
303
+		print _("No data available");
304
+	} else {
279 305
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
280 306
 		$tracker_data = '';
281 307
 		foreach($tracker_array as $tracker_item) {
@@ -319,8 +345,9 @@  discard block
 block discarded – undo
319 345
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
320 346
 <?php
321 347
 		$owner_array = $Satellite->countAllOwners(true);
322
-		if (count($owner_array) == 0) print _("No data available");
323
-		else {
348
+		if (count($owner_array) == 0) {
349
+			print _("No data available");
350
+		} else {
324 351
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
325 352
 			$owner_data = '';
326 353
 			foreach($owner_array as $owner_item) {
@@ -339,7 +366,10 @@  discard block
 block discarded – undo
339 366
 ?>
340 367
                <!--
341 368
                 <div class="more">
342
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
369
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
370
+	echo '/'.$airline_icao;
371
+}
372
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
343 373
                 </div>
344 374
                 -->
345 375
             </div>
@@ -348,8 +378,9 @@  discard block
 block discarded – undo
348 378
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
349 379
 <?php
350 380
 		$countries_array = $Satellite->countAllCountriesOwners(true);
351
-		if (count($countries_array) == 0) print _("No data available");
352
-		else {
381
+		if (count($countries_array) == 0) {
382
+			print _("No data available");
383
+		} else {
353 384
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
354 385
 			$owner_data = '';
355 386
 			foreach($countries_array as $owner_item) {
@@ -368,7 +399,10 @@  discard block
 block discarded – undo
368 399
 ?>
369 400
 	    <!--
370 401
                 <div class="more">
371
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
402
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
403
+	echo '/'.$airline_icao;
404
+}
405
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
372 406
                 </div>
373 407
                 -->
374 408
             </div>
@@ -380,8 +414,9 @@  discard block
 block discarded – undo
380 414
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
381 415
 <?php
382 416
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
383
-		if (count($launch_site_array) == 0) print _("No data available");
384
-		else {
417
+		if (count($launch_site_array) == 0) {
418
+			print _("No data available");
419
+		} else {
385 420
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
386 421
 			$launch_site_data = '';
387 422
 			foreach($launch_site_array as $launch_site_item) {
@@ -400,7 +435,10 @@  discard block
 block discarded – undo
400 435
 ?>
401 436
                <!--
402 437
                 <div class="more">
403
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
438
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
439
+	echo '/'.$airline_icao;
440
+}
441
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
404 442
                 </div>
405 443
                 -->
406 444
             </div>
@@ -423,8 +461,9 @@  discard block
 block discarded – undo
423 461
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
424 462
 <?php
425 463
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
426
-		if (count($pilot_array) == 0) print _("No data available");
427
-		else {
464
+		if (count($pilot_array) == 0) {
465
+			print _("No data available");
466
+		} else {
428 467
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
429 468
 			$pilot_data = '';
430 469
 			foreach($pilot_array as $pilot_item) {
@@ -442,7 +481,9 @@  discard block
 block discarded – undo
442 481
 		}
443 482
 		print '<div class="more">';
444 483
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
445
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
484
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
485
+			echo '/'.$airline_icao;
486
+		}
446 487
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
447 488
 		print '</div>';
448 489
 ?>
@@ -458,8 +499,9 @@  discard block
 block discarded – undo
458 499
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
459 500
 <?php
460 501
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
461
-		if (count($owner_array) == 0) print _("No data available");
462
-		else {
502
+		if (count($owner_array) == 0) {
503
+			print _("No data available");
504
+		} else {
463 505
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
464 506
 			$owner_data = '';
465 507
 			foreach($owner_array as $owner_item) {
@@ -477,7 +519,10 @@  discard block
 block discarded – undo
477 519
 		}
478 520
 ?>
479 521
                 <div class="more">
480
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
522
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
523
+	echo '/'.$airline_icao;
524
+}
525
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
481 526
                 </div>
482 527
             </div>
483 528
         
@@ -490,8 +535,9 @@  discard block
 block discarded – undo
490 535
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
491 536
 <?php
492 537
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
493
-		if (count($flightover_array) == 0) print _("No data available");
494
-		else {
538
+		if (count($flightover_array) == 0) {
539
+			print _("No data available");
540
+		} else {
495 541
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
496 542
 			print 'var series = [';
497 543
 			$flightover_data = '';
@@ -533,7 +579,10 @@  discard block
 block discarded – undo
533 579
 		}
534 580
 ?>
535 581
                 <div class="more">
536
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
582
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
583
+	echo '/'.$airline_icao;
584
+}
585
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
537 586
                 </div>
538 587
             </div>
539 588
 <?php
@@ -551,8 +600,9 @@  discard block
 block discarded – undo
551 600
 	<div class="col-md-6">
552 601
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
553 602
 <?php
554
-	if (count($flightover_array) == 0) print _("No data available");
555
-	else {
603
+	if (count($flightover_array) == 0) {
604
+		print _("No data available");
605
+	} else {
556 606
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
557 607
 		print 'var series = [';
558 608
 		$flightover_data = '';
@@ -608,8 +658,9 @@  discard block
 block discarded – undo
608 658
 	<div class="col-md-6">
609 659
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
610 660
 <?php
611
-	if (count($flightover_array) == 0) print _("No data available");
612
-	else {
661
+	if (count($flightover_array) == 0) {
662
+		print _("No data available");
663
+	} else {
613 664
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
614 665
 		print 'var series = [';
615 666
 		$flightover_data = '';
@@ -715,7 +766,9 @@  discard block
 block discarded – undo
715 766
 		});";
716 767
 		print '</script>';
717 768
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
718
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
769
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
770
+			echo '/'.$airline_icao;
771
+		}
719 772
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
720 773
 	}
721 774
 ?>
@@ -777,7 +830,9 @@  discard block
 block discarded – undo
777 830
 		});";
778 831
 		print '</script>';
779 832
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
780
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
833
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
834
+			echo '/'.$airline_icao;
835
+		}
781 836
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
782 837
 	}
783 838
 ?>
@@ -796,8 +851,9 @@  discard block
 block discarded – undo
796 851
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
797 852
 <?php
798 853
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
799
-		if (count($year_array) == 0) print _("No data available");
800
-		else {
854
+		if (count($year_array) == 0) {
855
+			print _("No data available");
856
+		} else {
801 857
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
802 858
 			$year_data = '';
803 859
 			$year_cnt = '';
@@ -816,7 +872,10 @@  discard block
 block discarded – undo
816 872
 		}
817 873
 ?>
818 874
                 <div class="more">
819
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
875
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
876
+	echo '/'.$airline_icao;
877
+}
878
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
820 879
                 </div>
821 880
             </div>
822 881
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -824,8 +883,9 @@  discard block
 block discarded – undo
824 883
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
825 884
 <?php
826 885
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
827
-		if (count($month_array) == 0) print _("No data available");
828
-		else {
886
+		if (count($month_array) == 0) {
887
+			print _("No data available");
888
+		} else {
829 889
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
830 890
 			$month_data = '';
831 891
 			$month_cnt = '';
@@ -844,7 +904,10 @@  discard block
 block discarded – undo
844 904
 		}
845 905
 ?>
846 906
                 <div class="more">
847
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
907
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
908
+	echo '/'.$airline_icao;
909
+}
910
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
848 911
                 </div>
849 912
             </div>
850 913
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -853,8 +916,9 @@  discard block
 block discarded – undo
853 916
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
854 917
 <?php
855 918
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
856
-		if (empty($date_array)) print _("No data available");
857
-		else {
919
+		if (empty($date_array)) {
920
+			print _("No data available");
921
+		} else {
858 922
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
859 923
 			$date_data = '';
860 924
 			$date_cnt = '';
@@ -873,7 +937,10 @@  discard block
 block discarded – undo
873 937
 		}
874 938
 ?>
875 939
                 <div class="more">
876
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
940
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
941
+	echo '/'.$airline_icao;
942
+}
943
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
877 944
                 </div>
878 945
             </div>
879 946
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -881,8 +948,9 @@  discard block
 block discarded – undo
881 948
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
882 949
 <?php
883 950
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
884
-		if (empty($hour_array)) print _("No data available");
885
-		else {
951
+		if (empty($hour_array)) {
952
+			print _("No data available");
953
+		} else {
886 954
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
887 955
 			$hour_data = '';
888 956
 			$hour_cnt = '';
@@ -901,7 +969,10 @@  discard block
 block discarded – undo
901 969
 		}
902 970
 ?>
903 971
                 <div class="more">
904
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
972
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
973
+	echo '/'.$airline_icao;
974
+}
975
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
905 976
                 </div>
906 977
             </div>
907 978
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -921,8 +992,9 @@  discard block
 block discarded – undo
921 992
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
922 993
 <?php
923 994
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
924
-		if (count($year_array) == 0) print _("No data available");
925
-		else {
995
+		if (count($year_array) == 0) {
996
+			print _("No data available");
997
+		} else {
926 998
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
927 999
 			$year_data = '';
928 1000
 			$year_cnt = '';
@@ -950,8 +1022,9 @@  discard block
 block discarded – undo
950 1022
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
951 1023
 <?php
952 1024
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
953
-		if (count($month_array) == 0) print _("No data available");
954
-		else {
1025
+		if (count($month_array) == 0) {
1026
+			print _("No data available");
1027
+		} else {
955 1028
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
956 1029
 			$month_data = '';
957 1030
 			$month_cnt = '';
@@ -979,8 +1052,9 @@  discard block
 block discarded – undo
979 1052
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
980 1053
 <?php
981 1054
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
982
-		if (empty($date_array)) print _("No data available");
983
-		else {
1055
+		if (empty($date_array)) {
1056
+			print _("No data available");
1057
+		} else {
984 1058
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
985 1059
 			$date_data = '';
986 1060
 			$date_cnt = '';
@@ -1007,8 +1081,9 @@  discard block
 block discarded – undo
1007 1081
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1008 1082
 <?php
1009 1083
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1010
-		if (empty($hour_array)) print _("No data available");
1011
-		else {
1084
+		if (empty($hour_array)) {
1085
+			print _("No data available");
1086
+		} else {
1012 1087
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1013 1088
 			$hour_data = '';
1014 1089
 			$hour_cnt = '';
@@ -1047,8 +1122,9 @@  discard block
 block discarded – undo
1047 1122
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1048 1123
 <?php
1049 1124
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1050
-		if (count($year_array) == 0) print _("No data available");
1051
-		else {
1125
+		if (count($year_array) == 0) {
1126
+			print _("No data available");
1127
+		} else {
1052 1128
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1053 1129
 			$year_data = '';
1054 1130
 			$year_cnt = '';
@@ -1076,8 +1152,9 @@  discard block
 block discarded – undo
1076 1152
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1077 1153
 <?php
1078 1154
 		$month_array = $Tracker->countAllDatesLastMonth();
1079
-		if (count($month_array) == 0) print _("No data available");
1080
-		else {
1155
+		if (count($month_array) == 0) {
1156
+			print _("No data available");
1157
+		} else {
1081 1158
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1082 1159
 			$month_data = '';
1083 1160
 			$month_cnt = '';
@@ -1105,8 +1182,9 @@  discard block
 block discarded – undo
1105 1182
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1106 1183
 <?php
1107 1184
 		$date_array = $Tracker->countAllDatesLast7Days();
1108
-		if (empty($date_array)) print _("No data available");
1109
-		else {
1185
+		if (empty($date_array)) {
1186
+			print _("No data available");
1187
+		} else {
1110 1188
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1111 1189
 			$date_data = '';
1112 1190
 			$date_cnt = '';
@@ -1133,8 +1211,9 @@  discard block
 block discarded – undo
1133 1211
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1134 1212
 <?php
1135 1213
 		$hour_array = $Tracker->countAllHours('hour',true);
1136
-		if (empty($hour_array)) print _("No data available");
1137
-		else {
1214
+		if (empty($hour_array)) {
1215
+			print _("No data available");
1216
+		} else {
1138 1217
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1139 1218
 			$hour_data = '';
1140 1219
 			$hour_cnt = '';
@@ -1173,8 +1252,9 @@  discard block
 block discarded – undo
1173 1252
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1174 1253
 <?php
1175 1254
 		$year_array = $Satellite->countAllMonthsLastYear();
1176
-		if (count($year_array) == 0) print _("No data available");
1177
-		else {
1255
+		if (count($year_array) == 0) {
1256
+			print _("No data available");
1257
+		} else {
1178 1258
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1179 1259
 			$year_data = '';
1180 1260
 			$year_cnt = '';
@@ -1204,8 +1284,9 @@  discard block
 block discarded – undo
1204 1284
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1205 1285
 <?php
1206 1286
 		$year_array = $Satellite->countAllYears();
1207
-		if (count($year_array) == 0) print _("No data available");
1208
-		else {
1287
+		if (count($year_array) == 0) {
1288
+			print _("No data available");
1289
+		} else {
1209 1290
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1210 1291
 			$year_data = '';
1211 1292
 			$year_cnt = '';
@@ -1247,8 +1328,9 @@  discard block
 block discarded – undo
1247 1328
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1248 1329
 <?php
1249 1330
 		$year_array = $Stats->countFatalitiesByYear();
1250
-		if (count($year_array) == 0) print _("No data available");
1251
-		else {
1331
+		if (count($year_array) == 0) {
1332
+			print _("No data available");
1333
+		} else {
1252 1334
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1253 1335
 			$year_data = '';
1254 1336
 			$year_cnt = '';
@@ -1277,8 +1359,9 @@  discard block
 block discarded – undo
1277 1359
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1278 1360
 <?php
1279 1361
 		$year_array = $Stats->countFatalitiesLast12Months();
1280
-		if (count($year_array) == 0) print _("No data available");
1281
-		else {
1362
+		if (count($year_array) == 0) {
1363
+			print _("No data available");
1364
+		} else {
1282 1365
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1283 1366
 			$year_data = '';
1284 1367
 			$year_cnt = '';
@@ -1349,8 +1432,11 @@  discard block
 block discarded – undo
1349 1432
 					$distance = $distance;
1350 1433
 					$unit = 'km';
1351 1434
 				}
1352
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1353
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1435
+				if (!isset($polar_data)) {
1436
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1437
+				} else {
1438
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1439
+				}
1354 1440
 			}
1355 1441
 ?>
1356 1442
             <div class="col-md-6">
@@ -1414,9 +1500,12 @@  discard block
 block discarded – undo
1414 1500
 		foreach ($msg as $eachmsg) {
1415 1501
 			//$eachmsg = $msg[0];
1416 1502
 			$data = $eachmsg['source_data'];
1417
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1418
-			else $max = 500;
1419
-?>
1503
+			if ($data > 500) {
1504
+				$max = (round(($data+100)/100))*100;
1505
+			} else {
1506
+				$max = 500;
1507
+			}
1508
+			?>
1420 1509
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1421 1510
         	<script>
1422 1511
 		      var g = new JustGage({
Please login to merge, or discard this patch.