Completed
Push — master ( ef15cd...5b4de3 )
by Yannick
07:21
created
install/class.update_db.php 1 patch
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 		curl_close($ch);
24 24
 	}
25 25
 
26
-	public static function gunzip($in_file,$out_file_name = '') {
26
+	public static function gunzip($in_file, $out_file_name = '') {
27 27
 		//echo $in_file.' -> '.$out_file_name."\n";
28 28
 		$buffer_size = 4096; // read 4kb at a time
29 29
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
30 30
 		if ($in_file != '' && file_exists($in_file)) {
31 31
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
32
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
33
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
32
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
33
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
34 34
 			$out_file = fopen($out_file_name, 'wb'); 
35
-			while(!gzeof($file)) {
35
+			while (!gzeof($file)) {
36 36
 				fwrite($out_file, gzread($file, $buffer_size));
37 37
 			}  
38 38
 			fclose($out_file);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		try {
57 57
 			self::$db_sqlite = new PDO('sqlite:'.$database);
58 58
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
59
-		} catch(PDOException $e) {
59
+		} catch (PDOException $e) {
60 60
 			return "error : ".$e->getMessage();
61 61
 		}
62 62
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			//$Connection = new Connection();
72 72
 			$sth = $Connection->db->prepare($query);
73 73
                         $sth->execute(array(':source' => $database_file));
74
-                } catch(PDOException $e) {
74
+                } catch (PDOException $e) {
75 75
                         return "error : ".$e->getMessage();
76 76
                 }
77 77
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		try {
83 83
                         $sth = update_db::$db_sqlite->prepare($query);
84 84
                         $sth->execute();
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         return "error : ".$e->getMessage();
87 87
                 }
88 88
 		//$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)';
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 			if ($globalTransaction) $Connection->db->beginTransaction();
94 94
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
95 95
 				//$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);
96
-				$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);
96
+				$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);
97 97
 				$sth_dest->execute($query_dest_values);
98 98
             		}
99 99
 			if ($globalTransaction) $Connection->db->commit();
100
-		} catch(PDOException $e) {
100
+		} catch (PDOException $e) {
101 101
 			if ($globalTransaction) $Connection->db->rollBack(); 
102 102
 			return "error : ".$e->getMessage();
103 103
 		}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			$Connection = new Connection();
112 112
 			$sth = $Connection->db->prepare($query);
113 113
                         $sth->execute(array(':source' => $database_file));
114
-                } catch(PDOException $e) {
114
+                } catch (PDOException $e) {
115 115
                         return "error : ".$e->getMessage();
116 116
                 }
117 117
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 			$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => $database_file));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		try {
129 129
                         $sth = update_db::$db_sqlite->prepare($query);
130 130
                         $sth->execute();
131
-                } catch(PDOException $e) {
131
+                } catch (PDOException $e) {
132 132
                         return "error : ".$e->getMessage();
133 133
                 }
134 134
 		//$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)';
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 			//$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']);
146 146
 				if ($values['UserString4'] == 'M') $type = 'military';
147 147
 				else $type = null;
148
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
148
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
149 149
 				$sth_dest->execute($query_dest_values);
150 150
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
151
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
151
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
152 152
 				    $sth_dest_owner->execute($query_dest_owner_values);
153 153
 				}
154 154
             		}
155 155
 			if ($globalTransaction) $Connection->db->commit();
156
-		} catch(PDOException $e) {
156
+		} catch (PDOException $e) {
157 157
 			return "error : ".$e->getMessage();
158 158
 		}
159 159
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 			$Connection = new Connection();
163 163
 			$sth = $Connection->db->prepare($query);
164 164
                         $sth->execute(array(':source' => $database_file));
165
-                } catch(PDOException $e) {
165
+                } catch (PDOException $e) {
166 166
                         return "error : ".$e->getMessage();
167 167
                 }
168 168
 		return '';
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 			$Connection = new Connection();
178 178
 			$sth = $Connection->db->prepare($query);
179 179
                         $sth->execute(array(':source' => $database_file));
180
-                } catch(PDOException $e) {
180
+                } catch (PDOException $e) {
181 181
                         return "error : ".$e->getMessage();
182 182
                 }
183 183
 		
184
-		if ($fh = fopen($database_file,"r")) {
184
+		if ($fh = fopen($database_file, "r")) {
185 185
 			//$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)';
186 186
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
187 187
 		
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 			try {
191 191
 				if ($globalTransaction) $Connection->db->beginTransaction();
192 192
             			while (!feof($fh)) {
193
-            				$line = $Common->hex2str(fgets($fh,9999));
193
+            				$line = $Common->hex2str(fgets($fh, 9999));
194 194
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
195
-            				$values['ModeS'] = substr($line,0,6);
196
-            				$values['Registration'] = trim(substr($line,69,6));
197
-            				$aircraft_name = trim(substr($line,48,6));
195
+            				$values['ModeS'] = substr($line, 0, 6);
196
+            				$values['Registration'] = trim(substr($line, 69, 6));
197
+            				$aircraft_name = trim(substr($line, 48, 6));
198 198
             				// Check if we can find ICAO, else set it to GLID
199
-            				$aircraft_name_split = explode(' ',$aircraft_name);
199
+            				$aircraft_name_split = explode(' ', $aircraft_name);
200 200
             				$search_more = '';
201 201
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
202 202
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -208,20 +208,20 @@  discard block
 block discarded – undo
208 208
 	            				if (isset($result['icao']) && $result['icao'] != '') {
209 209
 	            				    $values['ICAOTypeCode'] = $result['icao'];
210 210
 	            				} 
211
-					} catch(PDOException $e) {
211
+					} catch (PDOException $e) {
212 212
 						return "error : ".$e->getMessage();
213 213
 					}
214 214
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
215 215
 					// Add data to db
216 216
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') {
217 217
 						//$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']);
218
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
218
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
219 219
 						//print_r($query_dest_values);
220 220
 						$sth_dest->execute($query_dest_values);
221 221
 					}
222 222
 				}
223 223
 				if ($globalTransaction) $Connection->db->commit();
224
-			} catch(PDOException $e) {
224
+			} catch (PDOException $e) {
225 225
 				return "error : ".$e->getMessage();
226 226
 			}
