Completed
Push — master ( d7b90c...c585c5 )
by Yannick
31:05
created
require/class.Elevation.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			default:
42 42
 				throw new \Exception("bad resolution can be only one of 1,3");
43 43
 		}
44
-		register_shutdown_function(function () {
44
+		register_shutdown_function(function() {
45 45
 			$this->closeAllFiles();
46 46
 		});
47 47
 	}
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 	private function getElevationAtPosition($fileName, $row, $column) {
57 57
 		if (!array_key_exists($fileName, $this->openedFiles)) {
58
-			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
58
+			if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName)) {
59 59
 				throw new \Exception("File '{$fileName}' not exists.");
60 60
 			}
61
-			$file = fopen($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName, "r");
61
+			$file = fopen($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName, "r");
62 62
 			if ($file === false) {
63 63
 				throw new \Exception("Cant open file '{$fileName}' for reading.");
64 64
 			}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			throw new \Exception("Not implemented yet");
73 73
 		}
74 74
 		$aRow     = $this->measPerDeg - $row;
75
-		$position = ($this->measPerDeg * ($aRow - 1)) + $column;
75
+		$position = ($this->measPerDeg*($aRow - 1)) + $column;
76 76
 		$position *= 2;
77 77
 		fseek($file, $position);
78 78
 		$short  = fread($file, 2);
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 		$latSec = $this->getSec($lat);
101 101
 		$lonSec = $this->getSec($lon);
102 102
 
103
-		$Xn = round($latSec / $this->resolution, 3);
104
-		$Yn = round($lonSec / $this->resolution, 3);
103
+		$Xn = round($latSec/$this->resolution, 3);
104
+		$Yn = round($lonSec/$this->resolution, 3);
105 105
 
106 106
 		$a1 = round($Xn);
107 107
 		$a2 = round($Yn);
@@ -133,55 +133,55 @@  discard block
 block discarded – undo
133 133
 		$b3 = $this->getElevationAtPosition($fName, $b1, $b2);
134 134
 		$c3 = $this->getElevationAtPosition($fName, $c1, $c2);
135 135
 
136
-		$n1 = ($c2 - $a2) * ($b3 - $a3) - ($c3 - $a3) * ($b2 - $a2);
137
-		$n2 = ($c3 - $a3) * ($b1 - $a1) - ($c1 - $a1) * ($b3 - $a3);
138
-		$n3 = ($c1 - $a1) * ($b2 - $a2) - ($c2 - $a2) * ($b1 - $a1);
136
+		$n1 = ($c2 - $a2)*($b3 - $a3) - ($c3 - $a3)*($b2 - $a2);
137
+		$n2 = ($c3 - $a3)*($b1 - $a1) - ($c1 - $a1)*($b3 - $a3);
138
+		$n3 = ($c1 - $a1)*($b2 - $a2) - ($c2 - $a2)*($b1 - $a1);
139 139
 
140
-		$d  = -$n1 * $a1 - $n2 * $a2 - $n3 * $a3;
141
-		$zN = (-$n1 * $Xn - $n2 * $Yn - $d) / $n3;
140
+		$d  = -$n1*$a1 - $n2*$a2 - $n3*$a3;
141
+		$zN = (-$n1*$Xn - $n2*$Yn - $d)/$n3;
142 142
 
143 143
 		return $zN;
144 144
 	}
145 145
 
146 146
 	private function getDeg($deg, $numPrefix) {
147 147
 		$deg = abs($deg);
148
-		$d   = floor($deg);     // round degrees
148
+		$d   = floor($deg); // round degrees
149 149
 		if ($numPrefix >= 3) {
150 150
 			if ($d < 100) {
151
-				$d = '0' . $d;
151
+				$d = '0'.$d;
152 152
 			}
153 153
 		} // pad with leading zeros
154 154
 		if ($d < 10) {
155
-			$d = '0' . $d;
155
+			$d = '0'.$d;
156 156
 		}
157 157
 		return $d;
158 158
 	}
159 159
 
160 160
 	private function getSec($deg) {
161 161
 		$deg = abs($deg);
162
-		$sec = round($deg * 3600, 4);
163
-		$m   = fmod(floor($sec / 60), 60);
162
+		$sec = round($deg*3600, 4);
163
+		$m   = fmod(floor($sec/60), 60);
164 164
 		$s   = round(fmod($sec, 60), 4);
165
-		return ($m * 60) + $s;
165
+		return ($m*60) + $s;
166 166
 	}
167 167
 
168
-	public function download($lat,$lon, $debug = false) {
168
+	public function download($lat, $lon, $debug = false) {
169 169
 		$N      = $this->getDeg($lat, 2);
170 170
 		$E      = $this->getDeg($lon, 3);
171
-		$fileName  = "N{$N}E{$E}.hgt";
172
-		if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
171
+		$fileName = "N{$N}E{$E}.hgt";
172
+		if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName)) {
173 173
 			$Common = new Common();
174 174
 			if ($debug) echo 'Downloading '.$fileName.'.gz ...';
175
-			$Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
176
-			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz')) {
175
+			$Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz', $this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz');
176
+			if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz')) {
177 177
 				if ($debug) echo "File '{$fileName}.gz' not exists.";
178 178
 				return false;
179 179
 			}
180 180
 			if ($debug) echo 'Done'."\n";
181 181
 			if ($debug) echo 'Decompress '.$fileName.' ....';
182
-			$Common->gunzip($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName);
182
+			$Common->gunzip($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz', $this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName);
183 183
 			if ($debug) echo 'Done'."\n";
184
-			unlink($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
184
+			unlink($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz');
185 185
 		}
186 186
 		return true;
187 187
 	}
@@ -194,22 +194,22 @@  discard block
 block discarded – undo
194 194
 		try {
195 195
 			$sth = $db->prepare($query);
196 196
 			$sth->execute($query_values);
197
-		} catch(PDOException $e) {
197
+		} catch (PDOException $e) {
198 198
 			return "error : ".$e->getMessage();
199 199
 		}
200 200
 		while ($data = $sth->fetch(PDO::FETCH_ASSOC)) {
201
-			$this->download($data['latitude'],$data['longitude'],true);
201
+			$this->download($data['latitude'], $data['longitude'], true);
202 202
 		}
203 203
 		$query = 'SELECT latitude, longitude FROM tracker_output WHERE latitude <> 0 AND longitude <> 0 ORDER BY date DESC LIMIT 50';
204 204
 		$query_values = array();
205 205
 		try {
206 206
 			$sth = $db->prepare($query);
207 207
 			$sth->execute($query_values);
208
-		} catch(PDOException $e) {
208
+		} catch (PDOException $e) {
209 209
 			return "error : ".$e->getMessage();
210 210
 		}
211 211
 		while ($data = $sth->fetch(PDO::FETCH_ASSOC)) {
212
-			$this->download($data['latitude'],$data['longitude'],true);
212
+			$this->download($data['latitude'], $data['longitude'], true);
213 213
 		}
214 214
 	}
215 215
 }
Please login to merge, or discard this patch.
install/class.update_db.php 3 patches
Indentation   +379 added lines, -379 removed lines patch added patch discarded remove patch
@@ -85,38 +85,38 @@  discard block
 block discarded – undo
85 85
 		try {
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88
-                        $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
90
-                        return "error : ".$e->getMessage();
91
-                }
88
+						$sth->execute(array(':source' => $database_file));
89
+				} catch(PDOException $e) {
90
+						return "error : ".$e->getMessage();
91
+				}
92 92
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
94
-    		update_db::connect_sqlite($database_file);
93
+			if ($globalDebug) echo " - Add routes to DB -";
94
+			update_db::connect_sqlite($database_file);
95 95
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
96 96
 		$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";
97 97
 		try {
98
-                        $sth = update_db::$db_sqlite->prepare($query);
99
-                        $sth->execute();
100
-                } catch(PDOException $e) {
101
-                        return "error : ".$e->getMessage();
102
-                }
98
+						$sth = update_db::$db_sqlite->prepare($query);
99
+						$sth->execute();
100
+				} catch(PDOException $e) {
101
+						return "error : ".$e->getMessage();
102
+				}
103 103
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
104 104
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
105 105
 		$Connection = new Connection();
106 106
 		$sth_dest = $Connection->db->prepare($query_dest);
107 107
 		try {
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
109
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111 111
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
112 112
 				$sth_dest->execute($query_dest_values);
113
-            		}
113
+					}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115 115
 		} catch(PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
119
-                return '';
119
+				return '';
120 120
 	}
121 121
 	public static function retrieve_route_oneworld($database_file) {
122 122
 		global $globalDebug, $globalTransaction;
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 		try {
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130
-                        $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
132
-                        return "error : ".$e->getMessage();
133
-                }
130
+						$sth->execute(array(':source' => 'oneworld'));
131
+				} catch(PDOException $e) {
132
+						return "error : ".$e->getMessage();
133
+				}
134 134
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
135
+			if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138 138
 		if ($fh = fopen($database_file,"r")) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			}
157 157
 			if ($globalTransaction) $Connection->db->commit();
158 158
 		}
159
-                return '';
159
+				return '';
160 160
 	}
161 161
 	
162 162
 	public static function retrieve_route_skyteam($database_file) {
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 		try {
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171
-                        $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
173
-                        return "error : ".$e->getMessage();
174
-                }
171
+						$sth->execute(array(':source' => 'skyteam'));
172
+				} catch(PDOException $e) {
173
+						return "error : ".$e->getMessage();
174
+				}
175 175
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
176
+			if ($globalDebug) echo " - Add routes to DB -";
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
201 201
 		}
202
-                return '';
202
+				return '';
203 203
 	}
204 204
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
205 205
 		global $globalTransaction;
@@ -208,27 +208,27 @@  discard block
 block discarded – undo
208 208
 		try {
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211
-                        $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
213
-                        return "error : ".$e->getMessage();
214
-                }
211
+						$sth->execute(array(':source' => $database_file));
212
+				} catch(PDOException $e) {
213
+						return "error : ".$e->getMessage();
214
+				}
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
216 216
 		try {
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219
-                        $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
219
+						$sth->execute(array(':source' => $database_file));
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 
224
-    		update_db::connect_sqlite($database_file);
224
+			update_db::connect_sqlite($database_file);
225 225
 		$query = 'select * from Aircraft';
226 226
 		try {
227
-                        $sth = update_db::$db_sqlite->prepare($query);
228
-                        $sth->execute();
229
-                } catch(PDOException $e) {
230
-                        return "error : ".$e->getMessage();
231
-                }
227
+						$sth = update_db::$db_sqlite->prepare($query);
228
+						$sth->execute();
229
+				} catch(PDOException $e) {
230
+						return "error : ".$e->getMessage();
231
+				}
232 232
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
233 233
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
234 234
 		
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 240
 		try {
241 241
 			if ($globalTransaction) $Connection->db->beginTransaction();
242
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
242
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 243
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246 246
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
250
-				    $sth_dest_owner->execute($query_dest_owner_values);
249
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
250
+					$sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252
-            		}
252
+					}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254 254
 		} catch(PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 		try {
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263
-                        $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
265
-                        return "error : ".$e->getMessage();
266
-                }
263
+						$sth->execute(array(':source' => $database_file));
264
+				} catch(PDOException $e) {
265
+						return "error : ".$e->getMessage();
266
+				}
267 267
 		return '';
268 268
 	}
269 269
 
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 		try {
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278
-                        $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
280
-                        return "error : ".$e->getMessage();
281
-                }
278
+						$sth->execute(array(':source' => $database_file));
279
+				} catch(PDOException $e) {
280
+						return "error : ".$e->getMessage();
281
+				}
282 282
 		
283 283
 		if ($fh = fopen($database_file,"r")) {
284 284
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -288,26 +288,26 @@  discard block
 block discarded – undo
288 288
 			$sth_dest = $Connection->db->prepare($query_dest);
289 289
 			try {
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291
-            			while (!feof($fh)) {
292
-            				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
291
+						while (!feof($fh)) {
292
+							$values = array();
293
+							$line = $Common->hex2str(fgets($fh,9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
298
-            				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
300
-            				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303
-            				$sth_search = $Connection->db->prepare($query_search);
295
+							$values['ModeS'] = substr($line,0,6);
296
+							$values['Registration'] = trim(substr($line,69,6));
297
+							$aircraft_name = trim(substr($line,48,6));
298
+							// Check if we can find ICAO, else set it to GLID
299
+							$aircraft_name_split = explode(' ',$aircraft_name);
300
+							$search_more = '';
301
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303
+							$sth_search = $Connection->db->prepare($query_search);
304 304
 					try {
305
-                                    		$sth_search->execute();
306
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
307
-	            				//if (count($result) > 0) {
308
-	            				if (isset($result['icao']) && $result['icao'] != '') {
309
-	            				    $values['ICAOTypeCode'] = $result['icao'];
310
-	            				} 
305
+											$sth_search->execute();
306
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
307
+								//if (count($result) > 0) {
308
+								if (isset($result['icao']) && $result['icao'] != '') {
309
+									$values['ICAOTypeCode'] = $result['icao'];
310
+								} 
311 311
 					} catch(PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 		try {
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333
-                        $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
335
-                        return "error : ".$e->getMessage();
336
-                }
333
+						$sth->execute(array(':source' => $database_file));
334
+				} catch(PDOException $e) {
335
+						return "error : ".$e->getMessage();
336
+				}
337 337
 		return '';
338 338
 	}
339 339
 
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 		try {
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347
-                        $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
349
-                        return "error : ".$e->getMessage();
350
-                }
347
+						$sth->execute(array(':source' => $database_file));
348
+				} catch(PDOException $e) {
349
+						return "error : ".$e->getMessage();
350
+				}
351 351
 		
352 352
 		if ($fh = fopen($database_file,"r")) {
353 353
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360 360
 				$tmp = fgetcsv($fh,9999,',',"'");
361
-            			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
361
+						while (!feof($fh)) {
362
+							$line = fgetcsv($fh,9999,',',"'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
366
-            				$values['ModeS'] = $line[1];
367
-            				$values['Registration'] = $line[3];
368
-            				$values['ICAOTypeCode'] = '';
369
-            				$aircraft_name = $line[2];
370
-            				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
372
-            				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375
-            				$sth_search = $Connection->db->prepare($query_search);
366
+							$values['ModeS'] = $line[1];
367
+							$values['Registration'] = $line[3];
368
+							$values['ICAOTypeCode'] = '';
369
+							$aircraft_name = $line[2];
370
+							// Check if we can find ICAO, else set it to GLID
371
+							$aircraft_name_split = explode(' ',$aircraft_name);
372
+							$search_more = '';
373
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375
+							$sth_search = $Connection->db->prepare($query_search);
376 376
 					try {
377
-                                    		$sth_search->execute();
378
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
377
+											$sth_search->execute();
378
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380 380
 					} catch(PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 		try {
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402
-                        $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
404
-                        return "error : ".$e->getMessage();
405
-                }
402
+						$sth->execute(array(':source' => $database_file));
403
+				} catch(PDOException $e) {
404
+						return "error : ".$e->getMessage();
405
+				}
406 406
 		return '';
407 407
 	}
408 408
 
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 		try {
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416
-                        $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
418
-                        return "error : ".$e->getMessage();
419
-                }
416
+						$sth->execute(array(':source' => $database_file));
417
+				} catch(PDOException $e) {
418
+						return "error : ".$e->getMessage();
419
+				}
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422 422
 		if ($fh = fopen($database_file,"r")) {
423 423
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
425
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
426 426
 		        
427 427
 			$Connection = new Connection();
428 428
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -430,126 +430,126 @@  discard block
 block discarded – undo
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432 432
 				$tmp = fgetcsv($fh,9999,',','"');
433
-            			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
435
-            				$values = array();
436
-            				//print_r($line);
437
-            				if ($country == 'F') {
438
-            				    $values['registration'] = $line[0];
439
-            				    $values['base'] = $line[4];
440
-            				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
443
-					    $values['cancel'] = $line[7];
433
+						while (!feof($fh)) {
434
+							$line = fgetcsv($fh,9999,',','"');
435
+							$values = array();
436
+							//print_r($line);
437
+							if ($country == 'F') {
438
+								$values['registration'] = $line[0];
439
+								$values['base'] = $line[4];
440
+								$values['owner'] = $line[5];
441
+								if ($line[6] == '') $values['date_first_reg'] = null;
442
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
443
+						$values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[0];
447
-            				    $values['base'] = $line[3];
448
-            				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
451
-					    $values['cancel'] = '';
452
-					    $values['modes'] = $line[7];
453
-					    $values['icao'] = $line[8];
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[0];
447
+								$values['base'] = $line[3];
448
+								$values['owner'] = $line[2];
449
+								if ($line[1] == '') $values['date_first_reg'] = null;
450
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
451
+						$values['cancel'] = '';
452
+						$values['modes'] = $line[7];
453
+						$values['icao'] = $line[8];
454 454
 					    
455 455
 					} elseif ($country == 'HB') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[0];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    $values['date_first_reg'] = null;
461
-					    $values['cancel'] = '';
462
-					    $values['modes'] = $line[4];
463
-					    $values['icao'] = $line[7];
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[0];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								$values['date_first_reg'] = null;
461
+						$values['cancel'] = '';
462
+						$values['modes'] = $line[4];
463
+						$values['icao'] = $line[7];
464 464
 					} elseif ($country == 'OK') {
465
-					    // TODO : add modeS & reg to aircraft_modes
466
-            				    $values['registration'] = $line[3];
467
-            				    $values['base'] = null;
468
-            				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
471
-					    $values['cancel'] = '';
465
+						// TODO : add modeS & reg to aircraft_modes
466
+								$values['registration'] = $line[3];
467
+								$values['base'] = null;
468
+								$values['owner'] = $line[5];
469
+								if ($line[18] == '') $values['date_first_reg'] = null;
470
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
471
+						$values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473
-					    // TODO : add modeS & reg to aircraft_modes
474
-            				    $values['registration'] = $line[0];
475
-            				    $values['base'] = null;
476
-            				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
479
-
480
-					    $values['cancel'] = $line[39];
473
+						// TODO : add modeS & reg to aircraft_modes
474
+								$values['registration'] = $line[0];
475
+								$values['base'] = null;
476
+								$values['owner'] = $line[12];
477
+								if ($line[28] == '') $values['date_first_reg'] = null;
478
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
479
+
480
+						$values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
482
-            				    $values['registration'] = $line[0];
483
-            				    $values['base'] = null;
484
-            				    $values['owner'] = $line[4];
485
-            				    $values['date_first_reg'] = null;
486
-					    $values['cancel'] = '';
482
+								$values['registration'] = $line[0];
483
+								$values['base'] = null;
484
+								$values['owner'] = $line[4];
485
+								$values['date_first_reg'] = null;
486
+						$values['cancel'] = '';
487 487
 					} elseif ($country == 'CC') {
488
-            				    $values['registration'] = $line[0];
489
-            				    $values['base'] = null;
490
-            				    $values['owner'] = $line[6];
491
-            				    $values['date_first_reg'] = null;
492
-					    $values['cancel'] = '';
488
+								$values['registration'] = $line[0];
489
+								$values['base'] = null;
490
+								$values['owner'] = $line[6];
491
+								$values['date_first_reg'] = null;
492
+						$values['cancel'] = '';
493 493
 					} elseif ($country == 'HJ') {
494
-            				    $values['registration'] = $line[0];
495
-            				    $values['base'] = null;
496
-            				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
-					    $values['cancel'] = '';
494
+								$values['registration'] = $line[0];
495
+								$values['base'] = null;
496
+								$values['owner'] = $line[8];
497
+								if ($line[7] == '') $values['date_first_reg'] = null;
498
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
+						$values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501
-            				    $values['registration'] = $line[0];
502
-            				    $values['base'] = null;
503
-            				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
-					    $values['cancel'] = $line[7];
501
+								$values['registration'] = $line[0];
502
+								$values['base'] = null;
503
+								$values['owner'] = $line[4];
504
+								if ($line[6] == '') $values['date_first_reg'] = null;
505
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+						$values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508
-            				    $values['registration'] = $line[0];
509
-            				    $values['base'] = null;
510
-            				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
513
-					    $values['cancel'] = '';
508
+								$values['registration'] = $line[0];
509
+								$values['base'] = null;
510
+								$values['owner'] = $line[4];
511
+								if ($line[5] == '') $values['date_first_reg'] = null;
512
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
513
+						$values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515
-            				    $values['registration'] = $line[0];
516
-            				    $values['base'] = null;
517
-            				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
520
-					    $values['cancel'] = '';
515
+								$values['registration'] = $line[0];
516
+								$values['base'] = null;
517
+								$values['owner'] = $line[3];
518
+								if ($line[7] == '') $values['date_first_reg'] = null;
519
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
520
+						$values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522
-            				    $values['registration'] = $line[0];
523
-            				    $values['base'] = null;
524
-            				    $values['owner'] = $line[3];
525
-            				    $values['date_first_reg'] = null;
526
-					    $values['cancel'] = '';
527
-					    $values['modes'] = $line[5];
528
-					    $values['icao'] = $line[9];
522
+								$values['registration'] = $line[0];
523
+								$values['base'] = null;
524
+								$values['owner'] = $line[3];
525
+								$values['date_first_reg'] = null;
526
+						$values['cancel'] = '';
527
+						$values['modes'] = $line[5];
528
+						$values['icao'] = $line[9];
529 529
 					} elseif ($country == 'M') {
530
-            				    $values['registration'] = $line[0];
531
-            				    $values['base'] = null;
532
-            				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
535
-					    $values['modes'] = $line[4];
536
-					    $values['icao'] = $line[10];
530
+								$values['registration'] = $line[0];
531
+								$values['base'] = null;
532
+								$values['owner'] = $line[6];
533
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
535
+						$values['modes'] = $line[4];
536
+						$values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538
-            				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
540
-					    $values['modes'] = $line[5];
541
-					    $values['icao'] = $line[6];
538
+								$values['registration'] = $line[0];
539
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
540
+						$values['modes'] = $line[5];
541
+						$values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543
-            				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
545
-					    $values['modes'] = $line[4];
546
-					    $values['icao'] = $line[5];
543
+								$values['registration'] = $line[0];
544
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
545
+						$values['modes'] = $line[4];
546
+						$values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
548
-            				    $values['registration'] = $line[0];
549
-            				    $values['base'] = null;
550
-            				    $values['owner'] = $line[3];
551
-            				    $values['date_first_reg'] = null;
552
-					    $values['cancel'] = '';
548
+								$values['registration'] = $line[0];
549
+								$values['base'] = null;
550
+								$values['owner'] = $line[3];
551
+								$values['date_first_reg'] = null;
552
+						$values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555 555
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
                         return "error : ".$e->getMessage();
683 683
                 }
684 684
                 */
685
-                /*
685
+				/*
686 686
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
687 687
 		try {
688 688
 			$Connection = new Connection();
@@ -927,10 +927,10 @@  discard block
 block discarded – undo
927 927
 		try {
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930
-                        $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
932
-                        return "error : ".$e->getMessage();
933
-                }
930
+						$sth->execute(array(':source' => 'translation.csv'));
931
+				} catch(PDOException $e) {
932
+						return "error : ".$e->getMessage();
933
+				}
934 934
 
935 935
 		
936 936
 		//update_db::unzip($out_file);
@@ -949,21 +949,21 @@  discard block
 block discarded – undo
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
952
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
953
-                                                //echo substr($operator, 0, 2)."\n";;
954
-                                                if (count($airline_array) > 0) {
952
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
953
+												//echo substr($operator, 0, 2)."\n";;
954
+												if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956 956
 							$operator = $airline_array[0]['icao'].substr($operator,2);
957
-                                                }
958
-                                        }
957
+												}
958
+										}
959 959
 					
960 960
 					$operator_correct = $data[3];
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963
-                                                if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
965
-                                            	}
966
-                                        }
962
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963
+												if (count($airline_array) > 0) {
964
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
965
+												}
966
+										}
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 			//$Connection->db->commit();
978 978
 		}
979 979
 		return '';
980
-        }
980
+		}
981 981
 	
982 982
 	public static function translation_fam() {
983 983
 		global $tmp_dir, $globalTransaction;
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 			//$Connection->db->commit();
1016 1016
 		}
1017 1017
 		return '';
1018
-        }
1018
+		}
1019 1019
 
1020 1020
 	/*
1021 1021
 	* This function use FAA public data.
@@ -1027,19 +1027,19 @@  discard block
 block discarded – undo
1027 1027
 		try {
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030
-                        $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1032
-                        return "error : ".$e->getMessage();
1033
-                }
1030
+						$sth->execute(array(':source' => 'website_faa'));
1031
+				} catch(PDOException $e) {
1032
+						return "error : ".$e->getMessage();
1033
+				}
1034 1034
 
1035 1035
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1036 1036
 		try {
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039
-                        $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1041
-                        return "error : ".$e->getMessage();
1042
-                }
1039
+						$sth->execute(array(':source' => 'website_faa'));
1040
+				} catch(PDOException $e) {
1041
+						return "error : ".$e->getMessage();
1042
+				}
1043 1043
 
1044 1044
 		$delimiter = ",";
1045 1045
 		$mfr = array();
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 			return "error : ".$e->getMessage();
1200 1200
 		}
1201 1201
 		return '';
1202
-        }
1202
+		}
1203 1203
         
1204 1204
 	public static function owner_fam() {
1205 1205
 		global $tmp_dir, $globalTransaction;
@@ -1207,10 +1207,10 @@  discard block
 block discarded – undo
1207 1207
 		try {
1208 1208
 			$Connection = new Connection();
1209 1209
 			$sth = $Connection->db->prepare($query);
1210
-                        $sth->execute(array(':source' => 'website_fam'));
1211
-                } catch(PDOException $e) {
1212
-                        return "error : ".$e->getMessage();
1213
-                }
1210
+						$sth->execute(array(':source' => 'website_fam'));
1211
+				} catch(PDOException $e) {
1212
+						return "error : ".$e->getMessage();
1213
+				}
1214 1214
 
1215 1215
 		$delimiter = "\t";
1216 1216
 		$Connection = new Connection();
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 			if ($globalTransaction) $Connection->db->commit();
1237 1237
 		}
1238 1238
 		return '';
1239
-        }
1239
+		}
1240 1240
 
1241 1241
 	public static function routes_fam() {
1242 1242
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 			if ($globalTransaction) $Connection->db->commit();
1272 1272
 		}
1273 1273
 		return '';
1274
-        }
1274
+		}
1275 1275
 
1276 1276
 	public static function marine_identity_fam() {
1277 1277
 		global $tmp_dir, $globalTransaction;
@@ -1279,10 +1279,10 @@  discard block
 block discarded – undo
1279 1279
 		try {
1280 1280
 			$Connection = new Connection();
1281 1281
 			$sth = $Connection->db->prepare($query);
1282
-                        $sth->execute();
1283
-                } catch(PDOException $e) {
1284
-                        return "error : ".$e->getMessage();
1285
-                }
1282
+						$sth->execute();
1283
+				} catch(PDOException $e) {
1284
+						return "error : ".$e->getMessage();
1285
+				}
1286 1286
 
1287 1287
 		
1288 1288
 		//update_db::unzip($out_file);
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
 			if ($globalTransaction) $Connection->db->commit();
1313 1313
 		}
1314 1314
 		return '';
1315
-        }
1315
+		}
1316 1316
 
1317 1317
 	public static function satellite_fam() {
1318 1318
 		global $tmp_dir, $globalTransaction;
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 			if ($globalTransaction) $Connection->db->commit();
1384 1384
 		}
1385 1385
 		return '';
1386
-        }
1386
+		}
1387 1387
 
1388 1388
 	public static function tle($filename,$tletype) {
1389 1389
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1394,10 +1394,10 @@  discard block
 block discarded – undo
1394 1394
 		try {
1395 1395
 			$Connection = new Connection();
1396 1396
 			$sth = $Connection->db->prepare($query);
1397
-                        $sth->execute(array(':source' => $filename));
1398
-                } catch(PDOException $e) {
1399
-                        return "error : ".$e->getMessage();
1400
-                }
1397
+						$sth->execute(array(':source' => $filename));
1398
+				} catch(PDOException $e) {
1399
+						return "error : ".$e->getMessage();
1400
+				}
1401 1401
 		
1402 1402
 		$Connection = new Connection();
1403 1403
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
 			//$Connection->db->commit();
1433 1433
 		}
1434 1434
 		return '';
1435
-        }
1435
+		}
1436 1436
 
1437 1437
 	public static function satellite_ucsdb($filename) {
1438 1438
 		global $tmp_dir, $globalTransaction;
@@ -1681,11 +1681,11 @@  discard block
 block discarded – undo
1681 1681
 							try {
1682 1682
 								$sth = $Connection->db->prepare($query);
1683 1683
 								$sth->execute(array(
1684
-								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1685
-								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1686
-								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1687
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1688
-								    )
1684
+									':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1685
+									':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1686
+									':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1687
+									':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1688
+									)
1689 1689
 								);
1690 1690
 							} catch(PDOException $e) {
1691 1691
 								return "error : ".$e->getMessage();
@@ -1709,13 +1709,13 @@  discard block
 block discarded – undo
1709 1709
 			//$Connection->db->commit();
1710 1710
 		}
1711 1711
 		return '';
1712
-        }
1712
+		}
1713 1713
 
1714 1714
 	/**
1715
-        * Convert a HTML table to an array
1716
-        * @param String $data HTML page
1717
-        * @return Array array of the tables in HTML page
1718
-        */
1715
+	 * Convert a HTML table to an array
1716
+	 * @param String $data HTML page
1717
+	 * @return Array array of the tables in HTML page
1718
+	 */
1719 1719
 /*
1720 1720
         private static function table2array($data) {
1721 1721
                 $html = str_get_html($data);
@@ -1745,11 +1745,11 @@  discard block
 block discarded – undo
1745 1745
                 return(array_filter($tabledata));
1746 1746
         }
1747 1747
 */
1748
-       /**
1749
-        * Get data from form result
1750
-        * @param String $url form URL
1751
-        * @return String the result
1752
-        */
1748
+	   /**
1749
+	    * Get data from form result
1750
+	    * @param String $url form URL
1751
+	    * @return String the result
1752
+	    */
1753 1753
 /*
1754 1754
         private static function getData($url) {
1755 1755
                 $ch = curl_init();
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
 			if ($globalTransaction) $Connection->db->commit();
1843 1843
 		}
1844 1844
 		return '';
1845
-        }
1845
+		}
1846 1846
 
1847 1847
 	public static function ivao_airlines($filename) {
1848 1848
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1852,10 +1852,10 @@  discard block
 block discarded – undo
1852 1852
 		try {
1853 1853
 			$Connection = new Connection();
1854 1854
 			$sth = $Connection->db->prepare($query);
1855
-                        $sth->execute();
1856
-                } catch(PDOException $e) {
1857
-                        return "error : ".$e->getMessage();
1858
-                }
1855
+						$sth->execute();
1856
+				} catch(PDOException $e) {
1857
+						return "error : ".$e->getMessage();
1858
+				}
1859 1859
 
1860 1860
 		$header = NULL;
1861 1861
 		$delimiter = ':';
@@ -1879,7 +1879,7 @@  discard block
 block discarded – undo
1879 1879
 			if ($globalTransaction) $Connection->db->commit();
1880 1880
 		}
1881 1881
 		return '';
1882
-        }
1882
+		}
1883 1883
 	
1884 1884
 	public static function update_airspace() {
1885 1885
 		global $tmp_dir, $globalDBdriver;
@@ -1889,11 +1889,11 @@  discard block
 block discarded – undo
1889 1889
 			$query = 'DROP TABLE airspace';
1890 1890
 			try {
1891 1891
 				$sth = $Connection->db->prepare($query);
1892
-                    		$sth->execute();
1893
-	                } catch(PDOException $e) {
1892
+							$sth->execute();
1893
+					} catch(PDOException $e) {
1894 1894
 				return "error : ".$e->getMessage();
1895
-	                }
1896
-	        }
1895
+					}
1896
+			}
1897 1897
 
1898 1898
 
1899 1899
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1958,10 +1958,10 @@  discard block
 block discarded – undo
1958 1958
 			$query = 'DROP TABLE countries';
1959 1959
 			try {
1960 1960
 				$sth = $Connection->db->prepare($query);
1961
-            	        	$sth->execute();
1962
-	                } catch(PDOException $e) {
1963
-    	                	echo "error : ".$e->getMessage();
1964
-	                }
1961
+							$sth->execute();
1962
+					} catch(PDOException $e) {
1963
+							echo "error : ".$e->getMessage();
1964
+					}
1965 1965
 		}
1966 1966
 		if ($globalDBdriver == 'mysql') {
1967 1967
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2417,7 +2417,7 @@  discard block
 block discarded – undo
2417 2417
 						$error = update_db::airlines_fam();
2418 2418
 						update_db::insert_airlines_version($airlines_md5);
2419 2419
 					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2420
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2420
+				} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2421 2421
 			} elseif ($globalDebug) echo "No update";
2422 2422
 		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2423 2423
 		if ($error != '') {
@@ -2790,12 +2790,12 @@  discard block
 block discarded – undo
2790 2790
 		echo $data;
2791 2791
 		*/
2792 2792
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2793
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2794
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2795
-		    $result = fread($fh,100000000);
2796
-		    //echo $result;
2797
-		    //var_dump(str_get_html($result));
2798
-		    //print_r(self::table2array($result));
2793
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2794
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2795
+			$result = fread($fh,100000000);
2796
+			//echo $result;
2797
+			//var_dump(str_get_html($result));
2798
+			//print_r(self::table2array($result));
2799 2799
 		}
2800 2800
 
2801 2801
 	}
@@ -2809,10 +2809,10 @@  discard block
 block discarded – undo
2809 2809
 		try {
2810 2810
 			$Connection = new Connection();
2811 2811
 			$sth = $Connection->db->prepare($query);
2812
-                        $sth->execute();
2813
-                } catch(PDOException $e) {
2814
-                        return "error : ".$e->getMessage();
2815
-                }
2812
+						$sth->execute();
2813
+				} catch(PDOException $e) {
2814
+						return "error : ".$e->getMessage();
2815
+				}
2816 2816
 
2817 2817
 		$error = '';
2818 2818
 		if ($globalDebug) echo "Notam : Download...";
@@ -2868,8 +2868,8 @@  discard block
 block discarded – undo
2868 2868
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2869 2869
 					$data['permanent'] = 0;
2870 2870
 				} else {
2871
-				    $data['date_end'] = NULL;
2872
-				    $data['permanent'] = 1;
2871
+					$data['date_end'] = NULL;
2872
+					$data['permanent'] = 1;
2873 2873
 				}
2874 2874
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2875 2875
 				$NOTAM = new NOTAM();
@@ -2943,13 +2943,13 @@  discard block
 block discarded – undo
2943 2943
 		try {
2944 2944
 			$Connection = new Connection();
2945 2945
 			$sth = $Connection->db->prepare($query);
2946
-                        $sth->execute();
2947
-                } catch(PDOException $e) {
2948
-                        return "error : ".$e->getMessage();
2949
-                }
2950
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2951
-                if ($row['nb'] > 0) return false;
2952
-                else return true;
2946
+						$sth->execute();
2947
+				} catch(PDOException $e) {
2948
+						return "error : ".$e->getMessage();
2949
+				}
2950
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2951
+				if ($row['nb'] > 0) return false;
2952
+				else return true;
2953 2953
 	}
2954 2954
 
2955 2955
 	public static function insert_last_update() {
@@ -2958,10 +2958,10 @@  discard block
 block discarded – undo
2958 2958
 		try {
2959 2959
 			$Connection = new Connection();
2960 2960
 			$sth = $Connection->db->prepare($query);
2961
-                        $sth->execute();
2962
-                } catch(PDOException $e) {
2963
-                        return "error : ".$e->getMessage();
2964
-                }
2961
+						$sth->execute();
2962
+				} catch(PDOException $e) {
2963
+						return "error : ".$e->getMessage();
2964
+				}
2965 2965
 	}