227 227
 		}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 			$Connection = new Connection();
232 232
 			$sth = $Connection->db->prepare($query);
233 233
                         $sth->execute(array(':source' => $database_file));
234
-                } catch(PDOException $e) {
234
+                } catch (PDOException $e) {
235 235
                         return "error : ".$e->getMessage();
236 236
                 }
237 237
 		return '';
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 			$Connection = new Connection();
246 246
 			$sth = $Connection->db->prepare($query);
247 247
                         $sth->execute(array(':source' => $database_file));
248
-                } catch(PDOException $e) {
248
+                } catch (PDOException $e) {
249 249
                         return "error : ".$e->getMessage();
250 250
                 }
251 251
 		
252
-		if ($fh = fopen($database_file,"r")) {
252
+		if ($fh = fopen($database_file, "r")) {
253 253
 			//$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)';
254 254
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
255 255
 		
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 			$sth_dest = $Connection->db->prepare($query_dest);
258 258
 			try {
259 259
 				if ($globalTransaction) $Connection->db->beginTransaction();
260
-				$tmp = fgetcsv($fh,9999,',',"'");
260
+				$tmp = fgetcsv($fh, 9999, ',', "'");
261 261
             			while (!feof($fh)) {
262
-            				$line = fgetcsv($fh,9999,',',"'");
262
+            				$line = fgetcsv($fh, 9999, ',', "'");
263 263
             				
264 264
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
265 265
 					//print_r($line);
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
             				$values['Registration'] = $line[3];
268 268
             				$aircraft_name = $line[2];
269 269
             				// Check if we can find ICAO, else set it to GLID
270
-            				$aircraft_name_split = explode(' ',$aircraft_name);
270
+            				$aircraft_name_split = explode(' ', $aircraft_name);
271 271
             				$search_more = '';
272 272
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
273 273
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -276,20 +276,20 @@  discard block
 block discarded – undo
276 276
                                     		$sth_search->execute();
277 277
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
278 278
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
279
-					} catch(PDOException $e) {
279
+					} catch (PDOException $e) {
280 280
 						return "error : ".$e->getMessage();
281 281
 					}
282 282
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
283 283
 					// Add data to db
284 284
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
285 285
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
286
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
286
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
287 287
 						//print_r($query_dest_values);
288 288
 						$sth_dest->execute($query_dest_values);
289 289
 					}
290 290
 				}
291 291
 				if ($globalTransaction) $Connection->db->commit();
292
-			} catch(PDOException $e) {
292
+			} catch (PDOException $e) {
293 293
 				return "error : ".$e->getMessage();
294 294
 			}
295 295
 		}
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 			$Connection = new Connection();
300 300
 			$sth = $Connection->db->prepare($query);
301 301
                         $sth->execute(array(':source' => $database_file));
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
 		return '';
306 306
 	}
307 307
 
308
-	public static function retrieve_owner($database_file,$country = 'F') {
308
+	public static function retrieve_owner($database_file, $country = 'F') {
309 309
 		global $globalTransaction;
310 310
 		//$query = 'TRUNCATE TABLE aircraft_modes';
311 311
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 			$Connection = new Connection();
314 314
 			$sth = $Connection->db->prepare($query);
315 315
                         $sth->execute(array(':source' => $database_file));
316
-                } catch(PDOException $e) {
316
+                } catch (PDOException $e) {
317 317
                         return "error : ".$e->getMessage();
318 318
                 }
319 319
 		
320
-		if ($fh = fopen($database_file,"r")) {
320
+		if ($fh = fopen($database_file, "r")) {
321 321
 			//$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)';
322 322
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
323 323
 		
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
 			$sth_dest = $Connection->db->prepare($query_dest);
326 326
 			try {
327 327
 				if ($globalTransaction) $Connection->db->beginTransaction();
328
-				$tmp = fgetcsv($fh,9999,',','"');
328
+				$tmp = fgetcsv($fh, 9999, ',', '"');
329 329
             			while (!feof($fh)) {
330
-            				$line = fgetcsv($fh,9999,',','"');
330
+            				$line = fgetcsv($fh, 9999, ',', '"');
331 331
             				//print_r($line);
332 332
             				if ($country == 'F') {
333 333
             				    $values['registration'] = $line[0];
334 334
             				    $values['base'] = $line[4];
335 335
             				    $values['owner'] = $line[5];
336 336
             				    if ($line[6] == '') $values['date_first_reg'] = '';
337
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
337
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
338 338
 					    $values['cancel'] = $line[7];
339 339
 					} elseif ($country == 'EI') {
340 340
 					    // TODO : add modeS & reg to aircraft_modes
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             				    $values['base'] = $line[3];
343 343
             				    $values['owner'] = $line[2];
344 344
             				    if ($line[1] == '') $values['date_first_reg'] = '';
345
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
345
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
346 346
 					    $values['cancel'] = '';
347 347
 					} elseif ($country == 'HB') {
348 348
 					    // TODO : add modeS & reg to aircraft_modes
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             				    $values['base'] = null;
358 358
             				    $values['owner'] = $line[5];
359 359
             				    if ($line[18] == '') $values['date_first_reg'] = '';
360
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
360
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
361 361
 					    $values['cancel'] = '';
362 362
 					} elseif ($country == 'VH') {
363 363
 					    // TODO : add modeS & reg to aircraft_modes
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
             				    $values['base'] = null;
366 366
             				    $values['owner'] = $line[12];
367 367
             				    if ($line[28] == '') $values['date_first_reg'] = '';
368
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
368
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
369 369
 
370 370
 					    $values['cancel'] = $line[39];
371 371
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -385,28 +385,28 @@  discard block
 block discarded – undo
385 385
             				    $values['base'] = null;
386 386
             				    $values['owner'] = $line[8];
387 387
             				    if ($line[7] == '') $values['date_first_reg'] = '';
388
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
388
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
389 389
 					    $values['cancel'] = '';
390 390
 					} elseif ($country == 'PP') {
391 391
             				    $values['registration'] = $line[0];
392 392
             				    $values['base'] = null;
393 393
             				    $values['owner'] = $line[4];
394 394
             				    if ($line[6] == '') $values['date_first_reg'] = '';
395
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
395
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
396 396
 					    $values['cancel'] = $line[7];
397 397
 					} elseif ($country == 'E7') {
398 398
             				    $values['registration'] = $line[0];
399 399
             				    $values['base'] = null;
400 400
             				    $values['owner'] = $line[4];
401 401
             				    if ($line[5] == '') $values['date_first_reg'] = '';
402
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
402
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
403 403
 					    $values['cancel'] = '';
404 404
 					} elseif ($country == '8Q') {
405 405
             				    $values['registration'] = $line[0];
406 406
             				    $values['base'] = null;
407 407
             				    $values['owner'] = $line[3];
408 408
             				    if ($line[7] == '') $values['date_first_reg'] = '';
409
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
409
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
410 410
 					    $values['cancel'] = '';
411 411
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
412 412
             				    $values['registration'] = $line[0];
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
 					    $values['cancel'] = '';
417 417
 					}
418 418
 					if ($values['cancel'] == '' && $values['registration'] != null) {
419
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
419
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
420 420
 						$sth_dest->execute($query_dest_values);
421 421
 					}
422 422
 				}
423 423
 				if ($globalTransaction) $Connection->db->commit();
424
-			} catch(PDOException $e) {
424
+			} catch (PDOException $e) {
425 425
 				return "error : ".$e->getMessage();
426 426
 			}
427 427
 		}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 			$Connection = new Connection();
537 537
 			$sth = $Connection->db->prepare($query);
538 538
                         $sth->execute();
539
-                } catch(PDOException $e) {
539
+                } catch (PDOException $e) {
540 540
                         return "error : ".$e->getMessage();
541 541
                 }
542 542
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 			$Connection = new Connection();
547 547
 			$sth = $Connection->db->prepare($query);
548 548
                         $sth->execute();
549
-                } catch(PDOException $e) {
549
+                } catch (PDOException $e) {
550 550
                         return "error : ".$e->getMessage();
551 551
                 }
552 552
 
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		if ($globalTransaction) $Connection->db->beginTransaction();
558 558
   
559 559
 		$i = 0;
560
-		while($row = sparql_fetch_array($result))
560
+		while ($row = sparql_fetch_array($result))
561 561
 		{
562 562
 			if ($i >= 1) {
563 563
 			//print_r($row);
@@ -577,31 +577,31 @@  discard block
 block discarded – undo
577 577
 				$row['image'] = '';
578 578
 				$row['image_thumb'] = '';
579 579
 			} else {
580
-				$image = str_replace(' ','_',$row['image']);
580
+				$image = str_replace(' ', '_', $row['image']);
581 581
 				$digest = md5($image);
582
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
583
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
584
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
585
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
582
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
583
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
584
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
585
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
586 586
 			}
587 587
 			
588
-			$country = explode('-',$row['country']);
588
+			$country = explode('-', $row['country']);
589 589
 			$row['country'] = $country[0];
590 590
 			
591 591
 			$row['type'] = trim($row['type']);
592
-			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'])) {
592
+			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'])) {
593 593
 				$row['type'] = 'Military';
594 594
 			} 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') {
595 595
 				$row['type'] = 'small_airport';
596 596
 			}
597 597
 			
598
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
599
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $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']);
598
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
599
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $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']);
600 600
 			//print_r($query_dest_values);
601 601
 			