2966 2966
 
2967 2967
 	public static function check_airspace_version($version) {
@@ -2969,13 +2969,13 @@  discard block
 block discarded – undo
2969 2969
 		try {
2970 2970
 			$Connection = new Connection();
2971 2971
 			$sth = $Connection->db->prepare($query);
2972
-                        $sth->execute(array(':version' => $version));
2973
-                } catch(PDOException $e) {
2974
-                        return "error : ".$e->getMessage();
2975
-                }
2976
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2977
-                if ($row['nb'] > 0) return true;
2978
-                else return false;
2972
+						$sth->execute(array(':version' => $version));
2973
+				} catch(PDOException $e) {
2974
+						return "error : ".$e->getMessage();
2975
+				}
2976
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2977
+				if ($row['nb'] > 0) return true;
2978
+				else return false;
2979 2979
 	}
2980 2980
 
2981 2981
 	public static function check_geoid_version($version) {
@@ -2983,13 +2983,13 @@  discard block
 block discarded – undo
2983 2983
 		try {
2984 2984
 			$Connection = new Connection();
2985 2985
 			$sth = $Connection->db->prepare($query);
2986
-                        $sth->execute(array(':version' => $version));
2987
-                } catch(PDOException $e) {
2988
-                        return "error : ".$e->getMessage();
2989
-                }
2990
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2991
-                if ($row['nb'] > 0) return true;
2992
-                else return false;
2986
+						$sth->execute(array(':version' => $version));
2987
+				} catch(PDOException $e) {
2988
+						return "error : ".$e->getMessage();
2989
+				}
2990
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2991
+				if ($row['nb'] > 0) return true;
2992
+				else return false;
2993 2993
 	}
2994 2994
 
2995 2995
 	public static function check_marine_identity_version($version) {
@@ -3090,10 +3090,10 @@  discard block
 block discarded – undo
3090 3090
 		try {
3091 3091
 			$Connection = new Connection();
3092 3092
 			$sth = $Connection->db->prepare($query);
3093
-                        $sth->execute(array(':version' => $version));
3094
-                } catch(PDOException $e) {
3095
-                        return "error : ".$e->getMessage();
3096
-                }
3093
+						$sth->execute(array(':version' => $version));
3094
+				} catch(PDOException $e) {
3095
+						return "error : ".$e->getMessage();
3096
+				}
3097 3097
 	}
3098 3098
 
3099 3099
 	public static function insert_marine_identity_version($version) {
@@ -3130,13 +3130,13 @@  discard block
 block discarded – undo
3130 3130
 		try {
3131 3131
 			$Connection = new Connection();
3132 3132
 			$sth = $Connection->db->prepare($query);
3133
-                        $sth->execute();
3134
-                } catch(PDOException $e) {
3135
-                        return "error : ".$e->getMessage();
3136
-                }
3137
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3138
-                if ($row['nb'] > 0) return false;
3139
-                else return true;
3133
+						$sth->execute();
3134
+				} catch(PDOException $e) {
3135
+						return "error : ".$e->getMessage();
3136
+				}
3137
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3138
+				if ($row['nb'] > 0) return false;
3139
+				else return true;
3140 3140
 	}
3141 3141
 
3142 3142
 	public static function insert_last_notam_update() {
@@ -3145,10 +3145,10 @@  discard block
 block discarded – undo
3145 3145
 		try {
3146 3146
 			$Connection = new Connection();
3147 3147
 			$sth = $Connection->db->prepare($query);
3148
-                        $sth->execute();
3149
-                } catch(PDOException $e) {
3150
-                        return "error : ".$e->getMessage();
3151
-                }
3148
+						$sth->execute();
3149
+				} catch(PDOException $e) {
3150
+						return "error : ".$e->getMessage();
3151
+				}
3152 3152
 	}
3153 3153
 
3154 3154
 	public static function check_last_airspace_update() {
@@ -3161,13 +3161,13 @@  discard block
 block discarded – undo
3161 3161
 		try {
3162 3162
 			$Connection = new Connection();
3163 3163
 			$sth = $Connection->db->prepare($query);
3164
-                        $sth->execute();
3165
-                } catch(PDOException $e) {
3166
-                        return "error : ".$e->getMessage();
3167
-                }
3168
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3169
-                if ($row['nb'] > 0) return false;
3170
-                else return true;
3164
+						$sth->execute();
3165
+				} catch(PDOException $e) {
3166
+						return "error : ".$e->getMessage();
3167
+				}
3168
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3169
+				if ($row['nb'] > 0) return false;
3170
+				else return true;
3171 3171
 	}
3172 3172
 
3173 3173
 	public static function insert_last_airspace_update() {
@@ -3176,10 +3176,10 @@  discard block
 block discarded – undo
3176 3176
 		try {
3177 3177
 			$Connection = new Connection();
3178 3178
 			$sth = $Connection->db->prepare($query);
3179
-                        $sth->execute();
3180
-                } catch(PDOException $e) {
3181
-                        return "error : ".$e->getMessage();
3182
-                }
3179
+						$sth->execute();
3180
+				} catch(PDOException $e) {
3181
+						return "error : ".$e->getMessage();
3182
+				}
3183 3183
 	}
3184 3184
 
3185 3185
 	public static function check_last_geoid_update() {
@@ -3192,13 +3192,13 @@  discard block
 block discarded – undo
3192 3192
 		try {
3193 3193
 			$Connection = new Connection();
3194 3194
 			$sth = $Connection->db->prepare($query);
3195
-                        $sth->execute();
3196
-                } catch(PDOException $e) {
3197
-                        return "error : ".$e->getMessage();
3198
-                }
3199
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3200
-                if ($row['nb'] > 0) return false;
3201
-                else return true;
3195
+						$sth->execute();
3196
+				} catch(PDOException $e) {
3197
+						return "error : ".$e->getMessage();
3198
+				}
3199
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3200
+				if ($row['nb'] > 0) return false;
3201
+				else return true;
3202 3202
 	}
3203 3203
 
3204 3204
 	public static function insert_last_geoid_update() {
@@ -3207,10 +3207,10 @@  discard block
 block discarded – undo
3207 3207
 		try {
3208 3208
 			$Connection = new Connection();
3209 3209
 			$sth = $Connection->db->prepare($query);
3210
-                        $sth->execute();
3211
-                } catch(PDOException $e) {
3212
-                        return "error : ".$e->getMessage();
3213
-                }
3210
+						$sth->execute();
3211
+				} catch(PDOException $e) {
3212
+						return "error : ".$e->getMessage();
3213
+				}
3214 3214
 	}
3215 3215
 
3216 3216
 	public static function check_last_owner_update() {
@@ -3223,13 +3223,13 @@  discard block
 block discarded – undo
3223 3223
 		try {
3224 3224
 			$Connection = new Connection();
3225 3225
 			$sth = $Connection->db->prepare($query);
3226
-                        $sth->execute();
3227
-                } catch(PDOException $e) {
3228
-                        return "error : ".$e->getMessage();
3229
-                }
3230
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3231
-                if ($row['nb'] > 0) return false;
3232
-                else return true;
3226
+						$sth->execute();
3227
+				} catch(PDOException $e) {
3228
+						return "error : ".$e->getMessage();
3229
+				}
3230
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3231
+				if ($row['nb'] > 0) return false;
3232
+				else return true;
3233 3233
 	}
3234 3234
 
3235 3235
 	public static function insert_last_owner_update() {
@@ -3238,10 +3238,10 @@  discard block
 block discarded – undo
3238 3238
 		try {
3239 3239
 			$Connection = new Connection();
3240 3240
 			$sth = $Connection->db->prepare($query);
3241
-                        $sth->execute();
3242
-                } catch(PDOException $e) {
3243
-                        return "error : ".$e->getMessage();
3244
-                }
3241
+						$sth->execute();
3242
+				} catch(PDOException $e) {
3243
+						return "error : ".$e->getMessage();
3244
+				}
3245 3245
 	}
3246 3246
 	public static function check_last_schedules_update() {
3247 3247
 		global $globalDBdriver;
@@ -3253,13 +3253,13 @@  discard block
 block discarded – undo
3253 3253
 		try {
3254 3254
 			$Connection = new Connection();
3255 3255
 			$sth = $Connection->db->prepare($query);
3256
-                        $sth->execute();
3257
-                } catch(PDOException $e) {
3258
-                        return "error : ".$e->getMessage();
3259
-                }
3260
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3261
-                if ($row['nb'] > 0) return false;
3262
-                else return true;
3256
+						$sth->execute();
3257
+				} catch(PDOException $e) {
3258
+						return "error : ".$e->getMessage();
3259
+				}
3260
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3261
+				if ($row['nb'] > 0) return false;
3262
+				else return true;
3263 3263
 	}
3264 3264
 
3265 3265
 	public static function insert_last_schedules_update() {
@@ -3439,10 +3439,10 @@  discard block
 block discarded – undo
3439 3439
 		try {
3440 3440
 			$Connection = new Connection();
3441 3441
 			$sth = $Connection->db->prepare($query);
3442
-                        $sth->execute();
3443
-                } catch(PDOException $e) {
3444
-                        return "error : ".$e->getMessage();
3445
-                }
3442
+						$sth->execute();
3443
+				} catch(PDOException $e) {
3444
+						return "error : ".$e->getMessage();
3445
+				}
3446 3446
 	}
3447 3447
 	public static function delete_duplicateowner() {
3448 3448
 		global $globalDBdriver;
@@ -3454,10 +3454,10 @@  discard block
 block discarded – undo
3454 3454
 		try {
3455 3455
 			$Connection = new Connection();
3456 3456
 			$sth = $Connection->db->prepare($query);
3457
-                        $sth->execute();
3458
-                } catch(PDOException $e) {
3459
-                        return "error : ".$e->getMessage();
3460
-                }
3457
+						$sth->execute();
3458
+				} catch(PDOException $e) {
3459
+						return "error : ".$e->getMessage();
3460
+				}
3461 3461
 	}
3462 3462
 	
3463 3463
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +371 added lines, -371 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		$ch = curl_init();
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
19
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
19
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
20 20
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
21 21
 			}
22 22
 		}
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
 		fclose($fp);
35 35
 	}
36 36
 
37
-	public static function gunzip($in_file,$out_file_name = '') {
37
+	public static function gunzip($in_file, $out_file_name = '') {
38 38
 		//echo $in_file.' -> '.$out_file_name."\n";
39 39
 		$buffer_size = 4096; // read 4kb at a time
40 40
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
41 41
 		if ($in_file != '' && file_exists($in_file)) {
42 42
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
43
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
44
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
45 45
 			else {
46 46
 				echo 'gzopen not available';
47 47
 				die;
48 48
 			}
49 49
 			$out_file = fopen($out_file_name, 'wb'); 
50
-			while(!gzeof($file)) {
50
+			while (!gzeof($file)) {
51 51
 				fwrite($out_file, gzread($file, $buffer_size));
52 52
 			}  
53 53
 			fclose($out_file);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		try {
72 72
 			self::$db_sqlite = new PDO('sqlite:'.$database);
73 73
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
74
-		} catch(PDOException $e) {
74
+		} catch (PDOException $e) {
75 75
 			return "error : ".$e->getMessage();
76 76
 		}
77 77
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88 88
                         $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
89
+                } catch (PDOException $e) {
90 90
                         return "error : ".$e->getMessage();
91 91
                 }
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		try {
98 98
                         $sth = update_db::$db_sqlite->prepare($query);
99 99
                         $sth->execute();
100
-                } catch(PDOException $e) {
100
+                } catch (PDOException $e) {
101 101
                         return "error : ".$e->getMessage();
102 102
                 }
103 103
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109 109
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
112 112
 				$sth_dest->execute($query_dest_values);
113 113
             		}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115
-		} catch(PDOException $e) {
115
+		} catch (PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
@@ -128,26 +128,26 @@  discard block
 block discarded – undo
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130 130
                         $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
131
+                } catch (PDOException $e) {
132 132
                         return "error : ".$e->getMessage();
133 133
                 }
134 134
 
135 135
     		if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138
-		if ($fh = fopen($database_file,"r")) {
138
+		if ($fh = fopen($database_file, "r")) {
139 139
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
140 140
 			$Connection = new Connection();
141 141
 			$sth_dest = $Connection->db->prepare($query_dest);
142 142
 			if ($globalTransaction) $Connection->db->beginTransaction();
143 143
 			while (!feof($fh)) {
144
-				$line = fgetcsv($fh,9999,',');
144
+				$line = fgetcsv($fh, 9999, ',');
145 145
 				if ($line[0] != '') {
146 146
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
147 147
 						try {
148
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
148
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
149 149
 							$sth_dest->execute($query_dest_values);
150
-						} catch(PDOException $e) {
150
+						} catch (PDOException $e) {
151 151
 							if ($globalTransaction) $Connection->db->rollBack(); 
152 152
 							return "error : ".$e->getMessage();
153 153
 						}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171 171
                         $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
172
+                } catch (PDOException $e) {
173 173
                         return "error : ".$e->getMessage();
174 174
                 }
175 175
 
@@ -177,24 +177,24 @@  discard block
 block discarded – undo
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
180
-		if ($fh = fopen($database_file,"r")) {
180
+		if ($fh = fopen($database_file, "r")) {
181 181
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
182 182
 			$Connection = new Connection();
183 183
 			$sth_dest = $Connection->db->prepare($query_dest);
184 184
 			try {
185 185
 				if ($globalTransaction) $Connection->db->beginTransaction();
186 186
 				while (!feof($fh)) {
187
-					$line = fgetcsv($fh,9999,',');
187
+					$line = fgetcsv($fh, 9999, ',');
188 188
 					if ($line[0] != '') {
189
-						$datebe = explode('  -  ',$line[2]);
189
+						$datebe = explode('  -  ', $line[2]);
190 190
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
191
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
191
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
192 192
 							$sth_dest->execute($query_dest_values);
193 193
 						}
194 194
 					}
195 195
 				}
196 196
 				if ($globalTransaction) $Connection->db->commit();
197
-			} catch(PDOException $e) {
197
+			} catch (PDOException $e) {
198 198
 				if ($globalTransaction) $Connection->db->rollBack(); 
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211 211
                         $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
212
+                } catch (PDOException $e) {
213 213
                         return "error : ".$e->getMessage();
214 214
                 }
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219 219
                         $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		try {
227 227
                         $sth = update_db::$db_sqlite->prepare($query);
228 228
                         $sth->execute();
229
-                } catch(PDOException $e) {
229
+                } catch (PDOException $e) {
230 230
                         return "error : ".$e->getMessage();
231 231
                 }
232 232
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
246
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
247 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
249
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
250 250
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252 252
             		}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254
-		} catch(PDOException $e) {
254
+		} catch (PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
256 256
 		}
257 257
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263 263
                         $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
264
+                } catch (PDOException $e) {
265 265
                         return "error : ".$e->getMessage();
266 266
                 }
267 267
 		return '';
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278 278
                         $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
279
+                } catch (PDOException $e) {
280 280
                         return "error : ".$e->getMessage();
281 281
                 }
282 282
 		
283
-		if ($fh = fopen($database_file,"r")) {
283
+		if ($fh = fopen($database_file, "r")) {
284 284
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
285 285
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
286 286
 		
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291 291
             			while (!feof($fh)) {
292 292
             				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
293
+            				$line = $Common->hex2str(fgets($fh, 9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
295
+            				$values['ModeS'] = substr($line, 0, 6);
296
+            				$values['Registration'] = trim(substr($line, 69, 6));
297
+            				$aircraft_name = trim(substr($line, 48, 6));
298 298
             				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
299
+            				$aircraft_name_split = explode(' ', $aircraft_name);
300 300
             				$search_more = '';
301 301
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302 302
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	            				if (isset($result['icao']) && $result['icao'] != '') {
309 309
 	            				    $values['ICAOTypeCode'] = $result['icao'];
310 310
 	            				} 
311
-					} catch(PDOException $e) {
311
+					} catch (PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
314 314
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
315 315
 					// Add data to db
316 316
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 317
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
318
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
318
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
319 319
 						//print_r($query_dest_values);
320 320
 						$sth_dest->execute($query_dest_values);
321 321
 					}
322 322
 				}
323 323
 				if ($globalTransaction) $Connection->db->commit();
324
-			} catch(PDOException $e) {
324
+			} catch (PDOException $e) {
325 325
 				return "error : ".$e->getMessage();
326 326
 			}
327 327
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333 333
                         $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
334
+                } catch (PDOException $e) {
335 335
                         return "error : ".$e->getMessage();
336 336
                 }
337 337
 		return '';
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347 347
                         $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
348
+                } catch (PDOException $e) {
349 349
                         return "error : ".$e->getMessage();
350 350
                 }
351 351
 		
352
-		if ($fh = fopen($database_file,"r")) {
352
+		if ($fh = fopen($database_file, "r")) {
353 353
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
354 354
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
355 355
 		
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 			$sth_dest = $Connection->db->prepare($query_dest);
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360
-				$tmp = fgetcsv($fh,9999,',',"'");
360
+				$tmp = fgetcsv($fh, 9999, ',', "'");
361 361
             			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
362
+            				$line = fgetcsv($fh, 9999, ',', "'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
             				$values['ICAOTypeCode'] = '';
369 369
             				$aircraft_name = $line[2];
370 370
             				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
371
+            				$aircraft_name_split = explode(' ', $aircraft_name);
372 372
             				$search_more = '';
373 373
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374 374
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -377,20 +377,20 @@  discard block
 block discarded – undo
377 377
                                     		$sth_search->execute();
378 378
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379 379
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380
-					} catch(PDOException $e) {
380
+					} catch (PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
383 383
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
384 384
 					// Add data to db
385 385
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
386 386
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
387
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
387
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
388 388
 						//print_r($query_dest_values);
389 389
 						$sth_dest->execute($query_dest_values);
390 390
 					}
391 391
 				}
392 392
 				if ($globalTransaction) $Connection->db->commit();
393
-			} catch(PDOException $e) {
393
+			} catch (PDOException $e) {
394 394
 				return "error : ".$e->getMessage();
395 395
 			}
396 396
 		}
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402 402
                         $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