602 602
 			try {
603 603
 				$sth_dest->execute($query_dest_values);
604
-			} catch(PDOException $e) {
604
+			} catch (PDOException $e) {
605 605
 				return "error : ".$e->getMessage();
606 606
 			}
607 607
 			}
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			$Connection = new Connection();
616 616
 			$sth = $Connection->db->prepare($query);
617 617
                         $sth->execute();
618
-                } catch(PDOException $e) {
618
+                } catch (PDOException $e) {
619 619
                         return "error : ".$e->getMessage();
620 620
                 }
621 621
 
@@ -623,12 +623,12 @@  discard block
 block discarded – undo
623 623
 		if ($globalDebug) echo "Insert Not available Airport...\n";
624 624
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
625 625
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
626
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
626
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
627 627
 		try {
628 628
 			$Connection = new Connection();
629 629
 			$sth = $Connection->db->prepare($query);
630 630
                         $sth->execute($query_values);
631
-                } catch(PDOException $e) {
631
+                } catch (PDOException $e) {
632 632
                         return "error : ".$e->getMessage();
633 633
                 }
634 634
 		$i++;
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 		echo "Download data from ourairports.com...\n";
647 647
 		$delimiter = ',';
648 648
 		$out_file = $tmp_dir.'airports.csv';
649
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
649
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
650 650
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
651 651
 		echo "Add data from ourairports.com...\n";
652 652
 
@@ -657,32 +657,32 @@  discard block
 block discarded – undo
657 657
 			//$Connection->db->beginTransaction();
658 658
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
659 659
 			{
660
-				if(!$header) $header = $row;
660
+				if (!$header) $header = $row;
661 661
 				else {
662 662
 					$data = array();
663 663
 					$data = array_combine($header, $row);
664 664
 					try {
665 665
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
666 666
 						$sth->execute(array(':icao' => $data['gps_code']));
667
-					} catch(PDOException $e) {
667
+					} catch (PDOException $e) {
668 668
 						return "error : ".$e->getMessage();
669 669
 					}
670 670
 					if ($sth->fetchColumn() > 0) {
671 671
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
672 672
 						try {
673 673
 							$sth = $Connection->db->prepare($query);
674
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
675
-						} catch(PDOException $e) {
674
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
675
+						} catch (PDOException $e) {
676 676
 							return "error : ".$e->getMessage();
677 677
 						}
678 678
 					} else {
679 679
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
680 680
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
681
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
681
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
682 682
 						try {
683 683
 							$sth = $Connection->db->prepare($query);
684 684
 							$sth->execute($query_values);
685
-						} catch(PDOException $e) {
685
+						} catch (PDOException $e) {
686 686
 							return "error : ".$e->getMessage();
687 687
 						}
688 688
 						$i++;
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 
696 696
 		echo "Download data from another free database...\n";
697 697
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
698
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
698
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
699 699
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
700 700
 		update_db::unzip($out_file);
701 701
 		$header = NULL;
@@ -707,15 +707,15 @@  discard block
 block discarded – undo
707 707
 			//$Connection->db->beginTransaction();
708 708
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
709 709
 			{
710
-				if(!$header) $header = $row;
710
+				if (!$header) $header = $row;
711 711
 				else {
712 712
 					$data = $row;
713 713
 
714 714
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
715 715
 					try {
716 716
 						$sth = $Connection->db->prepare($query);
717
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
718
-					} catch(PDOException $e) {
717
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
718
+					} catch (PDOException $e) {
719 719
 						return "error : ".$e->getMessage();
720 720
 					}
721 721
 				}
@@ -729,15 +729,15 @@  discard block
 block discarded – undo
729 729
 		try {
730 730
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
731 731
 			$sth->execute();
732
-		} catch(PDOException $e) {
732
+		} catch (PDOException $e) {
733 733
 			return "error : ".$e->getMessage();
734 734
 		}
735 735
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
736 736
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
737 737
 			try {
738 738
 				$sth2 = $Connection->db->prepare($query2);
739
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
740
-			} catch(PDOException $e) {
739
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
740
+			} catch (PDOException $e) {
741 741
 				return "error : ".$e->getMessage();
742 742
 			}
743 743
 		}
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 			$Connection = new Connection();
762 762
 			$sth = $Connection->db->prepare($query);
763 763
                         $sth->execute(array(':source' => 'translation.csv'));
764
-                } catch(PDOException $e) {
764
+                } catch (PDOException $e) {
765 765
                         return "error : ".$e->getMessage();
766 766
                 }
767 767
 
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
779 779
 			{
780 780
 				$i++;
781
-				if($i > 12) {
781
+				if ($i > 12) {
782 782
 					$data = $row;
783 783
 					$operator = $data[2];
784 784
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
                                                 //echo substr($operator, 0, 2)."\n";;
787 787
                                                 if (count($airline_array) > 0) {
788 788
 							//print_r($airline_array);
789
-							$operator = $airline_array[0]['icao'].substr($operator,2);
789
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
790 790
                                                 }
791 791
                                         }
792 792
 					
@@ -794,14 +794,14 @@  discard block
 block discarded – undo
794 794
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
795 795
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
796 796
                                                 if (count($airline_array) > 0) {
797
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
797
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
798 798
                                             	}
799 799
                                         }
800 800
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
801 801
 					try {
802 802
 						$sth = $Connection->db->prepare($query);
803
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
804
-					} catch(PDOException $e) {
803
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
804
+					} catch (PDOException $e) {
805 805
 						return "error : ".$e->getMessage();
806 806
 					}
807 807
 				}
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 			$Connection = new Connection();
822 822
 			$sth = $Connection->db->prepare($query);
823 823
                         $sth->execute(array(':source' => 'website_fam'));
824
-                } catch(PDOException $e) {
824
+                } catch (PDOException $e) {
825 825
                         return "error : ".$e->getMessage();
826 826
                 }
827 827
 
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
842 842
 					try {
843 843
 						$sth = $Connection->db->prepare($query);
844
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
845
-					} catch(PDOException $e) {
844
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
845
+					} catch (PDOException $e) {
846 846
 						return "error : ".$e->getMessage();
847 847
 					}
848 848
 				}
@@ -861,28 +861,28 @@  discard block
 block discarded – undo
861 861
         */
862 862
         private static function table2array($data) {
863 863
                 $html = str_get_html($data);
864
-                $tabledata=array();
865
-                foreach($html->find('tr') as $element)
864
+                $tabledata = array();
865
+                foreach ($html->find('tr') as $element)
866 866
                 {
867 867
                         $td = array();
868
-                        foreach( $element->find('th') as $row)
868
+                        foreach ($element->find('th') as $row)
869 869
                         {
870 870
                                 $td [] = trim($row->plaintext);
871 871
                         }
872
-                        $td=array_filter($td);
872
+                        $td = array_filter($td);
873 873
                         $tabledata[] = $td;
874 874
 
875 875
                         $td = array();
876 876
                         $tdi = array();
877
-                        foreach( $element->find('td') as $row)
877
+                        foreach ($element->find('td') as $row)
878 878
                         {
879 879
                                 $td [] = trim($row->plaintext);
880 880
                                 $tdi [] = trim($row->innertext);
881 881
                         }
882
-                        $td=array_filter($td);
883
-                        $tdi=array_filter($tdi);
882
+                        $td = array_filter($td);
883
+                        $tdi = array_filter($tdi);
884 884
                     //    $tabledata[]=array_merge($td,$tdi);
885
-                        $tabledata[]=$td;
885
+                        $tabledata[] = $td;
886 886
                 }
887 887
                 return(array_filter($tabledata));
888 888
         }
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 			$Connection = new Connection();
951 951
 			$sth = $Connection->db->prepare($query);
952 952
                         $sth->execute();
953
-                } catch(PDOException $e) {
953
+                } catch (PDOException $e) {
954 954
                         return "error : ".$e->getMessage();
955 955
                 }
956 956
 
@@ -966,13 +966,13 @@  discard block
 block discarded – undo
966 966
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
967 967
 			{
968 968
 				$i++;
969
-				if($i > 3 && count($row) > 2) {
969
+				if ($i > 3 && count($row) > 2) {
970 970
 					$data = array_values(array_filter($row));
971 971
 					$cntdata = count($data);
972 972
 					if ($cntdata > 10) {
973 973
 						$value = $data[9];
974 974
 						
975
-						for ($i =10;$i < $cntdata;$i++) {
975
+						for ($i = 10; $i < $cntdata; $i++) {
976 976
 							$value .= ' '.$data[$i];
977 977
 						}
978 978
 						$data[9] = $value;
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
 						$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)';
983 983
 						try {
984 984
 							$sth = $Connection->db->prepare($query);
985
-							$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]));
986
-						} catch(PDOException $e) {
985
+							$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]));
986
+						} catch (PDOException $e) {
987 987
 							return "error : ".$e->getMessage();
988 988
 						}
989 989
 					}
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 			$Connection = new Connection();
1004 1004
 			$sth = $Connection->db->prepare($query);
1005 1005
                         $sth->execute();
1006
-                } catch(PDOException $e) {
1006
+                } catch (PDOException $e) {
1007 1007
                         return "error : ".$e->getMessage();
1008 1008
                 }
1009 1009
 
@@ -1015,12 +1015,12 @@  discard block
 block discarded – undo
1015 1015
 			if ($globalTransaction) $Connection->db->beginTransaction();