403
+                } catch (PDOException $e) {
404 404
                         return "error : ".$e->getMessage();
405 405
                 }
406 406
 		return '';
407 407
 	}
408 408
 
409
-	public static function retrieve_owner($database_file,$country = 'F') {
409
+	public static function retrieve_owner($database_file, $country = 'F') {
410 410
 		global $globalTransaction, $globalMasterSource;
411 411
 		//$query = 'TRUNCATE TABLE aircraft_modes';
412 412
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416 416
                         $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
417
+                } catch (PDOException $e) {
418 418
                         return "error : ".$e->getMessage();
419 419
                 }
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422
-		if ($fh = fopen($database_file,"r")) {
422
+		if ($fh = fopen($database_file, "r")) {
423 423
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425 425
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 			$sth_modes = $Connection->db->prepare($query_modes);
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432
-				$tmp = fgetcsv($fh,9999,',','"');
432
+				$tmp = fgetcsv($fh, 9999, ',', '"');
433 433
             			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
434
+            				$line = fgetcsv($fh, 9999, ',', '"');
435 435
             				$values = array();
436 436
             				//print_r($line);
437 437
             				if ($country == 'F') {
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             				    $values['base'] = $line[4];
440 440
             				    $values['owner'] = $line[5];
441 441
             				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
442
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
443 443
 					    $values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445 445
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             				    $values['base'] = $line[3];
448 448
             				    $values['owner'] = $line[2];
449 449
             				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
450
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
451 451
 					    $values['cancel'] = '';
452 452
 					    $values['modes'] = $line[7];
453 453
 					    $values['icao'] = $line[8];
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             				    $values['base'] = null;
468 468
             				    $values['owner'] = $line[5];
469 469
             				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
470
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
471 471
 					    $values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473 473
 					    // TODO : add modeS & reg to aircraft_modes
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
             				    $values['base'] = null;
476 476
             				    $values['owner'] = $line[12];
477 477
             				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
478
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
479 479
 
480 480
 					    $values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -495,28 +495,28 @@  discard block
 block discarded – undo
495 495
             				    $values['base'] = null;
496 496
             				    $values['owner'] = $line[8];
497 497
             				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
498
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
499 499
 					    $values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501 501
             				    $values['registration'] = $line[0];
502 502
             				    $values['base'] = null;
503 503
             				    $values['owner'] = $line[4];
504 504
             				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
505
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
506 506
 					    $values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508 508
             				    $values['registration'] = $line[0];
509 509
             				    $values['base'] = null;
510 510
             				    $values['owner'] = $line[4];
511 511
             				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
512
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
513 513
 					    $values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515 515
             				    $values['registration'] = $line[0];
516 516
             				    $values['base'] = null;
517 517
             				    $values['owner'] = $line[3];
518 518
             				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
519
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
520 520
 					    $values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522 522
             				    $values['registration'] = $line[0];
@@ -530,18 +530,18 @@  discard block
 block discarded – undo
530 530
             				    $values['registration'] = $line[0];
531 531
             				    $values['base'] = null;
532 532
             				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
533
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
534
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
535 535
 					    $values['modes'] = $line[4];
536 536
 					    $values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538 538
             				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
539
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
540 540
 					    $values['modes'] = $line[5];
541 541
 					    $values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543 543
             				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
544
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
545 545
 					    $values['modes'] = $line[4];
546 546
 					    $values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -552,17 +552,17 @@  discard block
 block discarded – undo
552 552
 					    $values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
555
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
556 556
 						$sth_dest->execute($query_dest_values);
557 557
 					}
558 558
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
559 559
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
560
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
560
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
561 561
 						$sth_modes->execute($query_modes_values);
562 562
 					}
563 563
 				}
564 564
 				if ($globalTransaction) $Connection->db->commit();
565
-			} catch(PDOException $e) {
565
+			} catch (PDOException $e) {
566 566
 				return "error : ".$e->getMessage();
567 567
 			}
568 568
 		}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		if ($globalTransaction) $Connection->db->beginTransaction();
701 701
   
702 702
 		$i = 0;
703
-		while($row = sparql_fetch_array($result))
703
+		while ($row = sparql_fetch_array($result))
704 704
 		{
705 705
 			if ($i >= 1) {
706 706
 			//print_r($row);
@@ -720,33 +720,33 @@  discard block
 block discarded – undo
720 720
 				$row['image'] = '';
721 721
 				$row['image_thumb'] = '';
722 722
 			} else {
723
-				$image = str_replace(' ','_',$row['image']);
723
+				$image = str_replace(' ', '_', $row['image']);
724 724
 				$digest = md5($image);
725
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
726
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
727
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
728
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
725
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
726
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
727
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
728
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
729 729
 			}
730 730
 			
731
-			$country = explode('-',$row['country']);
731
+			$country = explode('-', $row['country']);
732 732
 			$row['country'] = $country[0];
733 733
 			
734 734
 			$row['type'] = trim($row['type']);
735
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
735
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
736 736
 				$row['type'] = 'military';
737 737
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
738 738
 				$row['type'] = 'small_airport';
739 739
 			}
740 740
 			
741
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
742
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
741
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
742
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
743 743
 			//print_r($query_dest_values);
744 744
 			
745 745
 			if ($row['icao'] != '') {
746 746
 				try {
747 747
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
748 748
 					$sth->execute(array(':icao' => $row['icao']));
749
-				} catch(PDOException $e) {
749
+				} catch (PDOException $e) {
750 750
 					return "error : ".$e->getMessage();
751 751
 				}
752 752
 					if ($sth->fetchColumn() > 0) {
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
755 755
 						try {
756 756
 							$sth = $Connection->db->prepare($query);
757
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
758
-						} catch(PDOException $e) {
757
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
758
+						} catch (PDOException $e) {
759 759
 							return "error : ".$e->getMessage();
760 760
 						}
761 761
 						echo $row['icao'].' : '.$row['type']."\n";
762 762
 					} else {
763 763
 						try {
764 764
 							$sth_dest->execute($query_dest_values);
765
-						} catch(PDOException $e) {
765
+						} catch (PDOException $e) {
766 766
 							return "error : ".$e->getMessage();
767 767
 						}
768 768
 					}
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		echo "Download data from ourairports.com...\n";
814 814
 		$delimiter = ',';
815 815
 		$out_file = $tmp_dir.'airports.csv';
816
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
816
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
817 817
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
818 818
 		echo "Add data from ourairports.com...\n";
819 819
 
@@ -824,33 +824,33 @@  discard block
 block discarded – undo
824 824
 			//$Connection->db->beginTransaction();
825 825
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 826
 			{
827
-				if(!$header) $header = $row;
827
+				if (!$header) $header = $row;
828 828
 				else {
829 829
 					$data = array();
830 830
 					$data = array_combine($header, $row);
831 831
 					try {
832 832
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
833 833
 						$sth->execute(array(':icao' => $data['ident']));
834
-					} catch(PDOException $e) {
834
+					} catch (PDOException $e) {
835 835
 						return "error : ".$e->getMessage();
836 836
 					}
837 837
 					if ($sth->fetchColumn() > 0) {
838 838
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
839 839
 						try {
840 840
 							$sth = $Connection->db->prepare($query);
841
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
842
-						} catch(PDOException $e) {
841
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
842
+						} catch (PDOException $e) {
843 843
 							return "error : ".$e->getMessage();
844 844
 						}
845 845
 					} else {
846 846
 						if ($data['gps_code'] == $data['ident']) {
847 847
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
848 848
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
849
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
849
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
850 850
 						try {
851 851
 							$sth = $Connection->db->prepare($query);
852 852
 							$sth->execute($query_values);
853
-						} catch(PDOException $e) {
853
+						} catch (PDOException $e) {
854 854
 							return "error : ".$e->getMessage();
855 855
 						}
856 856
 						$i++;
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		
866 866
 		echo "Download data from another free database...\n";
867 867
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
868
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
869 869
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
870 870
 		update_db::unzip($out_file);
871 871
 		$header = NULL;
@@ -877,15 +877,15 @@  discard block
 block discarded – undo
877 877
 			//$Connection->db->beginTransaction();
878 878
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 879
 			{
880
-				if(!$header) $header = $row;
880
+				if (!$header) $header = $row;
881 881
 				else {
882 882
 					$data = $row;
883 883
 
884 884
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
885 885
 					try {
886 886
 						$sth = $Connection->db->prepare($query);
887
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
888
-					} catch(PDOException $e) {
887
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
888
+					} catch (PDOException $e) {
889 889
 						return "error : ".$e->getMessage();
890 890
 					}
891 891
 				}
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 		try {
900 900
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
901 901
 			$sth->execute();
902
-		} catch(PDOException $e) {
902
+		} catch (PDOException $e) {
903 903
 			return "error : ".$e->getMessage();
904 904
 		}
905 905
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
906 906
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
907 907
 			try {
908 908
 				$sth2 = $Connection->db->prepare($query2);
909
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
910
-			} catch(PDOException $e) {
909
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
910
+			} catch (PDOException $e) {
911 911
 				return "error : ".$e->getMessage();
912 912
 			}
913 913
 		}
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930 930
                         $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
931
+                } catch (PDOException $e) {
932 932
                         return "error : ".$e->getMessage();
933 933
                 }
934 934
 
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
946 946
 			{
947 947
 				$i++;
948
-				if($i > 12) {
948
+				if ($i > 12) {
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
                                                 //echo substr($operator, 0, 2)."\n";;
954 954
                                                 if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956
-							$operator = $airline_array[0]['icao'].substr($operator,2);
956
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
957 957
                                                 }
958 958
                                         }
959 959
 					
@@ -961,14 +961,14 @@  discard block
 block discarded – undo
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962 962
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963 963
                                                 if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
964
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
965 965
                                             	}
966 966
                                         }
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
970
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
-					} catch(PDOException $e) {
970
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
+					} catch (PDOException $e) {
972 972
 						return "error : ".$e->getMessage();
973 973
 					}
974 974
 				}
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 			$Connection = new Connection();
987 987
 			$sth = $Connection->db->prepare($query);
988 988
 			$sth->execute(array(':source' => 'website_fam'));
989
-		} catch(PDOException $e) {
989
+		} catch (PDOException $e) {
990 990
 			return "error : ".$e->getMessage();
991 991
 		}
992 992
 		//update_db::unzip($out_file);
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
1005 1005
 					try {
1006 1006
 						$sth = $Connection->db->prepare($query);
1007
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
-					} catch(PDOException $e) {
1007
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
+					} catch (PDOException $e) {
1009 1009
 						return "error : ".$e->getMessage();
1010 1010
 					}
1011 1011
 				}
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030 1030
                         $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1031
+                } catch (PDOException $e) {
1032 1032
                         return "error : ".$e->getMessage();
1033 1033
                 }
1034 1034
 
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039 1039
                         $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1040
+                } catch (PDOException $e) {
1041 1041
                         return "error : ".$e->getMessage();
1042 1042
                 }
1043 1043
 
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1055 1055
 					try {
1056 1056
 						$sths = $Connection->db->prepare($query_search);
1057
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1058
-					} catch(PDOException $e) {
1057
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1058
+					} catch (PDOException $e) {
1059 1059
 						return "error s : ".$e->getMessage();
1060 1060
 					}
1061 1061
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
 							//}
1069 1069
 						try {
1070 1070
 							$sthi = $Connection->db->prepare($queryi);
1071
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1072
-						} catch(PDOException $e) {
1071
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1072
+						} catch (PDOException $e) {
1073 1073
 							return "error u : ".$e->getMessage();
1074 1074
 						}
1075 1075
 					} else {
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 						try {
1078 1078
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1079 1079
 							$sthsm->execute(array(':mfr' => $data[2]));
1080
-						} catch(PDOException $e) {
1080
+						} catch (PDOException $e) {
1081 1081
 							return "error mfr : ".$e->getMessage();
1082 1082
 						}
1083 1083
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1088
 							try {
1089 1089
 								$sthf = $Connection->db->prepare($queryf);
1090
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1091
-							} catch(PDOException $e) {
1090
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1091
+							} catch (PDOException $e) {
1092 1092
 								return "error f : ".$e->getMessage();
1093 1093
 							}
1094 1094
 						}
@@ -1098,13 +1098,13 @@  discard block
 block discarded – undo
1098 1098
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1099
 						try {
1100 1100
 							$sth = $Connection->db->prepare($query);
1101
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1102
-						} catch(PDOException $e) {
1101
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1102
+						} catch (PDOException $e) {
1103 1103
 							return "error i : ".$e->getMessage();
1104 1104
 						}
1105 1105
 					}
1106 1106
 				}
1107
-				if ($i % 90 == 0) {
1107
+				if ($i%90 == 0) {
1108 1108
 					if ($globalTransaction) $Connection->db->commit();
1109 1109
 					if ($globalTransaction) $Connection->db->beginTransaction();
1110 1110
 				}
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			$Connection = new Connection();
1124 1124
 			$sth = $Connection->db->prepare($query);
1125 1125
 			$sth->execute(array(':source' => 'website_fam'));
1126
-		} catch(PDOException $e) {
1126
+		} catch (PDOException $e) {
1127 1127
 			return "error : ".$e->getMessage();
1128 1128
 		}
1129 1129
 		$delimiter = "\t";
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1140
 					try {
1141 1141
 						$sth = $Connection->db->prepare($query);
1142
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1143
-					} catch(PDOException $e) {
1142
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1143
+					} catch (PDOException $e) {
1144 1144
 						return "error : ".$e->getMessage();
1145 1145
 					}
1146 1146
 				}
@@ -1159,14 +1159,14 @@  discard block
 block discarded – undo
1159 1159
 		try {
1160 1160
 			$sth = $Connection->db->prepare($query);
1161 1161
 			$sth->execute();
1162
-		} catch(PDOException $e) {
1162
+		} catch (PDOException $e) {
1163 1163
 			return "error : ".$e->getMessage();
1164 1164
 		}
1165 1165
 		$query = "LOCK TABLE airlines WRITE";
1166 1166
 		try {
1167 1167
 			$sth = $Connection->db->prepare($query);
1168 1168
 			$sth->execute();
1169
-		} catch(PDOException $e) {
1169
+		} catch (PDOException $e) {
1170 1170
 			return "error : ".$e->getMessage();
1171 1171
 		}
1172 1172
 		$delimiter = "\t";
@@ -1181,8 +1181,8 @@  discard block
 block discarded – undo
1181 1181
 					$query = 'INSERT INTO airlines (name,alias,iata,icao,callsign,country,active,type,home,wikipedia_link,alliance,ban_eu) VALUES (:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1182 1182
 					try {
1183 1183
 						$sth = $Connection->db->prepare($query);
1184
-						$sth->execute(array(':name' => $data[0],':alias' => $data[1],':iata' => $data[2],':icao' => $data[3], ':callsign' => $data[4],':country' => $data[5],':active' => $data[6],':type' => $data[7],':home' => $data[8],':wikipedia_link' => $data[9],':alliance' => $data[10],':ban_eu' => $data[11]));
1185
-					} catch(PDOException $e) {
1184
+						$sth->execute(array(':name' => $data[0], ':alias' => $data[1], ':iata' => $data[2], ':icao' => $data[3], ':callsign' => $data[4], ':country' => $data[5], ':active' => $data[6], ':type' => $data[7], ':home' => $data[8], ':wikipedia_link' => $data[9], ':alliance' => $data[10], ':ban_eu' => $data[11]));
1185
+					} catch (PDOException $e) {
1186 1186
 						return "error : ".$e->getMessage();
1187 1187
 					}
1188 1188
 				}
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 		try {
1196 1196
 			$sth = $Connection->db->prepare($query);
1197 1197
 			$sth->execute();
1198
-		} catch(PDOException $e) {
1198
+		} catch (PDOException $e) {
1199 1199
 			return "error : ".$e->getMessage();
1200 1200
 		}
1201 1201
 		return '';
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 			$Connection = new Connection();
1209 1209
 			$sth = $Connection->db->prepare($query);
1210 1210
                         $sth->execute(array(':source' => 'website_fam'));
1211
-                } catch(PDOException $e) {
1211
+                } catch (PDOException $e) {
1212 1212
                         return "error : ".$e->getMessage();
1213 1213
                 }
1214 1214
 
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1225 1225
 					try {
1226 1226
 						$sth = $Connection->db->prepare($query);
1227
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1228
-					} catch(PDOException $e) {
1227
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1228
+					} catch (PDOException $e) {
1229 1229
 						//print_r($data);
1230 1230
 						return "error : ".$e->getMessage();
1231 1231
 					}
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 			$Connection = new Connection();
1246 1246
 			$sth = $Connection->db->prepare($query);
1247 1247
 			$sth->execute(array(':source' => 'website_fam'));
1248
-		} catch(PDOException $e) {
1248
+		} catch (PDOException $e) {
1249 1249
 			return "error : ".$e->getMessage();
1250 1250
 		}
1251 1251
 		$delimiter = "\t";
@@ -1260,9 +1260,9 @@  discard block
 block discarded – undo
1260 1260
 					$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)';
1261 1261
 					try {
1262 1262
 						$sth = $Connection->db->prepare($query);
1263
-						$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'));
1264
-					} catch(PDOException $e) {
1265
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1263
+						$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'));
1264
+					} catch (PDOException $e) {
1265
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1266 1266
 					}
1267 1267
 				}
1268 1268
 				$i++;
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 			$Connection = new Connection();
1281 1281
 			$sth = $Connection->db->prepare($query);
1282 1282
                         $sth->execute();
1283
-                } catch(PDOException $e) {
1283
+                } catch (PDOException $e) {
1284 1284
                         return "error : ".$e->getMessage();
1285 1285
                 }
1286 1286
 
@@ -1301,8 +1301,8 @@  discard block
 block discarded – undo
1301 1301
 					$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)';
1302 1302
 					try {
1303 1303
 						$sth = $Connection->db->prepare($query);
1304
-						$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]));
1305
-					} catch(PDOException $e) {
1304
+						$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]));
1305
+					} catch (PDOException $e) {
1306 1306
 						return "error : ".$e->getMessage();
1307 1307
 					}
1308 1308
 				}
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 			$Connection = new Connection();
1322 1322
 			$sth = $Connection->db->prepare($query);
1323 1323
 			$sth->execute();
1324
-		} catch(PDOException $e) {
1324
+		} catch (PDOException $e) {
1325 1325
 			return "error : ".$e->getMessage();
1326 1326
 		}
1327 1327
 		$delimiter = "\t";
@@ -1338,8 +1338,8 @@  discard block
 block discarded – undo
1338 1338
 					    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)';
1339 1339
 					try {
1340 1340
 						$sth = $Connection->db->prepare($query);
1341
-						$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]));
1342
-					} catch(PDOException $e) {
1341
+						$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]));
1342
+					} catch (PDOException $e) {
1343 1343
 						return "error : ".$e->getMessage();
1344 1344
 					}
1345 1345
 				}
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 			$Connection = new Connection();
1359 1359
 			$sth = $Connection->db->prepare($query);
1360 1360
 			$sth->execute();
1361
-		} catch(PDOException $e) {
1361
+		} catch (PDOException $e) {
1362 1362
 			return "error : ".$e->getMessage();
1363 1363
 		}
1364 1364
 
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 					try {
1375 1375
 						$sth = $Connection->db->prepare($query);
1376 1376
 						$sth->execute(array(':icao' => $icao));
1377
-					} catch(PDOException $e) {
1377
+					} catch (PDOException $e) {
1378 1378
 						return "error : ".$e->getMessage();
1379 1379
 					}
1380 1380
 				}
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 		return '';
1386 1386
         }
1387 1387
 
1388
-	public static function tle($filename,$tletype) {
1388
+	public static function tle($filename, $tletype) {
1389 1389
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1390 1390
 		global $tmp_dir, $globalTransaction;
1391 1391
 		//$Spotter = new Spotter();
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 			$Connection = new Connection();
1396 1396
 			$sth = $Connection->db->prepare($query);
1397 1397
                         $sth->execute(array(':source' => $filename));
1398
-                } catch(PDOException $e) {
1398
+                } catch (PDOException $e) {
1399 1399
                         return "error : ".$e->getMessage();
1400 1400
                 }
1401 1401
 		
@@ -1420,8 +1420,8 @@  discard block
 block discarded – undo
1420 1420
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1421 1421
 					try {
1422 1422
 						$sth = $Connection->db->prepare($query);
1423
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1424
-					} catch(PDOException $e) {
1423
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1424
+					} catch (PDOException $e) {
1425 1425
 						return "error : ".$e->getMessage();
1426 1426
 					}
1427 1427
 
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 			$Connection = new Connection();
1442 1442
 			$sth = $Connection->db->prepare($query);
1443 1443
 			$sth->execute(array(':source' => $filename));
1444
-		} catch(PDOException $e) {
1444
+		} catch (PDOException $e) {
1445 1445
 			return "error : ".$e->getMessage();
1446 1446
 		}
1447 1447
 		
@@ -1451,13 +1451,13 @@  discard block
 block discarded – undo
1451 1451
 			$i = 0;
1452 1452
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1453 1453
 			//$Connection->db->beginTransaction();
1454
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1454
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1455 1455
 			{
1456 1456
 				if ($i > 0 && $data[0] != '') {
1457 1457
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1458
-					$period = str_replace(',','',$data[14]);
1459
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1460
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1458
+					$period = str_replace(',', '', $data[14]);
1459
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1460
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1461 1461
 					else $launch_date = NULL;
1462 1462
 					$data = array_map(function($value) {
1463 1463
 						return trim($value) === '' ? null : $value;
@@ -1467,8 +1467,8 @@  discard block
 block discarded – undo
1467 1467
 					    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)';
1468 1468
 					try {
1469 1469
 						$sth = $Connection->db->prepare($query);
1470
-						$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));
1471
-					} catch(PDOException $e) {
1470
+						$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));
1471
+					} catch (PDOException $e) {
1472 1472
 						return "error : ".$e->getMessage();
1473 1473
 					}
1474 1474
 				}
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1509 1509
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1510 1510
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1511
-			'EST' => array('country' => 'Estonia','owner' => ''),
1511
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1512 1512
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1513 1513
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1514 1514
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1631,10 +1631,10 @@  discard block
 block discarded – undo
1631 1631
 			while (($data = fgets($handle, 1000)) !== FALSE)
1632 1632
 			{
1633 1633
 				$result = array();
1634
-				$result['cospar'] = trim(substr($data,0,11));
1635
-				$result['norad'] = trim(substr($data,13,6));
1636
-				$result['operational'] = trim(substr($data,21,1));
1637
-				$result['name'] = trim(substr($data,23,24));
1634
+				$result['cospar'] = trim(substr($data, 0, 11));
1635
+				$result['norad'] = trim(substr($data, 13, 6));
1636
+				$result['operational'] = trim(substr($data, 21, 1));
1637
+				$result['name'] = trim(substr($data, 23, 24));
1638 1638
 				/*
1639 1639
 				    * R/B(1) = Rocket body, first stage
1640 1640
 				    * R/B(2) = Rocket body, second stage
@@ -1646,20 +1646,20 @@  discard block
 block discarded – undo
1646 1646
 				    * An ampersand (&) indicates two or more objects are attached
1647 1647
 				*/
1648 1648
 				
1649
-				$owner_code = trim(substr($data,49,5));
1649
+				$owner_code = trim(substr($data, 49, 5));
1650 1650
 				if ($owner_code != 'TBD') {
1651 1651
 					$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1652 1652
 					$result['owner'] = $satcat_sources[$owner_code]['owner'];
1653
-					$result['launch_date'] = trim(substr($data,56,10));
1654
-					$launch_site_code = trim(substr($data,68,5));
1653
+					$result['launch_date'] = trim(substr($data, 56, 10));
1654
+					$launch_site_code = trim(substr($data, 68, 5));
1655 1655
 					$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1656
-					$result['lifetime'] = trim(substr($data,75,10));
1657
-					$result['period'] = trim(substr($data,87,7));
1658
-					$result['inclination'] = trim(substr($data,96,5));
1659
-					$result['apogee'] = trim(substr($data,103,6));
1660
-					$result['perigee'] = trim(substr($data,111,6));
1656
+					$result['lifetime'] = trim(substr($data, 75, 10));
1657
+					$result['period'] = trim(substr($data, 87, 7));
1658
+					$result['inclination'] = trim(substr($data, 96, 5));
1659
+					$result['apogee'] = trim(substr($data, 103, 6));
1660
+					$result['perigee'] = trim(substr($data, 111, 6));
1661 1661
 					//$result['radarcross'] = trim(substr($data,119,8));
1662
-					$result['status'] = trim(substr($data,129,3));
1662
+					$result['status'] = trim(substr($data, 129, 3));
1663 1663
 					//print_r($result);
1664 1664
 					$result = array_map(function($value) {
1665 1665
 						return trim($value) === '' ? null : $value;
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 							$sth = $Connection->db->prepare($query);
1673 1673
 							$sth->execute(array(':cospar' => $result['cospar']));
1674 1674
 							$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1675
-						} catch(PDOException $e) {
1675
+						} catch (PDOException $e) {
1676 1676
 							return "error : ".$e->getMessage();
1677 1677
 						}
1678 1678
 						if (empty($exist)) {
@@ -1684,10 +1684,10 @@  discard block
 block discarded – undo
1684 1684
 								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1685 1685
 								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1686 1686
 								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1687
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1687
+								    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1688 1688
 								    )
1689 1689
 								);
1690
-							} catch(PDOException $e) {
1690
+							} catch (PDOException $e) {
1691 1691
 								return "error : ".$e->getMessage();
1692 1692
 							}
1693 1693
 						} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1695,8 +1695,8 @@  discard block
 block discarded – undo
1695 1695
 							try {
1696 1696
 								$Connection = new Connection();
1697 1697
 								$sth = $Connection->db->prepare($query);
1698
-								$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1699
-							} catch(PDOException $e) {
1698
+								$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1699
+							} catch (PDOException $e) {
1700 1700
 								return "error : ".$e->getMessage();
1701 1701
 							}
1702 1702
 						}
@@ -1815,13 +1815,13 @@  discard block
 block discarded – undo
1815 1815
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1816 1816
 			{
1817 1817
 				$i++;
1818
-				if($i > 3 && count($row) > 2) {
1818
+				if ($i > 3 && count($row) > 2) {
1819 1819
 					$data = array_values(array_filter($row));
1820 1820
 					$cntdata = count($data);
1821 1821
 					if ($cntdata > 10) {
1822 1822
 						$value = $data[9];
1823 1823
 						
1824
-						for ($i =10;$i < $cntdata;$i++) {
1824
+						for ($i = 10; $i < $cntdata; $i++) {
1825 1825
 							$value .= ' '.$data[$i];
1826 1826
 						}
1827 1827
 						$data[9] = $value;
@@ -1831,8 +1831,8 @@  discard block
 block discarded – undo
1831 1831
 						$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)';
1832 1832
 						try {
1833 1833
 							$sth = $Connection->db->prepare($query);
1834
-							$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]));
1835
-						} catch(PDOException $e) {
1834
+							$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]));
1835
+						} catch (PDOException $e) {
1836 1836
 							return "error : ".$e->getMessage();
1837 1837
 						}
1838 1838
 					}
@@ -1853,7 +1853,7 @@  discard block
 block discarded – undo
1853 1853
 			$Connection = new Connection();
1854 1854
 			$sth = $Connection->db->prepare($query);
1855 1855
                         $sth->execute();
1856
-                } catch(PDOException $e) {
1856
+                } catch (PDOException $e) {
1857 1857
                         return "error : ".$e->getMessage();
1858 1858
                 }
1859 1859
 
@@ -1865,12 +1865,12 @@  discard block
 block discarded – undo
1865 1865
 			if ($globalTransaction) $Connection->db->beginTransaction();
1866 1866
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1867 1867
 			{
1868
-				if(count($row) > 1) {
1868
+				if (count($row) > 1) {
1869 1869
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1870 1870
 					try {
1871 1871
 						$sth = $Connection->db->prepare($query);
1872
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1873
-					} catch(PDOException $e) {
1872
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1873
+					} catch (PDOException $e) {
1874 1874
 						return "error : ".$e->getMessage();
1875 1875
 					}
1876 1876
 				}
@@ -1890,21 +1890,21 @@  discard block
 block discarded – undo
1890 1890
 			try {
1891 1891
 				$sth = $Connection->db->prepare($query);
1892 1892
                     		$sth->execute();
1893
-	                } catch(PDOException $e) {
1893
+	                } catch (PDOException $e) {
1894 1894
 				return "error : ".$e->getMessage();
1895 1895
 	                }
1896 1896
 	        }
1897 1897
 
1898 1898
 
1899
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1899
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1900 1900
 		else {
1901
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1901
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1902 1902
 			$query = "CREATE EXTENSION postgis";
1903
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1903
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1904 1904
 			try {
1905 1905
 				$sth = $Connection->db->prepare($query);
1906 1906
 				$sth->execute();
1907
-			} catch(PDOException $e) {
1907
+			} catch (PDOException $e) {
1908 1908
 				return "error : ".$e->getMessage();
1909 1909
 			}
1910 1910
 		}
@@ -1917,13 +1917,13 @@  discard block
 block discarded – undo
1917 1917
 		include_once('class.create_db.php');
1918 1918
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1919 1919
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1920
-		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1920
+		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5');
1921 1921
 		$error = '';
1922 1922
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
1923
-			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1923
+			$notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1924 1924
 			$notam_md5 = $notam_md5_file[0];
1925 1925
 			if (!update_db::check_notam_version($notam_md5)) {
1926
-				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1926
+				update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1927 1927
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
1928 1928
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1929 1929
 						if ($globalDebug) echo "Gunzip...";
@@ -1959,14 +1959,14 @@  discard block
 block discarded – undo
1959 1959
 			try {
1960 1960
 				$sth = $Connection->db->prepare($query);
1961 1961
             	        	$sth->execute();
1962
-	                } catch(PDOException $e) {
1962
+	                } catch (PDOException $e) {
1963 1963
     	                	echo "error : ".$e->getMessage();
1964 1964
 	                }
1965 1965
 		}
1966 1966
 		if ($globalDBdriver == 'mysql') {
1967
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1967
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1968 1968
 		} else {
1969
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1969
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1970 1970
 		}
1971 1971
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1972 1972
 		return $error;
@@ -1979,7 +1979,7 @@  discard block
 block discarded – undo
1979 1979
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1980 1980
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1981 1981
 //		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');
1982
-		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');
1982
+		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');
1983 1983
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1984 1984
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1985 1985
 		return $error;
@@ -2000,7 +2000,7 @@  discard block
 block discarded – undo
2000 2000
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2001 2001
 				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2002 2002
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2003
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2003
+					if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2004 2004
 				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2005 2005
 			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2006 2006
 		} else $error = "ZIP module not loaded but required for IVAO.";
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 		global $tmp_dir, $globalDebug;
2015 2015
 		$error = '';
2016 2016
 		if ($globalDebug) echo "Routes : Download...";
2017
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2017
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
2018 2018
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2019 2019
 			if ($globalDebug) echo "Gunzip...";
2020 2020
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -2030,7 +2030,7 @@  discard block
 block discarded – undo
2030 2030
 		global $tmp_dir, $globalDebug;
2031 2031
 		$error = '';
2032 2032
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
2033
-		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2033
+		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
2034 2034
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2035 2035
 			if ($globalDebug) echo "Gunzip...";
2036 2036
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -2046,7 +2046,7 @@  discard block
 block discarded – undo
2046 2046
 		global $tmp_dir, $globalDebug;
2047 2047
 		$error = '';
2048 2048
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
2049
-		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2049
+		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
2050 2050
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2051 2051
 			if ($globalDebug) echo "Gunzip...";
2052 2052
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2074,7 +2074,7 @@  discard block
 block discarded – undo
2074 2074
 */
2075 2075
 		if ($globalDebug) echo "Modes : Download...";
2076 2076
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2077
-		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2077
+		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2078 2078
 
2079 2079
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2080 2080
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
 	public static function update_ModeS_faa() {
2095 2095
 		global $tmp_dir, $globalDebug;
2096 2096
 		if ($globalDebug) echo "Modes FAA: Download...";
2097
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2097
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2098 2098
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2099 2099
 			if ($globalDebug) echo "Unzip...";
2100 2100
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2110,7 +2110,7 @@  discard block
 block discarded – undo
2110 2110
 	public static function update_ModeS_flarm() {
2111 2111
 		global $tmp_dir, $globalDebug;
2112 2112
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2113
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2113
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2114 2114
 		if (file_exists($tmp_dir.'data.fln')) {
2115 2115
 			if ($globalDebug) echo "Add to DB...";
2116 2116
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
 	public static function update_ModeS_ogn() {
2125 2125
 		global $tmp_dir, $globalDebug;
2126 2126
 		if ($globalDebug) echo "Modes OGN: Download...";
2127
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2127
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2128 2128
 		if (file_exists($tmp_dir.'ogn.csv')) {
2129 2129
 			if ($globalDebug) echo "Add to DB...";
2130 2130
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2139,201 +2139,201 @@  discard block
 block discarded – undo
2139 2139
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2140 2140
 		
2141 2141
 		if ($globalDebug) echo "Owner France: Download...";
2142
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2142
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2143 2143
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2144 2144
 			if ($globalDebug) echo "Add to DB...";
2145
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2145
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2146 2146
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2147 2147
 		if ($error != '') {
2148 2148
 			return $error;
2149 2149
 		} elseif ($globalDebug) echo "Done\n";
2150 2150
 		
2151 2151
 		if ($globalDebug) echo "Owner Ireland: Download...";
2152
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2152
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2153 2153
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2154 2154
 			if ($globalDebug) echo "Add to DB...";
2155
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2155
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2156 2156
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2157 2157
 		if ($error != '') {
2158 2158
 			return $error;
2159 2159
 		} elseif ($globalDebug) echo "Done\n";
2160 2160
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2161
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2161
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2162 2162
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2163 2163
 			if ($globalDebug) echo "Add to DB...";
2164
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2164
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2165 2165
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2166 2166
 		if ($error != '') {
2167 2167
 			return $error;
2168 2168
 		} elseif ($globalDebug) echo "Done\n";
2169 2169
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2170
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2170
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2171 2171
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2172 2172
 			if ($globalDebug) echo "Add to DB...";
2173
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2173
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2174 2174
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2175 2175
 		if ($error != '') {
2176 2176
 			return $error;
2177 2177
 		} elseif ($globalDebug) echo "Done\n";
2178 2178
 		if ($globalDebug) echo "Owner Australia: Download...";
2179
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2179
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2180 2180
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2181 2181
 			if ($globalDebug) echo "Add to DB...";
2182
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2182
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2183 2183
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2184 2184
 		if ($error != '') {
2185 2185
 			return $error;
2186 2186
 		} elseif ($globalDebug) echo "Done\n";
2187 2187
 		if ($globalDebug) echo "Owner Austria: Download...";
2188
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2188
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2189 2189
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2190 2190
 			if ($globalDebug) echo "Add to DB...";
2191
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2191
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2192 2192
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2193 2193
 		if ($error != '') {
2194 2194
 			return $error;
2195 2195
 		} elseif ($globalDebug) echo "Done\n";
2196 2196
 		if ($globalDebug) echo "Owner Chile: Download...";
2197
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2197
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2198 2198
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2199 2199
 			if ($globalDebug) echo "Add to DB...";
2200
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2200
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2201 2201
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2202 2202
 		if ($error != '') {
2203 2203
 			return $error;
2204 2204
 		} elseif ($globalDebug) echo "Done\n";
2205 2205
 		if ($globalDebug) echo "Owner Colombia: Download...";
2206
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2206
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2207 2207
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2208 2208
 			if ($globalDebug) echo "Add to DB...";
2209
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2209
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2210 2210
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2211 2211
 		if ($error != '') {
2212 2212
 			return $error;
2213 2213
 		} elseif ($globalDebug) echo "Done\n";
2214 2214
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2215
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2215
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2216 2216
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2217 2217
 			if ($globalDebug) echo "Add to DB...";
2218
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2218
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2219 2219
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2220 2220
 		if ($error != '') {
2221 2221
 			return $error;
2222 2222
 		} elseif ($globalDebug) echo "Done\n";
2223 2223
 		if ($globalDebug) echo "Owner Brazil: Download...";
2224
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2224
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2225 2225
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2226 2226
 			if ($globalDebug) echo "Add to DB...";
2227
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2227
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2228 2228
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2229 2229
 		if ($error != '') {
2230 2230
 			return $error;
2231 2231
 		} elseif ($globalDebug) echo "Done\n";
2232 2232
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2233
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2233
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2234 2234
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2235 2235
 			if ($globalDebug) echo "Add to DB...";
2236
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2236
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2237 2237
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2238 2238
 		if ($error != '') {
2239 2239
 			return $error;
2240 2240
 		} elseif ($globalDebug) echo "Done\n";
2241 2241
 		if ($globalDebug) echo "Owner Croatia: Download...";
2242
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2242
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2243 2243
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2244 2244
 			if ($globalDebug) echo "Add to DB...";
2245
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2245
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2246 2246
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2247 2247
 		if ($error != '') {
2248 2248
 			return $error;
2249 2249
 		} elseif ($globalDebug) echo "Done\n";
2250 2250
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2251
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2251
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2252 2252
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2253 2253
 			if ($globalDebug) echo "Add to DB...";
2254
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2254
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2255 2255
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2256 2256
 		if ($error != '') {
2257 2257
 			return $error;
2258 2258
 		} elseif ($globalDebug) echo "Done\n";
2259 2259
 		if ($globalDebug) echo "Owner Maldives: Download...";
2260
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2260
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2261 2261
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2262 2262
 			if ($globalDebug) echo "Add to DB...";
2263
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2263
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2264 2264
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2265 2265
 		if ($error != '') {
2266 2266
 			return $error;
2267 2267
 		} elseif ($globalDebug) echo "Done\n";
2268 2268
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2269
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2269
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2270 2270
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2271 2271
 			if ($globalDebug) echo "Add to DB...";
2272
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2272
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2273 2273
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2274 2274
 		if ($error != '') {
2275 2275
 			return $error;
2276 2276
 		} elseif ($globalDebug) echo "Done\n";
2277 2277
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2278
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2278
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2279 2279
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2280 2280
 			if ($globalDebug) echo "Add to DB...";
2281
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2281
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2282 2282
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2283 2283
 		if ($error != '') {
2284 2284
 			return $error;
2285 2285
 		} elseif ($globalDebug) echo "Done\n";
2286 2286
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2287
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2287
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2288 2288
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2289 2289
 			if ($globalDebug) echo "Add to DB...";
2290
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2290
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2291 2291
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2292 2292
 		if ($error != '') {
2293 2293
 			return $error;
2294 2294
 		} elseif ($globalDebug) echo "Done\n";
2295 2295
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2296
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2296
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2297 2297
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2298 2298
 			if ($globalDebug) echo "Add to DB...";
2299
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2299
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2300 2300
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2301 2301
 		if ($error != '') {
2302 2302
 			return $error;
2303 2303
 		} elseif ($globalDebug) echo "Done\n";
2304 2304
 		if ($globalDebug) echo "Owner Iceland: Download...";
2305
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2305
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2306 2306
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2307 2307
 			if ($globalDebug) echo "Add to DB...";
2308
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2308
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2309 2309
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2310 2310
 		if ($error != '') {
2311 2311
 			return $error;
2312 2312
 		} elseif ($globalDebug) echo "Done\n";
2313 2313
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2314
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2314
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2315 2315
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2316 2316
 			if ($globalDebug) echo "Add to DB...";
2317
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2317
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2318 2318
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2319 2319
 		if ($error != '') {
2320 2320
 			return $error;
2321 2321
 		} elseif ($globalDebug) echo "Done\n";
2322 2322
 		if ($globalMasterSource) {
2323 2323
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2324
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2324
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2325 2325
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2326 2326
 				if ($globalDebug) echo "Add to DB...";
2327
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2327
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2328 2328
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2329 2329
 			if ($error != '') {
2330 2330
 				return $error;
2331 2331
 			} elseif ($globalDebug) echo "Done\n";
2332 2332
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2333
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2333
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2334 2334
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2335 2335
 				if ($globalDebug) echo "Add to DB...";
2336
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2336
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2337 2337
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2338 2338
 			if ($error != '') {
2339 2339
 				return $error;
@@ -2346,7 +2346,7 @@  discard block
 block discarded – undo
2346 2346
 		global $tmp_dir, $globalDebug;
2347 2347
 		$error = '';
2348 2348
 		if ($globalDebug) echo "Translation : Download...";
2349
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2349
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2350 2350
 		if (file_exists($tmp_dir.'translation.zip')) {
2351 2351
 			if ($globalDebug) echo "Unzip...";
2352 2352
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2362,10 +2362,10 @@  discard block
 block discarded – undo
2362 2362
 	public static function update_translation_fam() {
2363 2363
 		global $tmp_dir, $globalDebug;
2364 2364
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2365
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2366
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2365
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2366
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5');
2367 2367
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2368
-			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2368
+			$translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2369 2369
 			$translation_md5 = $translation_md5_file[0];
2370 2370
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2371 2371
 				if ($globalDebug) echo "Gunzip...";
@@ -2382,10 +2382,10 @@  discard block
 block discarded – undo
2382 2382
 	public static function update_ModeS_fam() {
2383 2383
 		global $tmp_dir, $globalDebug;
2384 2384
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2385
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2386
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2385
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2386
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5');
2387 2387
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2388
-			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2388
+			$modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2389 2389
 			$modes_md5 = $modes_md5_file[0];
2390 2390
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2391 2391
 				if ($globalDebug) echo "Gunzip...";
@@ -2403,12 +2403,12 @@  discard block
 block discarded – undo
2403 2403
 	public static function update_airlines_fam() {
2404 2404
 		global $tmp_dir, $globalDebug;
2405 2405
 		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2406
-		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2406
+		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz');
2407 2407
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2408
-			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2408
+			$airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2409 2409
 			$airlines_md5 = $airlines_md5_file[0];
2410 2410
 			if (!update_db::check_airlines_version($airlines_md5)) {
2411
-				update_db::download('http://data.flightairmap.com/data/airliness.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2411
+				update_db::download('http://data.flightairmap.com/data/airliness.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5');
2412 2412
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2413 2413
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2414 2414
 						if ($globalDebug) echo "Gunzip...";
@@ -2432,14 +2432,14 @@  discard block
 block discarded – undo
2432 2432
 		global $tmp_dir, $globalDebug, $globalOwner;
2433 2433
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2434 2434
 		if ($globalOwner === TRUE) {
2435
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2436
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2435
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2436
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2437 2437
 		} else {
2438
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2439
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2438
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2439
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2440 2440
 		}
2441 2441
 		if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) {
2442
-			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2442
+			$owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2443 2443
 			$owners_md5 = $owners_md5_file[0];
2444 2444
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2445 2445
 				if ($globalDebug) echo "Gunzip...";
@@ -2456,10 +2456,10 @@  discard block
 block discarded – undo
2456 2456
 	public static function update_routes_fam() {
2457 2457
 		global $tmp_dir, $globalDebug;
2458 2458
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2459
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2460
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2459
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2460
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5');
2461 2461
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2462
-			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2462
+			$routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2463 2463
 			$routes_md5 = $routes_md5_file[0];
2464 2464
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2465 2465
 				if ($globalDebug) echo "Gunzip...";
@@ -2475,13 +2475,13 @@  discard block
 block discarded – undo
2475 2475
 	}
2476 2476
 	public static function update_marine_identity_fam() {
2477 2477
 		global $tmp_dir, $globalDebug;
2478
-		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2478
+		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2479 2479
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2480
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2480
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2481 2481
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2482 2482
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2483 2483
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2484
-				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2484
+				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2485 2485
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2486 2486
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2487 2487
 						if ($globalDebug) echo "Gunzip...";
@@ -2503,13 +2503,13 @@  discard block
 block discarded – undo
2503 2503
 
2504 2504
 	public static function update_satellite_fam() {
2505 2505
 		global $tmp_dir, $globalDebug;
2506
-		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2506
+		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2507 2507
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2508
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2508
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2509 2509
 			$satellite_md5 = $satellite_md5_file[0];
2510 2510
 			if (!update_db::check_satellite_version($satellite_md5)) {
2511 2511
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2512
-				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2512
+				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2513 2513
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2514 2514
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2515 2515
 						if ($globalDebug) echo "Gunzip...";
@@ -2531,7 +2531,7 @@  discard block
 block discarded – undo
2531 2531
 	public static function update_banned_fam() {
2532 2532
 		global $tmp_dir, $globalDebug;
2533 2533
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2534
-		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2534
+		update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2535 2535
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2536 2536
 			//if ($globalDebug) echo "Gunzip...";
2537 2537
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2550,18 +2550,18 @@  discard block
 block discarded – undo
2550 2550
 		$error = '';
2551 2551
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2552 2552
 		if ($globalDBdriver == 'mysql') {
2553
-			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2553
+			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2554 2554
 		} else {
2555
-			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2555
+			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2556 2556
 		}
2557 2557
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2558
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2558
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2559 2559
 			$airspace_md5 = $airspace_md5_file[0];
2560 2560
 			if (!update_db::check_airspace_version($airspace_md5)) {
2561 2561
 				if ($globalDBdriver == 'mysql') {
2562
-					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2562
+					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2563 2563
 				} else {
2564
-					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2564
+					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2565 2565
 				}
2566 2566
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2567 2567
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
@@ -2574,7 +2574,7 @@  discard block
 block discarded – undo
2574 2574
 							try {
2575 2575
 								$sth = $Connection->db->prepare($query);
2576 2576
 								$sth->execute();
2577
-							} catch(PDOException $e) {
2577
+							} catch (PDOException $e) {
2578 2578
 								return "error : ".$e->getMessage();
2579 2579
 							}
2580 2580
 						}
@@ -2594,16 +2594,16 @@  discard block
 block discarded – undo
2594 2594
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2595 2595
 		$error = '';
2596 2596
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2597
-		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2597
+		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2598 2598
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2599
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2599
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2600 2600
 			$geoid_md5 = $geoid_md5_file[0];
2601 2601
 			if (!update_db::check_geoid_version($geoid_md5)) {
2602
-				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2602
+				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2603 2603
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2604 2604
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2605 2605
 						if ($globalDebug) echo "Gunzip...";
2606
-						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2606
+						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2607 2607
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2608 2608
 							update_db::insert_geoid_version($geoid_md5);
2609 2609
 						}
@@ -2620,15 +2620,15 @@  discard block
 block discarded – undo
2620 2620
 	public static function update_tle() {
2621 2621
 		global $tmp_dir, $globalDebug;
2622 2622
 		if ($globalDebug) echo "Download TLE : Download...";
2623
-		$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',
2624
-		'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',
2625
-		'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');
2623
+		$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',
2624
+		'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',
2625
+		'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');
2626 2626
 		foreach ($alltle as $filename) {
2627 2627
 			if ($globalDebug) echo "downloading ".$filename.'...';
2628
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2628
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2629 2629
 			if (file_exists($tmp_dir.$filename)) {
2630 2630
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2631
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2631
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2632 2632
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2633 2633
 			if ($error != '') {
2634 2634
 				echo $error."\n";
@@ -2640,7 +2640,7 @@  discard block
 block discarded – undo
2640 2640
 	public static function update_ucsdb() {
2641 2641
 		global $tmp_dir, $globalDebug;
2642 2642
 		if ($globalDebug) echo "Download UCS DB : Download...";
2643
-		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');
2643
+		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');
2644 2644
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2645 2645
 			if ($globalDebug) echo "Add to DB...";
2646 2646
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
@@ -2654,7 +2654,7 @@  discard block
 block discarded – undo
2654 2654
 	public static function update_celestrak() {
2655 2655
 		global $tmp_dir, $globalDebug;
2656 2656
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2657
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2657
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2658 2658
 		if (file_exists($tmp_dir.'satcat.txt')) {
2659 2659
 			if ($globalDebug) echo "Add to DB...";
2660 2660
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2669,32 +2669,32 @@  discard block
 block discarded – undo
2669 2669
 		global $tmp_dir, $globalDebug;
2670 2670
 		$error = '';
2671 2671
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2672
-		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2672
+		update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2673 2673
 		if (file_exists($tmp_dir.'models.md5sum')) {
2674 2674
 			if ($globalDebug) echo "Check files...\n";
2675 2675
 			$newmodelsdb = array();
2676
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2677
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2676
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2677
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2678 2678
 					$model = trim($row[2]);
2679 2679
 					$newmodelsdb[$model] = trim($row[0]);
2680 2680
 				}
2681 2681
 			}
2682 2682
 			$modelsdb = array();
2683 2683
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2684
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2685
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2684
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2685
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2686 2686
 						$model = trim($row[2]);
2687 2687
 						$modelsdb[$model] = trim($row[0]);
2688 2688
 					}
2689 2689
 				}
2690 2690
 			}
2691
-			$diff = array_diff($newmodelsdb,$modelsdb);
2691
+			$diff = array_diff($newmodelsdb, $modelsdb);
2692 2692
 			foreach ($diff as $key => $value) {
2693 2693
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2694
-				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2694
+				update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2695 2695
 				
2696 2696
 			}
2697
-			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2697
+			update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2698 2698
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2699 2699
 		if ($error != '') {
2700 2700
 			return $error;
@@ -2706,32 +2706,32 @@  discard block
 block discarded – undo
2706 2706
 		global $tmp_dir, $globalDebug;
2707 2707
 		$error = '';
2708 2708
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2709
-		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2709
+		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2710 2710
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2711 2711
 			if ($globalDebug) echo "Check files...\n";
2712 2712
 			$newmodelsdb = array();
2713
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2714
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2713
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2714
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2715 2715
 					$model = trim($row[2]);
2716 2716
 					$newmodelsdb[$model] = trim($row[0]);
2717 2717
 				}
2718 2718
 			}
2719 2719
 			$modelsdb = array();
2720 2720
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2721
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2722
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2721
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2722
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2723 2723
 						$model = trim($row[2]);
2724 2724
 						$modelsdb[$model] = trim($row[0]);
2725 2725
 					}
2726 2726
 				}
2727 2727
 			}
2728
-			$diff = array_diff($newmodelsdb,$modelsdb);
2728
+			$diff = array_diff($newmodelsdb, $modelsdb);
2729 2729
 			foreach ($diff as $key => $value) {
2730 2730
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2731
-				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2731
+				update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2732 2732
 				
2733 2733
 			}
2734
-			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2734
+			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2735 2735
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2736 2736
 		if ($error != '') {
2737 2737
 			return $error;
@@ -2743,32 +2743,32 @@  discard block
 block discarded – undo
2743 2743
 		global $tmp_dir, $globalDebug;
2744 2744
 		$error = '';
2745 2745
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2746
-		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2746
+		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2747 2747
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2748 2748
 			if ($globalDebug) echo "Check files...\n";
2749 2749
 			$newmodelsdb = array();
2750
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2751
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2750
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2751
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2752 2752
 					$model = trim($row[2]);
2753 2753
 					$newmodelsdb[$model] = trim($row[0]);
2754 2754
 				}
2755 2755
 			}
2756 2756
 			$modelsdb = array();
2757 2757
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2758
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2759
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2758
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2759
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2760 2760
 						$model = trim($row[2]);
2761 2761
 						$modelsdb[$model] = trim($row[0]);
2762 2762
 					}
2763 2763
 				}
2764 2764
 			}
2765
-			$diff = array_diff($newmodelsdb,$modelsdb);
2765
+			$diff = array_diff($newmodelsdb, $modelsdb);
2766 2766
 			foreach ($diff as $key => $value) {
2767 2767
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2768
-				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2768
+				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2769 2769
 				
2770 2770
 			}
2771
-			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2771
+			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2772 2772
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2773 2773
 		if ($error != '') {
2774 2774
 			return $error;
@@ -2791,8 +2791,8 @@  discard block
 block discarded – undo
2791 2791
 		*/
2792 2792
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2793 2793
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2794
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2795
-		    $result = fread($fh,100000000);
2794
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2795
+		    $result = fread($fh, 100000000);
2796 2796
 		    //echo $result;
2797 2797
 		    //var_dump(str_get_html($result));
2798 2798
 		    //print_r(self::table2array($result));
@@ -2810,23 +2810,23 @@  discard block
 block discarded – undo
2810 2810
 			$Connection = new Connection();
2811 2811
 			$sth = $Connection->db->prepare($query);
2812 2812
                         $sth->execute();
2813
-                } catch(PDOException $e) {
2813
+                } catch (PDOException $e) {
2814 2814
                         return "error : ".$e->getMessage();
2815 2815
                 }
2816 2816
 
2817 2817
 		$error = '';
2818 2818
 		if ($globalDebug) echo "Notam : Download...";
2819
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2819
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2820 2820
 		if (file_exists($tmp_dir.'notam.rss')) {
2821
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2821
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2822 2822
 			foreach ($notams['channel']['item'] as $notam) {
2823
-				$title = explode(':',$notam['title']);
2823
+				$title = explode(':', $notam['title']);
2824 2824
 				$data['ref'] = trim($title[0]);
2825 2825
 				unset($title[0]);
2826
-				$data['title'] = trim(implode(':',$title));
2827
-				$description = strip_tags($notam['description'],'<pre>');
2828
-				preg_match(':^(.*?)<pre>:',$description,$match);
2829
-				$q = explode('/',$match[1]);
2826
+				$data['title'] = trim(implode(':', $title));
2827
+				$description = strip_tags($notam['description'], '<pre>');
2828
+				preg_match(':^(.*?)<pre>:', $description, $match);
2829
+				$q = explode('/', $match[1]);
2830 2830
 				$data['fir'] = $q[0];
2831 2831
 				$data['code'] = $q[1];
2832 2832
 				$ifrvfr = $q[2];
@@ -2842,30 +2842,30 @@  discard block
 block discarded – undo
2842 2842
 				$data['lower_limit'] = $q[5];
2843 2843
 				$data['upper_limit'] = $q[6];
2844 2844
 				$latlonrad = $q[7];
2845
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2846
-				$latitude = $Common->convertDec($las,'latitude');
2847
-				$longitude = $Common->convertDec($lns,'longitude');
2845
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2846
+				$latitude = $Common->convertDec($las, 'latitude');
2847
+				$longitude = $Common->convertDec($lns, 'longitude');
2848 2848
 				if ($lac == 'S') $latitude = '-'.$latitude;
2849 2849
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2850 2850
 				$data['center_latitude'] = $latitude;
2851 2851
 				$data['center_longitude'] = $longitude;
2852 2852
 				$data['radius'] = intval($radius);
2853 2853
 				
2854
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2854
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2855 2855
 				$data['text'] = $match[1];
2856
-				preg_match(':</pre>(.*?)$:',$description,$match);
2856
+				preg_match(':</pre>(.*?)$:', $description, $match);
2857 2857
 				$fromto = $match[1];
2858
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2858
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2859 2859
 				$fromall = trim($match[1]);
2860
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2860
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2861 2861
 				$from = trim($match[1]);
2862
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2863
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2862
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2863
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2864 2864
 				$toall = trim($match[1]);
2865
-				if (!preg_match(':Permanent:',$toall)) {
2866
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2865
+				if (!preg_match(':Permanent:', $toall)) {
2866
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2867 2867
 					$to = trim($match[1]);
2868
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2868
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2869 2869
 					$data['permanent'] = 0;
2870 2870
 				} else {
2871 2871
 				    $data['date_end'] = NULL;
@@ -2873,7 +2873,7 @@  discard block
 block discarded – undo
2873 2873
 				}
2874 2874
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2875 2875
 				$NOTAM = new NOTAM();
2876
-				$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']);
2876
+				$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']);
2877 2877
 				unset($data);
2878 2878
 			} 
2879 2879
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2896,16 +2896,16 @@  discard block
 block discarded – undo
2896 2896
 				$Connection = new Connection();
2897 2897
 				$sth = $Connection->db->prepare($query);
2898 2898
 				$sth->execute();
2899
-			} catch(PDOException $e) {
2899
+			} catch (PDOException $e) {
2900 2900
 				return "error : ".$e->getMessage();
2901 2901
 			}
2902 2902
 		}
2903 2903
 		$Common = new Common();
2904 2904
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2905
-		$airspace_json = json_decode($airspace_lst,true);
2905
+		$airspace_json = json_decode($airspace_lst, true);
2906 2906
 		foreach ($airspace_json['records'] as $airspace) {
2907 2907
 			if ($globalDebug) echo $airspace['name']."...\n";
2908
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2908
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2909 2909
 			if (file_exists($tmp_dir.$airspace['name'])) {
2910 2910
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2911 2911
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2927,7 +2927,7 @@  discard block
 block discarded – undo
2927 2927
 				$Connection = new Connection();
2928 2928
 				$sth = $Connection->db->prepare($query);
2929 2929
 				$sth->execute(array(':new' => $new, ':old' => $old));
2930
-			} catch(PDOException $e) {
2930
+			} catch (PDOException $e) {
2931 2931
 				return "error : ".$e->getMessage();
2932 2932
 			}
2933 2933
 		}
@@ -2944,7 +2944,7 @@  discard block
 block discarded – undo
2944 2944
 			$Connection = new Connection();
2945 2945
 			$sth = $Connection->db->prepare($query);
2946 2946
                         $sth->execute();
2947
-                } catch(PDOException $e) {
2947
+                } catch (PDOException $e) {
2948 2948
                         return "error : ".$e->getMessage();
2949 2949
                 }
2950 2950
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2959,7 +2959,7 @@  discard block
 block discarded – undo
2959 2959
 			$Connection = new Connection();
2960 2960
 			$sth = $Connection->db->prepare($query);
2961 2961
                         $sth->execute();
2962
-                } catch(PDOException $e) {
2962
+                } catch (PDOException $e) {
2963 2963
                         return "error : ".$e->getMessage();
2964 2964
                 }
2965 2965
 	}
@@ -2970,7 +2970,7 @@  discard block
 block discarded – undo
2970 2970
 			$Connection = new Connection();
2971 2971
 			$sth = $Connection->db->prepare($query);
2972 2972
                         $sth->execute(array(':version' => $version));
2973
-                } catch(PDOException $e) {
2973
+                } catch (PDOException $e) {
2974 2974
                         return "error : ".$e->getMessage();
2975 2975
                 }
2976 2976
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2984,7 +2984,7 @@  discard block
 block discarded – undo
2984 2984
 			$Connection = new Connection();
2985 2985
 			$sth = $Connection->db->prepare($query);
2986 2986
                         $sth->execute(array(':version' => $version));
2987
-                } catch(PDOException $e) {
2987
+                } catch (PDOException $e) {
2988 2988
                         return "error : ".$e->getMessage();
2989 2989
                 }
2990 2990
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2998,7 +2998,7 @@  discard block
 block discarded – undo
2998 2998
 			$Connection = new Connection();
2999 2999
 			$sth = $Connection->db->prepare($query);
3000 3000
 			$sth->execute(array(':version' => $version));
3001
-		} catch(PDOException $e) {
3001
+		} catch (PDOException $e) {
3002 3002
 			return "error : ".$e->getMessage();
3003 3003
 		}
3004 3004
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3012,7 +3012,7 @@  discard block
 block discarded – undo
3012 3012
 			$Connection = new Connection();
3013 3013
 			$sth = $Connection->db->prepare($query);
3014 3014
 			$sth->execute(array(':version' => $version));
3015
-		} catch(PDOException $e) {
3015
+		} catch (PDOException $e) {
3016 3016
 			return "error : ".$e->getMessage();
3017 3017
 		}
3018 3018
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3026,7 +3026,7 @@  discard block
 block discarded – undo
3026 3026
 			$Connection = new Connection();
3027 3027
 			$sth = $Connection->db->prepare($query);
3028 3028
 			$sth->execute(array(':version' => $version));
3029
-		} catch(PDOException $e) {
3029
+		} catch (PDOException $e) {
3030 3030
 			return "error : ".$e->getMessage();
3031 3031
 		}
3032 3032
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3040,7 +3040,7 @@  discard block
 block discarded – undo
3040 3040
 			$Connection = new Connection();
3041 3041
 			$sth = $Connection->db->prepare($query);
3042 3042
 			$sth->execute(array(':version' => $version));
3043
-		} catch(PDOException $e) {
3043
+		} catch (PDOException $e) {
3044 3044
 			return "error : ".$e->getMessage();
3045 3045
 		}
3046 3046
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3055,7 +3055,7 @@  discard block
 block discarded – undo
3055 3055
 			$Connection = new Connection();
3056 3056
 			$sth = $Connection->db->prepare($query);
3057 3057
 			$sth->execute(array(':version' => $version));
3058
-		} catch(PDOException $e) {
3058
+		} catch (PDOException $e) {
3059 3059
 			return "error : ".$e->getMessage();
3060 3060
 		}