1016 1016
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1017 1017
 			{
1018
-				if(count($row) > 1) {
1018
+				if (count($row) > 1) {
1019 1019
 					$query = "INSERT INTO airlines (name,icao,active) VALUES (:name, :icao, 'Y')";
1020 1020
 					try {
1021 1021
 						$sth = $Connection->db->prepare($query);
1022
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1023
-					} catch(PDOException $e) {
1022
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1023
+					} catch (PDOException $e) {
1024 1024
 						return "error : ".$e->getMessage();
1025 1025
 					}
1026 1026
 				}
@@ -1034,14 +1034,14 @@  discard block
 block discarded – undo
1034 1034
 	public static function update_airspace() {
1035 1035
 		global $tmp_dir, $globalDBdriver;
1036 1036
 		include_once('class.create_db.php');
1037
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1037
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1038 1038
 		else {
1039
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1039
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1040 1040
 			$query = "CREATE EXTENSION postgis";
1041 1041
 			try {
1042 1042
 				$sth = $Connection->db->prepare($query);
1043 1043
 				$sth->execute();
1044
-			} catch(PDOException $e) {
1044
+			} catch (PDOException $e) {
1045 1045
 				return "error : ".$e->getMessage();
1046 1046
 			}
1047 1047
 		}
@@ -1065,14 +1065,14 @@  discard block
 block discarded – undo
1065 1065
 			try {
1066 1066
 				$sth = $Connection->db->prepare($query);
1067 1067
             	        	$sth->execute();
1068
-	                } catch(PDOException $e) {
1068
+	                } catch (PDOException $e) {
1069 1069
     	                	echo "error : ".$e->getMessage();
1070 1070
 	                }
1071 1071
 		}
1072 1072
 		if ($globalDBdriver == 'mysql') {
1073
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1073
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1074 1074
 		} else {
1075
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1075
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1076 1076
 		}
1077 1077
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1078 1078
 		return $error;
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1086 1086
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1087 1087
 //		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');
1088
-		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');
1088
+		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');
1089 1089
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1090 1090
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1091 1091
 		return $error;
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1106 1106
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1107 1107
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1108
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1108
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1109 1109
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1110 1110
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1111 1111
 		if ($error != '') {
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 		global $tmp_dir, $globalDebug;
1119 1119
 		$error = '';
1120 1120
 		if ($globalDebug) echo "Routes : Download...";
1121
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1121
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1122 1122
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1123 1123
 			if ($globalDebug) echo "Gunzip...";
1124 1124
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 		} elseif ($globalDebug) echo "Done\n";
1146 1146
 */
1147 1147
 		if ($globalDebug) echo "Modes : Download...";
1148
-		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1148
+		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb');
1149 1149
 		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1150 1150
 			if ($globalDebug) echo "Unzip...";
1151 1151
 			update_db::unzip($tmp_dir.'basestation_latest.zip');
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 	public static function update_ModeS_flarm() {
1162 1162
 		global $tmp_dir, $globalDebug;
1163 1163
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1164
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1164
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1165 1165
 		if (file_exists($tmp_dir.'data.fln')) {
1166 1166
 			if ($globalDebug) echo "Add to DB...";
1167 1167
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 	public static function update_ModeS_ogn() {
1176 1176
 		global $tmp_dir, $globalDebug;
1177 1177
 		if ($globalDebug) echo "Modes OGN: Download...";
1178
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1178
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1179 1179
 		if (file_exists($tmp_dir.'ogn.csv')) {
1180 1180
 			if ($globalDebug) echo "Add to DB...";
1181 1181
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1190,173 +1190,173 @@  discard block
 block discarded – undo
1190 1190
 		global $tmp_dir, $globalDebug;
1191 1191
 		
1192 1192
 		if ($globalDebug) echo "Owner France: Download...";
1193
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1193
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1194 1194
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1195 1195
 			if ($globalDebug) echo "Add to DB...";
1196
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1196
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1197 1197
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1198 1198
 		if ($error != '') {
1199 1199
 			return $error;
1200 1200
 		} elseif ($globalDebug) echo "Done\n";
1201 1201
 		
1202 1202
 		if ($globalDebug) echo "Owner Ireland: Download...";
1203
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1203
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1204 1204
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1205 1205
 			if ($globalDebug) echo "Add to DB...";
1206
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1206
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1207 1207
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1208 1208
 		if ($error != '') {
1209 1209
 			return $error;
1210 1210
 		} elseif ($globalDebug) echo "Done\n";
1211 1211
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1212
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1212
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1213 1213
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1214 1214
 			if ($globalDebug) echo "Add to DB...";
1215
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1215
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1216 1216
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1217 1217
 		if ($error != '') {
1218 1218
 			return $error;
1219 1219
 		} elseif ($globalDebug) echo "Done\n";
1220 1220
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1221
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1221
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1222 1222
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1223 1223
 			if ($globalDebug) echo "Add to DB...";
1224
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1224
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1225 1225
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1226 1226
 		if ($error != '') {
1227 1227
 			return $error;
1228 1228
 		} elseif ($globalDebug) echo "Done\n";
1229 1229
 		if ($globalDebug) echo "Owner Australia: Download...";
1230
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1230
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1231 1231
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1232 1232
 			if ($globalDebug) echo "Add to DB...";
1233
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1233
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1234 1234
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1235 1235
 		if ($error != '') {
1236 1236
 			return $error;
1237 1237
 		} elseif ($globalDebug) echo "Done\n";
1238 1238
 		if ($globalDebug) echo "Owner Austria: Download...";
1239
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1239
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1240 1240
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1241 1241
 			if ($globalDebug) echo "Add to DB...";
1242
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1242
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1243 1243
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1244 1244
 		if ($error != '') {
1245 1245
 			return $error;
1246 1246
 		} elseif ($globalDebug) echo "Done\n";
1247 1247
 		if ($globalDebug) echo "Owner Chile: Download...";
1248
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1248
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1249 1249
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1250 1250
 			if ($globalDebug) echo "Add to DB...";
1251
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1251
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1252 1252
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1253 1253
 		if ($error != '') {
1254 1254
 			return $error;
1255 1255
 		} elseif ($globalDebug) echo "Done\n";
1256 1256
 		if ($globalDebug) echo "Owner Colombia: Download...";
1257
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1257
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1258 1258
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1259 1259
 			if ($globalDebug) echo "Add to DB...";
1260
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1260
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1261 1261
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1262 1262
 		if ($error != '') {
1263 1263
 			return $error;
1264 1264
 		} elseif ($globalDebug) echo "Done\n";
1265 1265
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1266
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1266
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1267 1267
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1268 1268
 			if ($globalDebug) echo "Add to DB...";
1269
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1269
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1270 1270
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1271 1271
 		if ($error != '') {
1272 1272
 			return $error;
1273 1273
 		} elseif ($globalDebug) echo "Done\n";
1274 1274
 		if ($globalDebug) echo "Owner Brazil: Download...";
1275
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1275
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1276 1276
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1277 1277
 			if ($globalDebug) echo "Add to DB...";
1278
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1278
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1279 1279
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1280 1280
 		if ($error != '') {
1281 1281
 			return $error;
1282 1282
 		} elseif ($globalDebug) echo "Done\n";
1283 1283
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1284
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1284
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1285 1285
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1286 1286
 			if ($globalDebug) echo "Add to DB...";
1287
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1287
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1288 1288
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1289 1289
 		if ($error != '') {
1290 1290
 			return $error;
1291 1291
 		} elseif ($globalDebug) echo "Done\n";
1292 1292
 		if ($globalDebug) echo "Owner Croatia: Download...";
1293
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1293
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1294 1294
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1295 1295
 			if ($globalDebug) echo "Add to DB...";
1296
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1296
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1297 1297
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1298 1298
 		if ($error != '') {
1299 1299
 			return $error;
1300 1300
 		} elseif ($globalDebug) echo "Done\n";
1301 1301
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1302
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1302
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1303 1303
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1304 1304
 			if ($globalDebug) echo "Add to DB...";
1305
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1305
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1306 1306
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1307 1307
 		if ($error != '') {
1308 1308
 			return $error;
1309 1309
 		} elseif ($globalDebug) echo "Done\n";
1310 1310
 		if ($globalDebug) echo "Owner Maldives: Download...";
1311
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1311
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1312 1312
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1313 1313
 			if ($globalDebug) echo "Add to DB...";
1314
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1314
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1315 1315
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1316 1316
 		if ($error != '') {
1317 1317
 			return $error;
1318 1318
 		} elseif ($globalDebug) echo "Done\n";
1319 1319
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1320
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1320
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1321 1321
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1322 1322
 			if ($globalDebug) echo "Add to DB...";
1323
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1323
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1324 1324
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1325 1325
 		if ($error != '') {
1326 1326
 			return $error;
1327 1327
 		} elseif ($globalDebug) echo "Done\n";
1328 1328
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1329
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1329
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1330 1330
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1331 1331
 			if ($globalDebug) echo "Add to DB...";
1332
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1332
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1333 1333
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1334 1334
 		if ($error != '') {
1335 1335
 			return $error;
1336 1336
 		} elseif ($globalDebug) echo "Done\n";
1337 1337
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1338
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1338
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1339 1339
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1340 1340
 			if ($globalDebug) echo "Add to DB...";
1341
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1341
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1342 1342
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1343 1343
 		if ($error != '') {
1344 1344
 			return $error;
1345 1345
 		} elseif ($globalDebug) echo "Done\n";
1346 1346
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1347
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1347
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1348 1348
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1349 1349
 			if ($globalDebug) echo "Add to DB...";
1350
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1350
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1351 1351
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1352 1352
 		if ($error != '') {
1353 1353
 			return $error;
1354 1354
 		} elseif ($globalDebug) echo "Done\n";
1355 1355
 		if ($globalDebug) echo "Owner Iceland: Download...";
1356
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1356
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1357 1357
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1358 1358
 			if ($globalDebug) echo "Add to DB...";
1359
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1359
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1360 1360
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1361 1361
 		if ($error != '') {
1362 1362
 			return $error;
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
 		global $tmp_dir, $globalDebug;
1369 1369
 		$error = '';
1370 1370
 		if ($globalDebug) echo "Translation : Download...";
1371
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1371
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1372 1372
 		if (file_exists($tmp_dir.'translation.zip')) {
1373 1373
 			if ($globalDebug) echo "Unzip...";
1374 1374
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 		global $tmp_dir, $globalDebug;
1386 1386
 		$error = '';
1387 1387
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1388
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1388
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1389 1389
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1390 1390
 			if ($globalDebug) echo "Gunzip...";
1391 1391
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1413,8 +1413,8 @@  discard block
 block discarded – undo
1413 1413
 		*/
1414 1414
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1415 1415
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1416
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1417
-		    $result = fread($fh,100000000);
1416
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
1417
+		    $result = fread($fh, 100000000);
1418 1418
 		    //echo $result;
1419 1419
 		    //var_dump(str_get_html($result));
1420 1420
 		    //print_r(self::table2array($result));
@@ -1432,23 +1432,23 @@  discard block
 block discarded – undo
1432 1432
 			$Connection = new Connection();
1433 1433
 			$sth = $Connection->db->prepare($query);
1434 1434
                         $sth->execute();
1435
-                } catch(PDOException $e) {
1435
+                } catch (PDOException $e) {
1436 1436
                         return "error : ".$e->getMessage();
1437 1437
                 }
1438 1438
 
1439 1439
 		$error = '';
1440 1440
 		if ($globalDebug) echo "Notam : Download...";
1441
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1441
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
1442 1442
 		if (file_exists($tmp_dir.'notam.rss')) {
1443
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
1443
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
1444 1444
 			foreach ($notams['channel']['item'] as $notam) {
1445
-				$title = explode(':',$notam['title']);
1445
+				$title = explode(':', $notam['title']);
1446 1446
 				$data['ref'] = trim($title[0]);
1447 1447
 				unset($title[0]);
1448
-				$data['title'] = trim(implode(':',$title));
1449
-				$description = strip_tags($notam['description'],'<pre>');
1450
-				preg_match(':^(.*?)<pre>:',$description,$match);
1451
-				$q = explode('/',$match[1]);
1448
+				$data['title'] = trim(implode(':', $title));
1449
+				$description = strip_tags($notam['description'], '<pre>');
1450
+				preg_match(':^(.*?)<pre>:', $description, $match);
1451
+				$q = explode('/', $match[1]);
1452 1452
 				$data['fir'] = $q[0];
1453 1453
 				$data['code'] = $q[1];
1454 1454
 				$ifrvfr = $q[2];
@@ -1464,30 +1464,30 @@  discard block
 block discarded – undo
1464 1464
 				$data['lower_limit'] = $q[5];
1465 1465
 				$data['upper_limit'] = $q[6];
1466 1466
 				$latlonrad = $q[7];
1467
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1468
-				$latitude = $Common->convertDec($las,'latitude');
1469
-				$longitude = $Common->convertDec($lns,'longitude');
1467
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
1468
+				$latitude = $Common->convertDec($las, 'latitude');
1469
+				$longitude = $Common->convertDec($lns, 'longitude');
1470 1470
 				if ($lac == 'S') $latitude = '-'.$latitude;
1471 1471
 				if ($lnc == 'W') $longitude = '-'.$longitude;
1472 1472
 				$data['center_latitude'] = $latitude;
1473 1473
 				$data['center_longitude'] = $longitude;
1474 1474
 				$data['radius'] = intval($radius);
1475 1475
 				
1476
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
1476
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
1477 1477
 				$data['text'] = $match[1];
1478
-				preg_match(':</pre>(.*?)$:',$description,$match);
1478
+				preg_match(':</pre>(.*?)$:', $description, $match);
1479 1479
 				$fromto = $match[1];
1480
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
1480
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
1481 1481
 				$fromall = trim($match[1]);
1482
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
1482
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
1483 1483
 				$from = trim($match[1]);
1484
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
1485
-				preg_match('#TO:(.*?)$#',$fromto,$match);
1484
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
1485
+				preg_match('#TO:(.*?)$#', $fromto, $match);
1486 1486
 				$toall = trim($match[1]);
1487
-				if (!preg_match(':Permanent:',$toall)) {
1488
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
1487
+				if (!preg_match(':Permanent:', $toall)) {
1488
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
1489 1489
 					$to = trim($match[1]);
1490
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1490
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
1491 1491
 					$data['permanent'] = 0;
1492 1492
 				} else {
1493 1493
 				    $data['date_end'] = NULL;
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 				}
1496 1496
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1497 1497
 				$NOTAM = new NOTAM();
1498
-				$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']);
1498
+				$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']);
1499 1499
 				unset($data);
1500 1500
 			} 
1501 1501
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 			$Connection = new Connection();
1517 1517
 			$sth = $Connection->db->prepare($query);
1518 1518
                         $sth->execute();
1519
-                } catch(PDOException $e) {
1519
+                } catch (PDOException $e) {
1520 1520
                         return "error : ".$e->getMessage();
1521 1521
                 }
1522 1522
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
 			$Connection = new Connection();
1532 1532
 			$sth = $Connection->db->prepare($query);
1533 1533
                         $sth->execute();
1534
-                } catch(PDOException $e) {
1534
+                } catch (PDOException $e) {
1535 1535
                         return "error : ".$e->getMessage();
1536 1536
                 }
1537 1537
 	}
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
 			$Connection = new Connection();
1548 1548
 			$sth = $Connection->db->prepare($query);
1549 1549
                         $sth->execute();
1550
-                } catch(PDOException $e) {
1550
+                } catch (PDOException $e) {
1551 1551
                         return "error : ".$e->getMessage();
1552 1552
                 }
1553 1553
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			$Connection = new Connection();
1563 1563
 			$sth = $Connection->db->prepare($query);
1564 1564
                         $sth->execute();
1565
-                } catch(PDOException $e) {
1565
+                } catch (PDOException $e) {
1566 1566
                         return "error : ".$e->getMessage();
1567 1567
                 }
1568 1568
 	}
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 			$Connection = new Connection();
1579 1579
 			$sth = $Connection->db->prepare($query);
1580 1580
                         $sth->execute();
1581
-                } catch(PDOException $e) {
1581
+                } catch (PDOException $e) {
1582 1582
                         return "error : ".$e->getMessage();
1583 1583
                 }
1584 1584
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 			$Connection = new Connection();
1594 1594
 			$sth = $Connection->db->prepare($query);
1595 1595
                         $sth->execute();
1596
-                } catch(PDOException $e) {
1596
+                } catch (PDOException $e) {
1597 1597
                         return "error : ".$e->getMessage();
1598 1598
                 }
1599 1599
 	}
Please login to merge, or discard this patch.