3061 3061
 	}
@@ -3067,7 +3067,7 @@  discard block
 block discarded – undo
3067 3067
 			$Connection = new Connection();
3068 3068
 			$sth = $Connection->db->prepare($query);
3069 3069
 			$sth->execute(array(':version' => $version));
3070
-		} catch(PDOException $e) {
3070
+		} catch (PDOException $e) {
3071 3071
 			return "error : ".$e->getMessage();
3072 3072
 		}
3073 3073
 	}
@@ -3079,7 +3079,7 @@  discard block
 block discarded – undo
3079 3079
 			$Connection = new Connection();
3080 3080
 			$sth = $Connection->db->prepare($query);
3081 3081
 			$sth->execute(array(':version' => $version));
3082
-		} catch(PDOException $e) {
3082
+		} catch (PDOException $e) {
3083 3083
 			return "error : ".$e->getMessage();
3084 3084
 		}
3085 3085
 	}
@@ -3091,7 +3091,7 @@  discard block
 block discarded – undo
3091 3091
 			$Connection = new Connection();
3092 3092
 			$sth = $Connection->db->prepare($query);
3093 3093
                         $sth->execute(array(':version' => $version));
3094
-                } catch(PDOException $e) {
3094
+                } catch (PDOException $e) {
3095 3095
                         return "error : ".$e->getMessage();
3096 3096
                 }
3097 3097
 	}
@@ -3103,7 +3103,7 @@  discard block
 block discarded – undo
3103 3103
 			$Connection = new Connection();
3104 3104
 			$sth = $Connection->db->prepare($query);
3105 3105
 			$sth->execute(array(':version' => $version));
3106
-		} catch(PDOException $e) {
3106
+		} catch (PDOException $e) {
3107 3107
 			return "error : ".$e->getMessage();
3108 3108
 		}
3109 3109
 	}
@@ -3115,7 +3115,7 @@  discard block
 block discarded – undo
3115 3115
 			$Connection = new Connection();
3116 3116
 			$sth = $Connection->db->prepare($query);
3117 3117
 			$sth->execute(array(':version' => $version));
3118
-		} catch(PDOException $e) {
3118
+		} catch (PDOException $e) {
3119 3119
 			return "error : ".$e->getMessage();
3120 3120
 		}
3121 3121
 	}
@@ -3131,7 +3131,7 @@  discard block
 block discarded – undo
3131 3131
 			$Connection = new Connection();
3132 3132
 			$sth = $Connection->db->prepare($query);
3133 3133
                         $sth->execute();
3134
-                } catch(PDOException $e) {
3134
+                } catch (PDOException $e) {
3135 3135
                         return "error : ".$e->getMessage();
3136 3136
                 }
3137 3137
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3146,7 +3146,7 @@  discard block
 block discarded – undo
3146 3146
 			$Connection = new Connection();
3147 3147
 			$sth = $Connection->db->prepare($query);
3148 3148
                         $sth->execute();
3149
-                } catch(PDOException $e) {
3149
+                } catch (PDOException $e) {
3150 3150
                         return "error : ".$e->getMessage();
3151 3151
                 }
3152 3152
 	}
@@ -3162,7 +3162,7 @@  discard block
 block discarded – undo
3162 3162
 			$Connection = new Connection();
3163 3163
 			$sth = $Connection->db->prepare($query);
3164 3164
                         $sth->execute();
3165
-                } catch(PDOException $e) {
3165
+                } catch (PDOException $e) {
3166 3166
                         return "error : ".$e->getMessage();
3167 3167
                 }
3168 3168
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3177,7 +3177,7 @@  discard block
 block discarded – undo
3177 3177
 			$Connection = new Connection();
3178 3178
 			$sth = $Connection->db->prepare($query);
3179 3179
                         $sth->execute();
3180
-                } catch(PDOException $e) {
3180
+                } catch (PDOException $e) {
3181 3181
                         return "error : ".$e->getMessage();
3182 3182
                 }
3183 3183
 	}
@@ -3193,7 +3193,7 @@  discard block
 block discarded – undo
3193 3193
 			$Connection = new Connection();
3194 3194
 			$sth = $Connection->db->prepare($query);
3195 3195
                         $sth->execute();
3196
-                } catch(PDOException $e) {
3196
+                } catch (PDOException $e) {
3197 3197
                         return "error : ".$e->getMessage();
3198 3198
                 }
3199 3199
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3208,7 +3208,7 @@  discard block
 block discarded – undo
3208 3208
 			$Connection = new Connection();
3209 3209
 			$sth = $Connection->db->prepare($query);
3210 3210
                         $sth->execute();
3211
-                } catch(PDOException $e) {
3211
+                } catch (PDOException $e) {
3212 3212
                         return "error : ".$e->getMessage();
3213 3213
                 }
3214 3214
 	}
@@ -3224,7 +3224,7 @@  discard block
 block discarded – undo
3224 3224
 			$Connection = new Connection();
3225 3225
 			$sth = $Connection->db->prepare($query);
3226 3226
                         $sth->execute();
3227
-                } catch(PDOException $e) {
3227
+                } catch (PDOException $e) {
3228 3228
                         return "error : ".$e->getMessage();
3229 3229
                 }
3230 3230
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3239,7 +3239,7 @@  discard block
 block discarded – undo
3239 3239
 			$Connection = new Connection();
3240 3240
 			$sth = $Connection->db->prepare($query);
3241 3241
                         $sth->execute();
3242
-                } catch(PDOException $e) {
3242
+                } catch (PDOException $e) {
3243 3243
                         return "error : ".$e->getMessage();
3244 3244
                 }
3245 3245
 	}
@@ -3254,7 +3254,7 @@  discard block
 block discarded – undo
3254 3254
 			$Connection = new Connection();
3255 3255
 			$sth = $Connection->db->prepare($query);
3256 3256
                         $sth->execute();
3257
-                } catch(PDOException $e) {
3257
+                } catch (PDOException $e) {
3258 3258
                         return "error : ".$e->getMessage();
3259 3259
                 }
3260 3260
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3269,7 +3269,7 @@  discard block
 block discarded – undo
3269 3269
 			$Connection = new Connection();
3270 3270
 			$sth = $Connection->db->prepare($query);
3271 3271
 			$sth->execute();
3272
-		} catch(PDOException $e) {
3272
+		} catch (PDOException $e) {
3273 3273
 			return "error : ".$e->getMessage();
3274 3274
 		}
3275 3275
 	}
@@ -3285,7 +3285,7 @@  discard block
 block discarded – undo
3285 3285
 			$Connection = new Connection();
3286 3286
 			$sth = $Connection->db->prepare($query);
3287 3287
 			$sth->execute();
3288
-		} catch(PDOException $e) {
3288
+		} catch (PDOException $e) {
3289 3289
 			return "error : ".$e->getMessage();
3290 3290
 		}
3291 3291
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3300,7 +3300,7 @@  discard block
 block discarded – undo
3300 3300
 			$Connection = new Connection();
3301 3301
 			$sth = $Connection->db->prepare($query);
3302 3302
 			$sth->execute();
3303
-		} catch(PDOException $e) {
3303
+		} catch (PDOException $e) {
3304 3304
 			return "error : ".$e->getMessage();
3305 3305
 		}
3306 3306
 	}
@@ -3316,7 +3316,7 @@  discard block
 block discarded – undo
3316 3316
 			$Connection = new Connection();
3317 3317
 			$sth = $Connection->db->prepare($query);
3318 3318
 			$sth->execute();
3319
-		} catch(PDOException $e) {
3319
+		} catch (PDOException $e) {
3320 3320
 			return "error : ".$e->getMessage();
3321 3321
 		}
3322 3322
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3331,7 +3331,7 @@  discard block
 block discarded – undo
3331 3331
 			$Connection = new Connection();
3332 3332
 			$sth = $Connection->db->prepare($query);
3333 3333
 			$sth->execute();
3334
-		} catch(PDOException $e) {
3334
+		} catch (PDOException $e) {
3335 3335
 			return "error : ".$e->getMessage();
3336 3336
 		}
3337 3337
 	}
@@ -3347,7 +3347,7 @@  discard block
 block discarded – undo
3347 3347
 			$Connection = new Connection();
3348 3348
 			$sth = $Connection->db->prepare($query);
3349 3349
 			$sth->execute();
3350
-		} catch(PDOException $e) {
3350
+		} catch (PDOException $e) {
3351 3351
 			return "error : ".$e->getMessage();
3352 3352
 		}
3353 3353
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3362,7 +3362,7 @@  discard block
 block discarded – undo
3362 3362
 			$Connection = new Connection();
3363 3363
 			$sth = $Connection->db->prepare($query);
3364 3364
 			$sth->execute();
3365
-		} catch(PDOException $e) {
3365
+		} catch (PDOException $e) {
3366 3366
 			return "error : ".$e->getMessage();
3367 3367
 		}
3368 3368
 	}
@@ -3378,7 +3378,7 @@  discard block
 block discarded – undo
3378 3378
 			$Connection = new Connection();
3379 3379
 			$sth = $Connection->db->prepare($query);
3380 3380
 			$sth->execute();
3381
-		} catch(PDOException $e) {
3381
+		} catch (PDOException $e) {
3382 3382
 			return "error : ".$e->getMessage();
3383 3383
 		}
3384 3384
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3397,7 +3397,7 @@  discard block
 block discarded – undo
3397 3397
 			$Connection = new Connection();
3398 3398
 			$sth = $Connection->db->prepare($query);
3399 3399
 			$sth->execute();
3400
-		} catch(PDOException $e) {
3400
+		} catch (PDOException $e) {
3401 3401
 			return "error : ".$e->getMessage();
3402 3402
 		}
3403 3403
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3412,7 +3412,7 @@  discard block
 block discarded – undo
3412 3412
 			$Connection = new Connection();
3413 3413
 			$sth = $Connection->db->prepare($query);
3414 3414
 			$sth->execute();
3415
-		} catch(PDOException $e) {
3415
+		} catch (PDOException $e) {
3416 3416
 			return "error : ".$e->getMessage();
3417 3417
 		}
3418 3418
 	}
@@ -3424,7 +3424,7 @@  discard block
 block discarded – undo
3424 3424
 			$Connection = new Connection();
3425 3425
 			$sth = $Connection->db->prepare($query);
3426 3426
 			$sth->execute();
3427
-		} catch(PDOException $e) {
3427
+		} catch (PDOException $e) {
3428 3428
 			return "error : ".$e->getMessage();
3429 3429
 		}
3430 3430
 	}
@@ -3440,7 +3440,7 @@  discard block
 block discarded – undo
3440 3440
 			$Connection = new Connection();
3441 3441
 			$sth = $Connection->db->prepare($query);
3442 3442
                         $sth->execute();
3443
-                } catch(PDOException $e) {
3443
+                } catch (PDOException $e) {
3444 3444
                         return "error : ".$e->getMessage();
3445 3445
                 }
3446 3446
 	}
@@ -3455,7 +3455,7 @@  discard block
 block discarded – undo
3455 3455
 			$Connection = new Connection();
3456 3456
 			$sth = $Connection->db->prepare($query);
3457 3457
                         $sth->execute();
3458
-                } catch(PDOException $e) {
3458
+                } catch (PDOException $e) {
3459 3459
                         return "error : ".$e->getMessage();
3460 3460
                 }
3461 3461
 	}
Please login to merge, or discard this patch.
Braces   +1111 added lines, -385 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 27
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28 28
 		curl_setopt($ch, CURLOPT_TIMEOUT, 20);
29
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
29
+		if ($referer != '') {
30
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
31
+		}
30 32
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
31 33
 		curl_setopt($ch, CURLOPT_FILE, $fp);
32 34
 		curl_exec($ch);
@@ -37,12 +39,16 @@  discard block
 block discarded – undo
37 39
 	public static function gunzip($in_file,$out_file_name = '') {
38 40
 		//echo $in_file.' -> '.$out_file_name."\n";
39 41
 		$buffer_size = 4096; // read 4kb at a time
40
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
42
+		if ($out_file_name == '') {
43
+			$out_file_name = str_replace('.gz', '', $in_file);
44
+		}
41 45
 		if ($in_file != '' && file_exists($in_file)) {
42 46
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
45
-			else {
47
+			if (function_exists('gzopen')) {
48
+				$file = gzopen($in_file,'rb');
49
+			} elseif (function_exists('gzopen64')) {
50
+				$file = gzopen64($in_file,'rb');
51
+			} else {
46 52
 				echo 'gzopen not available';
47 53
 				die;
48 54
 			}
@@ -63,8 +69,12 @@  discard block
 block discarded – undo
63 69
 			if ($res === TRUE) {
64 70
 				$zip->extractTo($path);
65 71
 				$zip->close();
66
-			} else return false;
67
-		} else return false;
72
+			} else {
73
+				return false;
74
+			}
75
+		} else {
76
+			return false;
77
+		}
68 78
 	}
69 79
 	
70 80
 	public static function connect_sqlite($database) {
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 90
 		global $globalDebug, $globalTransaction;
81 91
 		//$query = 'TRUNCATE TABLE routes';
82
-		if ($globalDebug) echo " - Delete previous routes from DB -";
92
+		if ($globalDebug) {
93
+			echo " - Delete previous routes from DB -";
94
+		}
83 95
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
84 96
 		$Connection = new Connection();
85 97
 		try {
@@ -90,7 +102,9 @@  discard block
 block discarded – undo
90 102
                         return "error : ".$e->getMessage();
91 103
                 }
92 104
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
105
+    		if ($globalDebug) {
106
+    			echo " - Add routes to DB -";
107
+    		}
94 108
     		update_db::connect_sqlite($database_file);
95 109
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
96 110
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -105,15 +119,21 @@  discard block
 block discarded – undo
105 119
 		$Connection = new Connection();
106 120
 		$sth_dest = $Connection->db->prepare($query_dest);
107 121
 		try {
108
-			if ($globalTransaction) $Connection->db->beginTransaction();
122
+			if ($globalTransaction) {
123
+				$Connection->db->beginTransaction();
124
+			}
109 125
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 126
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111 127
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
112 128
 				$sth_dest->execute($query_dest_values);
113 129
             		}
114
-			if ($globalTransaction) $Connection->db->commit();
130
+			if ($globalTransaction) {
131
+				$Connection->db->commit();
132
+			}
115 133
 		} catch(PDOException $e) {
116
-			if ($globalTransaction) $Connection->db->rollBack(); 
134
+			if ($globalTransaction) {
135
+				$Connection->db->rollBack();
136
+			}
117 137
 			return "error : ".$e->getMessage();
118 138
 		}
119 139
                 return '';
@@ -121,7 +141,9 @@  discard block
 block discarded – undo
121 141
 	public static function retrieve_route_oneworld($database_file) {
122 142
 		global $globalDebug, $globalTransaction;
123 143
 		//$query = 'TRUNCATE TABLE routes';
124
-		if ($globalDebug) echo " - Delete previous routes from DB -";
144
+		if ($globalDebug) {
145
+			echo " - Delete previous routes from DB -";
146
+		}
125 147
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
126 148
 		$Connection = new Connection();
127 149
 		try {
@@ -132,14 +154,18 @@  discard block
 block discarded – undo
132 154
                         return "error : ".$e->getMessage();
133 155
                 }
134 156
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
157
+    		if ($globalDebug) {
158
+    			echo " - Add routes to DB -";
159
+    		}
136 160
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 161
 		$Spotter = new Spotter();
138 162
 		if ($fh = fopen($database_file,"r")) {
139 163
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
140 164
 			$Connection = new Connection();
141 165
 			$sth_dest = $Connection->db->prepare($query_dest);
142
-			if ($globalTransaction) $Connection->db->beginTransaction();
166
+			if ($globalTransaction) {
167
+				$Connection->db->beginTransaction();
168
+			}
143 169
 			while (!feof($fh)) {
144 170
 				$line = fgetcsv($fh,9999,',');
145 171
 				if ($line[0] != '') {
@@ -148,13 +174,17 @@  discard block
 block discarded – undo
148 174
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
149 175
 							$sth_dest->execute($query_dest_values);
150 176
 						} catch(PDOException $e) {
151
-							if ($globalTransaction) $Connection->db->rollBack(); 
177
+							if ($globalTransaction) {
178
+								$Connection->db->rollBack();
179
+							}
152 180
 							return "error : ".$e->getMessage();
153 181
 						}
154 182
 					}
155 183
 				}
156 184
 			}
157
-			if ($globalTransaction) $Connection->db->commit();
185
+			if ($globalTransaction) {
186
+				$Connection->db->commit();
187
+			}
158 188
 		}
159 189
                 return '';
160 190
 	}
@@ -162,7 +192,9 @@  discard block
 block discarded – undo
162 192
 	public static function retrieve_route_skyteam($database_file) {
163 193
 		global $globalDebug, $globalTransaction;
164 194
 		//$query = 'TRUNCATE TABLE routes';
165
-		if ($globalDebug) echo " - Delete previous routes from DB -";
195
+		if ($globalDebug) {
196
+			echo " - Delete previous routes from DB -";
197
+		}
166 198
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
167 199
 		$Connection = new Connection();
168 200
 		try {
@@ -173,7 +205,9 @@  discard block
 block discarded – undo
173 205
                         return "error : ".$e->getMessage();
174 206
                 }
175 207
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
208
+    		if ($globalDebug) {
209
+    			echo " - Add routes to DB -";
210
+    		}
177 211
 
178 212
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 213
 		$Spotter = new Spotter();
@@ -182,7 +216,9 @@  discard block
 block discarded – undo
182 216
 			$Connection = new Connection();
183 217
 			$sth_dest = $Connection->db->prepare($query_dest);
184 218
 			try {
185
-				if ($globalTransaction) $Connection->db->beginTransaction();
219
+				if ($globalTransaction) {
220
+					$Connection->db->beginTransaction();
221
+				}
186 222
 				while (!feof($fh)) {
187 223
 					$line = fgetcsv($fh,9999,',');
188 224
 					if ($line[0] != '') {
@@ -193,9 +229,13 @@  discard block
 block discarded – undo
193 229
 						}
194 230
 					}
195 231
 				}
196
-				if ($globalTransaction) $Connection->db->commit();
232
+				if ($globalTransaction) {
233
+					$Connection->db->commit();
234
+				}
197 235
 			} catch(PDOException $e) {
198
-				if ($globalTransaction) $Connection->db->rollBack(); 
236
+				if ($globalTransaction) {
237
+					$Connection->db->rollBack();
238
+				}
199 239
 				return "error : ".$e->getMessage();
200 240
 			}
201 241
 		}
@@ -238,11 +278,16 @@  discard block
 block discarded – undo
238 278
 		$sth_dest = $Connection->db->prepare($query_dest);
239 279
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 280
 		try {
241
-			if ($globalTransaction) $Connection->db->beginTransaction();
281
+			if ($globalTransaction) {
282
+				$Connection->db->beginTransaction();
283
+			}
242 284
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 285
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244
-				if ($values['UserString4'] == 'M') $type = 'military';
245
-				else $type = null;
286
+				if ($values['UserString4'] == 'M') {
287
+					$type = 'military';
288
+				} else {
289
+					$type = null;
290
+				}
246 291
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 292
 				$sth_dest->execute($query_dest_values);
248 293
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -250,7 +295,9 @@  discard block
 block discarded – undo
250 295
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 296
 				}
252 297
             		}
253
-			if ($globalTransaction) $Connection->db->commit();
298
+			if ($globalTransaction) {
299
+				$Connection->db->commit();
300
+			}
254 301
 		} catch(PDOException $e) {
255 302
 			return "error : ".$e->getMessage();
256 303
 		}
@@ -287,7 +334,9 @@  discard block
 block discarded – undo
287 334
 			$Connection = new Connection();
288 335
 			$sth_dest = $Connection->db->prepare($query_dest);
289 336
 			try {
290
-				if ($globalTransaction) $Connection->db->beginTransaction();
337
+				if ($globalTransaction) {
338
+					$Connection->db->beginTransaction();
339
+				}
291 340
             			while (!feof($fh)) {
292 341
             				$values = array();
293 342
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -298,7 +347,9 @@  discard block
 block discarded – undo
298 347
             				// Check if we can find ICAO, else set it to GLID
299 348
             				$aircraft_name_split = explode(' ',$aircraft_name);
300 349
             				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
350
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
351
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
352
+            				}
302 353
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303 354
             				$sth_search = $Connection->db->prepare($query_search);
304 355
 					try {
@@ -311,7 +362,9 @@  discard block
 block discarded – undo
311 362
 					} catch(PDOException $e) {
312 363
 						return "error : ".$e->getMessage();
313 364
 					}
314
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
365
+					if (!isset($values['ICAOTypeCode'])) {
366
+						$values['ICAOTypeCode'] = 'GLID';
367
+					}
315 368
 					// Add data to db
316 369
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 370
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -320,7 +373,9 @@  discard block
 block discarded – undo
320 373
 						$sth_dest->execute($query_dest_values);
321 374
 					}
322 375
 				}
323
-				if ($globalTransaction) $Connection->db->commit();
376
+				if ($globalTransaction) {
377
+					$Connection->db->commit();
378
+				}
324 379
 			} catch(PDOException $e) {
325 380
 				return "error : ".$e->getMessage();
326 381
 			}
@@ -356,7 +411,9 @@  discard block
 block discarded – undo
356 411
 			$Connection = new Connection();
357 412
 			$sth_dest = $Connection->db->prepare($query_dest);
358 413
 			try {
359
-				if ($globalTransaction) $Connection->db->beginTransaction();
414
+				if ($globalTransaction) {
415
+					$Connection->db->beginTransaction();
416
+				}
360 417
 				$tmp = fgetcsv($fh,9999,',',"'");
361 418
             			while (!feof($fh)) {
362 419
             				$line = fgetcsv($fh,9999,',',"'");
@@ -370,13 +427,17 @@  discard block
 block discarded – undo
370 427
             				// Check if we can find ICAO, else set it to GLID
371 428
             				$aircraft_name_split = explode(' ',$aircraft_name);
372 429
             				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
430
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
431
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
432
+            				}
374 433
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375 434
             				$sth_search = $Connection->db->prepare($query_search);
376 435
 					try {
377 436
                                     		$sth_search->execute();
378 437
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
438
+	            				if (isset($result['icao']) && $result['icao'] != '') {
439
+	            					$values['ICAOTypeCode'] = $result['icao'];
440
+	            				}
380 441
 					} catch(PDOException $e) {
381 442
 						return "error : ".$e->getMessage();
382 443
 					}
@@ -389,7 +450,9 @@  discard block
 block discarded – undo
389 450
 						$sth_dest->execute($query_dest_values);
390 451
 					}
391 452
 				}
392
-				if ($globalTransaction) $Connection->db->commit();
453
+				if ($globalTransaction) {
454
+					$Connection->db->commit();
455
+				}
393 456
 			} catch(PDOException $e) {
394 457
 				return "error : ".$e->getMessage();
395 458
 			}
@@ -428,7 +491,9 @@  discard block
 block discarded – undo
428 491
 			$sth_dest = $Connection->db->prepare($query_dest);
429 492
 			$sth_modes = $Connection->db->prepare($query_modes);
430 493
 			try {
431
-				if ($globalTransaction) $Connection->db->beginTransaction();
494
+				if ($globalTransaction) {
495
+					$Connection->db->beginTransaction();
496
+				}
432 497
 				$tmp = fgetcsv($fh,9999,',','"');
433 498
             			while (!feof($fh)) {
434 499
             				$line = fgetcsv($fh,9999,',','"');
@@ -438,16 +503,22 @@  discard block
 block discarded – undo
438 503
             				    $values['registration'] = $line[0];
439 504
             				    $values['base'] = $line[4];
440 505
             				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+            				    if ($line[6] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
510
+					    }
443 511
 					    $values['cancel'] = $line[7];
444 512
 					} elseif ($country == 'EI') {
445 513
 					    // TODO : add modeS & reg to aircraft_modes
446 514
             				    $values['registration'] = $line[0];
447 515
             				    $values['base'] = $line[3];
448 516
             				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
517
+            				    if ($line[1] == '') {
518
+            				    	$values['date_first_reg'] = null;
519
+            				    } else {
520
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
521
+					    }
451 522
 					    $values['cancel'] = '';
452 523
 					    $values['modes'] = $line[7];
453 524
 					    $values['icao'] = $line[8];
@@ -466,16 +537,22 @@  discard block
 block discarded – undo
466 537
             				    $values['registration'] = $line[3];
467 538
             				    $values['base'] = null;
468 539
             				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
540
+            				    if ($line[18] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
544
+					    }
471 545
 					    $values['cancel'] = '';
472 546
 					} elseif ($country == 'VH') {
473 547
 					    // TODO : add modeS & reg to aircraft_modes
474 548
             				    $values['registration'] = $line[0];
475 549
             				    $values['base'] = null;
476 550
             				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
551
+            				    if ($line[28] == '') {
552
+            				    	$values['date_first_reg'] = null;
553
+            				    } else {
554
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
555
+					    }
479 556
 
480 557
 					    $values['cancel'] = $line[39];
481 558
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -494,29 +571,41 @@  discard block
 block discarded – undo
494 571
             				    $values['registration'] = $line[0];
495 572
             				    $values['base'] = null;
496 573
             				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
574
+            				    if ($line[7] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
578
+					    }
499 579
 					    $values['cancel'] = '';
500 580
 					} elseif ($country == 'PP') {
501 581
             				    $values['registration'] = $line[0];
502 582
             				    $values['base'] = null;
503 583
             				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
584
+            				    if ($line[6] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
588
+					    }
506 589
 					    $values['cancel'] = $line[7];
507 590
 					} elseif ($country == 'E7') {
508 591
             				    $values['registration'] = $line[0];
509 592
             				    $values['base'] = null;
510 593
             				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
594
+            				    if ($line[5] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
598
+					    }
513 599
 					    $values['cancel'] = '';
514 600
 					} elseif ($country == '8Q') {
515 601
             				    $values['registration'] = $line[0];
516 602
             				    $values['base'] = null;
517 603
             				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
604
+            				    if ($line[7] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
608
+					    }
520 609
 					    $values['cancel'] = '';
521 610
 					} elseif ($country == 'ZK') {
522 611
             				    $values['registration'] = $line[0];
@@ -561,7 +650,9 @@  discard block
 block discarded – undo
561 650
 						$sth_modes->execute($query_modes_values);
562 651
 					}
563 652
 				}
564
-				if ($globalTransaction) $Connection->db->commit();
653
+				if ($globalTransaction) {
654
+					$Connection->db->commit();
655
+				}
565 656
 			} catch(PDOException $e) {
566 657
 				return "error : ".$e->getMessage();
567 658
 			}
@@ -697,25 +788,45 @@  discard block
 block discarded – undo
697 788
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
698 789
 		$Connection = new Connection();
699 790
 		$sth_dest = $Connection->db->prepare($query_dest);
700
-		if ($globalTransaction) $Connection->db->beginTransaction();
791
+		if ($globalTransaction) {
792
+			$Connection->db->beginTransaction();
793
+		}
701 794
   
702 795
 		$i = 0;
703 796
 		while($row = sparql_fetch_array($result))
704 797
 		{
705 798
 			if ($i >= 1) {
706 799
 			//print_r($row);
707
-			if (!isset($row['iata'])) $row['iata'] = '';
708
-			if (!isset($row['icao'])) $row['icao'] = '';
709
-			if (!isset($row['type'])) $row['type'] = '';
710
-			if (!isset($row['altitude'])) $row['altitude'] = '';
800
+			if (!isset($row['iata'])) {
801
+				$row['iata'] = '';
802
+			}
803
+			if (!isset($row['icao'])) {
804
+				$row['icao'] = '';
805
+			}
806
+			if (!isset($row['type'])) {
807
+				$row['type'] = '';
808
+			}
809
+			if (!isset($row['altitude'])) {
810
+				$row['altitude'] = '';
811
+			}
711 812
 			if (isset($row['city_bis'])) {
712 813
 				$row['city'] = $row['city_bis'];
713 814
 			}
714
-			if (!isset($row['city'])) $row['city'] = '';
715
-			if (!isset($row['country'])) $row['country'] = '';
716
-			if (!isset($row['homepage'])) $row['homepage'] = '';
717
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
718
-			if (!isset($row['name'])) continue;
815
+			if (!isset($row['city'])) {
816
+				$row['city'] = '';
817
+			}
818
+			if (!isset($row['country'])) {
819
+				$row['country'] = '';
820
+			}
821
+			if (!isset($row['homepage'])) {
822
+				$row['homepage'] = '';
823
+			}
824
+			if (!isset($row['wikipedia_page'])) {
825
+				$row['wikipedia_page'] = '';
826
+			}
827
+			if (!isset($row['name'])) {
828
+				continue;
829
+			}
719 830
 			if (!isset($row['image'])) {
720 831
 				$row['image'] = '';
721 832
 				$row['image_thumb'] = '';
@@ -771,7 +882,9 @@  discard block
 block discarded – undo
771 882
 
772 883
 			$i++;
773 884
 		}
774
-		if ($globalTransaction) $Connection->db->commit();
885
+		if ($globalTransaction) {
886
+			$Connection->db->commit();
887
+		}
775 888
 		/*
776 889
 		echo "Delete duplicate rows...\n";
777 890
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -814,7 +927,9 @@  discard block
 block discarded – undo
814 927
 		$delimiter = ',';
815 928
 		$out_file = $tmp_dir.'airports.csv';
816 929
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
817
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
930
+		if (!file_exists($out_file) || !is_readable($out_file)) {
931
+			return FALSE;
932
+		}
818 933
 		echo "Add data from ourairports.com...\n";
819 934
 
820 935
 		$header = NULL;
@@ -824,8 +939,9 @@  discard block
 block discarded – undo
824 939
 			//$Connection->db->beginTransaction();
825 940
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 941
 			{
827
-				if(!$header) $header = $row;
828
-				else {
942
+				if(!$header) {
943
+					$header = $row;
944
+				} else {
829 945
 					$data = array();
830 946
 					$data = array_combine($header, $row);
831 947
 					try {
@@ -866,7 +982,9 @@  discard block
 block discarded – undo
866 982
 		echo "Download data from another free database...\n";
867 983
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868 984
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
869
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
985
+		if (!file_exists($out_file) || !is_readable($out_file)) {
986
+			return FALSE;
987
+		}
870 988
 		update_db::unzip($out_file);
871 989
 		$header = NULL;
872 990
 		echo "Add data from another free database...\n";
@@ -877,8 +995,9 @@  discard block
 block discarded – undo
877 995
 			//$Connection->db->beginTransaction();
878 996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 997
 			{
880
-				if(!$header) $header = $row;
881
-				else {
998
+				if(!$header) {
999
+					$header = $row;
1000
+				} else {
882 1001
 					$data = $row;
883 1002
 
884 1003
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1047,7 +1166,9 @@  discard block
 block discarded – undo
1047 1166
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1048 1167
 		{
1049 1168
 			$i = 0;
1050
-			if ($globalTransaction) $Connection->db->beginTransaction();
1169
+			if ($globalTransaction) {
1170
+				$Connection->db->beginTransaction();
1171
+			}
1051 1172
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1052 1173
 			{
1053 1174
 				if ($i > 0) {
@@ -1060,7 +1181,9 @@  discard block
 block discarded – undo
1060 1181
 					}
1061 1182
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1062 1183
 					if (!empty($result_search)) {
1063
-						if ($globalDebug) echo '.';
1184
+						if ($globalDebug) {
1185
+							echo '.';
1186
+						}
1064 1187
 							//if ($globalDBdriver == 'mysql') {
1065 1188
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1066 1189
 							//} else {
@@ -1082,8 +1205,12 @@  discard block
 block discarded – undo
1082 1205
 						}
1083 1206
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1084 1207
 						if (!empty($result_search_mfr)) {
1085
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1086
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1208
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1209
+								$data[16] = $data[23];
1210
+							}
1211
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1212
+								$data[16] = $data[15];
1213
+							}
1087 1214
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1215
 							try {
1089 1216
 								$sthf = $Connection->db->prepare($queryf);
@@ -1094,7 +1221,9 @@  discard block
 block discarded – undo
1094 1221
 						}
1095 1222
 					}
1096 1223
 					if (strtotime($data[29]) > time()) {
1097
-						if ($globalDebug) echo 'i';
1224
+						if ($globalDebug) {
1225
+							echo 'i';
1226
+						}
1098 1227
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1228
 						try {
1100 1229
 							$sth = $Connection->db->prepare($query);
@@ -1105,13 +1234,19 @@  discard block
 block discarded – undo
1105 1234
 					}
1106 1235
 				}
1107 1236
 				if ($i % 90 == 0) {
1108
-					if ($globalTransaction) $Connection->db->commit();
1109
-					if ($globalTransaction) $Connection->db->beginTransaction();
1237
+					if ($globalTransaction) {
1238
+						$Connection->db->commit();
1239
+					}
1240
+					if ($globalTransaction) {
1241
+						$Connection->db->beginTransaction();
1242
+					}
1110 1243
 				}
1111 1244
 				$i++;
1112 1245
 			}
1113 1246
 			fclose($handle);
1114
-			if ($globalTransaction) $Connection->db->commit();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->commit();
1249
+			}
1115 1250
 		}
1116 1251
 		return '';
1117 1252
 	}
@@ -1131,11 +1266,15 @@  discard block
 block discarded – undo
1131 1266
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1132 1267
 		{
1133 1268
 			$i = 0;
1134
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1135 1272
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1136 1273
 			{
1137 1274
 				if ($i > 0) {
1138
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1275
+					if ($data[1] == 'NULL') {
1276
+						$data[1] = $data[0];
1277
+					}
1139 1278
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1279
 					try {
1141 1280
 						$sth = $Connection->db->prepare($query);
@@ -1147,7 +1286,9 @@  discard block
 block discarded – undo
1147 1286
 				$i++;
1148 1287
 			}
1149 1288
 			fclose($handle);
1150
-			if ($globalTransaction) $Connection->db->commit();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->commit();
1291
+			}
1151 1292
 		}
1152 1293
 		return '';
1153 1294
 	}
@@ -1173,11 +1314,15 @@  discard block
 block discarded – undo
1173 1314
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1174 1315
 		{
1175 1316
 			$i = 0;
1176
-			if ($globalTransaction) $Connection->db->beginTransaction();
1317
+			if ($globalTransaction) {
1318
+				$Connection->db->beginTransaction();
1319
+			}
1177 1320
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1178 1321
 			{
1179 1322
 				if ($i > 0) {
1180
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1323
+					if ($data[1] == 'NULL') {
1324
+						$data[1] = $data[0];
1325
+					}
1181 1326
 					$query = 'INSERT INTO airlines (name,alias,iata,icao,callsign,country,active,type,home,wikipedia_link,alliance,ban_eu) VALUES (:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1182 1327
 					try {
1183 1328
 						$sth = $Connection->db->prepare($query);
@@ -1189,7 +1334,9 @@  discard block
 block discarded – undo
1189 1334
 				$i++;
1190 1335
 			}
1191 1336
 			fclose($handle);
1192
-			if ($globalTransaction) $Connection->db->commit();
1337
+			if ($globalTransaction) {
1338
+				$Connection->db->commit();
1339
+			}
1193 1340
 		}
1194 1341
 		$query = "UNLOCK TABLES";
1195 1342
 		try {
@@ -1217,7 +1364,9 @@  discard block
 block discarded – undo
1217 1364
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1218 1365
 		{
1219 1366
 			$i = 0;
1220
-			if ($globalTransaction) $Connection->db->beginTransaction();
1367
+			if ($globalTransaction) {
1368
+				$Connection->db->beginTransaction();
1369
+			}
1221 1370
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1222 1371
 			{
1223 1372
 				if ($i > 0) {
@@ -1233,7 +1382,9 @@  discard block
 block discarded – undo
1233 1382
 				$i++;
1234 1383
 			}
1235 1384
 			fclose($handle);
1236
-			if ($globalTransaction) $Connection->db->commit();
1385
+			if ($globalTransaction) {
1386
+				$Connection->db->commit();
1387
+			}
1237 1388
 		}
1238 1389
 		return '';
1239 1390
         }
@@ -1253,7 +1404,9 @@  discard block
 block discarded – undo
1253 1404
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1254 1405
 		{
1255 1406
 			$i = 0;
1256
-			if ($globalTransaction) $Connection->db->beginTransaction();
1407
+			if ($globalTransaction) {
1408
+				$Connection->db->beginTransaction();
1409
+			}
1257 1410
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1258 1411
 			{
1259 1412
 				if ($i > 0) {
@@ -1262,13 +1415,17 @@  discard block
 block discarded – undo
1262 1415
 						$sth = $Connection->db->prepare($query);
1263 1416
 						$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'));
1264 1417
 					} catch(PDOException $e) {
1265
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1418
+						if ($globalDebug) {
1419
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1420
+						}
1266 1421
 					}
1267 1422
 				}
1268 1423
 				$i++;
1269 1424
 			}
1270 1425
 			fclose($handle);
1271
-			if ($globalTransaction) $Connection->db->commit();
1426
+			if ($globalTransaction) {
1427
+				$Connection->db->commit();
1428
+			}
1272 1429
 		}
1273 1430
 		return '';
1274 1431
         }
@@ -1293,7 +1450,9 @@  discard block
 block discarded – undo
1293 1450
 			$i = 0;
1294 1451
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1295 1452
 			//$Connection->db->beginTransaction();
1296
-			if ($globalTransaction) $Connection->db->beginTransaction();
1453
+			if ($globalTransaction) {
1454
+				$Connection->db->beginTransaction();
1455
+			}
1297 1456
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1298 1457
 			{
1299 1458
 				if ($i > 0) {
@@ -1309,7 +1468,9 @@  discard block
 block discarded – undo
1309 1468
 				$i++;
1310 1469
 			}
1311 1470
 			fclose($handle);
1312
-			if ($globalTransaction) $Connection->db->commit();
1471
+			if ($globalTransaction) {
1472
+				$Connection->db->commit();
1473
+			}
1313 1474
 		}
1314 1475
 		return '';
1315 1476
         }
@@ -1329,7 +1490,9 @@  discard block
 block discarded – undo
1329 1490
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1330 1491
 		{
1331 1492
 			$i = 0;
1332
-			if ($globalTransaction) $Connection->db->beginTransaction();
1493
+			if ($globalTransaction) {
1494
+				$Connection->db->beginTransaction();
1495
+			}
1333 1496
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1334 1497
 			{
1335 1498
 				if ($i > 0) {
@@ -1346,7 +1509,9 @@  discard block
 block discarded – undo
1346 1509
 				$i++;
1347 1510
 			}
1348 1511
 			fclose($handle);
1349
-			if ($globalTransaction) $Connection->db->commit();
1512
+			if ($globalTransaction) {
1513
+				$Connection->db->commit();
1514
+			}
1350 1515
 		}
1351 1516
 		return '';
1352 1517
 	}
@@ -1365,7 +1530,9 @@  discard block
 block discarded – undo
1365 1530
 		$Connection = new Connection();
1366 1531
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1367 1532
 		{
1368
-			if ($globalTransaction) $Connection->db->beginTransaction();
1533
+			if ($globalTransaction) {
1534
+				$Connection->db->beginTransaction();
1535
+			}
1369 1536
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1370 1537
 			{
1371 1538
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1380,7 +1547,9 @@  discard block
 block discarded – undo
1380 1547
 				}
1381 1548
 			}
1382 1549
 			fclose($handle);
1383
-			if ($globalTransaction) $Connection->db->commit();
1550
+			if ($globalTransaction) {
1551
+				$Connection->db->commit();
1552
+			}
1384 1553
 		}
1385 1554
 		return '';
1386 1555
         }
@@ -1456,9 +1625,14 @@  discard block
 block discarded – undo
1456 1625
 				if ($i > 0 && $data[0] != '') {
1457 1626
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1458 1627
 					$period = str_replace(',','',$data[14]);
1459
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1460
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1461
-					else $launch_date = NULL;
1628
+					if (!empty($period) && strpos($period,'days')) {
1629
+						$period = str_replace(' days','',$period)*24*60;
1630
+					}
1631
+					if ($data[18] != '') {
1632
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1633
+					} else {
1634
+						$launch_date = NULL;
1635
+					}
1462 1636
 					$data = array_map(function($value) {
1463 1637
 						return trim($value) === '' ? null : $value;
1464 1638
 					}, $data);
@@ -1811,7 +1985,9 @@  discard block
 block discarded – undo
1811 1985
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1812 1986
 		{
1813 1987
 			$i = 0;
1814
-			if ($globalTransaction) $Connection->db->beginTransaction();
1988
+			if ($globalTransaction) {
1989
+				$Connection->db->beginTransaction();
1990
+			}
1815 1991
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1816 1992
 			{
1817 1993
 				$i++;
@@ -1839,7 +2015,9 @@  discard block
 block discarded – undo
1839 2015
 				}
1840 2016
 			}
1841 2017
 			fclose($handle);
1842
-			if ($globalTransaction) $Connection->db->commit();
2018
+			if ($globalTransaction) {
2019
+				$Connection->db->commit();
2020
+			}
1843 2021
 		}
1844 2022
 		return '';
1845 2023
         }
@@ -1862,7 +2040,9 @@  discard block
 block discarded – undo
1862 2040
 		$Connection = new Connection();
1863 2041
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1864 2042
 		{
1865
-			if ($globalTransaction) $Connection->db->beginTransaction();
2043
+			if ($globalTransaction) {
2044
+				$Connection->db->beginTransaction();
2045
+			}
1866 2046
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1867 2047
 			{
1868 2048
 				if(count($row) > 1) {
@@ -1876,7 +2056,9 @@  discard block
 block discarded – undo
1876 2056
 				}
1877 2057
 			}
1878 2058
 			fclose($handle);
1879
-			if ($globalTransaction) $Connection->db->commit();
2059
+			if ($globalTransaction) {
2060
+				$Connection->db->commit();
2061
+			}
1880 2062
 		}
1881 2063
 		return '';
1882 2064
         }
@@ -1896,8 +2078,9 @@  discard block
 block discarded – undo
1896 2078
 	        }
1897 2079
 
1898 2080
 
1899
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1900
-		else {
2081
+		if ($globalDBdriver == 'mysql') {
2082
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2083
+		} else {
1901 2084
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1902 2085
 			$query = "CREATE EXTENSION postgis";
1903 2086
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1916,7 +2099,9 @@  discard block
 block discarded – undo
1916 2099
 		global $tmp_dir, $globalDebug;
1917 2100
 		include_once('class.create_db.php');
1918 2101
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1919
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2102
+		if ($globalDebug) {
2103
+			echo "NOTAM from FlightAirMap website : Download...";
2104
+		}
1920 2105
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1921 2106
 		$error = '';
1922 2107
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -1926,20 +2111,34 @@  discard block
 block discarded – undo
1926 2111
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1927 2112
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
1928 2113
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1929
-						if ($globalDebug) echo "Gunzip...";
2114
+						if ($globalDebug) {
2115
+							echo "Gunzip...";
2116
+						}
1930 2117
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
1931
-						if ($globalDebug) echo "Add to DB...";
2118
+						if ($globalDebug) {
2119
+							echo "Add to DB...";
2120
+						}
1932 2121
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
1933 2122
 						$NOTAM = new NOTAM();
1934 2123
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1935 2124
 						update_db::insert_notam_version($notam_md5);
1936
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
1937
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1938
-			} elseif ($globalDebug) echo "No new version.";
1939
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2125
+					} else {
2126
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2127
+					}
2128
+				} else {
2129
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2130
+				}
2131
+			} elseif ($globalDebug) {
2132
+				echo "No new version.";
2133
+			}
2134
+		} else {
2135
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2136
+		}
1940 2137
 		if ($error != '') {
1941 2138
 			return $error;
1942
-		} elseif ($globalDebug) echo "Done\n";
2139
+		} elseif ($globalDebug) {
2140
+			echo "Done\n";
2141
+		}
1943 2142
 		return '';
1944 2143
 	}
1945 2144
 
@@ -1994,68 +2193,114 @@  discard block
 block discarded – undo
1994 2193
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1995 2194
 		if (extension_loaded('zip')) {
1996 2195
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1997
-				if ($globalDebug) echo "Unzip...";
2196
+				if ($globalDebug) {
2197
+					echo "Unzip...";
2198
+				}
1998 2199
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1999
-				if ($globalDebug) echo "Add to DB...";
2200
+				if ($globalDebug) {
2201
+					echo "Add to DB...";
2202
+				}
2000 2203
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2001
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2204
+				if ($globalDebug) {
2205
+					echo "Copy airlines logos to airlines images directory...";
2206
+				}
2002 2207
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2003
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2004
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2005
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2006
-		} else $error = "ZIP module not loaded but required for IVAO.";
2208
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2209
+						$error = "Failed to copy airlines logo.";
2210
+					}
2211
+				} else {
2212
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2213
+				}
2214
+			} else {
2215
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2216
+			}
2217
+		} else {
2218
+			$error = "ZIP module not loaded but required for IVAO.";
2219
+		}
2007 2220
 		if ($error != '') {
2008 2221
 			return $error;
2009
-		} elseif ($globalDebug) echo "Done\n";
2222
+		} elseif ($globalDebug) {
2223
+			echo "Done\n";
2224
+		}
2010 2225
 		return '';
2011 2226
 	}
2012 2227
 
2013 2228
 	public static function update_routes() {
2014 2229
 		global $tmp_dir, $globalDebug;
2015 2230
 		$error = '';
2016
-		if ($globalDebug) echo "Routes : Download...";
2231
+		if ($globalDebug) {
2232
+			echo "Routes : Download...";
2233
+		}
2017 2234
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2018 2235
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2019
-			if ($globalDebug) echo "Gunzip...";
2236
+			if ($globalDebug) {
2237
+				echo "Gunzip...";
2238
+			}
2020 2239
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2021
-			if ($globalDebug) echo "Add to DB...";
2240
+			if ($globalDebug) {
2241
+				echo "Add to DB...";
2242
+			}
2022 2243
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2023
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2244
+		} else {
2245
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2246
+		}
2024 2247
 		if ($error != '') {
2025 2248
 			return $error;
2026
-		} elseif ($globalDebug) echo "Done\n";
2249
+		} elseif ($globalDebug) {
2250
+			echo "Done\n";
2251
+		}
2027 2252
 		return '';
2028 2253
 	}
2029 2254
 	public static function update_oneworld() {
2030 2255
 		global $tmp_dir, $globalDebug;
2031 2256
 		$error = '';
2032
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2257
+		if ($globalDebug) {
2258
+			echo "Schedules Oneworld : Download...";
2259
+		}
2033 2260
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2034 2261
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2035
-			if ($globalDebug) echo "Gunzip...";
2262
+			if ($globalDebug) {
2263
+				echo "Gunzip...";
2264
+			}
2036 2265
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2037
-			if ($globalDebug) echo "Add to DB...";
2266
+			if ($globalDebug) {
2267
+				echo "Add to DB...";
2268
+			}
2038 2269
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2039
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2270
+		} else {
2271
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2272
+		}
2040 2273
 		if ($error != '') {
2041 2274
 			return $error;
2042
-		} elseif ($globalDebug) echo "Done\n";
2275
+		} elseif ($globalDebug) {
2276
+			echo "Done\n";
2277
+		}
2043 2278
 		return '';
2044 2279
 	}
2045 2280
 	public static function update_skyteam() {
2046 2281
 		global $tmp_dir, $globalDebug;
2047 2282
 		$error = '';
2048
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2283
+		if ($globalDebug) {
2284
+			echo "Schedules Skyteam : Download...";
2285
+		}
2049 2286
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2050 2287
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2051
-			if ($globalDebug) echo "Gunzip...";
2288
+			if ($globalDebug) {
2289
+				echo "Gunzip...";
2290
+			}
2052 2291
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2053
-			if ($globalDebug) echo "Add to DB...";
2292
+			if ($globalDebug) {
2293
+				echo "Add to DB...";
2294
+			}
2054 2295
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2055
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2296
+		} else {
2297
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2298
+		}
2056 2299
 		if ($error != '') {
2057 2300
 			return $error;
2058
-		} elseif ($globalDebug) echo "Done\n";
2301
+		} elseif ($globalDebug) {
2302
+			echo "Done\n";
2303
+		}
2059 2304
 		return '';
2060 2305
 	}
2061 2306
 	public static function update_ModeS() {
@@ -2072,337 +2317,587 @@  discard block
 block discarded – undo
2072 2317
 			exit;
2073 2318
 		} elseif ($globalDebug) echo "Done\n";
2074 2319
 */
2075
-		if ($globalDebug) echo "Modes : Download...";
2076
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2320
+		if ($globalDebug) {
2321
+			echo "Modes : Download...";
2322
+		}
2323
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2077 2324
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2078 2325
 
2079 2326
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2080 2327
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2081
-			if ($globalDebug) echo "Unzip...";
2082
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2328
+			if ($globalDebug) {
2329
+				echo "Unzip...";
2330
+			}
2331
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2083 2332
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2084
-			if ($globalDebug) echo "Add to DB...";
2333
+			if ($globalDebug) {
2334
+				echo "Add to DB...";
2335
+			}
2085 2336
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2086 2337
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2087
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2338
+		} else {
2339
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2340
+		}
2088 2341
 		if ($error != '') {
2089 2342
 			return $error;
2090
-		} elseif ($globalDebug) echo "Done\n";
2343
+		} elseif ($globalDebug) {
2344
+			echo "Done\n";
2345
+		}
2091 2346
 		return '';
2092 2347
 	}
2093 2348
 
2094 2349
 	public static function update_ModeS_faa() {
2095 2350
 		global $tmp_dir, $globalDebug;
2096
-		if ($globalDebug) echo "Modes FAA: Download...";
2351
+		if ($globalDebug) {
2352
+			echo "Modes FAA: Download...";
2353
+		}
2097 2354
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2098 2355
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2099
-			if ($globalDebug) echo "Unzip...";
2356
+			if ($globalDebug) {
2357
+				echo "Unzip...";
2358
+			}
2100 2359
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2101
-			if ($globalDebug) echo "Add to DB...";
2360
+			if ($globalDebug) {
2361
+				echo "Add to DB...";
2362
+			}
2102 2363
 			$error = update_db::modes_faa();
2103
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2364
+		} else {
2365
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2366
+		}
2104 2367
 		if ($error != '') {
2105 2368
 			return $error;
2106
-		} elseif ($globalDebug) echo "Done\n";
2369
+		} elseif ($globalDebug) {
2370
+			echo "Done\n";
2371
+		}
2107 2372
 		return '';
2108 2373
 	}
2109 2374
 
2110 2375
 	public static function update_ModeS_flarm() {
2111 2376
 		global $tmp_dir, $globalDebug;
2112
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2377
+		if ($globalDebug) {
2378
+			echo "Modes Flarmnet: Download...";
2379
+		}
2113 2380
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2114 2381
 		if (file_exists($tmp_dir.'data.fln')) {
2115
-			if ($globalDebug) echo "Add to DB...";
2382
+			if ($globalDebug) {
2383
+				echo "Add to DB...";
2384
+			}
2116 2385
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2117
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2386
+		} else {
2387
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2388
+		}
2118 2389
 		if ($error != '') {
2119 2390
 			return $error;
2120
-		} elseif ($globalDebug) echo "Done\n";
2391
+		} elseif ($globalDebug) {
2392
+			echo "Done\n";
2393
+		}
2121 2394
 		return '';
2122 2395
 	}
2123 2396
 
2124 2397
 	public static function update_ModeS_ogn() {
2125 2398
 		global $tmp_dir, $globalDebug;
2126
-		if ($globalDebug) echo "Modes OGN: Download...";
2399
+		if ($globalDebug) {
2400
+			echo "Modes OGN: Download...";
2401
+		}
2127 2402
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2128 2403
 		if (file_exists($tmp_dir.'ogn.csv')) {
2129
-			if ($globalDebug) echo "Add to DB...";
2404
+			if ($globalDebug) {
2405
+				echo "Add to DB...";
2406
+			}
2130 2407
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2131
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2408
+		} else {
2409
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2410
+		}
2132 2411
 		if ($error != '') {
2133 2412
 			return $error;
2134
-		} elseif ($globalDebug) echo "Done\n";
2413
+		} elseif ($globalDebug) {
2414
+			echo "Done\n";
2415
+		}
2135 2416
 		return '';
2136 2417
 	}
2137 2418
 
2138 2419
 	public static function update_owner() {
2139 2420
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2140 2421
 		
2141
-		if ($globalDebug) echo "Owner France: Download...";
2422
+		if ($globalDebug) {
2423
+			echo "Owner France: Download...";
2424
+		}
2142 2425
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2143 2426
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2144
-			if ($globalDebug) echo "Add to DB...";
2427
+			if ($globalDebug) {
2428
+				echo "Add to DB...";
2429
+			}
2145 2430
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2146
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2431
+		} else {
2432
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2433
+		}
2147 2434
 		if ($error != '') {
2148 2435
 			return $error;
2149
-		} elseif ($globalDebug) echo "Done\n";
2436
+		} elseif ($globalDebug) {
2437
+			echo "Done\n";
2438
+		}
2150 2439
 		
2151
-		if ($globalDebug) echo "Owner Ireland: Download...";
2440
+		if ($globalDebug) {
2441
+			echo "Owner Ireland: Download...";
2442
+		}
2152 2443
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2153 2444
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2154
-			if ($globalDebug) echo "Add to DB...";
2445
+			if ($globalDebug) {
2446
+				echo "Add to DB...";
2447
+			}
2155 2448
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2156
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2449
+		} else {
2450
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2451
+		}
2157 2452
 		if ($error != '') {
2158 2453
 			return $error;
2159
-		} elseif ($globalDebug) echo "Done\n";
2160
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2454
+		} elseif ($globalDebug) {
2455
+			echo "Done\n";
2456
+		}
2457
+		if ($globalDebug) {
2458
+			echo "Owner Switzerland: Download...";
2459
+		}
2161 2460
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2162 2461
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2163
-			if ($globalDebug) echo "Add to DB...";
2462
+			if ($globalDebug) {
2463
+				echo "Add to DB...";
2464
+			}
2164 2465
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2165
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2466
+		} else {
2467
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2468
+		}
2166 2469
 		if ($error != '') {
2167 2470
 			return $error;
2168
-		} elseif ($globalDebug) echo "Done\n";
2169
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2471
+		} elseif ($globalDebug) {
2472
+			echo "Done\n";
2473
+		}
2474
+		if ($globalDebug) {
2475
+			echo "Owner Czech Republic: Download...";
2476
+		}
2170 2477
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2171 2478
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2172
-			if ($globalDebug) echo "Add to DB...";
2479
+			if ($globalDebug) {
2480
+				echo "Add to DB...";
2481
+			}
2173 2482
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2174
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2483
+		} else {
2484
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2485
+		}
2175 2486
 		if ($error != '') {
2176 2487
 			return $error;
2177
-		} elseif ($globalDebug) echo "Done\n";
2178
-		if ($globalDebug) echo "Owner Australia: Download...";
2488
+		} elseif ($globalDebug) {
2489
+			echo "Done\n";
2490
+		}
2491
+		if ($globalDebug) {
2492
+			echo "Owner Australia: Download...";
2493
+		}
2179 2494
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2180 2495
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2181
-			if ($globalDebug) echo "Add to DB...";
2496
+			if ($globalDebug) {
2497
+				echo "Add to DB...";
2498
+			}
2182 2499
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2183
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2500
+		} else {
2501
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2502
+		}
2184 2503
 		if ($error != '') {
2185 2504
 			return $error;
2186
-		} elseif ($globalDebug) echo "Done\n";
2187
-		if ($globalDebug) echo "Owner Austria: Download...";
2505
+		} elseif ($globalDebug) {
2506
+			echo "Done\n";
2507
+		}
2508
+		if ($globalDebug) {
2509
+			echo "Owner Austria: Download...";
2510
+		}
2188 2511
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2189 2512
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2190
-			if ($globalDebug) echo "Add to DB...";
2513
+			if ($globalDebug) {
2514
+				echo "Add to DB...";
2515
+			}
2191 2516
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2192
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2517
+		} else {
2518
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2519
+		}
2193 2520
 		if ($error != '') {
2194 2521
 			return $error;
2195
-		} elseif ($globalDebug) echo "Done\n";
2196
-		if ($globalDebug) echo "Owner Chile: Download...";
2522
+		} elseif ($globalDebug) {
2523
+			echo "Done\n";
2524
+		}
2525
+		if ($globalDebug) {
2526
+			echo "Owner Chile: Download...";
2527
+		}
2197 2528
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2198 2529
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2199
-			if ($globalDebug) echo "Add to DB...";
2530
+			if ($globalDebug) {
2531
+				echo "Add to DB...";
2532
+			}
2200 2533
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2201
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2534
+		} else {
2535
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2536
+		}
2202 2537
 		if ($error != '') {
2203 2538
 			return $error;
2204
-		} elseif ($globalDebug) echo "Done\n";
2205
-		if ($globalDebug) echo "Owner Colombia: Download...";
2539
+		} elseif ($globalDebug) {
2540
+			echo "Done\n";
2541
+		}
2542
+		if ($globalDebug) {
2543
+			echo "Owner Colombia: Download...";
2544
+		}
2206 2545
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2207 2546
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2208
-			if ($globalDebug) echo "Add to DB...";
2547
+			if ($globalDebug) {
2548
+				echo "Add to DB...";
2549
+			}
2209 2550
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2210
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2551
+		} else {
2552
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2553
+		}
2211 2554
 		if ($error != '') {
2212 2555
 			return $error;
2213
-		} elseif ($globalDebug) echo "Done\n";
2214
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2556
+		} elseif ($globalDebug) {
2557
+			echo "Done\n";
2558
+		}
2559
+		if ($globalDebug) {
2560
+			echo "Owner Bosnia Herzegobina: Download...";
2561
+		}
2215 2562
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2216 2563
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2217
-			if ($globalDebug) echo "Add to DB...";
2564
+			if ($globalDebug) {
2565
+				echo "Add to DB...";
2566
+			}
2218 2567
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2219
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2568
+		} else {
2569
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2570
+		}
2220 2571
 		if ($error != '') {
2221 2572
 			return $error;
2222
-		} elseif ($globalDebug) echo "Done\n";
2223
-		if ($globalDebug) echo "Owner Brazil: Download...";
2573
+		} elseif ($globalDebug) {
2574
+			echo "Done\n";
2575
+		}
2576
+		if ($globalDebug) {
2577
+			echo "Owner Brazil: Download...";
2578
+		}
2224 2579
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2225 2580
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2226
-			if ($globalDebug) echo "Add to DB...";
2581
+			if ($globalDebug) {
2582
+				echo "Add to DB...";
2583
+			}
2227 2584
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2228
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2585
+		} else {
2586
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2587
+		}
2229 2588
 		if ($error != '') {
2230 2589
 			return $error;
2231
-		} elseif ($globalDebug) echo "Done\n";
2232
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2590
+		} elseif ($globalDebug) {
2591
+			echo "Done\n";
2592
+		}
2593
+		if ($globalDebug) {
2594
+			echo "Owner Cayman Islands: Download...";
2595
+		}
2233 2596
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2234 2597
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2235
-			if ($globalDebug) echo "Add to DB...";
2598
+			if ($globalDebug) {
2599
+				echo "Add to DB...";
2600
+			}
2236 2601
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2237
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2602
+		} else {
2603
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2604
+		}
2238 2605
 		if ($error != '') {
2239 2606
 			return $error;
2240
-		} elseif ($globalDebug) echo "Done\n";
2241
-		if ($globalDebug) echo "Owner Croatia: Download...";
2607
+		} elseif ($globalDebug) {
2608
+			echo "Done\n";
2609
+		}
2610
+		if ($globalDebug) {
2611
+			echo "Owner Croatia: Download...";
2612
+		}
2242 2613
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2243 2614
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2244
-			if ($globalDebug) echo "Add to DB...";
2615
+			if ($globalDebug) {
2616
+				echo "Add to DB...";
2617
+			}
2245 2618
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2246
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2619
+		} else {
2620
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2621
+		}
2247 2622
 		if ($error != '') {
2248 2623
 			return $error;
2249
-		} elseif ($globalDebug) echo "Done\n";
2250
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2624
+		} elseif ($globalDebug) {
2625
+			echo "Done\n";
2626
+		}
2627
+		if ($globalDebug) {
2628
+			echo "Owner Luxembourg: Download...";
2629
+		}
2251 2630
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2252 2631
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2253
-			if ($globalDebug) echo "Add to DB...";
2632
+			if ($globalDebug) {
2633
+				echo "Add to DB...";
2634
+			}
2254 2635
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2255
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2636
+		} else {
2637
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2638
+		}
2256 2639
 		if ($error != '') {
2257 2640
 			return $error;
2258
-		} elseif ($globalDebug) echo "Done\n";
2259
-		if ($globalDebug) echo "Owner Maldives: Download...";
2641
+		} elseif ($globalDebug) {
2642
+			echo "Done\n";
2643
+		}
2644
+		if ($globalDebug) {
2645
+			echo "Owner Maldives: Download...";
2646
+		}
2260 2647
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2261 2648
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2262
-			if ($globalDebug) echo "Add to DB...";
2649
+			if ($globalDebug) {
2650
+				echo "Add to DB...";
2651
+			}
2263 2652
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2264
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2653
+		} else {
2654
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2655
+		}
2265 2656
 		if ($error != '') {
2266 2657
 			return $error;
2267
-		} elseif ($globalDebug) echo "Done\n";
2268
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2658
+		} elseif ($globalDebug) {
2659
+			echo "Done\n";
2660
+		}
2661
+		if ($globalDebug) {
2662
+			echo "Owner New Zealand: Download...";
2663
+		}
2269 2664
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2270 2665
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2271
-			if ($globalDebug) echo "Add to DB...";
2666
+			if ($globalDebug) {
2667
+				echo "Add to DB...";
2668
+			}
2272 2669
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2273
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2670
+		} else {
2671
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2672
+		}
2274 2673
 		if ($error != '') {
2275 2674
 			return $error;
2276
-		} elseif ($globalDebug) echo "Done\n";
2277
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2675
+		} elseif ($globalDebug) {
2676
+			echo "Done\n";
2677
+		}
2678
+		if ($globalDebug) {
2679
+			echo "Owner Papua New Guinea: Download...";
2680
+		}
2278 2681
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2279 2682
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2280
-			if ($globalDebug) echo "Add to DB...";
2683
+			if ($globalDebug) {
2684
+				echo "Add to DB...";
2685
+			}
2281 2686
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2282
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2687
+		} else {
2688
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2689
+		}
2283 2690
 		if ($error != '') {
2284 2691
 			return $error;
2285
-		} elseif ($globalDebug) echo "Done\n";
2286
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2692
+		} elseif ($globalDebug) {
2693
+			echo "Done\n";
2694
+		}
2695
+		if ($globalDebug) {
2696
+			echo "Owner Slovakia: Download...";
2697
+		}
2287 2698
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2288 2699
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2289
-			if ($globalDebug) echo "Add to DB...";
2700
+			if ($globalDebug) {
2701
+				echo "Add to DB...";
2702
+			}
2290 2703
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2291
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2704
+		} else {
2705
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2706
+		}
2292 2707
 		if ($error != '') {
2293 2708
 			return $error;
2294
-		} elseif ($globalDebug) echo "Done\n";
2295
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2709
+		} elseif ($globalDebug) {
2710
+			echo "Done\n";
2711
+		}
2712
+		if ($globalDebug) {
2713
+			echo "Owner Ecuador: Download...";
2714
+		}
2296 2715
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2297 2716
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2298
-			if ($globalDebug) echo "Add to DB...";
2717
+			if ($globalDebug) {
2718
+				echo "Add to DB...";
2719
+			}
2299 2720
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2300
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2721
+		} else {
2722
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2723
+		}
2301 2724
 		if ($error != '') {
2302 2725
 			return $error;
2303
-		} elseif ($globalDebug) echo "Done\n";
2304
-		if ($globalDebug) echo "Owner Iceland: Download...";
2726
+		} elseif ($globalDebug) {
2727
+			echo "Done\n";
2728
+		}
2729
+		if ($globalDebug) {
2730
+			echo "Owner Iceland: Download...";
2731
+		}
2305 2732
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2306 2733
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2307
-			if ($globalDebug) echo "Add to DB...";
2734
+			if ($globalDebug) {
2735
+				echo "Add to DB...";
2736
+			}
2308 2737
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2309
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2738
+		} else {
2739
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2740
+		}
2310 2741
 		if ($error != '') {
2311 2742
 			return $error;
2312
-		} elseif ($globalDebug) echo "Done\n";
2313
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2743
+		} elseif ($globalDebug) {
2744
+			echo "Done\n";
2745
+		}
2746
+		if ($globalDebug) {
2747
+			echo "Owner Isle of Man: Download...";
2748
+		}
2314 2749
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2315 2750
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2316
-			if ($globalDebug) echo "Add to DB...";
2751
+			if ($globalDebug) {
2752
+				echo "Add to DB...";
2753
+			}
2317 2754
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2318
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2755
+		} else {
2756
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2757
+		}
2319 2758
 		if ($error != '') {
2320 2759
 			return $error;
2321
-		} elseif ($globalDebug) echo "Done\n";
2760
+		} elseif ($globalDebug) {
2761
+			echo "Done\n";
2762
+		}
2322 2763
 		if ($globalMasterSource) {
2323
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2764
+			if ($globalDebug) {
2765
+				echo "ModeS Netherlands: Download...";
2766
+			}
2324 2767
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2325 2768
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2326
-				if ($globalDebug) echo "Add to DB...";
2769
+				if ($globalDebug) {
2770
+					echo "Add to DB...";
2771
+				}
2327 2772
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2328
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2773
+			} else {
2774
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2775
+			}
2329 2776
 			if ($error != '') {
2330 2777
 				return $error;
2331
-			} elseif ($globalDebug) echo "Done\n";
2332
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2778
+			} elseif ($globalDebug) {
2779
+				echo "Done\n";
2780
+			}
2781
+			if ($globalDebug) {
2782
+				echo "ModeS Denmark: Download...";
2783
+			}
2333 2784
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2334 2785
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2335
-				if ($globalDebug) echo "Add to DB...";
2786
+				if ($globalDebug) {
2787
+					echo "Add to DB...";
2788
+				}
2336 2789
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2337
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2790
+			} else {
2791
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2792
+			}
2338 2793
 			if ($error != '') {
2339 2794
 				return $error;
2340
-			} elseif ($globalDebug) echo "Done\n";
2341
-		} elseif ($globalDebug) echo "Done\n";
2795
+			} elseif ($globalDebug) {
2796
+				echo "Done\n";
2797
+			}
2798
+		} elseif ($globalDebug) {
2799
+			echo "Done\n";
2800
+		}
2342 2801
 		return '';
2343 2802
 	}
2344 2803
 
2345 2804
 	public static function update_translation() {
2346 2805
 		global $tmp_dir, $globalDebug;
2347 2806
 		$error = '';
2348
-		if ($globalDebug) echo "Translation : Download...";
2807
+		if ($globalDebug) {
2808
+			echo "Translation : Download...";
2809
+		}
2349 2810
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2350 2811
 		if (file_exists($tmp_dir.'translation.zip')) {
2351
-			if ($globalDebug) echo "Unzip...";
2812
+			if ($globalDebug) {
2813
+				echo "Unzip...";
2814
+			}
2352 2815
 			update_db::unzip($tmp_dir.'translation.zip');
2353
-			if ($globalDebug) echo "Add to DB...";
2816
+			if ($globalDebug) {
2817
+				echo "Add to DB...";
2818
+			}
2354 2819
 			$error = update_db::translation();
2355
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2820
+		} else {
2821
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2822
+		}
2356 2823
 		if ($error != '') {
2357 2824
 			return $error;
2358
-		} elseif ($globalDebug) echo "Done\n";
2825
+		} elseif ($globalDebug) {
2826
+			echo "Done\n";
2827
+		}
2359 2828
 		return '';
2360 2829
 	}
2361 2830
 
2362 2831
 	public static function update_translation_fam() {
2363 2832
 		global $tmp_dir, $globalDebug;
2364
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2833
+		if ($globalDebug) {
2834
+			echo "Translation from FlightAirMap website : Download...";
2835
+		}
2365 2836
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2366 2837
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2367 2838
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2368 2839
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2369 2840
 			$translation_md5 = $translation_md5_file[0];
2370 2841
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2371
-				if ($globalDebug) echo "Gunzip...";
2842
+				if ($globalDebug) {
2843
+					echo "Gunzip...";
2844
+				}
2372 2845
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2373
-				if ($globalDebug) echo "Add to DB...";
2846
+				if ($globalDebug) {
2847
+					echo "Add to DB...";
2848
+				}
2374 2849
 				$error = update_db::translation_fam();
2375
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2376
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2850
+			} else {
2851
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2852
+			}
2853
+		} else {
2854
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2855
+		}
2377 2856
 		if ($error != '') {
2378 2857
 			return $error;
2379
-		} elseif ($globalDebug) echo "Done\n";
2858
+		} elseif ($globalDebug) {
2859
+			echo "Done\n";
2860
+		}
2380 2861
 		return '';
2381 2862
 	}
2382 2863
 	public static function update_ModeS_fam() {
2383 2864
 		global $tmp_dir, $globalDebug;
2384
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2865
+		if ($globalDebug) {
2866
+			echo "ModeS from FlightAirMap website : Download...";
2867
+		}
2385 2868
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2386 2869
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2387 2870
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2388 2871
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2389 2872
 			$modes_md5 = $modes_md5_file[0];
2390 2873
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2391
-				if ($globalDebug) echo "Gunzip...";
2874
+				if ($globalDebug) {
2875
+					echo "Gunzip...";
2876
+				}
2392 2877
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2393
-				if ($globalDebug) echo "Add to DB...";
2878
+				if ($globalDebug) {
2879
+					echo "Add to DB...";
2880
+				}
2394 2881
 				$error = update_db::modes_fam();
2395
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2396
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2882
+			} else {
2883
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2884
+			}
2885
+		} else {
2886
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2887
+		}
2397 2888
 		if ($error != '') {
2398 2889
 			return $error;
2399
-		} elseif ($globalDebug) echo "Done\n";
2890
+		} elseif ($globalDebug) {
2891
+			echo "Done\n";
2892
+		}
2400 2893
 		return '';
2401 2894
 	}
2402 2895
 
2403 2896
 	public static function update_airlines_fam() {
2404 2897
 		global $tmp_dir, $globalDebug;
2405
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2898
+		if ($globalDebug) {
2899
+			echo "Airlines from FlightAirMap website : Download...";
2900
+		}
2406 2901
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2407 2902
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2408 2903
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2411,26 +2906,42 @@  discard block
 block discarded – undo
2411 2906
 				update_db::download('http://data.flightairmap.com/data/airliness.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2412 2907
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2413 2908
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2414
-						if ($globalDebug) echo "Gunzip...";
2909
+						if ($globalDebug) {
2910
+							echo "Gunzip...";
2911
+						}
2415 2912
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2416
-						if ($globalDebug) echo "Add to DB...";
2913
+						if ($globalDebug) {
2914
+							echo "Add to DB...";
2915
+						}
2417 2916
 						$error = update_db::airlines_fam();
2418 2917
 						update_db::insert_airlines_version($airlines_md5);
2419
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2420
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2421
-			} elseif ($globalDebug) echo "No update";
2422
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2918
+					} else {
2919
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2920
+					}
2921
+			    } else {
2922
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2923
+			    }
2924
+			} elseif ($globalDebug) {
2925
+				echo "No update";
2926
+			}
2927
+		} else {
2928
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2929
+		}
2423 2930
 		if ($error != '') {
2424 2931
 			return $error;
2425 2932
 		} else {
2426
-			if ($globalDebug) echo "Done\n";
2933
+			if ($globalDebug) {
2934
+				echo "Done\n";
2935
+			}
2427 2936
 		}
2428 2937
 		return '';
2429 2938
 	}
2430 2939
 
2431 2940
 	public static function update_owner_fam() {
2432 2941
 		global $tmp_dir, $globalDebug, $globalOwner;
2433
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2942
+		if ($globalDebug) {
2943
+			echo "owner from FlightAirMap website : Download...";
2944
+		}
2434 2945
 		if ($globalOwner === TRUE) {
2435 2946
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2436 2947
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
@@ -2442,35 +2953,57 @@  discard block
 block discarded – undo
2442 2953
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2443 2954
 			$owners_md5 = $owners_md5_file[0];
2444 2955
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2445
-				if ($globalDebug) echo "Gunzip...";
2956
+				if ($globalDebug) {
2957
+					echo "Gunzip...";
2958
+				}
2446 2959
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2447
-				if ($globalDebug) echo "Add to DB...";
2960
+				if ($globalDebug) {
2961
+					echo "Add to DB...";
2962
+				}
2448 2963
 				$error = update_db::owner_fam();
2449
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2450
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2964
+			} else {
2965
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2966
+			}
2967
+		} else {
2968
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2969
+		}
2451 2970
 		if ($error != '') {
2452 2971
 			return $error;
2453
-		} elseif ($globalDebug) echo "Done\n";
2972
+		} elseif ($globalDebug) {
2973
+			echo "Done\n";
2974
+		}
2454 2975
 		return '';
2455 2976
 	}
2456 2977
 	public static function update_routes_fam() {
2457 2978
 		global $tmp_dir, $globalDebug;
2458
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2979
+		if ($globalDebug) {
2980
+			echo "Routes from FlightAirMap website : Download...";
2981
+		}
2459 2982
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2460 2983
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2461 2984
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2462 2985
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2463 2986
 			$routes_md5 = $routes_md5_file[0];
2464 2987
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2465
-				if ($globalDebug) echo "Gunzip...";
2988
+				if ($globalDebug) {
2989
+					echo "Gunzip...";
2990
+				}
2466 2991
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2467
-				if ($globalDebug) echo "Add to DB...";
2992
+				if ($globalDebug) {
2993
+					echo "Add to DB...";
2994
+				}
2468 2995
 				$error = update_db::routes_fam();
2469
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2470
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2996
+			} else {
2997
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2998
+			}
2999
+		} else {
3000
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3001
+		}
2471 3002
 		if ($error != '') {
2472 3003
 			return $error;
2473
-		} elseif ($globalDebug) echo "Done\n";
3004
+		} elseif ($globalDebug) {
3005
+			echo "Done\n";
3006
+		}
2474 3007
 		return '';
2475 3008
 	}
2476 3009
 	public static function update_marine_identity_fam() {
@@ -2480,21 +3013,33 @@  discard block
 block discarded – undo
2480 3013
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2481 3014
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2482 3015
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2483
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3016
+				if ($globalDebug) {
3017
+					echo "Marine identity from FlightAirMap website : Download...";
3018
+				}
2484 3019
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2485 3020
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2486 3021
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2487
-						if ($globalDebug) echo "Gunzip...";
3022
+						if ($globalDebug) {
3023
+							echo "Gunzip...";
3024
+						}
2488 3025
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2489
-						if ($globalDebug) echo "Add to DB...";
3026
+						if ($globalDebug) {
3027
+							echo "Add to DB...";
3028
+						}
2490 3029
 						$error = update_db::marine_identity_fam();
2491
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2492
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3030
+					} else {
3031
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3032
+					}
3033
+				} else {
3034
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3035
+				}
2493 3036
 				if ($error != '') {
2494 3037
 					return $error;
2495 3038
 				} else {
2496 3039
 					update_db::insert_marine_identity_version($marine_identity_md5);
2497
-					if ($globalDebug) echo "Done\n";
3040
+					if ($globalDebug) {
3041
+						echo "Done\n";
3042
+					}
2498 3043
 				}
2499 3044
 			}
2500 3045
 		}
@@ -2508,21 +3053,33 @@  discard block
 block discarded – undo
2508 3053
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2509 3054
 			$satellite_md5 = $satellite_md5_file[0];
2510 3055
 			if (!update_db::check_satellite_version($satellite_md5)) {
2511
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3056
+				if ($globalDebug) {
3057
+					echo "Satellite from FlightAirMap website : Download...";
3058
+				}
2512 3059
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2513 3060
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2514 3061
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2515
-						if ($globalDebug) echo "Gunzip...";
3062
+						if ($globalDebug) {
3063
+							echo "Gunzip...";
3064
+						}
2516 3065
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2517
-						if ($globalDebug) echo "Add to DB...";
3066
+						if ($globalDebug) {
3067
+							echo "Add to DB...";
3068
+						}
2518 3069
 						$error = update_db::satellite_fam();
2519
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2520
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3070
+					} else {
3071
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3072
+					}
3073
+				} else {
3074
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3075
+				}
2521 3076
 				if ($error != '') {
2522 3077
 					return $error;
2523 3078
 				} else {
2524 3079
 					update_db::insert_satellite_version($satellite_md5);
2525
-					if ($globalDebug) echo "Done\n";
3080
+					if ($globalDebug) {
3081
+						echo "Done\n";
3082
+					}
2526 3083
 				}
2527 3084
 			}
2528 3085
 		}
@@ -2530,17 +3087,25 @@  discard block
 block discarded – undo
2530 3087
 	}
2531 3088
 	public static function update_banned_fam() {
2532 3089
 		global $tmp_dir, $globalDebug;
2533
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3090
+		if ($globalDebug) {
3091
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3092
+		}
2534 3093
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2535 3094
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2536 3095
 			//if ($globalDebug) echo "Gunzip...";
2537 3096
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2538
-			if ($globalDebug) echo "Add to DB...";
3097
+			if ($globalDebug) {
3098
+				echo "Add to DB...";
3099
+			}
2539 3100
 			$error = update_db::banned_fam();
2540
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3101
+		} else {
3102
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3103
+		}
2541 3104
 		if ($error != '') {
2542 3105
 			return $error;
2543
-		} elseif ($globalDebug) echo "Done\n";
3106
+		} elseif ($globalDebug) {
3107
+			echo "Done\n";
3108
+		}
2544 3109
 		return '';
2545 3110
 	}
2546 3111
 
@@ -2548,7 +3113,9 @@  discard block
 block discarded – undo
2548 3113
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2549 3114
 		include_once('class.create_db.php');
2550 3115
 		$error = '';
2551
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3116
+		if ($globalDebug) {
3117
+			echo "Airspace from FlightAirMap website : Download...";
3118
+		}
2552 3119
 		if ($globalDBdriver == 'mysql') {
2553 3120
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2554 3121
 		} else {
@@ -2565,9 +3132,13 @@  discard block
 block discarded – undo
2565 3132
 				}
2566 3133
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2567 3134
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2568
-						if ($globalDebug) echo "Gunzip...";
3135
+						if ($globalDebug) {
3136
+							echo "Gunzip...";
3137
+						}
2569 3138
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2570
-						if ($globalDebug) echo "Add to DB...";
3139
+						if ($globalDebug) {
3140
+							echo "Add to DB...";
3141
+						}
2571 3142
 						$Connection = new Connection();
2572 3143
 						if ($Connection->tableExists('airspace')) {
2573 3144
 							$query = 'DROP TABLE airspace';
@@ -2580,20 +3151,30 @@  discard block
 block discarded – undo
2580 3151
 						}
2581 3152
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2582 3153
 						update_db::insert_airspace_version($airspace_md5);
2583
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2584
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3154
+					} else {
3155
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3156
+					}
3157
+				} else {
3158
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3159
+				}
2585 3160
 			}
2586
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3161
+		} else {
3162
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3163
+		}
2587 3164
 		if ($error != '') {
2588 3165
 			return $error;
2589
-		} elseif ($globalDebug) echo "Done\n";
3166
+		} elseif ($globalDebug) {
3167
+			echo "Done\n";
3168
+		}
2590 3169
 		return '';
2591 3170
 	}
2592 3171
 
2593 3172
 	public static function update_geoid_fam() {
2594 3173
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2595 3174
 		$error = '';
2596
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3175
+		if ($globalDebug) {
3176
+			echo "Geoid from FlightAirMap website : Download...";
3177
+		}
2597 3178
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2598 3179
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2599 3180
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2602,76 +3183,116 @@  discard block
 block discarded – undo
2602 3183
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2603 3184
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2604 3185
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2605
-						if ($globalDebug) echo "Gunzip...";
3186
+						if ($globalDebug) {
3187
+							echo "Gunzip...";
3188
+						}
2606 3189
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2607 3190
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2608 3191
 							update_db::insert_geoid_version($geoid_md5);
2609 3192
 						}
2610
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2611
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3193
+					} else {
3194
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3195
+					}
3196
+				} else {
3197
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3198
+				}
2612 3199
 			}
2613
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3200
+		} else {
3201
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3202
+		}
2614 3203
 		if ($error != '') {
2615 3204
 			return $error;
2616
-		} elseif ($globalDebug) echo "Done\n";
3205
+		} elseif ($globalDebug) {
3206
+			echo "Done\n";
3207
+		}
2617 3208
 		return '';
2618 3209
 	}
2619 3210
 
2620 3211
 	public static function update_tle() {
2621 3212
 		global $tmp_dir, $globalDebug;
2622
-		if ($globalDebug) echo "Download TLE : Download...";
3213
+		if ($globalDebug) {
3214
+			echo "Download TLE : Download...";
3215
+		}
2623 3216
 		$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',
2624 3217
 		'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',
2625 3218
 		'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');
2626 3219
 		foreach ($alltle as $filename) {
2627
-			if ($globalDebug) echo "downloading ".$filename.'...';
3220
+			if ($globalDebug) {
3221
+				echo "downloading ".$filename.'...';
3222
+			}
2628 3223
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2629 3224
 			if (file_exists($tmp_dir.$filename)) {
2630
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3225
+				if ($globalDebug) {
3226
+					echo "Add to DB ".$filename."...";
3227
+				}
2631 3228
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2632
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3229
+			} else {
3230
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3231
+			}
2633 3232
 			if ($error != '') {
2634 3233
 				echo $error."\n";
2635
-			} elseif ($globalDebug) echo "Done\n";
3234
+			} elseif ($globalDebug) {
3235
+				echo "Done\n";
3236
+			}
2636 3237
 		}
2637 3238
 		return '';
2638 3239
 	}
2639 3240
 
2640 3241
 	public static function update_ucsdb() {
2641 3242
 		global $tmp_dir, $globalDebug;
2642
-		if ($globalDebug) echo "Download UCS DB : Download...";
3243
+		if ($globalDebug) {
3244
+			echo "Download UCS DB : Download...";
3245
+		}
2643 3246
 		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');
2644 3247
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2645
-			if ($globalDebug) echo "Add to DB...";
3248
+			if ($globalDebug) {
3249
+				echo "Add to DB...";
3250
+			}
2646 3251
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2647
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3252
+		} else {
3253
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3254
+		}
2648 3255
 		if ($error != '') {
2649 3256
 			echo $error."\n";
2650
-		} elseif ($globalDebug) echo "Done\n";
3257
+		} elseif ($globalDebug) {
3258
+			echo "Done\n";
3259
+		}
2651 3260
 		return '';
2652 3261
 	}
2653 3262
 
2654 3263
 	public static function update_celestrak() {
2655 3264
 		global $tmp_dir, $globalDebug;
2656
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3265
+		if ($globalDebug) {
3266
+			echo "Download Celestrak DB : Download...";
3267
+		}
2657 3268
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2658 3269
 		if (file_exists($tmp_dir.'satcat.txt')) {
2659
-			if ($globalDebug) echo "Add to DB...";
3270
+			if ($globalDebug) {
3271
+				echo "Add to DB...";
3272
+			}
2660 3273
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2661
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3274
+		} else {
3275
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3276
+		}
2662 3277
 		if ($error != '') {
2663 3278
 			echo $error."\n";
2664
-		} elseif ($globalDebug) echo "Done\n";
3279
+		} elseif ($globalDebug) {
3280
+			echo "Done\n";
3281
+		}
2665 3282
 		return '';
2666 3283
 	}
2667 3284
 
2668 3285
 	public static function update_models() {
2669 3286
 		global $tmp_dir, $globalDebug;
2670 3287
 		$error = '';
2671
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3288
+		if ($globalDebug) {
3289
+			echo "Models from FlightAirMap website : Download...";
3290
+		}
2672 3291
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2673 3292
 		if (file_exists($tmp_dir.'models.md5sum')) {
2674
-			if ($globalDebug) echo "Check files...\n";
3293
+			if ($globalDebug) {
3294
+				echo "Check files...\n";
3295
+			}
2675 3296
 			$newmodelsdb = array();
2676 3297
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2677 3298
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2690,25 +3311,35 @@  discard block
 block discarded – undo
2690 3311
 			}
2691 3312
 			$diff = array_diff($newmodelsdb,$modelsdb);
2692 3313
 			foreach ($diff as $key => $value) {
2693
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3314
+				if ($globalDebug) {
3315
+					echo 'Downloading model '.$key.' ...'."\n";
3316
+				}
2694 3317
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2695 3318
 				
2696 3319
 			}
2697 3320
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2698
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3321
+		} else {
3322
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3323
+		}
2699 3324
 		if ($error != '') {
2700 3325
 			return $error;
2701
-		} elseif ($globalDebug) echo "Done\n";
3326
+		} elseif ($globalDebug) {
3327
+			echo "Done\n";
3328
+		}
2702 3329
 		return '';
2703 3330
 	}
2704 3331
 
2705 3332
 	public static function update_space_models() {
2706 3333
 		global $tmp_dir, $globalDebug;
2707 3334
 		$error = '';
2708
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3335
+		if ($globalDebug) {
3336
+			echo "Space models from FlightAirMap website : Download...";
3337
+		}
2709 3338
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2710 3339
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2711
-			if ($globalDebug) echo "Check files...\n";
3340
+			if ($globalDebug) {
3341
+				echo "Check files...\n";
3342
+			}
2712 3343
 			$newmodelsdb = array();
2713 3344
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2714 3345
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2727,25 +3358,35 @@  discard block
 block discarded – undo
2727 3358
 			}
2728 3359
 			$diff = array_diff($newmodelsdb,$modelsdb);
2729 3360
 			foreach ($diff as $key => $value) {
2730
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3361
+				if ($globalDebug) {
3362
+					echo 'Downloading space model '.$key.' ...'."\n";
3363
+				}
2731 3364
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2732 3365
 				
2733 3366
 			}
2734 3367
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2735
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3368
+		} else {
3369
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3370
+		}
2736 3371
 		if ($error != '') {
2737 3372
 			return $error;
2738
-		} elseif ($globalDebug) echo "Done\n";
3373
+		} elseif ($globalDebug) {
3374
+			echo "Done\n";
3375
+		}
2739 3376
 		return '';
2740 3377
 	}
2741 3378
 
2742 3379
 	public static function update_vehicules_models() {
2743 3380
 		global $tmp_dir, $globalDebug;
2744 3381
 		$error = '';
2745
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3382
+		if ($globalDebug) {
3383
+			echo "Vehicules models from FlightAirMap website : Download...";
3384
+		}
2746 3385
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2747 3386
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2748
-			if ($globalDebug) echo "Check files...\n";
3387
+			if ($globalDebug) {
3388
+				echo "Check files...\n";
3389
+			}
2749 3390
 			$newmodelsdb = array();
2750 3391
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2751 3392
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2764,15 +3405,21 @@  discard block
 block discarded – undo
2764 3405
 			}
2765 3406
 			$diff = array_diff($newmodelsdb,$modelsdb);
2766 3407
 			foreach ($diff as $key => $value) {
2767
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3408
+				if ($globalDebug) {
3409
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3410
+				}
2768 3411
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2769 3412
 				
2770 3413
 			}
2771 3414
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2772
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3415
+		} else {
3416
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3417
+		}
2773 3418
 		if ($error != '') {
2774 3419
 			return $error;
2775
-		} elseif ($globalDebug) echo "Done\n";
3420
+		} elseif ($globalDebug) {
3421
+			echo "Done\n";
3422
+		}
2776 3423
 		return '';
2777 3424
 	}
2778 3425
 
@@ -2815,7 +3462,9 @@  discard block
 block discarded – undo
2815 3462
                 }
2816 3463
 
2817 3464
 		$error = '';
2818
-		if ($globalDebug) echo "Notam : Download...";
3465
+		if ($globalDebug) {
3466
+			echo "Notam : Download...";
3467
+		}
2819 3468
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2820 3469
 		if (file_exists($tmp_dir.'notam.rss')) {
2821 3470
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2830,14 +3479,30 @@  discard block
 block discarded – undo
2830 3479
 				$data['fir'] = $q[0];
2831 3480
 				$data['code'] = $q[1];
2832 3481
 				$ifrvfr = $q[2];
2833
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2834
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2835
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2836
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2837
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2838
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2839
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2840
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3482
+				if ($ifrvfr == 'IV') {
3483
+					$data['rules'] = 'IFR/VFR';
3484
+				}
3485
+				if ($ifrvfr == 'I') {
3486
+					$data['rules'] = 'IFR';
3487
+				}
3488
+				if ($ifrvfr == 'V') {
3489
+					$data['rules'] = 'VFR';
3490
+				}
3491
+				if ($q[4] == 'A') {
3492
+					$data['scope'] = 'Airport warning';
3493
+				}
3494
+				if ($q[4] == 'E') {
3495
+					$data['scope'] = 'Enroute warning';
3496
+				}
3497
+				if ($q[4] == 'W') {
3498
+					$data['scope'] = 'Navigation warning';
3499
+				}
3500
+				if ($q[4] == 'AE') {
3501
+					$data['scope'] = 'Airport/Enroute warning';
3502
+				}
3503
+				if ($q[4] == 'AW') {
3504
+					$data['scope'] = 'Airport/Navigation warning';
3505
+				}
2841 3506
 				//$data['scope'] = $q[4];
2842 3507
 				$data['lower_limit'] = $q[5];
2843 3508
 				$data['upper_limit'] = $q[6];
@@ -2845,8 +3510,12 @@  discard block
 block discarded – undo
2845 3510
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2846 3511
 				$latitude = $Common->convertDec($las,'latitude');
2847 3512
 				$longitude = $Common->convertDec($lns,'longitude');
2848
-				if ($lac == 'S') $latitude = '-'.$latitude;
2849
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3513
+				if ($lac == 'S') {
3514
+					$latitude = '-'.$latitude;
3515
+				}
3516
+				if ($lnc == 'W') {
3517
+					$longitude = '-'.$longitude;
3518
+				}
2850 3519
 				$data['center_latitude'] = $latitude;
2851 3520
 				$data['center_longitude'] = $longitude;
2852 3521
 				$data['radius'] = intval($radius);
@@ -2876,10 +3545,14 @@  discard block
 block discarded – undo
2876 3545
 				$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']);
2877 3546
 				unset($data);
2878 3547
 			} 
2879
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3548
+		} else {
3549
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3550
+		}
2880 3551
 		if ($error != '') {
2881 3552
 			return $error;
2882
-		} elseif ($globalDebug) echo "Done\n";
3553
+		} elseif ($globalDebug) {
3554
+			echo "Done\n";
3555
+		}
2883 3556
 		return '';
2884 3557
 	}
2885 3558
 	
@@ -2904,7 +3577,9 @@  discard block
 block discarded – undo
2904 3577
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2905 3578
 		$airspace_json = json_decode($airspace_lst,true);
2906 3579
 		foreach ($airspace_json['records'] as $airspace) {
2907
-			if ($globalDebug) echo $airspace['name']."...\n";
3580
+			if ($globalDebug) {
3581
+				echo $airspace['name']."...\n";
3582
+			}
2908 3583
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2909 3584
 			if (file_exists($tmp_dir.$airspace['name'])) {
2910 3585
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2948,8 +3623,11 @@  discard block
 block discarded – undo
2948 3623
                         return "error : ".$e->getMessage();
2949 3624
                 }
2950 3625
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2951
-                if ($row['nb'] > 0) return false;
2952
-                else return true;
3626
+                if ($row['nb'] > 0) {
3627
+                	return false;
3628
+                } else {
3629
+                	return true;
3630
+                }
2953 3631
 	}
2954 3632
 
2955 3633
 	public static function insert_last_update() {
@@ -2974,8 +3652,11 @@  discard block
 block discarded – undo
2974 3652
                         return "error : ".$e->getMessage();
2975 3653
                 }
2976 3654
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2977
-                if ($row['nb'] > 0) return true;
2978
-                else return false;
3655
+                if ($row['nb'] > 0) {
3656
+                	return true;
3657
+                } else {
3658
+                	return false;
3659
+                }
2979 3660
 	}
2980 3661
 
2981 3662
 	public static function check_geoid_version($version) {
@@ -2988,8 +3669,11 @@  discard block
 block discarded – undo
2988 3669
                         return "error : ".$e->getMessage();
2989 3670
                 }
2990 3671
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2991
-                if ($row['nb'] > 0) return true;
2992
-                else return false;
3672
+                if ($row['nb'] > 0) {
3673
+                	return true;
3674
+                } else {
3675
+                	return false;
3676
+                }
2993 3677
 	}
2994 3678
 
2995 3679
 	public static function check_marine_identity_version($version) {
@@ -3002,8 +3686,11 @@  discard block
 block discarded – undo
3002 3686
 			return "error : ".$e->getMessage();
3003 3687
 		}
3004 3688
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3005
-		if ($row['nb'] > 0) return true;
3006
-		else return false;
3689
+		if ($row['nb'] > 0) {
3690
+			return true;
3691
+		} else {
3692
+			return false;
3693
+		}
3007 3694
 	}
3008 3695
 
3009 3696
 	public static function check_satellite_version($version) {
@@ -3016,8 +3703,11 @@  discard block
 block discarded – undo
3016 3703
 			return "error : ".$e->getMessage();
3017 3704
 		}
3018 3705
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3019
-		if ($row['nb'] > 0) return true;
3020
-		else return false;
3706
+		if ($row['nb'] > 0) {
3707
+			return true;
3708
+		} else {
3709
+			return false;
3710
+		}
3021 3711
 	}
3022 3712
 
3023 3713
 	public static function check_airlines_version($version) {
@@ -3030,8 +3720,11 @@  discard block
 block discarded – undo
3030 3720
 			return "error : ".$e->getMessage();
3031 3721
 		}
3032 3722
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3033
-		if ($row['nb'] > 0) return true;
3034
-		else return false;
3723
+		if ($row['nb'] > 0) {
3724
+			return true;
3725
+		} else {
3726
+			return false;
3727
+		}
3035 3728
 	}
3036 3729
 
3037 3730
 	public static function check_notam_version($version) {
@@ -3044,8 +3737,11 @@  discard block
 block discarded – undo
3044 3737
 			return "error : ".$e->getMessage();
3045 3738
 		}
3046 3739
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3047
-		if ($row['nb'] > 0) return true;
3048
-		else return false;
3740
+		if ($row['nb'] > 0) {
3741
+			return true;
3742
+		} else {
3743
+			return false;
3744
+		}
3049 3745
 	}
3050 3746
 
3051 3747
 	public static function insert_airlines_version($version) {
@@ -3135,8 +3831,11 @@  discard block
 block discarded – undo
3135 3831
                         return "error : ".$e->getMessage();
3136 3832
                 }
3137 3833
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3138
-                if ($row['nb'] > 0) return false;
3139
-                else return true;
3834
+                if ($row['nb'] > 0) {
3835
+                	return false;
3836
+                } else {
3837
+                	return true;
3838
+                }
3140 3839
 	}
3141 3840
 
3142 3841
 	public static function insert_last_notam_update() {
@@ -3166,8 +3865,11 @@  discard block
 block discarded – undo
3166 3865
                         return "error : ".$e->getMessage();
3167 3866
                 }
3168 3867
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3169
-                if ($row['nb'] > 0) return false;
3170
-                else return true;
3868
+                if ($row['nb'] > 0) {
3869
+                	return false;
3870
+                } else {
3871
+                	return true;
3872
+                }
3171 3873
 	}
3172 3874
 
3173 3875
 	public static function insert_last_airspace_update() {
@@ -3197,8 +3899,11 @@  discard block
 block discarded – undo
3197 3899
                         return "error : ".$e->getMessage();
3198 3900
                 }
3199 3901
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3200
-                if ($row['nb'] > 0) return false;
3201
-                else return true;
3902
+                if ($row['nb'] > 0) {
3903
+                	return false;
3904
+                } else {
3905
+                	return true;
3906
+                }
3202 3907
 	}
3203 3908
 
3204 3909
 	public static function insert_last_geoid_update() {
@@ -3228,8 +3933,11 @@  discard block
 block discarded – undo
3228 3933
                         return "error : ".$e->getMessage();
3229 3934
                 }
3230 3935
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3231
-                if ($row['nb'] > 0) return false;
3232
-                else return true;
3936
+                if ($row['nb'] > 0) {
3937
+                	return false;
3938
+                } else {
3939
+                	return true;
3940
+                }
3233 3941
 	}
3234 3942
 
3235 3943
 	public static function insert_last_owner_update() {
@@ -3258,8 +3966,11 @@  discard block
 block discarded – undo
3258 3966
                         return "error : ".$e->getMessage();
3259 3967
                 }
3260 3968
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3261
-                if ($row['nb'] > 0) return false;
3262
-                else return true;
3969
+                if ($row['nb'] > 0) {
3970
+                	return false;
3971
+                } else {
3972
+                	return true;
3973
+                }
3263 3974
 	}
3264 3975
 
3265 3976
 	public static function insert_last_schedules_update() {
@@ -3289,8 +4000,11 @@  discard block
 block discarded – undo
3289 4000
 			return "error : ".$e->getMessage();
3290 4001
 		}
3291 4002
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3292
-		if ($row['nb'] > 0) return false;
3293
-		else return true;
4003
+		if ($row['nb'] > 0) {
4004
+			return false;
4005
+		} else {
4006
+			return true;
4007
+		}
3294 4008
 	}
3295 4009
 
3296 4010
 	public static function insert_last_tle_update() {
@@ -3320,8 +4034,11 @@  discard block
 block discarded – undo
3320 4034
 			return "error : ".$e->getMessage();
3321 4035
 		}
3322 4036
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3323
-		if ($row['nb'] > 0) return false;
3324
-		else return true;
4037
+		if ($row['nb'] > 0) {
4038
+			return false;
4039
+		} else {
4040
+			return true;
4041
+		}
3325 4042
 	}
3326 4043
 
3327 4044
 	public static function insert_last_ucsdb_update() {
@@ -3351,8 +4068,11 @@  discard block
 block discarded – undo
3351 4068
 			return "error : ".$e->getMessage();
3352 4069
 		}
3353 4070
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3354
-		if ($row['nb'] > 0) return false;
3355
-		else return true;
4071
+		if ($row['nb'] > 0) {
4072
+			return false;
4073
+		} else {
4074
+			return true;
4075
+		}
3356 4076
 	}
3357 4077
 
3358 4078
 	public static function insert_last_celestrak_update() {
@@ -3382,8 +4102,11 @@  discard block
 block discarded – undo
3382 4102
 			return "error : ".$e->getMessage();
3383 4103
 		}
3384 4104
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3385
-		if ($row['nb'] > 0) return false;
3386
-		else return true;
4105
+		if ($row['nb'] > 0) {
4106
+			return false;
4107
+		} else {
4108
+			return true;
4109
+		}
3387 4110
 	}
3388 4111
 
3389 4112
 	public static function check_last_satellite_update() {
@@ -3401,8 +4124,11 @@  discard block
 block discarded – undo
3401 4124
 			return "error : ".$e->getMessage();
3402 4125
 		}
3403 4126
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3404
-		if ($row['nb'] > 0) return false;
3405
-		else return true;
4127
+		if ($row['nb'] > 0) {
4128
+			return false;
4129
+		} else {
4130
+			return true;
4131
+		}
3406 4132
 	}
3407 4133
 
3408 4134
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.