Completed
Push — master ( 649c27...efcf4c )
by Yannick
23:43
created
require/class.Connection.php 3 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@  discard block
 block discarded – undo
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 45;
8 8
 	
9
+	/**
10
+	 * @param string $dbname
11
+	 */
9 12
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10 13
 	    global $globalNoDB;
11 14
 	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
@@ -141,6 +144,9 @@  discard block
 block discarded – undo
141 144
 		return true;
142 145
 	}
143 146
 
147
+	/**
148
+	 * @param string $table
149
+	 */
144 150
 	public function tableExists($table)
145 151
 	{
146 152
 		global $globalDBdriver, $globalDBname;
@@ -190,6 +196,11 @@  discard block
 block discarded – undo
190 196
 	/*
191 197
 	* Check if index exist
192 198
 	*/
199
+
200
+	/**
201
+	 * @param string $table
202
+	 * @param string $index
203
+	 */
193 204
 	public function indexExists($table,$index)
194 205
 	{
195 206
 		global $globalDBdriver, $globalDBname;
@@ -232,6 +243,10 @@  discard block
 block discarded – undo
232 243
 		return $columns;
233 244
 	}
234 245
 
246
+	/**
247
+	 * @param string $table
248
+	 * @param string $column
249
+	 */
235 250
 	public function getColumnType($table,$column) {
236 251
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
237 252
 		$tomet = $select->getColumnMeta(0);
@@ -242,6 +257,11 @@  discard block
 block discarded – undo
242 257
 	* Check if a column name exist in a table
243 258
 	* @return Boolean column exist or not
244 259
 	*/
260
+
261
+	/**
262
+	 * @param string $table
263
+	 * @param string $name
264
+	 */
245 265
 	public function checkColumnName($table,$name)
246 266
 	{
247 267
 		global $globalDBdriver, $globalDBname;
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
 	public $latest_schema = 45;
8 8
 	
9 9
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10
-	    global $globalNoDB;
11
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
10
+		global $globalNoDB;
11
+		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
13
-	    } else {
13
+		} else {
14 14
 		if ($dbc === null) {
15
-		    if ($this->db === null && $dbname === null) {
15
+			if ($this->db === null && $dbname === null) {
16 16
 			if ($user === null && $pass === null) {
17
-			    $this->createDBConnection();
17
+				$this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+				$this->createDBConnection(null,$user,$pass);
20 20
 			}
21
-		    } else {
21
+			} else {
22 22
 			$this->createDBConnection($dbname);
23
-		    }
23
+			}
24 24
 		} elseif ($dbname === null || $dbname === 'default') {
25
-	    	    $this->db = $dbc;
26
-	    	    if ($this->connectionExists() === false) {
25
+				$this->db = $dbc;
26
+				if ($this->connectionExists() === false) {
27 27
 			/*
28 28
 			echo 'Restart Connection !!!'."\n";
29 29
 			$e = new \Exception;
30 30
 			var_dump($e->getTraceAsString());
31 31
 			*/
32 32
 			$this->createDBConnection();
33
-		    }
33
+			}
34 34
 		} else {
35
-		    //$this->connectionExists();
36
-		    $this->dbs[$dbname] = $dbc;
35
+			//$this->connectionExists();
36
+			$this->dbs[$dbname] = $dbc;
37
+		}
37 38
 		}
38
-	    }
39 39
 	}
40 40
 
41 41
 	public function db() {
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 
58 58
 	/**
59
-	* Creates the database connection
60
-	*
61
-	* @return Boolean of the database connection
62
-	*
63
-	*/
59
+	 * Creates the database connection
60
+	 *
61
+	 * @return Boolean of the database connection
62
+	 *
63
+	 */
64 64
 
65 65
 	public function createDBConnection($DBname = null, $user = null, $pass = null)
66 66
 	{
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			return false;
158 158
 		}
159 159
 		if($results->rowCount()>0) {
160
-		    return true; 
160
+			return true; 
161 161
 		}
162 162
 		else return false;
163 163
 	}
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 				$sum = $sum->fetchColumn(0);
175 175
 			} else $sum = 0;
176 176
 			if (intval($sum) !== 2) {
177
-			     return false;
177
+				 return false;
178 178
 			}
179 179
 			
180 180
 		} catch(PDOException $e) {
181 181
 			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
-            			throw $e;
183
-	                }
184
-	                //echo 'error ! '.$e->getMessage();
182
+						throw $e;
183
+					}
184
+					//echo 'error ! '.$e->getMessage();
185 185
 			return false;
186 186
 		}
187 187
 		return true; 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 		$version = 0;
286 286
 		if ($this->tableExists('aircraft')) {
287 287
 			if (!$this->tableExists('config')) {
288
-	    			$version = '1';
289
-	    			return $version;
288
+					$version = '1';
289
+					return $version;
290 290
 			} else {
291 291
 				$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
292 292
 				try {
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	* @return Boolean if latest version or not
308 308
 	*/
309 309
 	public function latest() {
310
-	    global $globalNoDB;
311
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
312
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
313
-	    else return false;
310
+		global $globalNoDB;
311
+		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
312
+		if ($this->check_schema_version() == $this->latest_schema) return true;
313
+		else return false;
314 314
 	}
315 315
 
316 316
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 45;
8 8
 	
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 	    global $globalNoDB;
11 11
 	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 			if ($user === null && $pass === null) {
17 17
 			    $this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+			    $this->createDBConnection(null, $user, $pass);
20 20
 			}
21 21
 		    } else {
22 22
 			$this->createDBConnection($dbname);
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		while (true) {
101 101
 			try {
102 102
 				if ($globalDBSdriver == 'mysql') {
103
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
103
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
104 104
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 105
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
106
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
107
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
108
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
109
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
110
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
111 111
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 112
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 113
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
118 118
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
119 119
 				} else {
120
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
120
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
121 121
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
123
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
124
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
125
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
126
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
127
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
128 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 129
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 130
 				}
131 131
 				break;
132
-			} catch(PDOException $e) {
132
+			} catch (PDOException $e) {
133 133
 				$i++;
134 134
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
135 135
 				//exit;
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 		try {
154 154
 			//$Connection = new Connection();
155 155
 			$results = $this->db->query($query);
156
-		} catch(PDOException $e) {
156
+		} catch (PDOException $e) {
157 157
 			return false;
158 158
 		}
159
-		if($results->rowCount()>0) {
159
+		if ($results->rowCount() > 0) {
160 160
 		    return true; 
161 161
 		}
162 162
 		else return false;
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 			     return false;
178 178
 			}
179 179
 			
180
-		} catch(PDOException $e) {
181
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
180
+		} catch (PDOException $e) {
181
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182 182
             			throw $e;
183 183
 	                }
184 184
 	                //echo 'error ! '.$e->getMessage();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	/*
191 191
 	* Check if index exist
192 192
 	*/
193
-	public function indexExists($table,$index)
193
+	public function indexExists($table, $index)
194 194
 	{
195 195
 		global $globalDBdriver, $globalDBname;
196 196
 		if ($globalDBdriver == 'mysql') {
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 		try {
202 202
 			//$Connection = new Connection();
203 203
 			$results = $this->db->query($query);
204
-		} catch(PDOException $e) {
204
+		} catch (PDOException $e) {
205 205
 			return false;
206 206
 		}
207 207
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
208
-		if($nb[0]['nb'] > 0) {
208
+		if ($nb[0]['nb'] > 0) {
209 209
 			return true; 
210 210
 		}
211 211
 		else return false;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		$query = "SELECT * FROM ".$table." LIMIT 0";
221 221
 		try {
222 222
 			$results = $this->db->query($query);
223
-		} catch(PDOException $e) {
223
+		} catch (PDOException $e) {
224 224
 			return "error : ".$e->getMessage()."\n";
225 225
 		}
226 226
 		$columns = array();
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		return $columns;
233 233
 	}
234 234
 
235
-	public function getColumnType($table,$column) {
235
+	public function getColumnType($table, $column) {
236 236
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
237 237
 		$tomet = $select->getColumnMeta(0);
238 238
 		return $tomet['native_type'];
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	* Check if a column name exist in a table
243 243
 	* @return Boolean column exist or not
244 244
 	*/
245
-	public function checkColumnName($table,$name)
245
+	public function checkColumnName($table, $name)
246 246
 	{
247 247
 		global $globalDBdriver, $globalDBname;
248 248
 		if ($globalDBdriver == 'mysql') {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 		}
253 253
 			try {
254 254
 				$sth = $this->db()->prepare($query);
255
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
256
-			} catch(PDOException $e) {
255
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
256
+			} catch (PDOException $e) {
257 257
 				echo "error : ".$e->getMessage()."\n";
258 258
 			}
259 259
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 				try {
293 293
 					$sth = $this->db->prepare($query);
294 294
 					$sth->execute();
295
-				} catch(PDOException $e) {
295
+				} catch (PDOException $e) {
296 296
 					return "error : ".$e->getMessage()."\n";
297 297
 				}
298 298
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
owner.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
 
8 8
 if (isset($_POST['owner']))
9 9
 {
10
-	header('Location: '.$globalURL.'/owner/'.filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING));
10
+	header('Location: '.$globalURL.'/owner/'.filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING));
11 11
 //} else if (isset($_GET['airport'])){
12 12
 } else {
13
-	$Spotter= new Spotter();
13
+	$Spotter = new Spotter();
14 14
 	$Stats = new Stats();
15 15
 	$Common = new Common();
16 16
 	$title = _("Owners");
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
 	ksort($owner_names);
25 25
 	$previous = null;
26 26
 	print '<div class="alphabet-legend">';
27
-	foreach($owner_names as $value) {
27
+	foreach ($owner_names as $value) {
28 28
 		$firstLetter = $Common->remove_accents(mb_strtoupper(mb_substr($value['owner_name'], 0, 1)));
29
-		if($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"')
29
+		if ($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"')
30 30
 		{
31
-			if ($previous !== null){
31
+			if ($previous !== null) {
32 32
 				print ' | ';
33 33
 			}
34 34
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 	print '</div>';
39 39
 	$previous = null;
40
-	foreach($owner_names as $value) {
40
+	foreach ($owner_names as $value) {
41 41
 		$firstLetter = $Common->remove_accents(mb_strtoupper(mb_substr($value['owner_name'], 0, 1)));
42 42
 		if ($firstLetter != "")
43 43
 		{
44
-			if($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"')
44
+			if ($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"')
45 45
 			{
46
-				if ($previous !== null){
46
+				if ($previous !== null) {
47 47
 					print '</div>';
48 48
 				}
49 49
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
Please login to merge, or discard this patch.
pilot.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 
7 7
 if (isset($_POST['pilot']))
8 8
 {
9
-	header('Location: '.$globalURL.'/pilot/'.filter_input(INPUT_POST,'pilot',FILTER_SANITIZE_STRING));
9
+	header('Location: '.$globalURL.'/pilot/'.filter_input(INPUT_POST, 'pilot', FILTER_SANITIZE_STRING));
10 10
 //} else if (isset($_GET['airport'])){
11 11
 } else {
12
-	$Spotter= new Spotter();
12
+	$Spotter = new Spotter();
13 13
 	$Stats = new Stats();
14 14
 	$title = _("Pilots");
15 15
 	require_once('header.php');
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 	//ksort($pilot_names);
23 23
 	$previous = null;
24 24
 	print '<div class="alphabet-legend">';
25
-	foreach($pilot_names as $value) {
25
+	foreach ($pilot_names as $value) {
26 26
 		$firstLetter = mb_strtoupper(mb_substr($value['pilot_name'], 0, 1));
27
-		if($previous !== $firstLetter && $firstLetter != "'")
27
+		if ($previous !== $firstLetter && $firstLetter != "'")
28 28
 		{
29
-			if ($previous !== null){
29
+			if ($previous !== null) {
30 30
 				print ' | ';
31 31
 			}
32 32
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 	}
36 36
 	print '</div>';
37 37
 	$previous = null;
38
-	foreach($pilot_names as $value) {
38
+	foreach ($pilot_names as $value) {
39 39
 		$firstLetter = mb_strtoupper(mb_substr($value['pilot_name'], 0, 1));
40 40
 		if ($firstLetter != "")
41 41
 		{
42
-			if($previous !== $firstLetter && $firstLetter != "'")
42
+			if ($previous !== $firstLetter && $firstLetter != "'")
43 43
 			{
44
-				if ($previous !== null){
44
+				if ($previous !== null) {
45 45
 					print '</div>';
46 46
 				}
47 47
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
Please login to merge, or discard this patch.
install/class.update_db.php 3 patches
Indentation   +418 added lines, -418 removed lines patch added patch discarded remove patch
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
 		try {
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79
-                        $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
81
-                        return "error : ".$e->getMessage();
82
-                }
79
+						$sth->execute(array(':source' => $database_file));
80
+				} catch(PDOException $e) {
81
+						return "error : ".$e->getMessage();
82
+				}
83 83
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
85
-    		update_db::connect_sqlite($database_file);
84
+			if ($globalDebug) echo " - Add routes to DB -";
85
+			update_db::connect_sqlite($database_file);
86 86
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 87
 		$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";
88 88
 		try {
89
-                        $sth = update_db::$db_sqlite->prepare($query);
90
-                        $sth->execute();
91
-                } catch(PDOException $e) {
92
-                        return "error : ".$e->getMessage();
93
-                }
89
+						$sth = update_db::$db_sqlite->prepare($query);
90
+						$sth->execute();
91
+				} catch(PDOException $e) {
92
+						return "error : ".$e->getMessage();
93
+				}
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
96 96
 		$Connection = new Connection();
97 97
 		$sth_dest = $Connection->db->prepare($query_dest);
98 98
 		try {
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104
-            		}
104
+					}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106 106
 		} catch(PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
110
-                return '';
110
+				return '';
111 111
 	}
112 112
 	public static function retrieve_route_oneworld($database_file) {
113 113
 		global $globalDebug, $globalTransaction;
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 		try {
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121
-                        $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
123
-                        return "error : ".$e->getMessage();
124
-                }
121
+						$sth->execute(array(':source' => 'oneworld'));
122
+				} catch(PDOException $e) {
123
+						return "error : ".$e->getMessage();
124
+				}
125 125
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
126
+			if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129 129
 		if ($fh = fopen($database_file,"r")) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 			if ($globalTransaction) $Connection->db->commit();
149 149
 		}
150
-                return '';
150
+				return '';
151 151
 	}
152 152
 	
153 153
 	public static function retrieve_route_skyteam($database_file) {
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 		try {
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162
-                        $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
164
-                        return "error : ".$e->getMessage();
165
-                }
162
+						$sth->execute(array(':source' => 'skyteam'));
163
+				} catch(PDOException $e) {
164
+						return "error : ".$e->getMessage();
165
+				}
166 166
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
167
+			if ($globalDebug) echo " - Add routes to DB -";
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
192 192
 		}
193
-                return '';
193
+				return '';
194 194
 	}
195 195
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 196
 		global $globalTransaction;
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 		try {
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202
-                        $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
204
-                        return "error : ".$e->getMessage();
205
-                }
202
+						$sth->execute(array(':source' => $database_file));
203
+				} catch(PDOException $e) {
204
+						return "error : ".$e->getMessage();
205
+				}
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
207 207
 		try {
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210
-                        $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
212
-                        return "error : ".$e->getMessage();
213
-                }
210
+						$sth->execute(array(':source' => $database_file));
211
+				} catch(PDOException $e) {
212
+						return "error : ".$e->getMessage();
213
+				}
214 214
 
215
-    		update_db::connect_sqlite($database_file);
215
+			update_db::connect_sqlite($database_file);
216 216
 		$query = 'select * from Aircraft';
217 217
 		try {
218
-                        $sth = update_db::$db_sqlite->prepare($query);
219
-                        $sth->execute();
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
218
+						$sth = update_db::$db_sqlite->prepare($query);
219
+						$sth->execute();
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
224 224
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
225 225
 		
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 231
 		try {
232 232
 			if ($globalTransaction) $Connection->db->beginTransaction();
233
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237 237
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
-				    $sth_dest_owner->execute($query_dest_owner_values);
240
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
241
+					$sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243
-            		}
243
+					}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245 245
 		} catch(PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 		try {
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254
-                        $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
256
-                        return "error : ".$e->getMessage();
257
-                }
254
+						$sth->execute(array(':source' => $database_file));
255
+				} catch(PDOException $e) {
256
+						return "error : ".$e->getMessage();
257
+				}
258 258
 		return '';
259 259
 	}
260 260
 
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 		try {
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269
-                        $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
271
-                        return "error : ".$e->getMessage();
272
-                }
269
+						$sth->execute(array(':source' => $database_file));
270
+				} catch(PDOException $e) {
271
+						return "error : ".$e->getMessage();
272
+				}
273 273
 		
274 274
 		if ($fh = fopen($database_file,"r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -279,26 +279,26 @@  discard block
 block discarded – undo
279 279
 			$sth_dest = $Connection->db->prepare($query_dest);
280 280
 			try {
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282
-            			while (!feof($fh)) {
283
-            				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
282
+						while (!feof($fh)) {
283
+							$values = array();
284
+							$line = $Common->hex2str(fgets($fh,9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
289
-            				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
291
-            				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
-            				$sth_search = $Connection->db->prepare($query_search);
286
+							$values['ModeS'] = substr($line,0,6);
287
+							$values['Registration'] = trim(substr($line,69,6));
288
+							$aircraft_name = trim(substr($line,48,6));
289
+							// Check if we can find ICAO, else set it to GLID
290
+							$aircraft_name_split = explode(' ',$aircraft_name);
291
+							$search_more = '';
292
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294
+							$sth_search = $Connection->db->prepare($query_search);
295 295
 					try {
296
-                                    		$sth_search->execute();
297
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
-	            				//if (count($result) > 0) {
299
-	            				if (isset($result['icao']) && $result['icao'] != '') {
300
-	            				    $values['ICAOTypeCode'] = $result['icao'];
301
-	            				} 
296
+											$sth_search->execute();
297
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
298
+								//if (count($result) > 0) {
299
+								if (isset($result['icao']) && $result['icao'] != '') {
300
+									$values['ICAOTypeCode'] = $result['icao'];
301
+								} 
302 302
 					} catch(PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		try {
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324
-                        $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
326
-                        return "error : ".$e->getMessage();
327
-                }
324
+						$sth->execute(array(':source' => $database_file));
325
+				} catch(PDOException $e) {
326
+						return "error : ".$e->getMessage();
327
+				}
328 328
 		return '';
329 329
 	}
330 330
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 		try {
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338
-                        $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
340
-                        return "error : ".$e->getMessage();
341
-                }
338
+						$sth->execute(array(':source' => $database_file));
339
+				} catch(PDOException $e) {
340
+						return "error : ".$e->getMessage();
341
+				}
342 342
 		
343 343
 		if ($fh = fopen($database_file,"r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -349,25 +349,25 @@  discard block
 block discarded – undo
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351 351
 				$tmp = fgetcsv($fh,9999,',',"'");
352
-            			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
352
+						while (!feof($fh)) {
353
+							$line = fgetcsv($fh,9999,',',"'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
357
-            				$values['ModeS'] = $line[1];
358
-            				$values['Registration'] = $line[3];
359
-            				$values['ICAOTypeCode'] = '';
360
-            				$aircraft_name = $line[2];
361
-            				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
363
-            				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
-            				$sth_search = $Connection->db->prepare($query_search);
357
+							$values['ModeS'] = $line[1];
358
+							$values['Registration'] = $line[3];
359
+							$values['ICAOTypeCode'] = '';
360
+							$aircraft_name = $line[2];
361
+							// Check if we can find ICAO, else set it to GLID
362
+							$aircraft_name_split = explode(' ',$aircraft_name);
363
+							$search_more = '';
364
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366
+							$sth_search = $Connection->db->prepare($query_search);
367 367
 					try {
368
-                                    		$sth_search->execute();
369
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
368
+											$sth_search->execute();
369
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371 371
 					} catch(PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 		try {
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393
-                        $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
395
-                        return "error : ".$e->getMessage();
396
-                }
393
+						$sth->execute(array(':source' => $database_file));
394
+				} catch(PDOException $e) {
395
+						return "error : ".$e->getMessage();
396
+				}
397 397
 		return '';
398 398
 	}
399 399
 
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 		try {
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407
-                        $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
409
-                        return "error : ".$e->getMessage();
410
-                }
407
+						$sth->execute(array(':source' => $database_file));
408
+				} catch(PDOException $e) {
409
+						return "error : ".$e->getMessage();
410
+				}
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413 413
 		if ($fh = fopen($database_file,"r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
416
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
417 417
 		        
418 418
 			$Connection = new Connection();
419 419
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -421,126 +421,126 @@  discard block
 block discarded – undo
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423 423
 				$tmp = fgetcsv($fh,9999,',','"');
424
-            			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
426
-            				$values = array();
427
-            				//print_r($line);
428
-            				if ($country == 'F') {
429
-            				    $values['registration'] = $line[0];
430
-            				    $values['base'] = $line[4];
431
-            				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
-					    $values['cancel'] = $line[7];
424
+						while (!feof($fh)) {
425
+							$line = fgetcsv($fh,9999,',','"');
426
+							$values = array();
427
+							//print_r($line);
428
+							if ($country == 'F') {
429
+								$values['registration'] = $line[0];
430
+								$values['base'] = $line[4];
431
+								$values['owner'] = $line[5];
432
+								if ($line[6] == '') $values['date_first_reg'] = null;
433
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
434
+						$values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436
-					    // TODO : add modeS & reg to aircraft_modes
437
-            				    $values['registration'] = $line[0];
438
-            				    $values['base'] = $line[3];
439
-            				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
-					    $values['cancel'] = '';
443
-					    $values['modes'] = $line[7];
444
-					    $values['icao'] = $line[8];
436
+						// TODO : add modeS & reg to aircraft_modes
437
+								$values['registration'] = $line[0];
438
+								$values['base'] = $line[3];
439
+								$values['owner'] = $line[2];
440
+								if ($line[1] == '') $values['date_first_reg'] = null;
441
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
442
+						$values['cancel'] = '';
443
+						$values['modes'] = $line[7];
444
+						$values['icao'] = $line[8];
445 445
 					    
446 446
 					} elseif ($country == 'HB') {
447
-					    // TODO : add modeS & reg to aircraft_modes
448
-            				    $values['registration'] = $line[0];
449
-            				    $values['base'] = null;
450
-            				    $values['owner'] = $line[5];
451
-            				    $values['date_first_reg'] = null;
452
-					    $values['cancel'] = '';
453
-					    $values['modes'] = $line[4];
454
-					    $values['icao'] = $line[7];
447
+						// TODO : add modeS & reg to aircraft_modes
448
+								$values['registration'] = $line[0];
449
+								$values['base'] = null;
450
+								$values['owner'] = $line[5];
451
+								$values['date_first_reg'] = null;
452
+						$values['cancel'] = '';
453
+						$values['modes'] = $line[4];
454
+						$values['icao'] = $line[7];
455 455
 					} elseif ($country == 'OK') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[3];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
-					    $values['cancel'] = '';
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[3];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								if ($line[18] == '') $values['date_first_reg'] = null;
461
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
462
+						$values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464
-					    // TODO : add modeS & reg to aircraft_modes
465
-            				    $values['registration'] = $line[0];
466
-            				    $values['base'] = null;
467
-            				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
-
471
-					    $values['cancel'] = $line[39];
464
+						// TODO : add modeS & reg to aircraft_modes
465
+								$values['registration'] = $line[0];
466
+								$values['base'] = null;
467
+								$values['owner'] = $line[12];
468
+								if ($line[28] == '') $values['date_first_reg'] = null;
469
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
470
+
471
+						$values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
473
-            				    $values['registration'] = $line[0];
474
-            				    $values['base'] = null;
475
-            				    $values['owner'] = $line[4];
476
-            				    $values['date_first_reg'] = null;
477
-					    $values['cancel'] = '';
473
+								$values['registration'] = $line[0];
474
+								$values['base'] = null;
475
+								$values['owner'] = $line[4];
476
+								$values['date_first_reg'] = null;
477
+						$values['cancel'] = '';
478 478
 					} elseif ($country == 'CC') {
479
-            				    $values['registration'] = $line[0];
480
-            				    $values['base'] = null;
481
-            				    $values['owner'] = $line[6];
482
-            				    $values['date_first_reg'] = null;
483
-					    $values['cancel'] = '';
479
+								$values['registration'] = $line[0];
480
+								$values['base'] = null;
481
+								$values['owner'] = $line[6];
482
+								$values['date_first_reg'] = null;
483
+						$values['cancel'] = '';
484 484
 					} elseif ($country == 'HJ') {
485
-            				    $values['registration'] = $line[0];
486
-            				    $values['base'] = null;
487
-            				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
-					    $values['cancel'] = '';
485
+								$values['registration'] = $line[0];
486
+								$values['base'] = null;
487
+								$values['owner'] = $line[8];
488
+								if ($line[7] == '') $values['date_first_reg'] = null;
489
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
490
+						$values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492
-            				    $values['registration'] = $line[0];
493
-            				    $values['base'] = null;
494
-            				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
-					    $values['cancel'] = $line[7];
492
+								$values['registration'] = $line[0];
493
+								$values['base'] = null;
494
+								$values['owner'] = $line[4];
495
+								if ($line[6] == '') $values['date_first_reg'] = null;
496
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+						$values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499
-            				    $values['registration'] = $line[0];
500
-            				    $values['base'] = null;
501
-            				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
-					    $values['cancel'] = '';
499
+								$values['registration'] = $line[0];
500
+								$values['base'] = null;
501
+								$values['owner'] = $line[4];
502
+								if ($line[5] == '') $values['date_first_reg'] = null;
503
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
504
+						$values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506
-            				    $values['registration'] = $line[0];
507
-            				    $values['base'] = null;
508
-            				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
-					    $values['cancel'] = '';
506
+								$values['registration'] = $line[0];
507
+								$values['base'] = null;
508
+								$values['owner'] = $line[3];
509
+								if ($line[7] == '') $values['date_first_reg'] = null;
510
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
511
+						$values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513
-            				    $values['registration'] = $line[0];
514
-            				    $values['base'] = null;
515
-            				    $values['owner'] = $line[3];
516
-            				    $values['date_first_reg'] = null;
517
-					    $values['cancel'] = '';
518
-					    $values['modes'] = $line[5];
519
-					    $values['icao'] = $line[9];
513
+								$values['registration'] = $line[0];
514
+								$values['base'] = null;
515
+								$values['owner'] = $line[3];
516
+								$values['date_first_reg'] = null;
517
+						$values['cancel'] = '';
518
+						$values['modes'] = $line[5];
519
+						$values['icao'] = $line[9];
520 520
 					} elseif ($country == 'M') {
521
-            				    $values['registration'] = $line[0];
522
-            				    $values['base'] = null;
523
-            				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
-					    $values['modes'] = $line[4];
527
-					    $values['icao'] = $line[10];
521
+								$values['registration'] = $line[0];
522
+								$values['base'] = null;
523
+								$values['owner'] = $line[6];
524
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
526
+						$values['modes'] = $line[4];
527
+						$values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529
-            				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
-					    $values['modes'] = $line[5];
532
-					    $values['icao'] = $line[6];
529
+								$values['registration'] = $line[0];
530
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
531
+						$values['modes'] = $line[5];
532
+						$values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534
-            				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
-					    $values['modes'] = $line[4];
537
-					    $values['icao'] = $line[5];
534
+								$values['registration'] = $line[0];
535
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
536
+						$values['modes'] = $line[4];
537
+						$values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
539
-            				    $values['registration'] = $line[0];
540
-            				    $values['base'] = null;
541
-            				    $values['owner'] = $line[3];
542
-            				    $values['date_first_reg'] = null;
543
-					    $values['cancel'] = '';
539
+								$values['registration'] = $line[0];
540
+								$values['base'] = null;
541
+								$values['owner'] = $line[3];
542
+								$values['date_first_reg'] = null;
543
+						$values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546 546
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
                         return "error : ".$e->getMessage();
674 674
                 }
675 675
                 */
676
-                /*
676
+				/*
677 677
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
678 678
 		try {
679 679
 			$Connection = new Connection();
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
 		try {
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921
-                        $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
923
-                        return "error : ".$e->getMessage();
924
-                }
921
+						$sth->execute(array(':source' => 'translation.csv'));
922
+				} catch(PDOException $e) {
923
+						return "error : ".$e->getMessage();
924
+				}
925 925
 
926 926
 		
927 927
 		//update_db::unzip($out_file);
@@ -940,21 +940,21 @@  discard block
 block discarded – undo
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
943
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
-                                                //echo substr($operator, 0, 2)."\n";;
945
-                                                if (count($airline_array) > 0) {
943
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
944
+												//echo substr($operator, 0, 2)."\n";;
945
+												if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947 947
 							$operator = $airline_array[0]['icao'].substr($operator,2);
948
-                                                }
949
-                                        }
948
+												}
949
+										}
950 950
 					
951 951
 					$operator_correct = $data[3];
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
-                                                if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
-                                            	}
957
-                                        }
953
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954
+												if (count($airline_array) > 0) {
955
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
956
+												}
957
+										}
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			//$Connection->db->commit();
969 969
 		}
970 970
 		return '';
971
-        }
971
+		}
972 972
 	
973 973
 	public static function translation_fam() {
974 974
 		global $tmp_dir, $globalTransaction;
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 			//$Connection->db->commit();
1007 1007
 		}
1008 1008
 		return '';
1009
-        }
1009
+		}
1010 1010
 
1011 1011
 	/*
1012 1012
 	* This function use FAA public data.
@@ -1018,19 +1018,19 @@  discard block
 block discarded – undo
1018 1018
 		try {
1019 1019
 			$Connection = new Connection();
1020 1020
 			$sth = $Connection->db->prepare($query);
1021
-                        $sth->execute(array(':source' => 'website_faa'));
1022
-                } catch(PDOException $e) {
1023
-                        return "error : ".$e->getMessage();
1024
-                }
1021
+						$sth->execute(array(':source' => 'website_faa'));
1022
+				} catch(PDOException $e) {
1023
+						return "error : ".$e->getMessage();
1024
+				}
1025 1025
 
1026 1026
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
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
 		$delimiter = ",";
1036 1036
 		$mfr = array();
@@ -1106,17 +1106,17 @@  discard block
 block discarded – undo
1106 1106
 		}
1107 1107
 		//print_r($mfr);
1108 1108
 		return '';
1109
-        }
1109
+		}
1110 1110
 	public static function modes_fam() {
1111 1111
 		global $tmp_dir, $globalTransaction;
1112 1112
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1113 1113
 		try {
1114 1114
 			$Connection = new Connection();
1115 1115
 			$sth = $Connection->db->prepare($query);
1116
-                        $sth->execute(array(':source' => 'website_fam'));
1117
-                } catch(PDOException $e) {
1118
-                        return "error : ".$e->getMessage();
1119
-                }
1116
+						$sth->execute(array(':source' => 'website_fam'));
1117
+				} catch(PDOException $e) {
1118
+						return "error : ".$e->getMessage();
1119
+				}
1120 1120
 
1121 1121
 		
1122 1122
 		//update_db::unzip($out_file);
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 			if ($globalTransaction) $Connection->db->commit();
1147 1147
 		}
1148 1148
 		return '';
1149
-        }
1149
+		}
1150 1150
         
1151 1151
 	public static function owner_fam() {
1152 1152
 		global $tmp_dir, $globalTransaction;
@@ -1154,10 +1154,10 @@  discard block
 block discarded – undo
1154 1154
 		try {
1155 1155
 			$Connection = new Connection();
1156 1156
 			$sth = $Connection->db->prepare($query);
1157
-                        $sth->execute(array(':source' => 'website_fam'));
1158
-                } catch(PDOException $e) {
1159
-                        return "error : ".$e->getMessage();
1160
-                }
1157
+						$sth->execute(array(':source' => 'website_fam'));
1158
+				} catch(PDOException $e) {
1159
+						return "error : ".$e->getMessage();
1160
+				}
1161 1161
 
1162 1162
 		$delimiter = "\t";
1163 1163
 		$Connection = new Connection();
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 			if ($globalTransaction) $Connection->db->commit();
1184 1184
 		}
1185 1185
 		return '';
1186
-        }
1186
+		}
1187 1187
 
1188 1188
 	public static function routes_fam() {
1189 1189
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 			if ($globalTransaction) $Connection->db->commit();
1219 1219
 		}
1220 1220
 		return '';
1221
-        }
1221
+		}
1222 1222
 
1223 1223
 	public static function marine_identity_fam() {
1224 1224
 		global $tmp_dir, $globalTransaction;
@@ -1226,10 +1226,10 @@  discard block
 block discarded – undo
1226 1226
 		try {
1227 1227
 			$Connection = new Connection();
1228 1228
 			$sth = $Connection->db->prepare($query);
1229
-                        $sth->execute();
1230
-                } catch(PDOException $e) {
1231
-                        return "error : ".$e->getMessage();
1232
-                }
1229
+						$sth->execute();
1230
+				} catch(PDOException $e) {
1231
+						return "error : ".$e->getMessage();
1232
+				}
1233 1233
 
1234 1234
 		
1235 1235
 		//update_db::unzip($out_file);
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 			if ($globalTransaction) $Connection->db->commit();
1260 1260
 		}
1261 1261
 		return '';
1262
-        }
1262
+		}
1263 1263
 
1264 1264
 	public static function banned_fam() {
1265 1265
 		global $tmp_dir, $globalTransaction;
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 			if ($globalTransaction) $Connection->db->commit();
1294 1294
 		}
1295 1295
 		return '';
1296
-        }
1296
+		}
1297 1297
 
1298 1298
 	public static function tle($filename,$tletype) {
1299 1299
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1304,10 +1304,10 @@  discard block
 block discarded – undo
1304 1304
 		try {
1305 1305
 			$Connection = new Connection();
1306 1306
 			$sth = $Connection->db->prepare($query);
1307
-                        $sth->execute(array(':source' => $filename));
1308
-                } catch(PDOException $e) {
1309
-                        return "error : ".$e->getMessage();
1310
-                }
1307
+						$sth->execute(array(':source' => $filename));
1308
+				} catch(PDOException $e) {
1309
+						return "error : ".$e->getMessage();
1310
+				}
1311 1311
 		
1312 1312
 		$Connection = new Connection();
1313 1313
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1342,13 +1342,13 @@  discard block
 block discarded – undo
1342 1342
 			//$Connection->db->commit();
1343 1343
 		}
1344 1344
 		return '';
1345
-        }
1345
+		}
1346 1346
 
1347 1347
 	/**
1348
-        * Convert a HTML table to an array
1349
-        * @param String $data HTML page
1350
-        * @return Array array of the tables in HTML page
1351
-        */
1348
+	 * Convert a HTML table to an array
1349
+	 * @param String $data HTML page
1350
+	 * @return Array array of the tables in HTML page
1351
+	 */
1352 1352
 /*
1353 1353
         private static function table2array($data) {
1354 1354
                 $html = str_get_html($data);
@@ -1378,11 +1378,11 @@  discard block
 block discarded – undo
1378 1378
                 return(array_filter($tabledata));
1379 1379
         }
1380 1380
 */
1381
-       /**
1382
-        * Get data from form result
1383
-        * @param String $url form URL
1384
-        * @return String the result
1385
-        */
1381
+	   /**
1382
+	    * Get data from form result
1383
+	    * @param String $url form URL
1384
+	    * @return String the result
1385
+	    */
1386 1386
 /*
1387 1387
         private static function getData($url) {
1388 1388
                 $ch = curl_init();
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
 			if ($globalTransaction) $Connection->db->commit();
1476 1476
 		}
1477 1477
 		return '';
1478
-        }
1478
+		}
1479 1479
 
1480 1480
 	public static function ivao_airlines($filename) {
1481 1481
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1485,10 +1485,10 @@  discard block
 block discarded – undo
1485 1485
 		try {
1486 1486
 			$Connection = new Connection();
1487 1487
 			$sth = $Connection->db->prepare($query);
1488
-                        $sth->execute();
1489
-                } catch(PDOException $e) {
1490
-                        return "error : ".$e->getMessage();
1491
-                }
1488
+						$sth->execute();
1489
+				} catch(PDOException $e) {
1490
+						return "error : ".$e->getMessage();
1491
+				}
1492 1492
 
1493 1493
 		$header = NULL;
1494 1494
 		$delimiter = ':';
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 			if ($globalTransaction) $Connection->db->commit();
1513 1513
 		}
1514 1514
 		return '';
1515
-        }
1515
+		}
1516 1516
 	
1517 1517
 	public static function update_airspace() {
1518 1518
 		global $tmp_dir, $globalDBdriver;
@@ -1522,11 +1522,11 @@  discard block
 block discarded – undo
1522 1522
 			$query = 'DROP TABLE airspace';
1523 1523
 			try {
1524 1524
 				$sth = $Connection->db->prepare($query);
1525
-                    		$sth->execute();
1526
-	                } catch(PDOException $e) {
1525
+							$sth->execute();
1526
+					} catch(PDOException $e) {
1527 1527
 				return "error : ".$e->getMessage();
1528
-	                }
1529
-	        }
1528
+					}
1529
+			}
1530 1530
 
1531 1531
 
1532 1532
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1581,10 +1581,10 @@  discard block
 block discarded – undo
1581 1581
 			$query = 'DROP TABLE countries';
1582 1582
 			try {
1583 1583
 				$sth = $Connection->db->prepare($query);
1584
-            	        	$sth->execute();
1585
-	                } catch(PDOException $e) {
1586
-    	                	echo "error : ".$e->getMessage();
1587
-	                }
1584
+							$sth->execute();
1585
+					} catch(PDOException $e) {
1586
+							echo "error : ".$e->getMessage();
1587
+					}
1588 1588
 		}
1589 1589
 		if ($globalDBdriver == 'mysql') {
1590 1590
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2113,11 +2113,11 @@  discard block
 block discarded – undo
2113 2113
 						$query = 'DROP TABLE airspace';
2114 2114
 						try {
2115 2115
 							$sth = $Connection->db->prepare($query);
2116
-    	    	    					$sth->execute();
2117
-			            		} catch(PDOException $e) {
2116
+										$sth->execute();
2117
+								} catch(PDOException $e) {
2118 2118
 							return "error : ".$e->getMessage();
2119
-		            			}
2120
-		    			}
2119
+								}
2120
+						}
2121 2121
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2122 2122
 					update_db::insert_airspace_version($airspace_md5);
2123 2123
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2299,12 +2299,12 @@  discard block
 block discarded – undo
2299 2299
 		echo $data;
2300 2300
 		*/
2301 2301
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2302
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2303
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2304
-		    $result = fread($fh,100000000);
2305
-		    //echo $result;
2306
-		    //var_dump(str_get_html($result));
2307
-		    //print_r(self::table2array($result));
2302
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2303
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2304
+			$result = fread($fh,100000000);
2305
+			//echo $result;
2306
+			//var_dump(str_get_html($result));
2307
+			//print_r(self::table2array($result));
2308 2308
 		}
2309 2309
 
2310 2310
 	}
@@ -2318,10 +2318,10 @@  discard block
 block discarded – undo
2318 2318
 		try {
2319 2319
 			$Connection = new Connection();
2320 2320
 			$sth = $Connection->db->prepare($query);
2321
-                        $sth->execute();
2322
-                } catch(PDOException $e) {
2323
-                        return "error : ".$e->getMessage();
2324
-                }
2321
+						$sth->execute();
2322
+				} catch(PDOException $e) {
2323
+						return "error : ".$e->getMessage();
2324
+				}
2325 2325
 
2326 2326
 		$error = '';
2327 2327
 		if ($globalDebug) echo "Notam : Download...";
@@ -2377,8 +2377,8 @@  discard block
 block discarded – undo
2377 2377
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2378 2378
 					$data['permanent'] = 0;
2379 2379
 				} else {
2380
-				    $data['date_end'] = NULL;
2381
-				    $data['permanent'] = 1;
2380
+					$data['date_end'] = NULL;
2381
+					$data['permanent'] = 1;
2382 2382
 				}
2383 2383
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2384 2384
 				$NOTAM = new NOTAM();
@@ -2452,13 +2452,13 @@  discard block
 block discarded – undo
2452 2452
 		try {
2453 2453
 			$Connection = new Connection();
2454 2454
 			$sth = $Connection->db->prepare($query);
2455
-                        $sth->execute();
2456
-                } catch(PDOException $e) {
2457
-                        return "error : ".$e->getMessage();
2458
-                }
2459
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2460
-                if ($row['nb'] > 0) return false;
2461
-                else return true;
2455
+						$sth->execute();
2456
+				} catch(PDOException $e) {
2457
+						return "error : ".$e->getMessage();
2458
+				}
2459
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2460
+				if ($row['nb'] > 0) return false;
2461
+				else return true;
2462 2462
 	}
2463 2463
 
2464 2464
 	public static function insert_last_update() {
@@ -2467,10 +2467,10 @@  discard block
 block discarded – undo
2467 2467
 		try {
2468 2468
 			$Connection = new Connection();
2469 2469
 			$sth = $Connection->db->prepare($query);
2470
-                        $sth->execute();
2471
-                } catch(PDOException $e) {
2472
-                        return "error : ".$e->getMessage();
2473
-                }
2470
+						$sth->execute();
2471
+				} catch(PDOException $e) {
2472
+						return "error : ".$e->getMessage();
2473
+				}
2474 2474
 	}
2475 2475
 
2476 2476
 	public static function check_airspace_version($version) {
@@ -2478,13 +2478,13 @@  discard block
 block discarded – undo
2478 2478
 		try {
2479 2479
 			$Connection = new Connection();
2480 2480
 			$sth = $Connection->db->prepare($query);
2481
-                        $sth->execute(array(':version' => $version));
2482
-                } catch(PDOException $e) {
2483
-                        return "error : ".$e->getMessage();
2484
-                }
2485
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2486
-                if ($row['nb'] > 0) return true;
2487
-                else return false;
2481
+						$sth->execute(array(':version' => $version));
2482
+				} catch(PDOException $e) {
2483
+						return "error : ".$e->getMessage();
2484
+				}
2485
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2486
+				if ($row['nb'] > 0) return true;
2487
+				else return false;
2488 2488
 	}
2489 2489
 
2490 2490
 	public static function check_geoid_version($version) {
@@ -2492,13 +2492,13 @@  discard block
 block discarded – undo
2492 2492
 		try {
2493 2493
 			$Connection = new Connection();
2494 2494
 			$sth = $Connection->db->prepare($query);
2495
-                        $sth->execute(array(':version' => $version));
2496
-                } catch(PDOException $e) {
2497
-                        return "error : ".$e->getMessage();
2498
-                }
2499
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2500
-                if ($row['nb'] > 0) return true;
2501
-                else return false;
2495
+						$sth->execute(array(':version' => $version));
2496
+				} catch(PDOException $e) {
2497
+						return "error : ".$e->getMessage();
2498
+				}
2499
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2500
+				if ($row['nb'] > 0) return true;
2501
+				else return false;
2502 2502
 	}
2503 2503
 
2504 2504
 	public static function check_marine_identity_version($version) {
@@ -2506,13 +2506,13 @@  discard block
 block discarded – undo
2506 2506
 		try {
2507 2507
 			$Connection = new Connection();
2508 2508
 			$sth = $Connection->db->prepare($query);
2509
-                        $sth->execute(array(':version' => $version));
2510
-                } catch(PDOException $e) {
2511
-                        return "error : ".$e->getMessage();
2512
-                }
2513
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2514
-                if ($row['nb'] > 0) return true;
2515
-                else return false;
2509
+						$sth->execute(array(':version' => $version));
2510
+				} catch(PDOException $e) {
2511
+						return "error : ".$e->getMessage();
2512
+				}
2513
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2514
+				if ($row['nb'] > 0) return true;
2515
+				else return false;
2516 2516
 	}
2517 2517
 
2518 2518
 
@@ -2534,10 +2534,10 @@  discard block
 block discarded – undo
2534 2534
 		try {
2535 2535
 			$Connection = new Connection();
2536 2536
 			$sth = $Connection->db->prepare($query);
2537
-                        $sth->execute(array(':version' => $version));
2538
-                } catch(PDOException $e) {
2539
-                        return "error : ".$e->getMessage();
2540
-                }
2537
+						$sth->execute(array(':version' => $version));
2538
+				} catch(PDOException $e) {
2539
+						return "error : ".$e->getMessage();
2540
+				}
2541 2541
 	}
2542 2542
 
2543 2543
 	public static function insert_marine_identity_version($version) {
@@ -2546,10 +2546,10 @@  discard block
 block discarded – undo
2546 2546
 		try {
2547 2547
 			$Connection = new Connection();
2548 2548
 			$sth = $Connection->db->prepare($query);
2549
-                        $sth->execute(array(':version' => $version));
2550
-                } catch(PDOException $e) {
2551
-                        return "error : ".$e->getMessage();
2552
-                }
2549
+						$sth->execute(array(':version' => $version));
2550
+				} catch(PDOException $e) {
2551
+						return "error : ".$e->getMessage();
2552
+				}
2553 2553
 	}
2554 2554
 
2555 2555
 	public static function check_last_notam_update() {
@@ -2562,13 +2562,13 @@  discard block
 block discarded – undo
2562 2562
 		try {
2563 2563
 			$Connection = new Connection();
2564 2564
 			$sth = $Connection->db->prepare($query);
2565
-                        $sth->execute();
2566
-                } catch(PDOException $e) {
2567
-                        return "error : ".$e->getMessage();
2568
-                }
2569
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2570
-                if ($row['nb'] > 0) return false;
2571
-                else return true;
2565
+						$sth->execute();
2566
+				} catch(PDOException $e) {
2567
+						return "error : ".$e->getMessage();
2568
+				}
2569
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2570
+				if ($row['nb'] > 0) return false;
2571
+				else return true;
2572 2572
 	}
2573 2573
 
2574 2574
 	public static function insert_last_notam_update() {
@@ -2577,10 +2577,10 @@  discard block
 block discarded – undo
2577 2577
 		try {
2578 2578
 			$Connection = new Connection();
2579 2579
 			$sth = $Connection->db->prepare($query);
2580
-                        $sth->execute();
2581
-                } catch(PDOException $e) {
2582
-                        return "error : ".$e->getMessage();
2583
-                }
2580
+						$sth->execute();
2581
+				} catch(PDOException $e) {
2582
+						return "error : ".$e->getMessage();
2583
+				}
2584 2584
 	}
2585 2585
 
2586 2586
 	public static function check_last_airspace_update() {
@@ -2593,13 +2593,13 @@  discard block
 block discarded – undo
2593 2593
 		try {
2594 2594
 			$Connection = new Connection();
2595 2595
 			$sth = $Connection->db->prepare($query);
2596
-                        $sth->execute();
2597
-                } catch(PDOException $e) {
2598
-                        return "error : ".$e->getMessage();
2599
-                }
2600
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2601
-                if ($row['nb'] > 0) return false;
2602
-                else return true;
2596
+						$sth->execute();
2597
+				} catch(PDOException $e) {
2598
+						return "error : ".$e->getMessage();
2599
+				}
2600
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2601
+				if ($row['nb'] > 0) return false;
2602
+				else return true;
2603 2603
 	}
2604 2604
 
2605 2605
 	public static function insert_last_airspace_update() {
@@ -2608,10 +2608,10 @@  discard block
 block discarded – undo
2608 2608
 		try {
2609 2609
 			$Connection = new Connection();
2610 2610
 			$sth = $Connection->db->prepare($query);
2611
-                        $sth->execute();
2612
-                } catch(PDOException $e) {
2613
-                        return "error : ".$e->getMessage();
2614
-                }
2611
+						$sth->execute();
2612
+				} catch(PDOException $e) {
2613
+						return "error : ".$e->getMessage();
2614
+				}
2615 2615
 	}
2616 2616
 
2617 2617
 	public static function check_last_geoid_update() {
@@ -2624,13 +2624,13 @@  discard block
 block discarded – undo
2624 2624
 		try {
2625 2625
 			$Connection = new Connection();
2626 2626
 			$sth = $Connection->db->prepare($query);
2627
-                        $sth->execute();
2628
-                } catch(PDOException $e) {
2629
-                        return "error : ".$e->getMessage();
2630
-                }
2631
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2632
-                if ($row['nb'] > 0) return false;
2633
-                else return true;
2627
+						$sth->execute();
2628
+				} catch(PDOException $e) {
2629
+						return "error : ".$e->getMessage();
2630
+				}
2631
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2632
+				if ($row['nb'] > 0) return false;
2633
+				else return true;
2634 2634
 	}
2635 2635
 
2636 2636
 	public static function insert_last_geoid_update() {
@@ -2639,10 +2639,10 @@  discard block
 block discarded – undo
2639 2639
 		try {
2640 2640
 			$Connection = new Connection();
2641 2641
 			$sth = $Connection->db->prepare($query);
2642
-                        $sth->execute();
2643
-                } catch(PDOException $e) {
2644
-                        return "error : ".$e->getMessage();
2645
-                }
2642
+						$sth->execute();
2643
+				} catch(PDOException $e) {
2644
+						return "error : ".$e->getMessage();
2645
+				}
2646 2646
 	}
2647 2647
 
2648 2648
 	public static function check_last_owner_update() {
@@ -2655,13 +2655,13 @@  discard block
 block discarded – undo
2655 2655
 		try {
2656 2656
 			$Connection = new Connection();
2657 2657
 			$sth = $Connection->db->prepare($query);
2658
-                        $sth->execute();
2659
-                } catch(PDOException $e) {
2660
-                        return "error : ".$e->getMessage();
2661
-                }
2662
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2663
-                if ($row['nb'] > 0) return false;
2664
-                else return true;
2658
+						$sth->execute();
2659
+				} catch(PDOException $e) {
2660
+						return "error : ".$e->getMessage();
2661
+				}
2662
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2663
+				if ($row['nb'] > 0) return false;
2664
+				else return true;
2665 2665
 	}
2666 2666
 
2667 2667
 	public static function insert_last_owner_update() {
@@ -2670,10 +2670,10 @@  discard block
 block discarded – undo
2670 2670
 		try {
2671 2671
 			$Connection = new Connection();
2672 2672
 			$sth = $Connection->db->prepare($query);
2673
-                        $sth->execute();
2674
-                } catch(PDOException $e) {
2675
-                        return "error : ".$e->getMessage();
2676
-                }
2673
+						$sth->execute();
2674
+				} catch(PDOException $e) {
2675
+						return "error : ".$e->getMessage();
2676
+				}
2677 2677
 	}
2678 2678
 	public static function check_last_schedules_update() {
2679 2679
 		global $globalDBdriver;
@@ -2685,13 +2685,13 @@  discard block
 block discarded – undo
2685 2685
 		try {
2686 2686
 			$Connection = new Connection();
2687 2687
 			$sth = $Connection->db->prepare($query);
2688
-                        $sth->execute();
2689
-                } catch(PDOException $e) {
2690
-                        return "error : ".$e->getMessage();
2691
-                }
2692
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2693
-                if ($row['nb'] > 0) return false;
2694
-                else return true;
2688
+						$sth->execute();
2689
+				} catch(PDOException $e) {
2690
+						return "error : ".$e->getMessage();
2691
+				}
2692
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2693
+				if ($row['nb'] > 0) return false;
2694
+				else return true;
2695 2695
 	}
2696 2696
 
2697 2697
 	public static function insert_last_schedules_update() {
@@ -2700,10 +2700,10 @@  discard block
 block discarded – undo
2700 2700
 		try {
2701 2701
 			$Connection = new Connection();
2702 2702
 			$sth = $Connection->db->prepare($query);
2703
-                        $sth->execute();
2704
-                } catch(PDOException $e) {
2705
-                        return "error : ".$e->getMessage();
2706
-                }
2703
+						$sth->execute();
2704
+				} catch(PDOException $e) {
2705
+						return "error : ".$e->getMessage();
2706
+				}
2707 2707
 	}
2708 2708
 	public static function check_last_tle_update() {
2709 2709
 		global $globalDBdriver;
@@ -2715,13 +2715,13 @@  discard block
 block discarded – undo
2715 2715
 		try {
2716 2716
 			$Connection = new Connection();
2717 2717
 			$sth = $Connection->db->prepare($query);
2718
-                        $sth->execute();
2719
-                } catch(PDOException $e) {
2720
-                        return "error : ".$e->getMessage();
2721
-                }
2722
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2723
-                if ($row['nb'] > 0) return false;
2724
-                else return true;
2718
+						$sth->execute();
2719
+				} catch(PDOException $e) {
2720
+						return "error : ".$e->getMessage();
2721
+				}
2722
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2723
+				if ($row['nb'] > 0) return false;
2724
+				else return true;
2725 2725
 	}
2726 2726
 
2727 2727
 	public static function insert_last_tle_update() {
@@ -2730,10 +2730,10 @@  discard block
 block discarded – undo
2730 2730
 		try {
2731 2731
 			$Connection = new Connection();
2732 2732
 			$sth = $Connection->db->prepare($query);
2733
-                        $sth->execute();
2734
-                } catch(PDOException $e) {
2735
-                        return "error : ".$e->getMessage();
2736
-                }
2733
+						$sth->execute();
2734
+				} catch(PDOException $e) {
2735
+						return "error : ".$e->getMessage();
2736
+				}
2737 2737
 	}
2738 2738
 	public static function check_last_marine_identity_update() {
2739 2739
 		global $globalDBdriver;
@@ -2745,13 +2745,13 @@  discard block
 block discarded – undo
2745 2745
 		try {
2746 2746
 			$Connection = new Connection();
2747 2747
 			$sth = $Connection->db->prepare($query);
2748
-                        $sth->execute();
2749
-                } catch(PDOException $e) {
2750
-                        return "error : ".$e->getMessage();
2751
-                }
2752
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2753
-                if ($row['nb'] > 0) return false;
2754
-                else return true;
2748
+						$sth->execute();
2749
+				} catch(PDOException $e) {
2750
+						return "error : ".$e->getMessage();
2751
+				}
2752
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2753
+				if ($row['nb'] > 0) return false;
2754
+				else return true;
2755 2755
 	}
2756 2756
 
2757 2757
 	public static function insert_last_marine_identity_update() {
@@ -2760,10 +2760,10 @@  discard block
 block discarded – undo
2760 2760
 		try {
2761 2761
 			$Connection = new Connection();
2762 2762
 			$sth = $Connection->db->prepare($query);
2763
-                        $sth->execute();
2764
-                } catch(PDOException $e) {
2765
-                        return "error : ".$e->getMessage();
2766
-                }
2763
+						$sth->execute();
2764
+				} catch(PDOException $e) {
2765
+						return "error : ".$e->getMessage();
2766
+				}
2767 2767
 	}
2768 2768
 	public static function delete_duplicatemodes() {
2769 2769
 		global $globalDBdriver;
@@ -2775,10 +2775,10 @@  discard block
 block discarded – undo
2775 2775
 		try {
2776 2776
 			$Connection = new Connection();
2777 2777
 			$sth = $Connection->db->prepare($query);
2778
-                        $sth->execute();
2779
-                } catch(PDOException $e) {
2780
-                        return "error : ".$e->getMessage();
2781
-                }
2778
+						$sth->execute();
2779
+				} catch(PDOException $e) {
2780
+						return "error : ".$e->getMessage();
2781
+				}
2782 2782
 	}
2783 2783
 	public static function delete_duplicateowner() {
2784 2784
 		global $globalDBdriver;
@@ -2790,10 +2790,10 @@  discard block
 block discarded – undo
2790 2790
 		try {
2791 2791
 			$Connection = new Connection();
2792 2792
 			$sth = $Connection->db->prepare($query);
2793
-                        $sth->execute();
2794
-                } catch(PDOException $e) {
2795
-                        return "error : ".$e->getMessage();
2796
-                }
2793
+						$sth->execute();
2794
+				} catch(PDOException $e) {
2795
+						return "error : ".$e->getMessage();
2796
+				}
2797 2797
 	}
2798 2798
 	
2799 2799
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		fclose($fp);
26 26
 	}
27 27
 
28
-	public static function gunzip($in_file,$out_file_name = '') {
28
+	public static function gunzip($in_file, $out_file_name = '') {
29 29
 		//echo $in_file.' -> '.$out_file_name."\n";
30 30
 		$buffer_size = 4096; // read 4kb at a time
31 31
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32 32
 		if ($in_file != '' && file_exists($in_file)) {
33 33
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
34
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
35
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
36 36
 			else {
37 37
 				echo 'gzopen not available';
38 38
 				die;
39 39
 			}
40 40
 			$out_file = fopen($out_file_name, 'wb'); 
41
-			while(!gzeof($file)) {
41
+			while (!gzeof($file)) {
42 42
 				fwrite($out_file, gzread($file, $buffer_size));
43 43
 			}  
44 44
 			fclose($out_file);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			self::$db_sqlite = new PDO('sqlite:'.$database);
64 64
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79 79
                         $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         return "error : ".$e->getMessage();
82 82
                 }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		try {
89 89
                         $sth = update_db::$db_sqlite->prepare($query);
90 90
                         $sth->execute();
91
-                } catch(PDOException $e) {
91
+                } catch (PDOException $e) {
92 92
                         return "error : ".$e->getMessage();
93 93
                 }
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100 100
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104 104
             		}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
126 126
     		if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129
-		if ($fh = fopen($database_file,"r")) {
129
+		if ($fh = fopen($database_file, "r")) {
130 130
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 131
 			$Connection = new Connection();
132 132
 			$sth_dest = $Connection->db->prepare($query_dest);
133 133
 			if ($globalTransaction) $Connection->db->beginTransaction();
134 134
 			while (!feof($fh)) {
135
-				$line = fgetcsv($fh,9999,',');
135
+				$line = fgetcsv($fh, 9999, ',');
136 136
 				if ($line[0] != '') {
137 137
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
138 138
 						try {
139
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
140 140
 							$sth_dest->execute($query_dest_values);
141
-						} catch(PDOException $e) {
141
+						} catch (PDOException $e) {
142 142
 							if ($globalTransaction) $Connection->db->rollBack(); 
143 143
 							return "error : ".$e->getMessage();
144 144
 						}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162 162
                         $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         return "error : ".$e->getMessage();
165 165
                 }
166 166
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
171
-		if ($fh = fopen($database_file,"r")) {
171
+		if ($fh = fopen($database_file, "r")) {
172 172
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
173 173
 			$Connection = new Connection();
174 174
 			$sth_dest = $Connection->db->prepare($query_dest);
175 175
 			try {
176 176
 				if ($globalTransaction) $Connection->db->beginTransaction();
177 177
 				while (!feof($fh)) {
178
-					$line = fgetcsv($fh,9999,',');
178
+					$line = fgetcsv($fh, 9999, ',');
179 179
 					if ($line[0] != '') {
180
-						$datebe = explode('  -  ',$line[2]);
180
+						$datebe = explode('  -  ', $line[2]);
181 181
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
182
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
182
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
183 183
 							$sth_dest->execute($query_dest_values);
184 184
 						}
185 185
 					}
186 186
 				}
187 187
 				if ($globalTransaction) $Connection->db->commit();
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				if ($globalTransaction) $Connection->db->rollBack(); 
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202 202
                         $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         return "error : ".$e->getMessage();
205 205
                 }
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210 210
                         $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         return "error : ".$e->getMessage();
213 213
                 }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		try {
218 218
                         $sth = update_db::$db_sqlite->prepare($query);
219 219
                         $sth->execute();
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
241 241
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243 243
             		}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245
-		} catch(PDOException $e) {
245
+		} catch (PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
247 247
 		}
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254 254
                         $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
255
+                } catch (PDOException $e) {
256 256
                         return "error : ".$e->getMessage();
257 257
                 }
258 258
 		return '';
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269 269
                         $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
270
+                } catch (PDOException $e) {
271 271
                         return "error : ".$e->getMessage();
272 272
                 }
273 273
 		
274
-		if ($fh = fopen($database_file,"r")) {
274
+		if ($fh = fopen($database_file, "r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
276 276
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
277 277
 		
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282 282
             			while (!feof($fh)) {
283 283
             				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
284
+            				$line = $Common->hex2str(fgets($fh, 9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
286
+            				$values['ModeS'] = substr($line, 0, 6);
287
+            				$values['Registration'] = trim(substr($line, 69, 6));
288
+            				$aircraft_name = trim(substr($line, 48, 6));
289 289
             				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
+            				$aircraft_name_split = explode(' ', $aircraft_name);
291 291
             				$search_more = '';
292 292
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293 293
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	            				if (isset($result['icao']) && $result['icao'] != '') {
300 300
 	            				    $values['ICAOTypeCode'] = $result['icao'];
301 301
 	            				} 
302
-					} catch(PDOException $e) {
302
+					} catch (PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
305 305
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
306 306
 					// Add data to db
307 307
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 308
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
309
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
309
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
310 310
 						//print_r($query_dest_values);
311 311
 						$sth_dest->execute($query_dest_values);
312 312
 					}
313 313
 				}
314 314
 				if ($globalTransaction) $Connection->db->commit();
315
-			} catch(PDOException $e) {
315
+			} catch (PDOException $e) {
316 316
 				return "error : ".$e->getMessage();
317 317
 			}
318 318
 		}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324 324
                         $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
325
+                } catch (PDOException $e) {
326 326
                         return "error : ".$e->getMessage();
327 327
                 }
328 328
 		return '';
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338 338
                         $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
339
+                } catch (PDOException $e) {
340 340
                         return "error : ".$e->getMessage();
341 341
                 }
342 342
 		
343
-		if ($fh = fopen($database_file,"r")) {
343
+		if ($fh = fopen($database_file, "r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
345 345
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
346 346
 		
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 			$sth_dest = $Connection->db->prepare($query_dest);
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351
-				$tmp = fgetcsv($fh,9999,',',"'");
351
+				$tmp = fgetcsv($fh, 9999, ',', "'");
352 352
             			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
353
+            				$line = fgetcsv($fh, 9999, ',', "'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             				$values['ICAOTypeCode'] = '';
360 360
             				$aircraft_name = $line[2];
361 361
             				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
362
+            				$aircraft_name_split = explode(' ', $aircraft_name);
363 363
             				$search_more = '';
364 364
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365 365
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
                                     		$sth_search->execute();
369 369
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370 370
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371
-					} catch(PDOException $e) {
371
+					} catch (PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
374 374
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375 375
 					// Add data to db
376 376
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
377 377
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
378
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
378
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
379 379
 						//print_r($query_dest_values);
380 380
 						$sth_dest->execute($query_dest_values);
381 381
 					}
382 382
 				}
383 383
 				if ($globalTransaction) $Connection->db->commit();
384
-			} catch(PDOException $e) {
384
+			} catch (PDOException $e) {
385 385
 				return "error : ".$e->getMessage();
386 386
 			}
387 387
 		}
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
                         $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
394
+                } catch (PDOException $e) {
395 395
                         return "error : ".$e->getMessage();
396 396
                 }
397 397
 		return '';
398 398
 	}
399 399
 
400
-	public static function retrieve_owner($database_file,$country = 'F') {
400
+	public static function retrieve_owner($database_file, $country = 'F') {
401 401
 		global $globalTransaction, $globalMasterSource;
402 402
 		//$query = 'TRUNCATE TABLE aircraft_modes';
403 403
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407 407
                         $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
408
+                } catch (PDOException $e) {
409 409
                         return "error : ".$e->getMessage();
410 410
                 }
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413
-		if ($fh = fopen($database_file,"r")) {
413
+		if ($fh = fopen($database_file, "r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416 416
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 			$sth_modes = $Connection->db->prepare($query_modes);
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423
-				$tmp = fgetcsv($fh,9999,',','"');
423
+				$tmp = fgetcsv($fh, 9999, ',', '"');
424 424
             			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
425
+            				$line = fgetcsv($fh, 9999, ',', '"');
426 426
             				$values = array();
427 427
             				//print_r($line);
428 428
             				if ($country == 'F') {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             				    $values['base'] = $line[4];
431 431
             				    $values['owner'] = $line[5];
432 432
             				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
433
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
434 434
 					    $values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436 436
 					    // TODO : add modeS & reg to aircraft_modes
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             				    $values['base'] = $line[3];
439 439
             				    $values['owner'] = $line[2];
440 440
             				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
441
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
442 442
 					    $values['cancel'] = '';
443 443
 					    $values['modes'] = $line[7];
444 444
 					    $values['icao'] = $line[8];
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             				    $values['base'] = null;
459 459
             				    $values['owner'] = $line[5];
460 460
             				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
461
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
462 462
 					    $values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464 464
 					    // TODO : add modeS & reg to aircraft_modes
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             				    $values['base'] = null;
467 467
             				    $values['owner'] = $line[12];
468 468
             				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
469
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
470 470
 
471 471
 					    $values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -486,28 +486,28 @@  discard block
 block discarded – undo
486 486
             				    $values['base'] = null;
487 487
             				    $values['owner'] = $line[8];
488 488
             				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
489
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
490 490
 					    $values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492 492
             				    $values['registration'] = $line[0];
493 493
             				    $values['base'] = null;
494 494
             				    $values['owner'] = $line[4];
495 495
             				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
497 497
 					    $values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499 499
             				    $values['registration'] = $line[0];
500 500
             				    $values['base'] = null;
501 501
             				    $values['owner'] = $line[4];
502 502
             				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
503
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
504 504
 					    $values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506 506
             				    $values['registration'] = $line[0];
507 507
             				    $values['base'] = null;
508 508
             				    $values['owner'] = $line[3];
509 509
             				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
510
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
511 511
 					    $values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513 513
             				    $values['registration'] = $line[0];
@@ -521,18 +521,18 @@  discard block
 block discarded – undo
521 521
             				    $values['registration'] = $line[0];
522 522
             				    $values['base'] = null;
523 523
             				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
525
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
526 526
 					    $values['modes'] = $line[4];
527 527
 					    $values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529 529
             				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
530
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
531 531
 					    $values['modes'] = $line[5];
532 532
 					    $values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534 534
             				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
535
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
536 536
 					    $values['modes'] = $line[4];
537 537
 					    $values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
 					    $values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
546
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
547 547
 						$sth_dest->execute($query_dest_values);
548 548
 					}
549 549
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
550 550
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
551
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
551
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
552 552
 						$sth_modes->execute($query_modes_values);
553 553
 					}
554 554
 				}
555 555
 				if ($globalTransaction) $Connection->db->commit();
556
-			} catch(PDOException $e) {
556
+			} catch (PDOException $e) {
557 557
 				return "error : ".$e->getMessage();
558 558
 			}
559 559
 		}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		if ($globalTransaction) $Connection->db->beginTransaction();
692 692
   
693 693
 		$i = 0;
694
-		while($row = sparql_fetch_array($result))
694
+		while ($row = sparql_fetch_array($result))
695 695
 		{
696 696
 			if ($i >= 1) {
697 697
 			//print_r($row);
@@ -711,33 +711,33 @@  discard block
 block discarded – undo
711 711
 				$row['image'] = '';
712 712
 				$row['image_thumb'] = '';
713 713
 			} else {
714
-				$image = str_replace(' ','_',$row['image']);
714
+				$image = str_replace(' ', '_', $row['image']);
715 715
 				$digest = md5($image);
716
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
717
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
718
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
719
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
716
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
717
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
718
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
719
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
720 720
 			}
721 721
 			
722
-			$country = explode('-',$row['country']);
722
+			$country = explode('-', $row['country']);
723 723
 			$row['country'] = $country[0];
724 724
 			
725 725
 			$row['type'] = trim($row['type']);
726
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
726
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
727 727
 				$row['type'] = 'military';
728 728
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
729 729
 				$row['type'] = 'small_airport';
730 730
 			}
731 731
 			
732
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
733
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
732
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
733
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
734 734
 			//print_r($query_dest_values);
735 735
 			
736 736
 			if ($row['icao'] != '') {
737 737
 				try {
738 738
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
739 739
 					$sth->execute(array(':icao' => $row['icao']));
740
-				} catch(PDOException $e) {
740
+				} catch (PDOException $e) {
741 741
 					return "error : ".$e->getMessage();
742 742
 				}
743 743
 					if ($sth->fetchColumn() > 0) {
@@ -745,15 +745,15 @@  discard block
 block discarded – undo
745 745
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
746 746
 						try {
747 747
 							$sth = $Connection->db->prepare($query);
748
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
749
-						} catch(PDOException $e) {
748
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
749
+						} catch (PDOException $e) {
750 750
 							return "error : ".$e->getMessage();
751 751
 						}
752 752
 						echo $row['icao'].' : '.$row['type']."\n";
753 753
 					} else {
754 754
 						try {
755 755
 							$sth_dest->execute($query_dest_values);
756
-						} catch(PDOException $e) {
756
+						} catch (PDOException $e) {
757 757
 							return "error : ".$e->getMessage();
758 758
 						}
759 759
 					}
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		echo "Download data from ourairports.com...\n";
805 805
 		$delimiter = ',';
806 806
 		$out_file = $tmp_dir.'airports.csv';
807
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
807
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
808 808
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
809 809
 		echo "Add data from ourairports.com...\n";
810 810
 
@@ -815,33 +815,33 @@  discard block
 block discarded – undo
815 815
 			//$Connection->db->beginTransaction();
816 816
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 817
 			{
818
-				if(!$header) $header = $row;
818
+				if (!$header) $header = $row;
819 819
 				else {
820 820
 					$data = array();
821 821
 					$data = array_combine($header, $row);
822 822
 					try {
823 823
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
824 824
 						$sth->execute(array(':icao' => $data['ident']));
825
-					} catch(PDOException $e) {
825
+					} catch (PDOException $e) {
826 826
 						return "error : ".$e->getMessage();
827 827
 					}
828 828
 					if ($sth->fetchColumn() > 0) {
829 829
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
830 830
 						try {
831 831
 							$sth = $Connection->db->prepare($query);
832
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
833
-						} catch(PDOException $e) {
832
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
833
+						} catch (PDOException $e) {
834 834
 							return "error : ".$e->getMessage();
835 835
 						}
836 836
 					} else {
837 837
 						if ($data['gps_code'] == $data['ident']) {
838 838
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
839 839
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
840
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
840
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
841 841
 						try {
842 842
 							$sth = $Connection->db->prepare($query);
843 843
 							$sth->execute($query_values);
844
-						} catch(PDOException $e) {
844
+						} catch (PDOException $e) {
845 845
 							return "error : ".$e->getMessage();
846 846
 						}
847 847
 						$i++;
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		
857 857
 		echo "Download data from another free database...\n";
858 858
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
859
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
860 860
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
861 861
 		update_db::unzip($out_file);
862 862
 		$header = NULL;
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 			//$Connection->db->beginTransaction();
869 869
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 870
 			{
871
-				if(!$header) $header = $row;
871
+				if (!$header) $header = $row;
872 872
 				else {
873 873
 					$data = $row;
874 874
 
875 875
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
876 876
 					try {
877 877
 						$sth = $Connection->db->prepare($query);
878
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
879
-					} catch(PDOException $e) {
878
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
879
+					} catch (PDOException $e) {
880 880
 						return "error : ".$e->getMessage();
881 881
 					}
882 882
 				}
@@ -890,15 +890,15 @@  discard block
 block discarded – undo
890 890
 		try {
891 891
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
892 892
 			$sth->execute();
893
-		} catch(PDOException $e) {
893
+		} catch (PDOException $e) {
894 894
 			return "error : ".$e->getMessage();
895 895
 		}
896 896
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
897 897
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
898 898
 			try {
899 899
 				$sth2 = $Connection->db->prepare($query2);
900
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
901
-			} catch(PDOException $e) {
900
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
901
+			} catch (PDOException $e) {
902 902
 				return "error : ".$e->getMessage();
903 903
 			}
904 904
 		}
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 			$Connection = new Connection();
920 920
 			$sth = $Connection->db->prepare($query);
921 921
                         $sth->execute(array(':source' => 'translation.csv'));
922
-                } catch(PDOException $e) {
922
+                } catch (PDOException $e) {
923 923
                         return "error : ".$e->getMessage();
924 924
                 }
925 925
 
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
937 937
 			{
938 938
 				$i++;
939
-				if($i > 12) {
939
+				if ($i > 12) {
940 940
 					$data = $row;
941 941
 					$operator = $data[2];
942 942
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
                                                 //echo substr($operator, 0, 2)."\n";;
945 945
                                                 if (count($airline_array) > 0) {
946 946
 							//print_r($airline_array);
947
-							$operator = $airline_array[0]['icao'].substr($operator,2);
947
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
948 948
                                                 }
949 949
                                         }
950 950
 					
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
953 953
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
954 954
                                                 if (count($airline_array) > 0) {
955
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
955
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
956 956
                                             	}
957 957
                                         }
958 958
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
959 959
 					try {
960 960
 						$sth = $Connection->db->prepare($query);
961
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
-					} catch(PDOException $e) {
961
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
962
+					} catch (PDOException $e) {
963 963
 						return "error : ".$e->getMessage();
964 964
 					}
965 965
 				}
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 			$Connection = new Connection();
978 978
 			$sth = $Connection->db->prepare($query);
979 979
 			$sth->execute(array(':source' => 'website_fam'));
980
-		} catch(PDOException $e) {
980
+		} catch (PDOException $e) {
981 981
 			return "error : ".$e->getMessage();
982 982
 		}
983 983
 		//update_db::unzip($out_file);
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
996 996
 					try {
997 997
 						$sth = $Connection->db->prepare($query);
998
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
999
-					} catch(PDOException $e) {
998
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
999
+					} catch (PDOException $e) {
1000 1000
 						return "error : ".$e->getMessage();
1001 1001
 					}
1002 1002
 				}
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 			$Connection = new Connection();
1020 1020
 			$sth = $Connection->db->prepare($query);
1021 1021
                         $sth->execute(array(':source' => 'website_faa'));
1022
-                } catch(PDOException $e) {
1022
+                } catch (PDOException $e) {
1023 1023
                         return "error : ".$e->getMessage();
1024 1024
                 }
1025 1025
 
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030 1030
                         $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1031
+                } catch (PDOException $e) {
1032 1032
                         return "error : ".$e->getMessage();
1033 1033
                 }
1034 1034
 
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1046 1046
 					try {
1047 1047
 						$sths = $Connection->db->prepare($query_search);
1048
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1049
-					} catch(PDOException $e) {
1048
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1049
+					} catch (PDOException $e) {
1050 1050
 						return "error s : ".$e->getMessage();
1051 1051
 					}
1052 1052
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 							//}
1060 1060
 						try {
1061 1061
 							$sthi = $Connection->db->prepare($queryi);
1062
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1063
-						} catch(PDOException $e) {
1062
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1063
+						} catch (PDOException $e) {
1064 1064
 							return "error u : ".$e->getMessage();
1065 1065
 						}
1066 1066
 					} else {
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 						try {
1069 1069
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1070 1070
 							$sthsm->execute(array(':mfr' => $data[2]));
1071
-						} catch(PDOException $e) {
1071
+						} catch (PDOException $e) {
1072 1072
 							return "error mfr : ".$e->getMessage();
1073 1073
 						}
1074 1074
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1079 1079
 							try {
1080 1080
 								$sthf = $Connection->db->prepare($queryf);
1081
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1082
-							} catch(PDOException $e) {
1081
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1082
+							} catch (PDOException $e) {
1083 1083
 								return "error f : ".$e->getMessage();
1084 1084
 							}
1085 1085
 						}
@@ -1089,13 +1089,13 @@  discard block
 block discarded – undo
1089 1089
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1090 1090
 						try {
1091 1091
 							$sth = $Connection->db->prepare($query);
1092
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1093
-						} catch(PDOException $e) {
1092
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1093
+						} catch (PDOException $e) {
1094 1094
 							return "error i : ".$e->getMessage();
1095 1095
 						}
1096 1096
 					}
1097 1097
 				}
1098
-				if ($i % 90 == 0) {
1098
+				if ($i%90 == 0) {
1099 1099
 					if ($globalTransaction) $Connection->db->commit();
1100 1100
 					if ($globalTransaction) $Connection->db->beginTransaction();
1101 1101
 				}
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 			$Connection = new Connection();
1115 1115
 			$sth = $Connection->db->prepare($query);
1116 1116
                         $sth->execute(array(':source' => 'website_fam'));
1117
-                } catch(PDOException $e) {
1117
+                } catch (PDOException $e) {
1118 1118
                         return "error : ".$e->getMessage();
1119 1119
                 }
1120 1120
 
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1136 1136
 					try {
1137 1137
 						$sth = $Connection->db->prepare($query);
1138
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1139
-					} catch(PDOException $e) {
1138
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1139
+					} catch (PDOException $e) {
1140 1140
 						return "error : ".$e->getMessage();
1141 1141
 					}
1142 1142
 				}
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			$Connection = new Connection();
1156 1156
 			$sth = $Connection->db->prepare($query);
1157 1157
                         $sth->execute(array(':source' => 'website_fam'));
1158
-                } catch(PDOException $e) {
1158
+                } catch (PDOException $e) {
1159 1159
                         return "error : ".$e->getMessage();
1160 1160
                 }
1161 1161
 
@@ -1171,8 +1171,8 @@  discard block
 block discarded – undo
1171 1171
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1172 1172
 					try {
1173 1173
 						$sth = $Connection->db->prepare($query);
1174
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1175
-					} catch(PDOException $e) {
1174
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1175
+					} catch (PDOException $e) {
1176 1176
 						//print_r($data);
1177 1177
 						return "error : ".$e->getMessage();
1178 1178
 					}
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 			$Connection = new Connection();
1193 1193
 			$sth = $Connection->db->prepare($query);
1194 1194
 			$sth->execute(array(':source' => 'website_fam'));
1195
-		} catch(PDOException $e) {
1195
+		} catch (PDOException $e) {
1196 1196
 			return "error : ".$e->getMessage();
1197 1197
 		}
1198 1198
 		$delimiter = "\t";
@@ -1207,9 +1207,9 @@  discard block
 block discarded – undo
1207 1207
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1208 1208
 					try {
1209 1209
 						$sth = $Connection->db->prepare($query);
1210
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1211
-					} catch(PDOException $e) {
1212
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1210
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1211
+					} catch (PDOException $e) {
1212
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1213 1213
 					}
1214 1214
 				}
1215 1215
 				$i++;
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			$Connection = new Connection();
1228 1228
 			$sth = $Connection->db->prepare($query);
1229 1229
                         $sth->execute();
1230
-                } catch(PDOException $e) {
1230
+                } catch (PDOException $e) {
1231 1231
                         return "error : ".$e->getMessage();
1232 1232
                 }
1233 1233
 
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1249 1249
 					try {
1250 1250
 						$sth = $Connection->db->prepare($query);
1251
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1252
-					} catch(PDOException $e) {
1251
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1252
+					} catch (PDOException $e) {
1253 1253
 						return "error : ".$e->getMessage();
1254 1254
 					}
1255 1255
 				}
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 			$Connection = new Connection();
1269 1269
 			$sth = $Connection->db->prepare($query);
1270 1270
 			$sth->execute();
1271
-		} catch(PDOException $e) {
1271
+		} catch (PDOException $e) {
1272 1272
 			return "error : ".$e->getMessage();
1273 1273
 		}
1274 1274
 
@@ -1284,7 +1284,7 @@  discard block
 block discarded – undo
1284 1284
 					try {
1285 1285
 						$sth = $Connection->db->prepare($query);
1286 1286
 						$sth->execute(array(':icao' => $icao));
1287
-					} catch(PDOException $e) {
1287
+					} catch (PDOException $e) {
1288 1288
 						return "error : ".$e->getMessage();
1289 1289
 					}
1290 1290
 				}
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 		return '';
1296 1296
         }
1297 1297
 
1298
-	public static function tle($filename,$tletype) {
1298
+	public static function tle($filename, $tletype) {
1299 1299
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1300 1300
 		global $tmp_dir, $globalTransaction;
1301 1301
 		//$Spotter = new Spotter();
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 			$Connection = new Connection();
1306 1306
 			$sth = $Connection->db->prepare($query);
1307 1307
                         $sth->execute(array(':source' => $filename));
1308
-                } catch(PDOException $e) {
1308
+                } catch (PDOException $e) {
1309 1309
                         return "error : ".$e->getMessage();
1310 1310
                 }
1311 1311
 		
@@ -1330,8 +1330,8 @@  discard block
 block discarded – undo
1330 1330
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1331 1331
 					try {
1332 1332
 						$sth = $Connection->db->prepare($query);
1333
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1334
-					} catch(PDOException $e) {
1333
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1334
+					} catch (PDOException $e) {
1335 1335
 						return "error : ".$e->getMessage();
1336 1336
 					}
1337 1337
 
@@ -1448,13 +1448,13 @@  discard block
 block discarded – undo
1448 1448
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1449 1449
 			{
1450 1450
 				$i++;
1451
-				if($i > 3 && count($row) > 2) {
1451
+				if ($i > 3 && count($row) > 2) {
1452 1452
 					$data = array_values(array_filter($row));
1453 1453
 					$cntdata = count($data);
1454 1454
 					if ($cntdata > 10) {
1455 1455
 						$value = $data[9];
1456 1456
 						
1457
-						for ($i =10;$i < $cntdata;$i++) {
1457
+						for ($i = 10; $i < $cntdata; $i++) {
1458 1458
 							$value .= ' '.$data[$i];
1459 1459
 						}
1460 1460
 						$data[9] = $value;
@@ -1464,8 +1464,8 @@  discard block
 block discarded – undo
1464 1464
 						$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)';
1465 1465
 						try {
1466 1466
 							$sth = $Connection->db->prepare($query);
1467
-							$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]));
1468
-						} catch(PDOException $e) {
1467
+							$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]));
1468
+						} catch (PDOException $e) {
1469 1469
 							return "error : ".$e->getMessage();
1470 1470
 						}
1471 1471
 					}
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
 			$Connection = new Connection();
1487 1487
 			$sth = $Connection->db->prepare($query);
1488 1488
                         $sth->execute();
1489
-                } catch(PDOException $e) {
1489
+                } catch (PDOException $e) {
1490 1490
                         return "error : ".$e->getMessage();
1491 1491
                 }
1492 1492
 
@@ -1498,12 +1498,12 @@  discard block
 block discarded – undo
1498 1498
 			if ($globalTransaction) $Connection->db->beginTransaction();
1499 1499
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1500 1500
 			{
1501
-				if(count($row) > 1) {
1501
+				if (count($row) > 1) {
1502 1502
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1503 1503
 					try {
1504 1504
 						$sth = $Connection->db->prepare($query);
1505
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1506
-					} catch(PDOException $e) {
1505
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1506
+					} catch (PDOException $e) {
1507 1507
 						return "error : ".$e->getMessage();
1508 1508
 					}
1509 1509
 				}
@@ -1523,21 +1523,21 @@  discard block
 block discarded – undo
1523 1523
 			try {
1524 1524
 				$sth = $Connection->db->prepare($query);
1525 1525
                     		$sth->execute();
1526
-	                } catch(PDOException $e) {
1526
+	                } catch (PDOException $e) {
1527 1527
 				return "error : ".$e->getMessage();
1528 1528
 	                }
1529 1529
 	        }
1530 1530
 
1531 1531
 
1532
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1532
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1533 1533
 		else {
1534
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1534
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1535 1535
 			$query = "CREATE EXTENSION postgis";
1536
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1536
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1537 1537
 			try {
1538 1538
 				$sth = $Connection->db->prepare($query);
1539 1539
 				$sth->execute();
1540
-			} catch(PDOException $e) {
1540
+			} catch (PDOException $e) {
1541 1541
 				return "error : ".$e->getMessage();
1542 1542
 			}
1543 1543
 		}
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
 		include_once('class.create_db.php');
1551 1551
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1552 1552
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1553
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1553
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1554 1554
 		$error = '';
1555 1555
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1556 1556
 			if ($globalDebug) echo "Gunzip...";
@@ -1582,14 +1582,14 @@  discard block
 block discarded – undo
1582 1582
 			try {
1583 1583
 				$sth = $Connection->db->prepare($query);
1584 1584
             	        	$sth->execute();
1585
-	                } catch(PDOException $e) {
1585
+	                } catch (PDOException $e) {
1586 1586
     	                	echo "error : ".$e->getMessage();
1587 1587
 	                }
1588 1588
 		}
1589 1589
 		if ($globalDBdriver == 'mysql') {
1590
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1590
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1591 1591
 		} else {
1592
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1592
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1593 1593
 		}
1594 1594
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1595 1595
 		return $error;
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1603 1603
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1604 1604
 //		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');
1605
-		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');
1605
+		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');
1606 1606
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1607 1607
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1608 1608
 		return $error;
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1623 1623
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1624 1624
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1625
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1625
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1626 1626
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1627 1627
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1628 1628
 		if ($error != '') {
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 		global $tmp_dir, $globalDebug;
1636 1636
 		$error = '';
1637 1637
 		if ($globalDebug) echo "Routes : Download...";
1638
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1638
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1639 1639
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1640 1640
 			if ($globalDebug) echo "Gunzip...";
1641 1641
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1651,7 +1651,7 @@  discard block
 block discarded – undo
1651 1651
 		global $tmp_dir, $globalDebug;
1652 1652
 		$error = '';
1653 1653
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1654
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1654
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1655 1655
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1656 1656
 			if ($globalDebug) echo "Gunzip...";
1657 1657
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1667,7 +1667,7 @@  discard block
 block discarded – undo
1667 1667
 		global $tmp_dir, $globalDebug;
1668 1668
 		$error = '';
1669 1669
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1670
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1670
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1671 1671
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1672 1672
 			if ($globalDebug) echo "Gunzip...";
1673 1673
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
 */
1696 1696
 		if ($globalDebug) echo "Modes : Download...";
1697 1697
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1698
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1698
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1699 1699
 
1700 1700
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1701 1701
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
 	public static function update_ModeS_faa() {
1716 1716
 		global $tmp_dir, $globalDebug;
1717 1717
 		if ($globalDebug) echo "Modes FAA: Download...";
1718
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1718
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1719 1719
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1720 1720
 			if ($globalDebug) echo "Unzip...";
1721 1721
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 	public static function update_ModeS_flarm() {
1732 1732
 		global $tmp_dir, $globalDebug;
1733 1733
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1734
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1734
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1735 1735
 		if (file_exists($tmp_dir.'data.fln')) {
1736 1736
 			if ($globalDebug) echo "Add to DB...";
1737 1737
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 	public static function update_ModeS_ogn() {
1746 1746
 		global $tmp_dir, $globalDebug;
1747 1747
 		if ($globalDebug) echo "Modes OGN: Download...";
1748
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1748
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1749 1749
 		if (file_exists($tmp_dir.'ogn.csv')) {
1750 1750
 			if ($globalDebug) echo "Add to DB...";
1751 1751
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1760,201 +1760,201 @@  discard block
 block discarded – undo
1760 1760
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1761 1761
 		
1762 1762
 		if ($globalDebug) echo "Owner France: Download...";
1763
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1763
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1764 1764
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1765 1765
 			if ($globalDebug) echo "Add to DB...";
1766
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1766
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1767 1767
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1768 1768
 		if ($error != '') {
1769 1769
 			return $error;
1770 1770
 		} elseif ($globalDebug) echo "Done\n";
1771 1771
 		
1772 1772
 		if ($globalDebug) echo "Owner Ireland: Download...";
1773
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1773
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1774 1774
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1775 1775
 			if ($globalDebug) echo "Add to DB...";
1776
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1776
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1777 1777
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1778 1778
 		if ($error != '') {
1779 1779
 			return $error;
1780 1780
 		} elseif ($globalDebug) echo "Done\n";
1781 1781
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1782
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1782
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1783 1783
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1784 1784
 			if ($globalDebug) echo "Add to DB...";
1785
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1785
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1786 1786
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1787 1787
 		if ($error != '') {
1788 1788
 			return $error;
1789 1789
 		} elseif ($globalDebug) echo "Done\n";
1790 1790
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1791
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1791
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1792 1792
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1793 1793
 			if ($globalDebug) echo "Add to DB...";
1794
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1794
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1795 1795
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1796 1796
 		if ($error != '') {
1797 1797
 			return $error;
1798 1798
 		} elseif ($globalDebug) echo "Done\n";
1799 1799
 		if ($globalDebug) echo "Owner Australia: Download...";
1800
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1800
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1801 1801
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1802 1802
 			if ($globalDebug) echo "Add to DB...";
1803
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1803
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1804 1804
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1805 1805
 		if ($error != '') {
1806 1806
 			return $error;
1807 1807
 		} elseif ($globalDebug) echo "Done\n";
1808 1808
 		if ($globalDebug) echo "Owner Austria: Download...";
1809
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1809
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1810 1810
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1811 1811
 			if ($globalDebug) echo "Add to DB...";
1812
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1812
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1813 1813
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1814 1814
 		if ($error != '') {
1815 1815
 			return $error;
1816 1816
 		} elseif ($globalDebug) echo "Done\n";
1817 1817
 		if ($globalDebug) echo "Owner Chile: Download...";
1818
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1818
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1819 1819
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1820 1820
 			if ($globalDebug) echo "Add to DB...";
1821
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1821
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1822 1822
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1823 1823
 		if ($error != '') {
1824 1824
 			return $error;
1825 1825
 		} elseif ($globalDebug) echo "Done\n";
1826 1826
 		if ($globalDebug) echo "Owner Colombia: Download...";
1827
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1827
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1828 1828
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1829 1829
 			if ($globalDebug) echo "Add to DB...";
1830
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1830
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1831 1831
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1832 1832
 		if ($error != '') {
1833 1833
 			return $error;
1834 1834
 		} elseif ($globalDebug) echo "Done\n";
1835 1835
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1836
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1836
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1837 1837
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1838 1838
 			if ($globalDebug) echo "Add to DB...";
1839
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1839
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1840 1840
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1841 1841
 		if ($error != '') {
1842 1842
 			return $error;
1843 1843
 		} elseif ($globalDebug) echo "Done\n";
1844 1844
 		if ($globalDebug) echo "Owner Brazil: Download...";
1845
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1845
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1846 1846
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1847 1847
 			if ($globalDebug) echo "Add to DB...";
1848
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1848
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1849 1849
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1850 1850
 		if ($error != '') {
1851 1851
 			return $error;
1852 1852
 		} elseif ($globalDebug) echo "Done\n";
1853 1853
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1854
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1854
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1855 1855
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1856 1856
 			if ($globalDebug) echo "Add to DB...";
1857
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1857
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1858 1858
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1859 1859
 		if ($error != '') {
1860 1860
 			return $error;
1861 1861
 		} elseif ($globalDebug) echo "Done\n";
1862 1862
 		if ($globalDebug) echo "Owner Croatia: Download...";
1863
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1863
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1864 1864
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1865 1865
 			if ($globalDebug) echo "Add to DB...";
1866
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1866
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1867 1867
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1868 1868
 		if ($error != '') {
1869 1869
 			return $error;
1870 1870
 		} elseif ($globalDebug) echo "Done\n";
1871 1871
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1872
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1872
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1873 1873
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1874 1874
 			if ($globalDebug) echo "Add to DB...";
1875
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1875
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1876 1876
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1877 1877
 		if ($error != '') {
1878 1878
 			return $error;
1879 1879
 		} elseif ($globalDebug) echo "Done\n";
1880 1880
 		if ($globalDebug) echo "Owner Maldives: Download...";
1881
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1881
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1882 1882
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1883 1883
 			if ($globalDebug) echo "Add to DB...";
1884
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1884
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1885 1885
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1886 1886
 		if ($error != '') {
1887 1887
 			return $error;
1888 1888
 		} elseif ($globalDebug) echo "Done\n";
1889 1889
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1890
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1890
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1891 1891
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1892 1892
 			if ($globalDebug) echo "Add to DB...";
1893
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1893
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1894 1894
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1895 1895
 		if ($error != '') {
1896 1896
 			return $error;
1897 1897
 		} elseif ($globalDebug) echo "Done\n";
1898 1898
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1899
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1899
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1900 1900
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1901 1901
 			if ($globalDebug) echo "Add to DB...";
1902
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1902
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1903 1903
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1904 1904
 		if ($error != '') {
1905 1905
 			return $error;
1906 1906
 		} elseif ($globalDebug) echo "Done\n";
1907 1907
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1908
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1908
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1909 1909
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1910 1910
 			if ($globalDebug) echo "Add to DB...";
1911
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1911
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1912 1912
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1913 1913
 		if ($error != '') {
1914 1914
 			return $error;
1915 1915
 		} elseif ($globalDebug) echo "Done\n";
1916 1916
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1917
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1917
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1918 1918
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1919 1919
 			if ($globalDebug) echo "Add to DB...";
1920
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1920
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1921 1921
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1922 1922
 		if ($error != '') {
1923 1923
 			return $error;
1924 1924
 		} elseif ($globalDebug) echo "Done\n";
1925 1925
 		if ($globalDebug) echo "Owner Iceland: Download...";
1926
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1926
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1927 1927
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1928 1928
 			if ($globalDebug) echo "Add to DB...";
1929
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1929
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1930 1930
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1931 1931
 		if ($error != '') {
1932 1932
 			return $error;
1933 1933
 		} elseif ($globalDebug) echo "Done\n";
1934 1934
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1935
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1935
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1936 1936
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1937 1937
 			if ($globalDebug) echo "Add to DB...";
1938
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1938
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1939 1939
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1940 1940
 		if ($error != '') {
1941 1941
 			return $error;
1942 1942
 		} elseif ($globalDebug) echo "Done\n";
1943 1943
 		if ($globalMasterSource) {
1944 1944
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1945
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1945
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1946 1946
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1947 1947
 				if ($globalDebug) echo "Add to DB...";
1948
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1948
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1949 1949
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1950 1950
 			if ($error != '') {
1951 1951
 				return $error;
1952 1952
 			} elseif ($globalDebug) echo "Done\n";
1953 1953
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1954
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1954
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1955 1955
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1956 1956
 				if ($globalDebug) echo "Add to DB...";
1957
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1957
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1958 1958
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1959 1959
 			if ($error != '') {
1960 1960
 				return $error;
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
 		global $tmp_dir, $globalDebug;
1968 1968
 		$error = '';
1969 1969
 		if ($globalDebug) echo "Translation : Download...";
1970
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1970
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1971 1971
 		if (file_exists($tmp_dir.'translation.zip')) {
1972 1972
 			if ($globalDebug) echo "Unzip...";
1973 1973
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 	public static function update_translation_fam() {
1984 1984
 		global $tmp_dir, $globalDebug;
1985 1985
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1986
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1986
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1987 1987
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1988 1988
 			if ($globalDebug) echo "Gunzip...";
1989 1989
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 	public static function update_ModeS_fam() {
1999 1999
 		global $tmp_dir, $globalDebug;
2000 2000
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2001
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2001
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2002 2002
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2003 2003
 			if ($globalDebug) echo "Gunzip...";
2004 2004
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -2014,9 +2014,9 @@  discard block
 block discarded – undo
2014 2014
 		global $tmp_dir, $globalDebug, $globalOwner;
2015 2015
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2016 2016
 		if ($globalOwner === TRUE) {
2017
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2017
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2018 2018
 		} else {
2019
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2019
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2020 2020
 		}
2021 2021
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2022 2022
 			if ($globalDebug) echo "Gunzip...";
@@ -2032,7 +2032,7 @@  discard block
 block discarded – undo
2032 2032
 	public static function update_routes_fam() {
2033 2033
 		global $tmp_dir, $globalDebug;
2034 2034
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2035
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2035
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2036 2036
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2037 2037
 			if ($globalDebug) echo "Gunzip...";
2038 2038
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2046,13 +2046,13 @@  discard block
 block discarded – undo
2046 2046
 	}
2047 2047
 	public static function update_marine_identity_fam() {
2048 2048
 		global $tmp_dir, $globalDebug;
2049
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2049
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2050 2050
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2051
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2051
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2052 2052
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2053 2053
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2054 2054
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2055
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2055
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2056 2056
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2057 2057
 					if ($globalDebug) echo "Gunzip...";
2058 2058
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
 	public static function update_banned_fam() {
2073 2073
 		global $tmp_dir, $globalDebug;
2074 2074
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2075
-		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2075
+		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2076 2076
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2077 2077
 			//if ($globalDebug) echo "Gunzip...";
2078 2078
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2091,18 +2091,18 @@  discard block
 block discarded – undo
2091 2091
 		$error = '';
2092 2092
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2093 2093
 		if ($globalDBdriver == 'mysql') {
2094
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2094
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2095 2095
 		} else {
2096
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2096
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2097 2097
 		}
2098 2098
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2099
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2099
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2100 2100
 			$airspace_md5 = $airspace_md5_file[0];
2101 2101
 			if (!update_db::check_airspace_version($airspace_md5)) {
2102 2102
 				if ($globalDBdriver == 'mysql') {
2103
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2103
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2104 2104
 				} else {
2105
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2105
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2106 2106
 				}
2107 2107
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2108 2108
 					if ($globalDebug) echo "Gunzip...";
@@ -2114,7 +2114,7 @@  discard block
 block discarded – undo
2114 2114
 						try {
2115 2115
 							$sth = $Connection->db->prepare($query);
2116 2116
     	    	    					$sth->execute();
2117
-			            		} catch(PDOException $e) {
2117
+			            		} catch (PDOException $e) {
2118 2118
 							return "error : ".$e->getMessage();
2119 2119
 		            			}
2120 2120
 		    			}
@@ -2133,15 +2133,15 @@  discard block
 block discarded – undo
2133 2133
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2134 2134
 		$error = '';
2135 2135
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2136
-		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2136
+		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2137 2137
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2138
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2138
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2139 2139
 			$geoid_md5 = $geoid_md5_file[0];
2140 2140
 			if (!update_db::check_geoid_version($geoid_md5)) {
2141
-				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2141
+				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2142 2142
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2143 2143
 					if ($globalDebug) echo "Gunzip...";
2144
-					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2144
+					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2145 2145
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2146 2146
 						update_db::insert_geoid_version($geoid_md5);
2147 2147
 					}
@@ -2157,15 +2157,15 @@  discard block
 block discarded – undo
2157 2157
 	public static function update_tle() {
2158 2158
 		global $tmp_dir, $globalDebug;
2159 2159
 		if ($globalDebug) echo "Download TLE : Download...";
2160
-		$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',
2161
-		'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',
2162
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2160
+		$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',
2161
+		'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',
2162
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2163 2163
 		foreach ($alltle as $filename) {
2164 2164
 			if ($globalDebug) echo "downloading ".$filename.'...';
2165
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2165
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2166 2166
 			if (file_exists($tmp_dir.$filename)) {
2167 2167
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2168
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2168
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2169 2169
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2170 2170
 			if ($error != '') {
2171 2171
 				echo $error."\n";
@@ -2178,32 +2178,32 @@  discard block
 block discarded – undo
2178 2178
 		global $tmp_dir, $globalDebug;
2179 2179
 		$error = '';
2180 2180
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2181
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2181
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2182 2182
 		if (file_exists($tmp_dir.'models.md5sum')) {
2183 2183
 			if ($globalDebug) echo "Check files...\n";
2184 2184
 			$newmodelsdb = array();
2185
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2186
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2185
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2186
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2187 2187
 					$model = trim($row[2]);
2188 2188
 					$newmodelsdb[$model] = trim($row[0]);
2189 2189
 				}
2190 2190
 			}
2191 2191
 			$modelsdb = array();
2192 2192
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2193
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2194
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2193
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2194
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2195 2195
 						$model = trim($row[2]);
2196 2196
 						$modelsdb[$model] = trim($row[0]);
2197 2197
 					}
2198 2198
 				}
2199 2199
 			}
2200
-			$diff = array_diff($newmodelsdb,$modelsdb);
2200
+			$diff = array_diff($newmodelsdb, $modelsdb);
2201 2201
 			foreach ($diff as $key => $value) {
2202 2202
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2203
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2203
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2204 2204
 				
2205 2205
 			}
2206
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2206
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2207 2207
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2208 2208
 		if ($error != '') {
2209 2209
 			return $error;
@@ -2215,32 +2215,32 @@  discard block
 block discarded – undo
2215 2215
 		global $tmp_dir, $globalDebug;
2216 2216
 		$error = '';
2217 2217
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2218
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2218
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2219 2219
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2220 2220
 			if ($globalDebug) echo "Check files...\n";
2221 2221
 			$newmodelsdb = array();
2222
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2223
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2222
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2223
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2224 2224
 					$model = trim($row[2]);
2225 2225
 					$newmodelsdb[$model] = trim($row[0]);
2226 2226
 				}
2227 2227
 			}
2228 2228
 			$modelsdb = array();
2229 2229
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2230
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2231
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2230
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2231
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2232 2232
 						$model = trim($row[2]);
2233 2233
 						$modelsdb[$model] = trim($row[0]);
2234 2234
 					}
2235 2235
 				}
2236 2236
 			}
2237
-			$diff = array_diff($newmodelsdb,$modelsdb);
2237
+			$diff = array_diff($newmodelsdb, $modelsdb);
2238 2238
 			foreach ($diff as $key => $value) {
2239 2239
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2240
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2240
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2241 2241
 				
2242 2242
 			}
2243
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2243
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2244 2244
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2245 2245
 		if ($error != '') {
2246 2246
 			return $error;
@@ -2252,32 +2252,32 @@  discard block
 block discarded – undo
2252 2252
 		global $tmp_dir, $globalDebug;
2253 2253
 		$error = '';
2254 2254
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2255
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2255
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2256 2256
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2257 2257
 			if ($globalDebug) echo "Check files...\n";
2258 2258
 			$newmodelsdb = array();
2259
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2260
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2259
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2260
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2261 2261
 					$model = trim($row[2]);
2262 2262
 					$newmodelsdb[$model] = trim($row[0]);
2263 2263
 				}
2264 2264
 			}
2265 2265
 			$modelsdb = array();
2266 2266
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2267
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2268
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2267
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2268
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2269 2269
 						$model = trim($row[2]);
2270 2270
 						$modelsdb[$model] = trim($row[0]);
2271 2271
 					}
2272 2272
 				}
2273 2273
 			}
2274
-			$diff = array_diff($newmodelsdb,$modelsdb);
2274
+			$diff = array_diff($newmodelsdb, $modelsdb);
2275 2275
 			foreach ($diff as $key => $value) {
2276 2276
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2277
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2277
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2278 2278
 				
2279 2279
 			}
2280
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2280
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2281 2281
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2282 2282
 		if ($error != '') {
2283 2283
 			return $error;
@@ -2300,8 +2300,8 @@  discard block
 block discarded – undo
2300 2300
 		*/
2301 2301
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2302 2302
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2303
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2304
-		    $result = fread($fh,100000000);
2303
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2304
+		    $result = fread($fh, 100000000);
2305 2305
 		    //echo $result;
2306 2306
 		    //var_dump(str_get_html($result));
2307 2307
 		    //print_r(self::table2array($result));
@@ -2319,23 +2319,23 @@  discard block
 block discarded – undo
2319 2319
 			$Connection = new Connection();
2320 2320
 			$sth = $Connection->db->prepare($query);
2321 2321
                         $sth->execute();
2322
-                } catch(PDOException $e) {
2322
+                } catch (PDOException $e) {
2323 2323
                         return "error : ".$e->getMessage();
2324 2324
                 }
2325 2325
 
2326 2326
 		$error = '';
2327 2327
 		if ($globalDebug) echo "Notam : Download...";
2328
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2328
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2329 2329
 		if (file_exists($tmp_dir.'notam.rss')) {
2330
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2330
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2331 2331
 			foreach ($notams['channel']['item'] as $notam) {
2332
-				$title = explode(':',$notam['title']);
2332
+				$title = explode(':', $notam['title']);
2333 2333
 				$data['ref'] = trim($title[0]);
2334 2334
 				unset($title[0]);
2335
-				$data['title'] = trim(implode(':',$title));
2336
-				$description = strip_tags($notam['description'],'<pre>');
2337
-				preg_match(':^(.*?)<pre>:',$description,$match);
2338
-				$q = explode('/',$match[1]);
2335
+				$data['title'] = trim(implode(':', $title));
2336
+				$description = strip_tags($notam['description'], '<pre>');
2337
+				preg_match(':^(.*?)<pre>:', $description, $match);
2338
+				$q = explode('/', $match[1]);
2339 2339
 				$data['fir'] = $q[0];
2340 2340
 				$data['code'] = $q[1];
2341 2341
 				$ifrvfr = $q[2];
@@ -2351,30 +2351,30 @@  discard block
 block discarded – undo
2351 2351
 				$data['lower_limit'] = $q[5];
2352 2352
 				$data['upper_limit'] = $q[6];
2353 2353
 				$latlonrad = $q[7];
2354
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2355
-				$latitude = $Common->convertDec($las,'latitude');
2356
-				$longitude = $Common->convertDec($lns,'longitude');
2354
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2355
+				$latitude = $Common->convertDec($las, 'latitude');
2356
+				$longitude = $Common->convertDec($lns, 'longitude');
2357 2357
 				if ($lac == 'S') $latitude = '-'.$latitude;
2358 2358
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2359 2359
 				$data['center_latitude'] = $latitude;
2360 2360
 				$data['center_longitude'] = $longitude;
2361 2361
 				$data['radius'] = intval($radius);
2362 2362
 				
2363
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2363
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2364 2364
 				$data['text'] = $match[1];
2365
-				preg_match(':</pre>(.*?)$:',$description,$match);
2365
+				preg_match(':</pre>(.*?)$:', $description, $match);
2366 2366
 				$fromto = $match[1];
2367
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2367
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2368 2368
 				$fromall = trim($match[1]);
2369
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2369
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2370 2370
 				$from = trim($match[1]);
2371
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2372
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2371
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2372
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2373 2373
 				$toall = trim($match[1]);
2374
-				if (!preg_match(':Permanent:',$toall)) {
2375
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2374
+				if (!preg_match(':Permanent:', $toall)) {
2375
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2376 2376
 					$to = trim($match[1]);
2377
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2377
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2378 2378
 					$data['permanent'] = 0;
2379 2379
 				} else {
2380 2380
 				    $data['date_end'] = NULL;
@@ -2382,7 +2382,7 @@  discard block
 block discarded – undo
2382 2382
 				}
2383 2383
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2384 2384
 				$NOTAM = new NOTAM();
2385
-				$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']);
2385
+				$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']);
2386 2386
 				unset($data);
2387 2387
 			} 
2388 2388
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2405,16 +2405,16 @@  discard block
 block discarded – undo
2405 2405
 				$Connection = new Connection();
2406 2406
 				$sth = $Connection->db->prepare($query);
2407 2407
 				$sth->execute();
2408
-			} catch(PDOException $e) {
2408
+			} catch (PDOException $e) {
2409 2409
 				return "error : ".$e->getMessage();
2410 2410
 			}
2411 2411
 		}
2412 2412
 		$Common = new Common();
2413 2413
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2414
-		$airspace_json = json_decode($airspace_lst,true);
2414
+		$airspace_json = json_decode($airspace_lst, true);
2415 2415
 		foreach ($airspace_json['records'] as $airspace) {
2416 2416
 			if ($globalDebug) echo $airspace['name']."...\n";
2417
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2417
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2418 2418
 			if (file_exists($tmp_dir.$airspace['name'])) {
2419 2419
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2420 2420
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2436,7 +2436,7 @@  discard block
 block discarded – undo
2436 2436
 				$Connection = new Connection();
2437 2437
 				$sth = $Connection->db->prepare($query);
2438 2438
 				$sth->execute(array(':new' => $new, ':old' => $old));
2439
-			} catch(PDOException $e) {
2439
+			} catch (PDOException $e) {
2440 2440
 				return "error : ".$e->getMessage();
2441 2441
 			}
2442 2442
 		}
@@ -2453,7 +2453,7 @@  discard block
 block discarded – undo
2453 2453
 			$Connection = new Connection();
2454 2454
 			$sth = $Connection->db->prepare($query);
2455 2455
                         $sth->execute();
2456
-                } catch(PDOException $e) {
2456
+                } catch (PDOException $e) {
2457 2457
                         return "error : ".$e->getMessage();
2458 2458
                 }
2459 2459
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
 			$Connection = new Connection();
2469 2469
 			$sth = $Connection->db->prepare($query);
2470 2470
                         $sth->execute();
2471
-                } catch(PDOException $e) {
2471
+                } catch (PDOException $e) {
2472 2472
                         return "error : ".$e->getMessage();
2473 2473
                 }
2474 2474
 	}
@@ -2479,7 +2479,7 @@  discard block
 block discarded – undo
2479 2479
 			$Connection = new Connection();
2480 2480
 			$sth = $Connection->db->prepare($query);
2481 2481
                         $sth->execute(array(':version' => $version));
2482
-                } catch(PDOException $e) {
2482
+                } catch (PDOException $e) {
2483 2483
                         return "error : ".$e->getMessage();
2484 2484
                 }
2485 2485
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2493,7 +2493,7 @@  discard block
 block discarded – undo
2493 2493
 			$Connection = new Connection();
2494 2494
 			$sth = $Connection->db->prepare($query);
2495 2495
                         $sth->execute(array(':version' => $version));
2496
-                } catch(PDOException $e) {
2496
+                } catch (PDOException $e) {
2497 2497
                         return "error : ".$e->getMessage();
2498 2498
                 }
2499 2499
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2507,7 +2507,7 @@  discard block
 block discarded – undo
2507 2507
 			$Connection = new Connection();
2508 2508
 			$sth = $Connection->db->prepare($query);
2509 2509
                         $sth->execute(array(':version' => $version));
2510
-                } catch(PDOException $e) {
2510
+                } catch (PDOException $e) {
2511 2511
                         return "error : ".$e->getMessage();
2512 2512
                 }
2513 2513
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2523,7 +2523,7 @@  discard block
 block discarded – undo
2523 2523
 			$Connection = new Connection();
2524 2524
 			$sth = $Connection->db->prepare($query);
2525 2525
 			$sth->execute(array(':version' => $version));
2526
-		} catch(PDOException $e) {
2526
+		} catch (PDOException $e) {
2527 2527
 			return "error : ".$e->getMessage();
2528 2528
 		}
2529 2529
 	}
@@ -2535,7 +2535,7 @@  discard block
 block discarded – undo
2535 2535
 			$Connection = new Connection();
2536 2536
 			$sth = $Connection->db->prepare($query);
2537 2537
                         $sth->execute(array(':version' => $version));
2538
-                } catch(PDOException $e) {
2538
+                } catch (PDOException $e) {
2539 2539
                         return "error : ".$e->getMessage();
2540 2540
                 }
2541 2541
 	}
@@ -2547,7 +2547,7 @@  discard block
 block discarded – undo
2547 2547
 			$Connection = new Connection();
2548 2548
 			$sth = $Connection->db->prepare($query);
2549 2549
                         $sth->execute(array(':version' => $version));
2550
-                } catch(PDOException $e) {
2550
+                } catch (PDOException $e) {
2551 2551
                         return "error : ".$e->getMessage();
2552 2552
                 }
2553 2553
 	}
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
 			$Connection = new Connection();
2564 2564
 			$sth = $Connection->db->prepare($query);
2565 2565
                         $sth->execute();
2566
-                } catch(PDOException $e) {
2566
+                } catch (PDOException $e) {
2567 2567
                         return "error : ".$e->getMessage();
2568 2568
                 }
2569 2569
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2578,7 +2578,7 @@  discard block
 block discarded – undo
2578 2578
 			$Connection = new Connection();
2579 2579
 			$sth = $Connection->db->prepare($query);
2580 2580
                         $sth->execute();
2581
-                } catch(PDOException $e) {
2581
+                } catch (PDOException $e) {
2582 2582
                         return "error : ".$e->getMessage();
2583 2583
                 }
2584 2584
 	}
@@ -2594,7 +2594,7 @@  discard block
 block discarded – undo
2594 2594
 			$Connection = new Connection();
2595 2595
 			$sth = $Connection->db->prepare($query);
2596 2596
                         $sth->execute();
2597
-                } catch(PDOException $e) {
2597
+                } catch (PDOException $e) {
2598 2598
                         return "error : ".$e->getMessage();
2599 2599
                 }
2600 2600
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2609,7 +2609,7 @@  discard block
 block discarded – undo
2609 2609
 			$Connection = new Connection();
2610 2610
 			$sth = $Connection->db->prepare($query);
2611 2611
                         $sth->execute();
2612
-                } catch(PDOException $e) {
2612
+                } catch (PDOException $e) {
2613 2613
                         return "error : ".$e->getMessage();
2614 2614
                 }
2615 2615
 	}
@@ -2625,7 +2625,7 @@  discard block
 block discarded – undo
2625 2625
 			$Connection = new Connection();
2626 2626
 			$sth = $Connection->db->prepare($query);
2627 2627
                         $sth->execute();
2628
-                } catch(PDOException $e) {
2628
+                } catch (PDOException $e) {
2629 2629
                         return "error : ".$e->getMessage();
2630 2630
                 }
2631 2631
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2640,7 +2640,7 @@  discard block
 block discarded – undo
2640 2640
 			$Connection = new Connection();
2641 2641
 			$sth = $Connection->db->prepare($query);
2642 2642
                         $sth->execute();
2643
-                } catch(PDOException $e) {
2643
+                } catch (PDOException $e) {
2644 2644
                         return "error : ".$e->getMessage();
2645 2645
                 }
2646 2646
 	}
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
 			$Connection = new Connection();
2657 2657
 			$sth = $Connection->db->prepare($query);
2658 2658
                         $sth->execute();
2659
-                } catch(PDOException $e) {
2659
+                } catch (PDOException $e) {
2660 2660
                         return "error : ".$e->getMessage();
2661 2661
                 }
2662 2662
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2671,7 +2671,7 @@  discard block
 block discarded – undo
2671 2671
 			$Connection = new Connection();
2672 2672
 			$sth = $Connection->db->prepare($query);
2673 2673
                         $sth->execute();
2674
-                } catch(PDOException $e) {
2674
+                } catch (PDOException $e) {
2675 2675
                         return "error : ".$e->getMessage();
2676 2676
                 }
2677 2677
 	}
@@ -2686,7 +2686,7 @@  discard block
 block discarded – undo
2686 2686
 			$Connection = new Connection();
2687 2687
 			$sth = $Connection->db->prepare($query);
2688 2688
                         $sth->execute();
2689
-                } catch(PDOException $e) {
2689
+                } catch (PDOException $e) {
2690 2690
                         return "error : ".$e->getMessage();
2691 2691
                 }
2692 2692
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2701,7 +2701,7 @@  discard block
 block discarded – undo
2701 2701
 			$Connection = new Connection();
2702 2702
 			$sth = $Connection->db->prepare($query);
2703 2703
                         $sth->execute();
2704
-                } catch(PDOException $e) {
2704
+                } catch (PDOException $e) {
2705 2705
                         return "error : ".$e->getMessage();
2706 2706
                 }
2707 2707
 	}
@@ -2716,7 +2716,7 @@  discard block
 block discarded – undo
2716 2716
 			$Connection = new Connection();
2717 2717
 			$sth = $Connection->db->prepare($query);
2718 2718
                         $sth->execute();
2719
-                } catch(PDOException $e) {
2719
+                } catch (PDOException $e) {
2720 2720
                         return "error : ".$e->getMessage();
2721 2721
                 }
2722 2722
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2731,7 +2731,7 @@  discard block
 block discarded – undo
2731 2731
 			$Connection = new Connection();
2732 2732
 			$sth = $Connection->db->prepare($query);
2733 2733
                         $sth->execute();
2734
-                } catch(PDOException $e) {
2734
+                } catch (PDOException $e) {
2735 2735
                         return "error : ".$e->getMessage();
2736 2736
                 }
2737 2737
 	}
@@ -2746,7 +2746,7 @@  discard block
 block discarded – undo
2746 2746
 			$Connection = new Connection();
2747 2747
 			$sth = $Connection->db->prepare($query);
2748 2748
                         $sth->execute();
2749
-                } catch(PDOException $e) {
2749
+                } catch (PDOException $e) {
2750 2750
                         return "error : ".$e->getMessage();
2751 2751
                 }
2752 2752
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2761,7 +2761,7 @@  discard block
 block discarded – undo
2761 2761
 			$Connection = new Connection();
2762 2762
 			$sth = $Connection->db->prepare($query);
2763 2763
                         $sth->execute();
2764
-                } catch(PDOException $e) {
2764
+                } catch (PDOException $e) {
2765 2765
                         return "error : ".$e->getMessage();
2766 2766
                 }
2767 2767
 	}
@@ -2776,7 +2776,7 @@  discard block
 block discarded – undo
2776 2776
 			$Connection = new Connection();
2777 2777
 			$sth = $Connection->db->prepare($query);
2778 2778
                         $sth->execute();
2779
-                } catch(PDOException $e) {
2779
+                } catch (PDOException $e) {
2780 2780
                         return "error : ".$e->getMessage();
2781 2781
                 }
2782 2782
 	}
@@ -2791,7 +2791,7 @@  discard block
 block discarded – undo
2791 2791
 			$Connection = new Connection();
2792 2792
 			$sth = $Connection->db->prepare($query);
2793 2793
                         $sth->execute();
2794
-                } catch(PDOException $e) {
2794
+                } catch (PDOException $e) {
2795 2795
                         return "error : ".$e->getMessage();
2796 2796
                 }
2797 2797
 	}
Please login to merge, or discard this patch.
Braces   +956 added lines, -331 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19 19
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
20
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
20
+		if ($referer != '') {
21
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
22
+		}
21 23
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
22 24
 		curl_setopt($ch, CURLOPT_FILE, $fp);
23 25
 		curl_exec($ch);
@@ -28,12 +30,16 @@  discard block
 block discarded – undo
28 30
 	public static function gunzip($in_file,$out_file_name = '') {
29 31
 		//echo $in_file.' -> '.$out_file_name."\n";
30 32
 		$buffer_size = 4096; // read 4kb at a time
31
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
33
+		if ($out_file_name == '') {
34
+			$out_file_name = str_replace('.gz', '', $in_file);
35
+		}
32 36
 		if ($in_file != '' && file_exists($in_file)) {
33 37
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
36
-			else {
38
+			if (function_exists('gzopen')) {
39
+				$file = gzopen($in_file,'rb');
40
+			} elseif (function_exists('gzopen64')) {
41
+				$file = gzopen64($in_file,'rb');
42
+			} else {
37 43
 				echo 'gzopen not available';
38 44
 				die;
39 45
 			}
@@ -54,8 +60,12 @@  discard block
 block discarded – undo
54 60
 			if ($res === TRUE) {
55 61
 				$zip->extractTo($path);
56 62
 				$zip->close();
57
-			} else return false;
58
-		} else return false;
63
+			} else {
64
+				return false;
65
+			}
66
+		} else {
67
+			return false;
68
+		}
59 69
 	}
60 70
 	
61 71
 	public static function connect_sqlite($database) {
@@ -70,7 +80,9 @@  discard block
 block discarded – undo
70 80
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 81
 		global $globalDebug, $globalTransaction;
72 82
 		//$query = 'TRUNCATE TABLE routes';
73
-		if ($globalDebug) echo " - Delete previous routes from DB -";
83
+		if ($globalDebug) {
84
+			echo " - Delete previous routes from DB -";
85
+		}
74 86
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
75 87
 		$Connection = new Connection();
76 88
 		try {
@@ -81,7 +93,9 @@  discard block
 block discarded – undo
81 93
                         return "error : ".$e->getMessage();
82 94
                 }
83 95
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
96
+    		if ($globalDebug) {
97
+    			echo " - Add routes to DB -";
98
+    		}
85 99
     		update_db::connect_sqlite($database_file);
86 100
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 101
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -96,15 +110,21 @@  discard block
 block discarded – undo
96 110
 		$Connection = new Connection();
97 111
 		$sth_dest = $Connection->db->prepare($query_dest);
98 112
 		try {
99
-			if ($globalTransaction) $Connection->db->beginTransaction();
113
+			if ($globalTransaction) {
114
+				$Connection->db->beginTransaction();
115
+			}
100 116
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 117
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 119
 				$sth_dest->execute($query_dest_values);
104 120
             		}
105
-			if ($globalTransaction) $Connection->db->commit();
121
+			if ($globalTransaction) {
122
+				$Connection->db->commit();
123
+			}
106 124
 		} catch(PDOException $e) {
107
-			if ($globalTransaction) $Connection->db->rollBack(); 
125
+			if ($globalTransaction) {
126
+				$Connection->db->rollBack();
127
+			}
108 128
 			return "error : ".$e->getMessage();
109 129
 		}
110 130
                 return '';
@@ -112,7 +132,9 @@  discard block
 block discarded – undo
112 132
 	public static function retrieve_route_oneworld($database_file) {
113 133
 		global $globalDebug, $globalTransaction;
114 134
 		//$query = 'TRUNCATE TABLE routes';
115
-		if ($globalDebug) echo " - Delete previous routes from DB -";
135
+		if ($globalDebug) {
136
+			echo " - Delete previous routes from DB -";
137
+		}
116 138
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
117 139
 		$Connection = new Connection();
118 140
 		try {
@@ -123,14 +145,18 @@  discard block
 block discarded – undo
123 145
                         return "error : ".$e->getMessage();
124 146
                 }
125 147
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
148
+    		if ($globalDebug) {
149
+    			echo " - Add routes to DB -";
150
+    		}
127 151
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 152
 		$Spotter = new Spotter();
129 153
 		if ($fh = fopen($database_file,"r")) {
130 154
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 155
 			$Connection = new Connection();
132 156
 			$sth_dest = $Connection->db->prepare($query_dest);
133
-			if ($globalTransaction) $Connection->db->beginTransaction();
157
+			if ($globalTransaction) {
158
+				$Connection->db->beginTransaction();
159
+			}
134 160
 			while (!feof($fh)) {
135 161
 				$line = fgetcsv($fh,9999,',');
136 162
 				if ($line[0] != '') {
@@ -139,13 +165,17 @@  discard block
 block discarded – undo
139 165
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
140 166
 							$sth_dest->execute($query_dest_values);
141 167
 						} catch(PDOException $e) {
142
-							if ($globalTransaction) $Connection->db->rollBack(); 
168
+							if ($globalTransaction) {
169
+								$Connection->db->rollBack();
170
+							}
143 171
 							return "error : ".$e->getMessage();
144 172
 						}
145 173
 					}
146 174
 				}
147 175
 			}
148
-			if ($globalTransaction) $Connection->db->commit();
176
+			if ($globalTransaction) {
177
+				$Connection->db->commit();
178
+			}
149 179
 		}
150 180
                 return '';
151 181
 	}
@@ -153,7 +183,9 @@  discard block
 block discarded – undo
153 183
 	public static function retrieve_route_skyteam($database_file) {
154 184
 		global $globalDebug, $globalTransaction;
155 185
 		//$query = 'TRUNCATE TABLE routes';
156
-		if ($globalDebug) echo " - Delete previous routes from DB -";
186
+		if ($globalDebug) {
187
+			echo " - Delete previous routes from DB -";
188
+		}
157 189
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
158 190
 		$Connection = new Connection();
159 191
 		try {
@@ -164,7 +196,9 @@  discard block
 block discarded – undo
164 196
                         return "error : ".$e->getMessage();
165 197
                 }
166 198
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
199
+    		if ($globalDebug) {
200
+    			echo " - Add routes to DB -";
201
+    		}
168 202
 
169 203
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 204
 		$Spotter = new Spotter();
@@ -173,7 +207,9 @@  discard block
 block discarded – undo
173 207
 			$Connection = new Connection();
174 208
 			$sth_dest = $Connection->db->prepare($query_dest);
175 209
 			try {
176
-				if ($globalTransaction) $Connection->db->beginTransaction();
210
+				if ($globalTransaction) {
211
+					$Connection->db->beginTransaction();
212
+				}
177 213
 				while (!feof($fh)) {
178 214
 					$line = fgetcsv($fh,9999,',');
179 215
 					if ($line[0] != '') {
@@ -184,9 +220,13 @@  discard block
 block discarded – undo
184 220
 						}
185 221
 					}
186 222
 				}
187
-				if ($globalTransaction) $Connection->db->commit();
223
+				if ($globalTransaction) {
224
+					$Connection->db->commit();
225
+				}
188 226
 			} catch(PDOException $e) {
189
-				if ($globalTransaction) $Connection->db->rollBack(); 
227
+				if ($globalTransaction) {
228
+					$Connection->db->rollBack();
229
+				}
190 230
 				return "error : ".$e->getMessage();
191 231
 			}
192 232
 		}
@@ -229,11 +269,16 @@  discard block
 block discarded – undo
229 269
 		$sth_dest = $Connection->db->prepare($query_dest);
230 270
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 271
 		try {
232
-			if ($globalTransaction) $Connection->db->beginTransaction();
272
+			if ($globalTransaction) {
273
+				$Connection->db->beginTransaction();
274
+			}
233 275
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 276
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235
-				if ($values['UserString4'] == 'M') $type = 'military';
236
-				else $type = null;
277
+				if ($values['UserString4'] == 'M') {
278
+					$type = 'military';
279
+				} else {
280
+					$type = null;
281
+				}
237 282
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 283
 				$sth_dest->execute($query_dest_values);
239 284
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -241,7 +286,9 @@  discard block
 block discarded – undo
241 286
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 287
 				}
243 288
             		}
244
-			if ($globalTransaction) $Connection->db->commit();
289
+			if ($globalTransaction) {
290
+				$Connection->db->commit();
291
+			}
245 292
 		} catch(PDOException $e) {
246 293
 			return "error : ".$e->getMessage();
247 294
 		}
@@ -278,7 +325,9 @@  discard block
 block discarded – undo
278 325
 			$Connection = new Connection();
279 326
 			$sth_dest = $Connection->db->prepare($query_dest);
280 327
 			try {
281
-				if ($globalTransaction) $Connection->db->beginTransaction();
328
+				if ($globalTransaction) {
329
+					$Connection->db->beginTransaction();
330
+				}
282 331
             			while (!feof($fh)) {
283 332
             				$values = array();
284 333
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -289,7 +338,9 @@  discard block
 block discarded – undo
289 338
             				// Check if we can find ICAO, else set it to GLID
290 339
             				$aircraft_name_split = explode(' ',$aircraft_name);
291 340
             				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
342
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
343
+            				}
293 344
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294 345
             				$sth_search = $Connection->db->prepare($query_search);
295 346
 					try {
@@ -302,7 +353,9 @@  discard block
 block discarded – undo
302 353
 					} catch(PDOException $e) {
303 354
 						return "error : ".$e->getMessage();
304 355
 					}
305
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
356
+					if (!isset($values['ICAOTypeCode'])) {
357
+						$values['ICAOTypeCode'] = 'GLID';
358
+					}
306 359
 					// Add data to db
307 360
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 361
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -311,7 +364,9 @@  discard block
 block discarded – undo
311 364
 						$sth_dest->execute($query_dest_values);
312 365
 					}
313 366
 				}
314
-				if ($globalTransaction) $Connection->db->commit();
367
+				if ($globalTransaction) {
368
+					$Connection->db->commit();
369
+				}
315 370
 			} catch(PDOException $e) {
316 371
 				return "error : ".$e->getMessage();
317 372
 			}
@@ -347,7 +402,9 @@  discard block
 block discarded – undo
347 402
 			$Connection = new Connection();
348 403
 			$sth_dest = $Connection->db->prepare($query_dest);
349 404
 			try {
350
-				if ($globalTransaction) $Connection->db->beginTransaction();
405
+				if ($globalTransaction) {
406
+					$Connection->db->beginTransaction();
407
+				}
351 408
 				$tmp = fgetcsv($fh,9999,',',"'");
352 409
             			while (!feof($fh)) {
353 410
             				$line = fgetcsv($fh,9999,',',"'");
@@ -361,13 +418,17 @@  discard block
 block discarded – undo
361 418
             				// Check if we can find ICAO, else set it to GLID
362 419
             				$aircraft_name_split = explode(' ',$aircraft_name);
363 420
             				$search_more = '';
364
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
422
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
423
+            				}
365 424
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
366 425
             				$sth_search = $Connection->db->prepare($query_search);
367 426
 					try {
368 427
                                     		$sth_search->execute();
369 428
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
429
+	            				if (isset($result['icao']) && $result['icao'] != '') {
430
+	            					$values['ICAOTypeCode'] = $result['icao'];
431
+	            				}
371 432
 					} catch(PDOException $e) {
372 433
 						return "error : ".$e->getMessage();
373 434
 					}
@@ -380,7 +441,9 @@  discard block
 block discarded – undo
380 441
 						$sth_dest->execute($query_dest_values);
381 442
 					}
382 443
 				}
383
-				if ($globalTransaction) $Connection->db->commit();
444
+				if ($globalTransaction) {
445
+					$Connection->db->commit();
446
+				}
384 447
 			} catch(PDOException $e) {
385 448
 				return "error : ".$e->getMessage();
386 449
 			}
@@ -419,7 +482,9 @@  discard block
 block discarded – undo
419 482
 			$sth_dest = $Connection->db->prepare($query_dest);
420 483
 			$sth_modes = $Connection->db->prepare($query_modes);
421 484
 			try {
422
-				if ($globalTransaction) $Connection->db->beginTransaction();
485
+				if ($globalTransaction) {
486
+					$Connection->db->beginTransaction();
487
+				}
423 488
 				$tmp = fgetcsv($fh,9999,',','"');
424 489
             			while (!feof($fh)) {
425 490
             				$line = fgetcsv($fh,9999,',','"');
@@ -429,16 +494,22 @@  discard block
 block discarded – undo
429 494
             				    $values['registration'] = $line[0];
430 495
             				    $values['base'] = $line[4];
431 496
             				    $values['owner'] = $line[5];
432
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
497
+            				    if ($line[6] == '') {
498
+            				    	$values['date_first_reg'] = null;
499
+            				    } else {
500
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
501
+					    }
434 502
 					    $values['cancel'] = $line[7];
435 503
 					} elseif ($country == 'EI') {
436 504
 					    // TODO : add modeS & reg to aircraft_modes
437 505
             				    $values['registration'] = $line[0];
438 506
             				    $values['base'] = $line[3];
439 507
             				    $values['owner'] = $line[2];
440
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
508
+            				    if ($line[1] == '') {
509
+            				    	$values['date_first_reg'] = null;
510
+            				    } else {
511
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
512
+					    }
442 513
 					    $values['cancel'] = '';
443 514
 					    $values['modes'] = $line[7];
444 515
 					    $values['icao'] = $line[8];
@@ -457,16 +528,22 @@  discard block
 block discarded – undo
457 528
             				    $values['registration'] = $line[3];
458 529
             				    $values['base'] = null;
459 530
             				    $values['owner'] = $line[5];
460
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
531
+            				    if ($line[18] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
535
+					    }
462 536
 					    $values['cancel'] = '';
463 537
 					} elseif ($country == 'VH') {
464 538
 					    // TODO : add modeS & reg to aircraft_modes
465 539
             				    $values['registration'] = $line[0];
466 540
             				    $values['base'] = null;
467 541
             				    $values['owner'] = $line[12];
468
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
542
+            				    if ($line[28] == '') {
543
+            				    	$values['date_first_reg'] = null;
544
+            				    } else {
545
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
546
+					    }
470 547
 
471 548
 					    $values['cancel'] = $line[39];
472 549
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -485,29 +562,41 @@  discard block
 block discarded – undo
485 562
             				    $values['registration'] = $line[0];
486 563
             				    $values['base'] = null;
487 564
             				    $values['owner'] = $line[8];
488
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
565
+            				    if ($line[7] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
569
+					    }
490 570
 					    $values['cancel'] = '';
491 571
 					} elseif ($country == 'PP') {
492 572
             				    $values['registration'] = $line[0];
493 573
             				    $values['base'] = null;
494 574
             				    $values['owner'] = $line[4];
495
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
575
+            				    if ($line[6] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
579
+					    }
497 580
 					    $values['cancel'] = $line[7];
498 581
 					} elseif ($country == 'E7') {
499 582
             				    $values['registration'] = $line[0];
500 583
             				    $values['base'] = null;
501 584
             				    $values['owner'] = $line[4];
502
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
585
+            				    if ($line[5] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
589
+					    }
504 590
 					    $values['cancel'] = '';
505 591
 					} elseif ($country == '8Q') {
506 592
             				    $values['registration'] = $line[0];
507 593
             				    $values['base'] = null;
508 594
             				    $values['owner'] = $line[3];
509
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
595
+            				    if ($line[7] == '') {
596
+            				    	$values['date_first_reg'] = null;
597
+            				    } else {
598
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
599
+					    }
511 600
 					    $values['cancel'] = '';
512 601
 					} elseif ($country == 'ZK') {
513 602
             				    $values['registration'] = $line[0];
@@ -552,7 +641,9 @@  discard block
 block discarded – undo
552 641
 						$sth_modes->execute($query_modes_values);
553 642
 					}
554 643
 				}
555
-				if ($globalTransaction) $Connection->db->commit();
644
+				if ($globalTransaction) {
645
+					$Connection->db->commit();
646
+				}
556 647
 			} catch(PDOException $e) {
557 648
 				return "error : ".$e->getMessage();
558 649
 			}
@@ -688,25 +779,45 @@  discard block
 block discarded – undo
688 779
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
689 780
 		$Connection = new Connection();
690 781
 		$sth_dest = $Connection->db->prepare($query_dest);
691
-		if ($globalTransaction) $Connection->db->beginTransaction();
782
+		if ($globalTransaction) {
783
+			$Connection->db->beginTransaction();
784
+		}
692 785
   
693 786
 		$i = 0;
694 787
 		while($row = sparql_fetch_array($result))
695 788
 		{
696 789
 			if ($i >= 1) {
697 790
 			//print_r($row);
698
-			if (!isset($row['iata'])) $row['iata'] = '';
699
-			if (!isset($row['icao'])) $row['icao'] = '';
700
-			if (!isset($row['type'])) $row['type'] = '';
701
-			if (!isset($row['altitude'])) $row['altitude'] = '';
791
+			if (!isset($row['iata'])) {
792
+				$row['iata'] = '';
793
+			}
794
+			if (!isset($row['icao'])) {
795
+				$row['icao'] = '';
796
+			}
797
+			if (!isset($row['type'])) {
798
+				$row['type'] = '';
799
+			}
800
+			if (!isset($row['altitude'])) {
801
+				$row['altitude'] = '';
802
+			}
702 803
 			if (isset($row['city_bis'])) {
703 804
 				$row['city'] = $row['city_bis'];
704 805
 			}
705
-			if (!isset($row['city'])) $row['city'] = '';
706
-			if (!isset($row['country'])) $row['country'] = '';
707
-			if (!isset($row['homepage'])) $row['homepage'] = '';
708
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
709
-			if (!isset($row['name'])) continue;
806
+			if (!isset($row['city'])) {
807
+				$row['city'] = '';
808
+			}
809
+			if (!isset($row['country'])) {
810
+				$row['country'] = '';
811
+			}
812
+			if (!isset($row['homepage'])) {
813
+				$row['homepage'] = '';
814
+			}
815
+			if (!isset($row['wikipedia_page'])) {
816
+				$row['wikipedia_page'] = '';
817
+			}
818
+			if (!isset($row['name'])) {
819
+				continue;
820
+			}
710 821
 			if (!isset($row['image'])) {
711 822
 				$row['image'] = '';
712 823
 				$row['image_thumb'] = '';
@@ -762,7 +873,9 @@  discard block
 block discarded – undo
762 873
 
763 874
 			$i++;
764 875
 		}
765
-		if ($globalTransaction) $Connection->db->commit();
876
+		if ($globalTransaction) {
877
+			$Connection->db->commit();
878
+		}
766 879
 		/*
767 880
 		echo "Delete duplicate rows...\n";
768 881
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -805,7 +918,9 @@  discard block
 block discarded – undo
805 918
 		$delimiter = ',';
806 919
 		$out_file = $tmp_dir.'airports.csv';
807 920
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
808
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
921
+		if (!file_exists($out_file) || !is_readable($out_file)) {
922
+			return FALSE;
923
+		}
809 924
 		echo "Add data from ourairports.com...\n";
810 925
 
811 926
 		$header = NULL;
@@ -815,8 +930,9 @@  discard block
 block discarded – undo
815 930
 			//$Connection->db->beginTransaction();
816 931
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
817 932
 			{
818
-				if(!$header) $header = $row;
819
-				else {
933
+				if(!$header) {
934
+					$header = $row;
935
+				} else {
820 936
 					$data = array();
821 937
 					$data = array_combine($header, $row);
822 938
 					try {
@@ -857,7 +973,9 @@  discard block
 block discarded – undo
857 973
 		echo "Download data from another free database...\n";
858 974
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
859 975
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
860
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
976
+		if (!file_exists($out_file) || !is_readable($out_file)) {
977
+			return FALSE;
978
+		}
861 979
 		update_db::unzip($out_file);
862 980
 		$header = NULL;
863 981
 		echo "Add data from another free database...\n";
@@ -868,8 +986,9 @@  discard block
 block discarded – undo
868 986
 			//$Connection->db->beginTransaction();
869 987
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 988
 			{
871
-				if(!$header) $header = $row;
872
-				else {
989
+				if(!$header) {
990
+					$header = $row;
991
+				} else {
873 992
 					$data = $row;
874 993
 
875 994
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1038,7 +1157,9 @@  discard block
 block discarded – undo
1038 1157
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1039 1158
 		{
1040 1159
 			$i = 0;
1041
-			if ($globalTransaction) $Connection->db->beginTransaction();
1160
+			if ($globalTransaction) {
1161
+				$Connection->db->beginTransaction();
1162
+			}
1042 1163
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1043 1164
 			{
1044 1165
 				if ($i > 0) {
@@ -1051,7 +1172,9 @@  discard block
 block discarded – undo
1051 1172
 					}
1052 1173
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1053 1174
 					if (!empty($result_search)) {
1054
-						if ($globalDebug) echo '.';
1175
+						if ($globalDebug) {
1176
+							echo '.';
1177
+						}
1055 1178
 							//if ($globalDBdriver == 'mysql') {
1056 1179
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1057 1180
 							//} else {
@@ -1073,8 +1196,12 @@  discard block
 block discarded – undo
1073 1196
 						}
1074 1197
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1075 1198
 						if (!empty($result_search_mfr)) {
1076
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1077
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1199
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1200
+								$data[16] = $data[23];
1201
+							}
1202
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1203
+								$data[16] = $data[15];
1204
+							}
1078 1205
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1079 1206
 							try {
1080 1207
 								$sthf = $Connection->db->prepare($queryf);
@@ -1085,7 +1212,9 @@  discard block
 block discarded – undo
1085 1212
 						}
1086 1213
 					}
1087 1214
 					if (strtotime($data[29]) > time()) {
1088
-						if ($globalDebug) echo 'i';
1215
+						if ($globalDebug) {
1216
+							echo 'i';
1217
+						}
1089 1218
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1090 1219
 						try {
1091 1220
 							$sth = $Connection->db->prepare($query);
@@ -1096,13 +1225,19 @@  discard block
 block discarded – undo
1096 1225
 					}
1097 1226
 				}
1098 1227
 				if ($i % 90 == 0) {
1099
-					if ($globalTransaction) $Connection->db->commit();
1100
-					if ($globalTransaction) $Connection->db->beginTransaction();
1228
+					if ($globalTransaction) {
1229
+						$Connection->db->commit();
1230
+					}
1231
+					if ($globalTransaction) {
1232
+						$Connection->db->beginTransaction();
1233
+					}
1101 1234
 				}
1102 1235
 				$i++;
1103 1236
 			}
1104 1237
 			fclose($handle);
1105
-			if ($globalTransaction) $Connection->db->commit();
1238
+			if ($globalTransaction) {
1239
+				$Connection->db->commit();
1240
+			}
1106 1241
 		}
1107 1242
 		//print_r($mfr);
1108 1243
 		return '';
@@ -1127,11 +1262,15 @@  discard block
 block discarded – undo
1127 1262
 			$i = 0;
1128 1263
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1129 1264
 			//$Connection->db->beginTransaction();
1130
-			if ($globalTransaction) $Connection->db->beginTransaction();
1265
+			if ($globalTransaction) {
1266
+				$Connection->db->beginTransaction();
1267
+			}
1131 1268
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1132 1269
 			{
1133 1270
 				if ($i > 0) {
1134
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1271
+					if ($data[1] == 'NULL') {
1272
+						$data[1] = $data[0];
1273
+					}
1135 1274
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1136 1275
 					try {
1137 1276
 						$sth = $Connection->db->prepare($query);
@@ -1143,7 +1282,9 @@  discard block
 block discarded – undo
1143 1282
 				$i++;
1144 1283
 			}
1145 1284
 			fclose($handle);
1146
-			if ($globalTransaction) $Connection->db->commit();
1285
+			if ($globalTransaction) {
1286
+				$Connection->db->commit();
1287
+			}
1147 1288
 		}
1148 1289
 		return '';
1149 1290
         }
@@ -1164,7 +1305,9 @@  discard block
 block discarded – undo
1164 1305
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1165 1306
 		{
1166 1307
 			$i = 0;
1167
-			if ($globalTransaction) $Connection->db->beginTransaction();
1308
+			if ($globalTransaction) {
1309
+				$Connection->db->beginTransaction();
1310
+			}
1168 1311
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1169 1312
 			{
1170 1313
 				if ($i > 0) {
@@ -1180,7 +1323,9 @@  discard block
 block discarded – undo
1180 1323
 				$i++;
1181 1324
 			}
1182 1325
 			fclose($handle);
1183
-			if ($globalTransaction) $Connection->db->commit();
1326
+			if ($globalTransaction) {
1327
+				$Connection->db->commit();
1328
+			}
1184 1329
 		}
1185 1330
 		return '';
1186 1331
         }
@@ -1200,7 +1345,9 @@  discard block
 block discarded – undo
1200 1345
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1201 1346
 		{
1202 1347
 			$i = 0;
1203
-			if ($globalTransaction) $Connection->db->beginTransaction();
1348
+			if ($globalTransaction) {
1349
+				$Connection->db->beginTransaction();
1350
+			}
1204 1351
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1205 1352
 			{
1206 1353
 				if ($i > 0) {
@@ -1209,13 +1356,17 @@  discard block
 block discarded – undo
1209 1356
 						$sth = $Connection->db->prepare($query);
1210 1357
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1211 1358
 					} catch(PDOException $e) {
1212
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1359
+						if ($globalDebug) {
1360
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1361
+						}
1213 1362
 					}
1214 1363
 				}
1215 1364
 				$i++;
1216 1365
 			}
1217 1366
 			fclose($handle);
1218
-			if ($globalTransaction) $Connection->db->commit();
1367
+			if ($globalTransaction) {
1368
+				$Connection->db->commit();
1369
+			}
1219 1370
 		}
1220 1371
 		return '';
1221 1372
         }
@@ -1240,7 +1391,9 @@  discard block
 block discarded – undo
1240 1391
 			$i = 0;
1241 1392
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1242 1393
 			//$Connection->db->beginTransaction();
1243
-			if ($globalTransaction) $Connection->db->beginTransaction();
1394
+			if ($globalTransaction) {
1395
+				$Connection->db->beginTransaction();
1396
+			}
1244 1397
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1245 1398
 			{
1246 1399
 				if ($i > 0) {
@@ -1256,7 +1409,9 @@  discard block
 block discarded – undo
1256 1409
 				$i++;
1257 1410
 			}
1258 1411
 			fclose($handle);
1259
-			if ($globalTransaction) $Connection->db->commit();
1412
+			if ($globalTransaction) {
1413
+				$Connection->db->commit();
1414
+			}
1260 1415
 		}
1261 1416
 		return '';
1262 1417
         }
@@ -1275,7 +1430,9 @@  discard block
 block discarded – undo
1275 1430
 		$Connection = new Connection();
1276 1431
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1277 1432
 		{
1278
-			if ($globalTransaction) $Connection->db->beginTransaction();
1433
+			if ($globalTransaction) {
1434
+				$Connection->db->beginTransaction();
1435
+			}
1279 1436
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1280 1437
 			{
1281 1438
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1290,7 +1447,9 @@  discard block
 block discarded – undo
1290 1447
 				}
1291 1448
 			}
1292 1449
 			fclose($handle);
1293
-			if ($globalTransaction) $Connection->db->commit();
1450
+			if ($globalTransaction) {
1451
+				$Connection->db->commit();
1452
+			}
1294 1453
 		}
1295 1454
 		return '';
1296 1455
         }
@@ -1444,7 +1603,9 @@  discard block
 block discarded – undo
1444 1603
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1445 1604
 		{
1446 1605
 			$i = 0;
1447
-			if ($globalTransaction) $Connection->db->beginTransaction();
1606
+			if ($globalTransaction) {
1607
+				$Connection->db->beginTransaction();
1608
+			}
1448 1609
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1449 1610
 			{
1450 1611
 				$i++;
@@ -1472,7 +1633,9 @@  discard block
 block discarded – undo
1472 1633
 				}
1473 1634
 			}
1474 1635
 			fclose($handle);
1475
-			if ($globalTransaction) $Connection->db->commit();
1636
+			if ($globalTransaction) {
1637
+				$Connection->db->commit();
1638
+			}
1476 1639
 		}
1477 1640
 		return '';
1478 1641
         }
@@ -1495,7 +1658,9 @@  discard block
 block discarded – undo
1495 1658
 		$Connection = new Connection();
1496 1659
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1497 1660
 		{
1498
-			if ($globalTransaction) $Connection->db->beginTransaction();
1661
+			if ($globalTransaction) {
1662
+				$Connection->db->beginTransaction();
1663
+			}
1499 1664
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1500 1665
 			{
1501 1666
 				if(count($row) > 1) {
@@ -1509,7 +1674,9 @@  discard block
 block discarded – undo
1509 1674
 				}
1510 1675
 			}
1511 1676
 			fclose($handle);
1512
-			if ($globalTransaction) $Connection->db->commit();
1677
+			if ($globalTransaction) {
1678
+				$Connection->db->commit();
1679
+			}
1513 1680
 		}
1514 1681
 		return '';
1515 1682
         }
@@ -1529,8 +1696,9 @@  discard block
 block discarded – undo
1529 1696
 	        }
1530 1697
 
1531 1698
 
1532
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1533
-		else {
1699
+		if ($globalDBdriver == 'mysql') {
1700
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1701
+		} else {
1534 1702
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1535 1703
 			$query = "CREATE EXTENSION postgis";
1536 1704
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1549,20 +1717,30 @@  discard block
 block discarded – undo
1549 1717
 		global $tmp_dir, $globalDebug;
1550 1718
 		include_once('class.create_db.php');
1551 1719
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1552
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1720
+		if ($globalDebug) {
1721
+			echo "NOTAM from FlightAirMap website : Download...";
1722
+		}
1553 1723
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1554 1724
 		$error = '';
1555 1725
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1556
-			if ($globalDebug) echo "Gunzip...";
1726
+			if ($globalDebug) {
1727
+				echo "Gunzip...";
1728
+			}
1557 1729
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1558
-			if ($globalDebug) echo "Add to DB...";
1730
+			if ($globalDebug) {
1731
+				echo "Add to DB...";
1732
+			}
1559 1733
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1560 1734
 			$NOTAM = new NOTAM();
1561 1735
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1562
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1736
+		} else {
1737
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1738
+		}
1563 1739
 		if ($error != '') {
1564 1740
 			return $error;
1565
-		} elseif ($globalDebug) echo "Done\n";
1741
+		} elseif ($globalDebug) {
1742
+			echo "Done\n";
1743
+		}
1566 1744
 		return '';
1567 1745
 	}
1568 1746
 
@@ -1616,67 +1794,111 @@  discard block
 block discarded – undo
1616 1794
 		//if ($globalDebug) echo "IVAO : Download...";
1617 1795
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1618 1796
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1619
-			if ($globalDebug) echo "Unzip...";
1797
+			if ($globalDebug) {
1798
+				echo "Unzip...";
1799
+			}
1620 1800
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1621
-			if ($globalDebug) echo "Add to DB...";
1801
+			if ($globalDebug) {
1802
+				echo "Add to DB...";
1803
+			}
1622 1804
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1623
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1805
+			if ($globalDebug) {
1806
+				echo "Copy airlines logos to airlines images directory...";
1807
+			}
1624 1808
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1625
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1626
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1627
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1809
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1810
+					$error = "Failed to copy airlines logo.";
1811
+				}
1812
+			} else {
1813
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1814
+			}
1815
+		} else {
1816
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1817
+		}
1628 1818
 		if ($error != '') {
1629 1819
 			return $error;
1630
-		} elseif ($globalDebug) echo "Done\n";
1820
+		} elseif ($globalDebug) {
1821
+			echo "Done\n";
1822
+		}
1631 1823
 		return '';
1632 1824
 	}
1633 1825
 
1634 1826
 	public static function update_routes() {
1635 1827
 		global $tmp_dir, $globalDebug;
1636 1828
 		$error = '';
1637
-		if ($globalDebug) echo "Routes : Download...";
1829
+		if ($globalDebug) {
1830
+			echo "Routes : Download...";
1831
+		}
1638 1832
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1639 1833
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1640
-			if ($globalDebug) echo "Gunzip...";
1834
+			if ($globalDebug) {
1835
+				echo "Gunzip...";
1836
+			}
1641 1837
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1642
-			if ($globalDebug) echo "Add to DB...";
1838
+			if ($globalDebug) {
1839
+				echo "Add to DB...";
1840
+			}
1643 1841
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1644
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1842
+		} else {
1843
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1844
+		}
1645 1845
 		if ($error != '') {
1646 1846
 			return $error;
1647
-		} elseif ($globalDebug) echo "Done\n";
1847
+		} elseif ($globalDebug) {
1848
+			echo "Done\n";
1849
+		}
1648 1850
 		return '';
1649 1851
 	}
1650 1852
 	public static function update_oneworld() {
1651 1853
 		global $tmp_dir, $globalDebug;
1652 1854
 		$error = '';
1653
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1855
+		if ($globalDebug) {
1856
+			echo "Schedules Oneworld : Download...";
1857
+		}
1654 1858
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1655 1859
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1656
-			if ($globalDebug) echo "Gunzip...";
1860
+			if ($globalDebug) {
1861
+				echo "Gunzip...";
1862
+			}
1657 1863
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1658
-			if ($globalDebug) echo "Add to DB...";
1864
+			if ($globalDebug) {
1865
+				echo "Add to DB...";
1866
+			}
1659 1867
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1660
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1868
+		} else {
1869
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1870
+		}
1661 1871
 		if ($error != '') {
1662 1872
 			return $error;
1663
-		} elseif ($globalDebug) echo "Done\n";
1873
+		} elseif ($globalDebug) {
1874
+			echo "Done\n";
1875
+		}
1664 1876
 		return '';
1665 1877
 	}
1666 1878
 	public static function update_skyteam() {
1667 1879
 		global $tmp_dir, $globalDebug;
1668 1880
 		$error = '';
1669
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1881
+		if ($globalDebug) {
1882
+			echo "Schedules Skyteam : Download...";
1883
+		}
1670 1884
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1671 1885
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1672
-			if ($globalDebug) echo "Gunzip...";
1886
+			if ($globalDebug) {
1887
+				echo "Gunzip...";
1888
+			}
1673 1889
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1674
-			if ($globalDebug) echo "Add to DB...";
1890
+			if ($globalDebug) {
1891
+				echo "Add to DB...";
1892
+			}
1675 1893
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1676
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1894
+		} else {
1895
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1896
+		}
1677 1897
 		if ($error != '') {
1678 1898
 			return $error;
1679
-		} elseif ($globalDebug) echo "Done\n";
1899
+		} elseif ($globalDebug) {
1900
+			echo "Done\n";
1901
+		}
1680 1902
 		return '';
1681 1903
 	}
1682 1904
 	public static function update_ModeS() {
@@ -1693,355 +1915,619 @@  discard block
 block discarded – undo
1693 1915
 			exit;
1694 1916
 		} elseif ($globalDebug) echo "Done\n";
1695 1917
 */
1696
-		if ($globalDebug) echo "Modes : Download...";
1697
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1918
+		if ($globalDebug) {
1919
+			echo "Modes : Download...";
1920
+		}
1921
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1698 1922
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1699 1923
 
1700 1924
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1701 1925
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1702
-			if ($globalDebug) echo "Unzip...";
1703
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1926
+			if ($globalDebug) {
1927
+				echo "Unzip...";
1928
+			}
1929
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1704 1930
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1705
-			if ($globalDebug) echo "Add to DB...";
1931
+			if ($globalDebug) {
1932
+				echo "Add to DB...";
1933
+			}
1706 1934
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1707 1935
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1708
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1936
+		} else {
1937
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1938
+		}
1709 1939
 		if ($error != '') {
1710 1940
 			return $error;
1711
-		} elseif ($globalDebug) echo "Done\n";
1941
+		} elseif ($globalDebug) {
1942
+			echo "Done\n";
1943
+		}
1712 1944
 		return '';
1713 1945
 	}
1714 1946
 
1715 1947
 	public static function update_ModeS_faa() {
1716 1948
 		global $tmp_dir, $globalDebug;
1717
-		if ($globalDebug) echo "Modes FAA: Download...";
1949
+		if ($globalDebug) {
1950
+			echo "Modes FAA: Download...";
1951
+		}
1718 1952
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1719 1953
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1720
-			if ($globalDebug) echo "Unzip...";
1954
+			if ($globalDebug) {
1955
+				echo "Unzip...";
1956
+			}
1721 1957
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1722
-			if ($globalDebug) echo "Add to DB...";
1958
+			if ($globalDebug) {
1959
+				echo "Add to DB...";
1960
+			}
1723 1961
 			$error = update_db::modes_faa();
1724
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1962
+		} else {
1963
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1964
+		}
1725 1965
 		if ($error != '') {
1726 1966
 			return $error;
1727
-		} elseif ($globalDebug) echo "Done\n";
1967
+		} elseif ($globalDebug) {
1968
+			echo "Done\n";
1969
+		}
1728 1970
 		return '';
1729 1971
 	}
1730 1972
 
1731 1973
 	public static function update_ModeS_flarm() {
1732 1974
 		global $tmp_dir, $globalDebug;
1733
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1975
+		if ($globalDebug) {
1976
+			echo "Modes Flarmnet: Download...";
1977
+		}
1734 1978
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1735 1979
 		if (file_exists($tmp_dir.'data.fln')) {
1736
-			if ($globalDebug) echo "Add to DB...";
1980
+			if ($globalDebug) {
1981
+				echo "Add to DB...";
1982
+			}
1737 1983
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1738
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1984
+		} else {
1985
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1986
+		}
1739 1987
 		if ($error != '') {
1740 1988
 			return $error;
1741
-		} elseif ($globalDebug) echo "Done\n";
1989
+		} elseif ($globalDebug) {
1990
+			echo "Done\n";
1991
+		}
1742 1992
 		return '';
1743 1993
 	}
1744 1994
 
1745 1995
 	public static function update_ModeS_ogn() {
1746 1996
 		global $tmp_dir, $globalDebug;
1747
-		if ($globalDebug) echo "Modes OGN: Download...";
1997
+		if ($globalDebug) {
1998
+			echo "Modes OGN: Download...";
1999
+		}
1748 2000
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1749 2001
 		if (file_exists($tmp_dir.'ogn.csv')) {
1750
-			if ($globalDebug) echo "Add to DB...";
2002
+			if ($globalDebug) {
2003
+				echo "Add to DB...";
2004
+			}
1751 2005
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1752
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2006
+		} else {
2007
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2008
+		}
1753 2009
 		if ($error != '') {
1754 2010
 			return $error;
1755
-		} elseif ($globalDebug) echo "Done\n";
2011
+		} elseif ($globalDebug) {
2012
+			echo "Done\n";
2013
+		}
1756 2014
 		return '';
1757 2015
 	}
1758 2016
 
1759 2017
 	public static function update_owner() {
1760 2018
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1761 2019
 		
1762
-		if ($globalDebug) echo "Owner France: Download...";
2020
+		if ($globalDebug) {
2021
+			echo "Owner France: Download...";
2022
+		}
1763 2023
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1764 2024
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1765
-			if ($globalDebug) echo "Add to DB...";
2025
+			if ($globalDebug) {
2026
+				echo "Add to DB...";
2027
+			}
1766 2028
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1767
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2029
+		} else {
2030
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2031
+		}
1768 2032
 		if ($error != '') {
1769 2033
 			return $error;
1770
-		} elseif ($globalDebug) echo "Done\n";
2034
+		} elseif ($globalDebug) {
2035
+			echo "Done\n";
2036
+		}
1771 2037
 		
1772
-		if ($globalDebug) echo "Owner Ireland: Download...";
2038
+		if ($globalDebug) {
2039
+			echo "Owner Ireland: Download...";
2040
+		}
1773 2041
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1774 2042
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1775
-			if ($globalDebug) echo "Add to DB...";
2043
+			if ($globalDebug) {
2044
+				echo "Add to DB...";
2045
+			}
1776 2046
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1777
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2047
+		} else {
2048
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2049
+		}
1778 2050
 		if ($error != '') {
1779 2051
 			return $error;
1780
-		} elseif ($globalDebug) echo "Done\n";
1781
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2052
+		} elseif ($globalDebug) {
2053
+			echo "Done\n";
2054
+		}
2055
+		if ($globalDebug) {
2056
+			echo "Owner Switzerland: Download...";
2057
+		}
1782 2058
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1783 2059
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1784
-			if ($globalDebug) echo "Add to DB...";
2060
+			if ($globalDebug) {
2061
+				echo "Add to DB...";
2062
+			}
1785 2063
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1786
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2064
+		} else {
2065
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2066
+		}
1787 2067
 		if ($error != '') {
1788 2068
 			return $error;
1789
-		} elseif ($globalDebug) echo "Done\n";
1790
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2069
+		} elseif ($globalDebug) {
2070
+			echo "Done\n";
2071
+		}
2072
+		if ($globalDebug) {
2073
+			echo "Owner Czech Republic: Download...";
2074
+		}
1791 2075
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1792 2076
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1793
-			if ($globalDebug) echo "Add to DB...";
2077
+			if ($globalDebug) {
2078
+				echo "Add to DB...";
2079
+			}
1794 2080
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1795
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2081
+		} else {
2082
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2083
+		}
1796 2084
 		if ($error != '') {
1797 2085
 			return $error;
1798
-		} elseif ($globalDebug) echo "Done\n";
1799
-		if ($globalDebug) echo "Owner Australia: Download...";
2086
+		} elseif ($globalDebug) {
2087
+			echo "Done\n";
2088
+		}
2089
+		if ($globalDebug) {
2090
+			echo "Owner Australia: Download...";
2091
+		}
1800 2092
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1801 2093
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1802
-			if ($globalDebug) echo "Add to DB...";
2094
+			if ($globalDebug) {
2095
+				echo "Add to DB...";
2096
+			}
1803 2097
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1804
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2098
+		} else {
2099
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2100
+		}
1805 2101
 		if ($error != '') {
1806 2102
 			return $error;
1807
-		} elseif ($globalDebug) echo "Done\n";
1808
-		if ($globalDebug) echo "Owner Austria: Download...";
2103
+		} elseif ($globalDebug) {
2104
+			echo "Done\n";
2105
+		}
2106
+		if ($globalDebug) {
2107
+			echo "Owner Austria: Download...";
2108
+		}
1809 2109
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1810 2110
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1811
-			if ($globalDebug) echo "Add to DB...";
2111
+			if ($globalDebug) {
2112
+				echo "Add to DB...";
2113
+			}
1812 2114
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1813
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2115
+		} else {
2116
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2117
+		}
1814 2118
 		if ($error != '') {
1815 2119
 			return $error;
1816
-		} elseif ($globalDebug) echo "Done\n";
1817
-		if ($globalDebug) echo "Owner Chile: Download...";
2120
+		} elseif ($globalDebug) {
2121
+			echo "Done\n";
2122
+		}
2123
+		if ($globalDebug) {
2124
+			echo "Owner Chile: Download...";
2125
+		}
1818 2126
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1819 2127
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1820
-			if ($globalDebug) echo "Add to DB...";
2128
+			if ($globalDebug) {
2129
+				echo "Add to DB...";
2130
+			}
1821 2131
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1822
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2132
+		} else {
2133
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2134
+		}
1823 2135
 		if ($error != '') {
1824 2136
 			return $error;
1825
-		} elseif ($globalDebug) echo "Done\n";
1826
-		if ($globalDebug) echo "Owner Colombia: Download...";
2137
+		} elseif ($globalDebug) {
2138
+			echo "Done\n";
2139
+		}
2140
+		if ($globalDebug) {
2141
+			echo "Owner Colombia: Download...";
2142
+		}
1827 2143
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1828 2144
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1829
-			if ($globalDebug) echo "Add to DB...";
2145
+			if ($globalDebug) {
2146
+				echo "Add to DB...";
2147
+			}
1830 2148
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1831
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2149
+		} else {
2150
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2151
+		}
1832 2152
 		if ($error != '') {
1833 2153
 			return $error;
1834
-		} elseif ($globalDebug) echo "Done\n";
1835
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2154
+		} elseif ($globalDebug) {
2155
+			echo "Done\n";
2156
+		}
2157
+		if ($globalDebug) {
2158
+			echo "Owner Bosnia Herzegobina: Download...";
2159
+		}
1836 2160
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1837 2161
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1838
-			if ($globalDebug) echo "Add to DB...";
2162
+			if ($globalDebug) {
2163
+				echo "Add to DB...";
2164
+			}
1839 2165
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1840
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2166
+		} else {
2167
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2168
+		}
1841 2169
 		if ($error != '') {
1842 2170
 			return $error;
1843
-		} elseif ($globalDebug) echo "Done\n";
1844
-		if ($globalDebug) echo "Owner Brazil: Download...";
2171
+		} elseif ($globalDebug) {
2172
+			echo "Done\n";
2173
+		}
2174
+		if ($globalDebug) {
2175
+			echo "Owner Brazil: Download...";
2176
+		}
1845 2177
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1846 2178
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1847
-			if ($globalDebug) echo "Add to DB...";
2179
+			if ($globalDebug) {
2180
+				echo "Add to DB...";
2181
+			}
1848 2182
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1849
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2183
+		} else {
2184
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2185
+		}
1850 2186
 		if ($error != '') {
1851 2187
 			return $error;
1852
-		} elseif ($globalDebug) echo "Done\n";
1853
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2188
+		} elseif ($globalDebug) {
2189
+			echo "Done\n";
2190
+		}
2191
+		if ($globalDebug) {
2192
+			echo "Owner Cayman Islands: Download...";
2193
+		}
1854 2194
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1855 2195
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1856
-			if ($globalDebug) echo "Add to DB...";
2196
+			if ($globalDebug) {
2197
+				echo "Add to DB...";
2198
+			}
1857 2199
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1858
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2200
+		} else {
2201
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2202
+		}
1859 2203
 		if ($error != '') {
1860 2204
 			return $error;
1861
-		} elseif ($globalDebug) echo "Done\n";
1862
-		if ($globalDebug) echo "Owner Croatia: Download...";
2205
+		} elseif ($globalDebug) {
2206
+			echo "Done\n";
2207
+		}
2208
+		if ($globalDebug) {
2209
+			echo "Owner Croatia: Download...";
2210
+		}
1863 2211
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1864 2212
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1865
-			if ($globalDebug) echo "Add to DB...";
2213
+			if ($globalDebug) {
2214
+				echo "Add to DB...";
2215
+			}
1866 2216
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1867
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2217
+		} else {
2218
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2219
+		}
1868 2220
 		if ($error != '') {
1869 2221
 			return $error;
1870
-		} elseif ($globalDebug) echo "Done\n";
1871
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2222
+		} elseif ($globalDebug) {
2223
+			echo "Done\n";
2224
+		}
2225
+		if ($globalDebug) {
2226
+			echo "Owner Luxembourg: Download...";
2227
+		}
1872 2228
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1873 2229
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1874
-			if ($globalDebug) echo "Add to DB...";
2230
+			if ($globalDebug) {
2231
+				echo "Add to DB...";
2232
+			}
1875 2233
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1876
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2234
+		} else {
2235
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2236
+		}
1877 2237
 		if ($error != '') {
1878 2238
 			return $error;
1879
-		} elseif ($globalDebug) echo "Done\n";
1880
-		if ($globalDebug) echo "Owner Maldives: Download...";
2239
+		} elseif ($globalDebug) {
2240
+			echo "Done\n";
2241
+		}
2242
+		if ($globalDebug) {
2243
+			echo "Owner Maldives: Download...";
2244
+		}
1881 2245
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1882 2246
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1883
-			if ($globalDebug) echo "Add to DB...";
2247
+			if ($globalDebug) {
2248
+				echo "Add to DB...";
2249
+			}
1884 2250
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1885
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2251
+		} else {
2252
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2253
+		}
1886 2254
 		if ($error != '') {
1887 2255
 			return $error;
1888
-		} elseif ($globalDebug) echo "Done\n";
1889
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2256
+		} elseif ($globalDebug) {
2257
+			echo "Done\n";
2258
+		}
2259
+		if ($globalDebug) {
2260
+			echo "Owner New Zealand: Download...";
2261
+		}
1890 2262
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1891 2263
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1892
-			if ($globalDebug) echo "Add to DB...";
2264
+			if ($globalDebug) {
2265
+				echo "Add to DB...";
2266
+			}
1893 2267
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1894
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2268
+		} else {
2269
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2270
+		}
1895 2271
 		if ($error != '') {
1896 2272
 			return $error;
1897
-		} elseif ($globalDebug) echo "Done\n";
1898
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2273
+		} elseif ($globalDebug) {
2274
+			echo "Done\n";
2275
+		}
2276
+		if ($globalDebug) {
2277
+			echo "Owner Papua New Guinea: Download...";
2278
+		}
1899 2279
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1900 2280
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1901
-			if ($globalDebug) echo "Add to DB...";
2281
+			if ($globalDebug) {
2282
+				echo "Add to DB...";
2283
+			}
1902 2284
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1903
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2285
+		} else {
2286
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2287
+		}
1904 2288
 		if ($error != '') {
1905 2289
 			return $error;
1906
-		} elseif ($globalDebug) echo "Done\n";
1907
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2290
+		} elseif ($globalDebug) {
2291
+			echo "Done\n";
2292
+		}
2293
+		if ($globalDebug) {
2294
+			echo "Owner Slovakia: Download...";
2295
+		}
1908 2296
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1909 2297
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1910
-			if ($globalDebug) echo "Add to DB...";
2298
+			if ($globalDebug) {
2299
+				echo "Add to DB...";
2300
+			}
1911 2301
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1912
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2302
+		} else {
2303
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2304
+		}
1913 2305
 		if ($error != '') {
1914 2306
 			return $error;
1915
-		} elseif ($globalDebug) echo "Done\n";
1916
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2307
+		} elseif ($globalDebug) {
2308
+			echo "Done\n";
2309
+		}
2310
+		if ($globalDebug) {
2311
+			echo "Owner Ecuador: Download...";
2312
+		}
1917 2313
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1918 2314
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1919
-			if ($globalDebug) echo "Add to DB...";
2315
+			if ($globalDebug) {
2316
+				echo "Add to DB...";
2317
+			}
1920 2318
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1921
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2319
+		} else {
2320
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2321
+		}
1922 2322
 		if ($error != '') {
1923 2323
 			return $error;
1924
-		} elseif ($globalDebug) echo "Done\n";
1925
-		if ($globalDebug) echo "Owner Iceland: Download...";
2324
+		} elseif ($globalDebug) {
2325
+			echo "Done\n";
2326
+		}
2327
+		if ($globalDebug) {
2328
+			echo "Owner Iceland: Download...";
2329
+		}
1926 2330
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1927 2331
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1928
-			if ($globalDebug) echo "Add to DB...";
2332
+			if ($globalDebug) {
2333
+				echo "Add to DB...";
2334
+			}
1929 2335
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1930
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2336
+		} else {
2337
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2338
+		}
1931 2339
 		if ($error != '') {
1932 2340
 			return $error;
1933
-		} elseif ($globalDebug) echo "Done\n";
1934
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2341
+		} elseif ($globalDebug) {
2342
+			echo "Done\n";
2343
+		}
2344
+		if ($globalDebug) {
2345
+			echo "Owner Isle of Man: Download...";
2346
+		}
1935 2347
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1936 2348
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1937
-			if ($globalDebug) echo "Add to DB...";
2349
+			if ($globalDebug) {
2350
+				echo "Add to DB...";
2351
+			}
1938 2352
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1939
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2353
+		} else {
2354
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2355
+		}
1940 2356
 		if ($error != '') {
1941 2357
 			return $error;
1942
-		} elseif ($globalDebug) echo "Done\n";
2358
+		} elseif ($globalDebug) {
2359
+			echo "Done\n";
2360
+		}
1943 2361
 		if ($globalMasterSource) {
1944
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2362
+			if ($globalDebug) {
2363
+				echo "ModeS Netherlands: Download...";
2364
+			}
1945 2365
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1946 2366
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1947
-				if ($globalDebug) echo "Add to DB...";
2367
+				if ($globalDebug) {
2368
+					echo "Add to DB...";
2369
+				}
1948 2370
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1949
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2371
+			} else {
2372
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2373
+			}
1950 2374
 			if ($error != '') {
1951 2375
 				return $error;
1952
-			} elseif ($globalDebug) echo "Done\n";
1953
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2376
+			} elseif ($globalDebug) {
2377
+				echo "Done\n";
2378
+			}
2379
+			if ($globalDebug) {
2380
+				echo "ModeS Denmark: Download...";
2381
+			}
1954 2382
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1955 2383
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1956
-				if ($globalDebug) echo "Add to DB...";
2384
+				if ($globalDebug) {
2385
+					echo "Add to DB...";
2386
+				}
1957 2387
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1958
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2388
+			} else {
2389
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2390
+			}
1959 2391
 			if ($error != '') {
1960 2392
 				return $error;
1961
-			} elseif ($globalDebug) echo "Done\n";
1962
-		} elseif ($globalDebug) echo "Done\n";
2393
+			} elseif ($globalDebug) {
2394
+				echo "Done\n";
2395
+			}
2396
+		} elseif ($globalDebug) {
2397
+			echo "Done\n";
2398
+		}
1963 2399
 		return '';
1964 2400
 	}
1965 2401
 
1966 2402
 	public static function update_translation() {
1967 2403
 		global $tmp_dir, $globalDebug;
1968 2404
 		$error = '';
1969
-		if ($globalDebug) echo "Translation : Download...";
2405
+		if ($globalDebug) {
2406
+			echo "Translation : Download...";
2407
+		}
1970 2408
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1971 2409
 		if (file_exists($tmp_dir.'translation.zip')) {
1972
-			if ($globalDebug) echo "Unzip...";
2410
+			if ($globalDebug) {
2411
+				echo "Unzip...";
2412
+			}
1973 2413
 			update_db::unzip($tmp_dir.'translation.zip');
1974
-			if ($globalDebug) echo "Add to DB...";
2414
+			if ($globalDebug) {
2415
+				echo "Add to DB...";
2416
+			}
1975 2417
 			$error = update_db::translation();
1976
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2418
+		} else {
2419
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2420
+		}
1977 2421
 		if ($error != '') {
1978 2422
 			return $error;
1979
-		} elseif ($globalDebug) echo "Done\n";
2423
+		} elseif ($globalDebug) {
2424
+			echo "Done\n";
2425
+		}
1980 2426
 		return '';
1981 2427
 	}
1982 2428
 
1983 2429
 	public static function update_translation_fam() {
1984 2430
 		global $tmp_dir, $globalDebug;
1985
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2431
+		if ($globalDebug) {
2432
+			echo "Translation from FlightAirMap website : Download...";
2433
+		}
1986 2434
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1987 2435
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1988
-			if ($globalDebug) echo "Gunzip...";
2436
+			if ($globalDebug) {
2437
+				echo "Gunzip...";
2438
+			}
1989 2439
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1990
-			if ($globalDebug) echo "Add to DB...";
2440
+			if ($globalDebug) {
2441
+				echo "Add to DB...";
2442
+			}
1991 2443
 			$error = update_db::translation_fam();
1992
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2444
+		} else {
2445
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2446
+		}
1993 2447
 		if ($error != '') {
1994 2448
 			return $error;
1995
-		} elseif ($globalDebug) echo "Done\n";
2449
+		} elseif ($globalDebug) {
2450
+			echo "Done\n";
2451
+		}
1996 2452
 		return '';
1997 2453
 	}
1998 2454
 	public static function update_ModeS_fam() {
1999 2455
 		global $tmp_dir, $globalDebug;
2000
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2456
+		if ($globalDebug) {
2457
+			echo "ModeS from FlightAirMap website : Download...";
2458
+		}
2001 2459
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2002 2460
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
2003
-			if ($globalDebug) echo "Gunzip...";
2461
+			if ($globalDebug) {
2462
+				echo "Gunzip...";
2463
+			}
2004 2464
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
2005
-			if ($globalDebug) echo "Add to DB...";
2465
+			if ($globalDebug) {
2466
+				echo "Add to DB...";
2467
+			}
2006 2468
 			$error = update_db::modes_fam();
2007
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2469
+		} else {
2470
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2471
+		}
2008 2472
 		if ($error != '') {
2009 2473
 			return $error;
2010
-		} elseif ($globalDebug) echo "Done\n";
2474
+		} elseif ($globalDebug) {
2475
+			echo "Done\n";
2476
+		}
2011 2477
 		return '';
2012 2478
 	}
2013 2479
 	public static function update_owner_fam() {
2014 2480
 		global $tmp_dir, $globalDebug, $globalOwner;
2015
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2481
+		if ($globalDebug) {
2482
+			echo "owner from FlightAirMap website : Download...";
2483
+		}
2016 2484
 		if ($globalOwner === TRUE) {
2017 2485
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2018 2486
 		} else {
2019 2487
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2020 2488
 		}
2021 2489
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2022
-			if ($globalDebug) echo "Gunzip...";
2490
+			if ($globalDebug) {
2491
+				echo "Gunzip...";
2492
+			}
2023 2493
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2024
-			if ($globalDebug) echo "Add to DB...";
2494
+			if ($globalDebug) {
2495
+				echo "Add to DB...";
2496
+			}
2025 2497
 			$error = update_db::owner_fam();
2026
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2498
+		} else {
2499
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2500
+		}
2027 2501
 		if ($error != '') {
2028 2502
 			return $error;
2029
-		} elseif ($globalDebug) echo "Done\n";
2503
+		} elseif ($globalDebug) {
2504
+			echo "Done\n";
2505
+		}
2030 2506
 		return '';
2031 2507
 	}
2032 2508
 	public static function update_routes_fam() {
2033 2509
 		global $tmp_dir, $globalDebug;
2034
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2510
+		if ($globalDebug) {
2511
+			echo "Routes from FlightAirMap website : Download...";
2512
+		}
2035 2513
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2036 2514
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2037
-			if ($globalDebug) echo "Gunzip...";
2515
+			if ($globalDebug) {
2516
+				echo "Gunzip...";
2517
+			}
2038 2518
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2039
-			if ($globalDebug) echo "Add to DB...";
2519
+			if ($globalDebug) {
2520
+				echo "Add to DB...";
2521
+			}
2040 2522
 			$error = update_db::routes_fam();
2041
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2523
+		} else {
2524
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2525
+		}
2042 2526
 		if ($error != '') {
2043 2527
 			return $error;
2044
-		} elseif ($globalDebug) echo "Done\n";
2528
+		} elseif ($globalDebug) {
2529
+			echo "Done\n";
2530
+		}
2045 2531
 		return '';
2046 2532
 	}
2047 2533
 	public static function update_marine_identity_fam() {
@@ -2051,14 +2537,22 @@  discard block
 block discarded – undo
2051 2537
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2052 2538
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2053 2539
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2054
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2540
+				if ($globalDebug) {
2541
+					echo "Marine identity from FlightAirMap website : Download...";
2542
+				}
2055 2543
 				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2056 2544
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2057
-					if ($globalDebug) echo "Gunzip...";
2545
+					if ($globalDebug) {
2546
+						echo "Gunzip...";
2547
+					}
2058 2548
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2059
-					if ($globalDebug) echo "Add to DB...";
2549
+					if ($globalDebug) {
2550
+						echo "Add to DB...";
2551
+					}
2060 2552
 					$error = update_db::marine_identity_fam();
2061
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2553
+				} else {
2554
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2555
+				}
2062 2556
 				if ($error != '') {
2063 2557
 					return $error;
2064 2558
 				} elseif ($globalDebug) {
@@ -2071,17 +2565,25 @@  discard block
 block discarded – undo
2071 2565
 	}
2072 2566
 	public static function update_banned_fam() {
2073 2567
 		global $tmp_dir, $globalDebug;
2074
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2568
+		if ($globalDebug) {
2569
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2570
+		}
2075 2571
 		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2076 2572
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2077 2573
 			//if ($globalDebug) echo "Gunzip...";
2078 2574
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2079
-			if ($globalDebug) echo "Add to DB...";
2575
+			if ($globalDebug) {
2576
+				echo "Add to DB...";
2577
+			}
2080 2578
 			$error = update_db::banned_fam();
2081
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2579
+		} else {
2580
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2581
+		}
2082 2582
 		if ($error != '') {
2083 2583
 			return $error;
2084
-		} elseif ($globalDebug) echo "Done\n";
2584
+		} elseif ($globalDebug) {
2585
+			echo "Done\n";
2586
+		}
2085 2587
 		return '';
2086 2588
 	}
2087 2589
 
@@ -2089,7 +2591,9 @@  discard block
 block discarded – undo
2089 2591
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2090 2592
 		include_once('class.create_db.php');
2091 2593
 		$error = '';
2092
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2594
+		if ($globalDebug) {
2595
+			echo "Airspace from FlightAirMap website : Download...";
2596
+		}
2093 2597
 		if ($globalDBdriver == 'mysql') {
2094 2598
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2095 2599
 		} else {
@@ -2105,9 +2609,13 @@  discard block
 block discarded – undo
2105 2609
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2106 2610
 				}
2107 2611
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2108
-					if ($globalDebug) echo "Gunzip...";
2612
+					if ($globalDebug) {
2613
+						echo "Gunzip...";
2614
+					}
2109 2615
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2110
-					if ($globalDebug) echo "Add to DB...";
2616
+					if ($globalDebug) {
2617
+						echo "Add to DB...";
2618
+					}
2111 2619
 					$Connection = new Connection();
2112 2620
 					if ($Connection->tableExists('airspace')) {
2113 2621
 						$query = 'DROP TABLE airspace';
@@ -2120,19 +2628,27 @@  discard block
 block discarded – undo
2120 2628
 		    			}
2121 2629
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2122 2630
 					update_db::insert_airspace_version($airspace_md5);
2123
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2631
+				} else {
2632
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2633
+				}
2124 2634
 			}
2125
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2635
+		} else {
2636
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2637
+		}
2126 2638
 		if ($error != '') {
2127 2639
 			return $error;
2128
-		} elseif ($globalDebug) echo "Done\n";
2640
+		} elseif ($globalDebug) {
2641
+			echo "Done\n";
2642
+		}
2129 2643
 		return '';
2130 2644
 	}
2131 2645
 
2132 2646
 	public static function update_geoid_fam() {
2133 2647
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2134 2648
 		$error = '';
2135
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2649
+		if ($globalDebug) {
2650
+			echo "Geoid from FlightAirMap website : Download...";
2651
+		}
2136 2652
 		update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2137 2653
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2138 2654
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2140,36 +2656,54 @@  discard block
 block discarded – undo
2140 2656
 			if (!update_db::check_geoid_version($geoid_md5)) {
2141 2657
 				update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2142 2658
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2143
-					if ($globalDebug) echo "Gunzip...";
2659
+					if ($globalDebug) {
2660
+						echo "Gunzip...";
2661
+					}
2144 2662
 					update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2145 2663
 					if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2146 2664
 						update_db::insert_geoid_version($geoid_md5);
2147 2665
 					}
2148
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2666
+				} else {
2667
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2668
+				}
2149 2669
 			}
2150
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
2670
+		} else {
2671
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
2672
+		}
2151 2673
 		if ($error != '') {
2152 2674
 			return $error;
2153
-		} elseif ($globalDebug) echo "Done\n";
2675
+		} elseif ($globalDebug) {
2676
+			echo "Done\n";
2677
+		}
2154 2678
 		return '';
2155 2679
 	}
2156 2680
 
2157 2681
 	public static function update_tle() {
2158 2682
 		global $tmp_dir, $globalDebug;
2159
-		if ($globalDebug) echo "Download TLE : Download...";
2683
+		if ($globalDebug) {
2684
+			echo "Download TLE : Download...";
2685
+		}
2160 2686
 		$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',
2161 2687
 		'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',
2162 2688
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2163 2689
 		foreach ($alltle as $filename) {
2164
-			if ($globalDebug) echo "downloading ".$filename.'...';
2690
+			if ($globalDebug) {
2691
+				echo "downloading ".$filename.'...';
2692
+			}
2165 2693
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2166 2694
 			if (file_exists($tmp_dir.$filename)) {
2167
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2695
+				if ($globalDebug) {
2696
+					echo "Add to DB ".$filename."...";
2697
+				}
2168 2698
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2169
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2699
+			} else {
2700
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2701
+			}
2170 2702
 			if ($error != '') {
2171 2703
 				echo $error."\n";
2172
-			} elseif ($globalDebug) echo "Done\n";
2704
+			} elseif ($globalDebug) {
2705
+				echo "Done\n";
2706
+			}
2173 2707
 		}
2174 2708
 		return '';
2175 2709
 	}
@@ -2177,10 +2711,14 @@  discard block
 block discarded – undo
2177 2711
 	public static function update_models() {
2178 2712
 		global $tmp_dir, $globalDebug;
2179 2713
 		$error = '';
2180
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2714
+		if ($globalDebug) {
2715
+			echo "Models from FlightAirMap website : Download...";
2716
+		}
2181 2717
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2182 2718
 		if (file_exists($tmp_dir.'models.md5sum')) {
2183
-			if ($globalDebug) echo "Check files...\n";
2719
+			if ($globalDebug) {
2720
+				echo "Check files...\n";
2721
+			}
2184 2722
 			$newmodelsdb = array();
2185 2723
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2186 2724
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2199,25 +2737,35 @@  discard block
 block discarded – undo
2199 2737
 			}
2200 2738
 			$diff = array_diff($newmodelsdb,$modelsdb);
2201 2739
 			foreach ($diff as $key => $value) {
2202
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2740
+				if ($globalDebug) {
2741
+					echo 'Downloading model '.$key.' ...'."\n";
2742
+				}
2203 2743
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2204 2744
 				
2205 2745
 			}
2206 2746
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2207
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2747
+		} else {
2748
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2749
+		}
2208 2750
 		if ($error != '') {
2209 2751
 			return $error;
2210
-		} elseif ($globalDebug) echo "Done\n";
2752
+		} elseif ($globalDebug) {
2753
+			echo "Done\n";
2754
+		}
2211 2755
 		return '';
2212 2756
 	}
2213 2757
 
2214 2758
 	public static function update_space_models() {
2215 2759
 		global $tmp_dir, $globalDebug;
2216 2760
 		$error = '';
2217
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2761
+		if ($globalDebug) {
2762
+			echo "Space models from FlightAirMap website : Download...";
2763
+		}
2218 2764
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2219 2765
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2220
-			if ($globalDebug) echo "Check files...\n";
2766
+			if ($globalDebug) {
2767
+				echo "Check files...\n";
2768
+			}
2221 2769
 			$newmodelsdb = array();
2222 2770
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2223 2771
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2236,25 +2784,35 @@  discard block
 block discarded – undo
2236 2784
 			}
2237 2785
 			$diff = array_diff($newmodelsdb,$modelsdb);
2238 2786
 			foreach ($diff as $key => $value) {
2239
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2787
+				if ($globalDebug) {
2788
+					echo 'Downloading space model '.$key.' ...'."\n";
2789
+				}
2240 2790
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2241 2791
 				
2242 2792
 			}
2243 2793
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2244
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2794
+		} else {
2795
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2796
+		}
2245 2797
 		if ($error != '') {
2246 2798
 			return $error;
2247
-		} elseif ($globalDebug) echo "Done\n";
2799
+		} elseif ($globalDebug) {
2800
+			echo "Done\n";
2801
+		}
2248 2802
 		return '';
2249 2803
 	}
2250 2804
 
2251 2805
 	public static function update_vehicules_models() {
2252 2806
 		global $tmp_dir, $globalDebug;
2253 2807
 		$error = '';
2254
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2808
+		if ($globalDebug) {
2809
+			echo "Vehicules models from FlightAirMap website : Download...";
2810
+		}
2255 2811
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2256 2812
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2257
-			if ($globalDebug) echo "Check files...\n";
2813
+			if ($globalDebug) {
2814
+				echo "Check files...\n";
2815
+			}
2258 2816
 			$newmodelsdb = array();
2259 2817
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2260 2818
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2273,15 +2831,21 @@  discard block
 block discarded – undo
2273 2831
 			}
2274 2832
 			$diff = array_diff($newmodelsdb,$modelsdb);
2275 2833
 			foreach ($diff as $key => $value) {
2276
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2834
+				if ($globalDebug) {
2835
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
2836
+				}
2277 2837
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2278 2838
 				
2279 2839
 			}
2280 2840
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2281
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2841
+		} else {
2842
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2843
+		}
2282 2844
 		if ($error != '') {
2283 2845
 			return $error;
2284
-		} elseif ($globalDebug) echo "Done\n";
2846
+		} elseif ($globalDebug) {
2847
+			echo "Done\n";
2848
+		}
2285 2849
 		return '';
2286 2850
 	}
2287 2851
 
@@ -2324,7 +2888,9 @@  discard block
 block discarded – undo
2324 2888
                 }
2325 2889
 
2326 2890
 		$error = '';
2327
-		if ($globalDebug) echo "Notam : Download...";
2891
+		if ($globalDebug) {
2892
+			echo "Notam : Download...";
2893
+		}
2328 2894
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2329 2895
 		if (file_exists($tmp_dir.'notam.rss')) {
2330 2896
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2339,14 +2905,30 @@  discard block
 block discarded – undo
2339 2905
 				$data['fir'] = $q[0];
2340 2906
 				$data['code'] = $q[1];
2341 2907
 				$ifrvfr = $q[2];
2342
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2343
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2344
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2345
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2346
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2347
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2348
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2349
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2908
+				if ($ifrvfr == 'IV') {
2909
+					$data['rules'] = 'IFR/VFR';
2910
+				}
2911
+				if ($ifrvfr == 'I') {
2912
+					$data['rules'] = 'IFR';
2913
+				}
2914
+				if ($ifrvfr == 'V') {
2915
+					$data['rules'] = 'VFR';
2916
+				}
2917
+				if ($q[4] == 'A') {
2918
+					$data['scope'] = 'Airport warning';
2919
+				}
2920
+				if ($q[4] == 'E') {
2921
+					$data['scope'] = 'Enroute warning';
2922
+				}
2923
+				if ($q[4] == 'W') {
2924
+					$data['scope'] = 'Navigation warning';
2925
+				}
2926
+				if ($q[4] == 'AE') {
2927
+					$data['scope'] = 'Airport/Enroute warning';
2928
+				}
2929
+				if ($q[4] == 'AW') {
2930
+					$data['scope'] = 'Airport/Navigation warning';
2931
+				}
2350 2932
 				//$data['scope'] = $q[4];
2351 2933
 				$data['lower_limit'] = $q[5];
2352 2934
 				$data['upper_limit'] = $q[6];
@@ -2354,8 +2936,12 @@  discard block
 block discarded – undo
2354 2936
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2355 2937
 				$latitude = $Common->convertDec($las,'latitude');
2356 2938
 				$longitude = $Common->convertDec($lns,'longitude');
2357
-				if ($lac == 'S') $latitude = '-'.$latitude;
2358
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2939
+				if ($lac == 'S') {
2940
+					$latitude = '-'.$latitude;
2941
+				}
2942
+				if ($lnc == 'W') {
2943
+					$longitude = '-'.$longitude;
2944
+				}
2359 2945
 				$data['center_latitude'] = $latitude;
2360 2946
 				$data['center_longitude'] = $longitude;
2361 2947
 				$data['radius'] = intval($radius);
@@ -2385,10 +2971,14 @@  discard block
 block discarded – undo
2385 2971
 				$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']);
2386 2972
 				unset($data);
2387 2973
 			} 
2388
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2974
+		} else {
2975
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2976
+		}
2389 2977
 		if ($error != '') {
2390 2978
 			return $error;
2391
-		} elseif ($globalDebug) echo "Done\n";
2979
+		} elseif ($globalDebug) {
2980
+			echo "Done\n";
2981
+		}
2392 2982
 		return '';
2393 2983
 	}
2394 2984
 	
@@ -2413,7 +3003,9 @@  discard block
 block discarded – undo
2413 3003
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2414 3004
 		$airspace_json = json_decode($airspace_lst,true);
2415 3005
 		foreach ($airspace_json['records'] as $airspace) {
2416
-			if ($globalDebug) echo $airspace['name']."...\n";
3006
+			if ($globalDebug) {
3007
+				echo $airspace['name']."...\n";
3008
+			}
2417 3009
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2418 3010
 			if (file_exists($tmp_dir.$airspace['name'])) {
2419 3011
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2457,8 +3049,11 @@  discard block
 block discarded – undo
2457 3049
                         return "error : ".$e->getMessage();
2458 3050
                 }
2459 3051
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2460
-                if ($row['nb'] > 0) return false;
2461
-                else return true;
3052
+                if ($row['nb'] > 0) {
3053
+                	return false;
3054
+                } else {
3055
+                	return true;
3056
+                }
2462 3057
 	}
2463 3058
 
2464 3059
 	public static function insert_last_update() {
@@ -2483,8 +3078,11 @@  discard block
 block discarded – undo
2483 3078
                         return "error : ".$e->getMessage();
2484 3079
                 }
2485 3080
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2486
-                if ($row['nb'] > 0) return true;
2487
-                else return false;
3081
+                if ($row['nb'] > 0) {
3082
+                	return true;
3083
+                } else {
3084
+                	return false;
3085
+                }
2488 3086
 	}
2489 3087
 
2490 3088
 	public static function check_geoid_version($version) {
@@ -2497,8 +3095,11 @@  discard block
 block discarded – undo
2497 3095
                         return "error : ".$e->getMessage();
2498 3096
                 }
2499 3097
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2500
-                if ($row['nb'] > 0) return true;
2501
-                else return false;
3098
+                if ($row['nb'] > 0) {
3099
+                	return true;
3100
+                } else {
3101
+                	return false;
3102
+                }
2502 3103
 	}
2503 3104
 
2504 3105
 	public static function check_marine_identity_version($version) {
@@ -2511,8 +3112,11 @@  discard block
 block discarded – undo
2511 3112
                         return "error : ".$e->getMessage();
2512 3113
                 }
2513 3114
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2514
-                if ($row['nb'] > 0) return true;
2515
-                else return false;
3115
+                if ($row['nb'] > 0) {
3116
+                	return true;
3117
+                } else {
3118
+                	return false;
3119
+                }
2516 3120
 	}
2517 3121
 
2518 3122
 
@@ -2567,8 +3171,11 @@  discard block
 block discarded – undo
2567 3171
                         return "error : ".$e->getMessage();
2568 3172
                 }
2569 3173
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2570
-                if ($row['nb'] > 0) return false;
2571
-                else return true;
3174
+                if ($row['nb'] > 0) {
3175
+                	return false;
3176
+                } else {
3177
+                	return true;
3178
+                }
2572 3179
 	}
2573 3180
 
2574 3181
 	public static function insert_last_notam_update() {
@@ -2598,8 +3205,11 @@  discard block
 block discarded – undo
2598 3205
                         return "error : ".$e->getMessage();
2599 3206
                 }
2600 3207
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2601
-                if ($row['nb'] > 0) return false;
2602
-                else return true;
3208
+                if ($row['nb'] > 0) {
3209
+                	return false;
3210
+                } else {
3211
+                	return true;
3212
+                }
2603 3213
 	}
2604 3214
 
2605 3215
 	public static function insert_last_airspace_update() {
@@ -2629,8 +3239,11 @@  discard block
 block discarded – undo
2629 3239
                         return "error : ".$e->getMessage();
2630 3240
                 }
2631 3241
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2632
-                if ($row['nb'] > 0) return false;
2633
-                else return true;
3242
+                if ($row['nb'] > 0) {
3243
+                	return false;
3244
+                } else {
3245
+                	return true;
3246
+                }
2634 3247
 	}
2635 3248
 
2636 3249
 	public static function insert_last_geoid_update() {
@@ -2660,8 +3273,11 @@  discard block
 block discarded – undo
2660 3273
                         return "error : ".$e->getMessage();
2661 3274
                 }
2662 3275
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2663
-                if ($row['nb'] > 0) return false;
2664
-                else return true;
3276
+                if ($row['nb'] > 0) {
3277
+                	return false;
3278
+                } else {
3279
+                	return true;
3280
+                }
2665 3281
 	}
2666 3282
 
2667 3283
 	public static function insert_last_owner_update() {
@@ -2690,8 +3306,11 @@  discard block
 block discarded – undo
2690 3306
                         return "error : ".$e->getMessage();
2691 3307
                 }
2692 3308
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2693
-                if ($row['nb'] > 0) return false;
2694
-                else return true;
3309
+                if ($row['nb'] > 0) {
3310
+                	return false;
3311
+                } else {
3312
+                	return true;
3313
+                }
2695 3314
 	}
2696 3315
 
2697 3316
 	public static function insert_last_schedules_update() {
@@ -2720,8 +3339,11 @@  discard block
 block discarded – undo
2720 3339
                         return "error : ".$e->getMessage();
2721 3340
                 }
2722 3341
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2723
-                if ($row['nb'] > 0) return false;
2724
-                else return true;
3342
+                if ($row['nb'] > 0) {
3343
+                	return false;
3344
+                } else {
3345
+                	return true;
3346
+                }
2725 3347
 	}
2726 3348
 
2727 3349
 	public static function insert_last_tle_update() {
@@ -2750,8 +3372,11 @@  discard block
 block discarded – undo
2750 3372
                         return "error : ".$e->getMessage();
2751 3373
                 }
2752 3374
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2753
-                if ($row['nb'] > 0) return false;
2754
-                else return true;
3375
+                if ($row['nb'] > 0) {
3376
+                	return false;
3377
+                } else {
3378
+                	return true;
3379
+                }
2755 3380
 	}
2756 3381
 
2757 3382
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.ACARS.php 2 patches
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	* @return String the icao
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25
-		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
25
+		if (substr($ident, 0, 2) == 'AF') {
26
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
28 28
 		} else {
29 29
 			$Spotter = new Spotter($this->db);
30
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
30
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
31 31
 			if (isset($identicao[0])) {
32
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
32
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
33 33
 			} else $icao = $ident;
34 34
 		}
35 35
 		return $icao;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 			$sth = $this->db->prepare($query);
55 55
 			$sth->execute();
56
-		} catch(PDOException $e) {
56
+		} catch (PDOException $e) {
57 57
 			return "error";
58 58
 		}
59 59
 		return "success";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute();
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error";
82 82
 		}
83 83
 		return "success";
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 		$ident = '';
103 103
 		$message = '';
104 104
 		$result = array();
105
-		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
105
+		$n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
106
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
107
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
108
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
109 109
 		if ($n != 0) {
110
-			$registration = str_replace('.','',$registration);
111
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
110
+			$registration = str_replace('.', '', $registration);
111
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
112 112
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113 113
 		} else $message = $data;
114 114
 		$decode = array();
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 				$temp = '';
129 129
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
130 130
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131
-					$latitude = $la / 10000.0;
132
-					$longitude = $ln / 10000.0;
131
+					$latitude = $la/10000.0;
132
+					$longitude = $ln/10000.0;
133 133
 					if ($lac == 'S') $latitude = '-'.$latitude;
134 134
 					if ($lnc == 'W') $longitude = '-'.$longitude;
135 135
 					// Temp not always available
136 136
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
137
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
138
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
139 139
 
140 140
 					//$icao = $Translation->checkTranslation($ident);
141 141
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -147,19 +147,19 @@  discard block
 block discarded – undo
147 147
 				$dhour = '';
148 148
 				$darr = '';
149 149
 				$ahour = '';
150
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
150
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
151 151
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
152
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
153
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
154
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
155 155
 					//$icao = ACARS->ident2icao($ident);
156 156
 					//$icao = $Translation->checkTranslation($ident);
157 157
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 158
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 159
 					$found = true;
160 160
 				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
161
+				elseif ($n == 2 || $n == 4) {
162
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
163 163
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
164 164
 					//$icao = ACARS->ident2icao($ident);
165 165
 					//$icao = $Translation->checkTranslation($ident);
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 				$ahour = '';
218 218
 				$aair = '';
219 219
 				$apiste = '';
220
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
220
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
221 221
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
222
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
224
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
225 225
 					$icao = trim($aident);
226 226
 
227 227
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
247 247
 					$las = $las.'.'.$lass;
248 248
 					$lns = $lns.'.'.$lns;
249
-					$latitude = $las / 1000.0;
250
-					$longitude = $lns / 1000.0;
249
+					$latitude = $las/1000.0;
250
+					$longitude = $lns/1000.0;
251 251
 					if ($lac == 'S') $latitude = '-'.$latitude;
252 252
 					if ($lnc == 'W') $longitude = '-'.$longitude;
253 253
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -342,17 +342,17 @@  discard block
 block discarded – undo
342 342
 				$alt = '';
343 343
 				$fuel = '';
344 344
 				$speed = '';
345
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
345
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
346 346
 				if ($n == 9) {
347 347
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
348 348
 					$icao = trim($aident);
349 349
 					$decode['icao'] = $icao;
350
-					$latitude = $las / 100.0;
351
-					$longitude = $lns / 100.0;
350
+					$latitude = $las/100.0;
351
+					$longitude = $lns/100.0;
352 352
 					if ($lac == 'S') $latitude = '-'.$latitude;
353 353
 					if ($lnc == 'W') $longitude = '-'.$longitude;
354 354
 
355
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
355
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
356 356
 					$found = true;
357 357
 				}
358 358
 			}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 					if ($lac == 'S') $latitude = '-'.$latitude;
372 372
 					if ($lnc == 'W') $longitude = '-'.$longitude;
373 373
 
374
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
374
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
375 375
 					$found = true;
376 376
 				}
377 377
 			}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				$dair = '';
405 405
 				$darr = '';
406 406
 				$aident = '';
407
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
407
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 408
 				if ($n == 8) {
409 409
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
410 410
 					$icao = trim($aident);
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 				*/
437 437
 				$dair = '';
438 438
 				$darr = '';
439
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
439
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
440 440
 				if ($n == 3) {
441 441
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
442 442
 					//$icao = $Translation->checkTranslation($ident);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 				*/
452 452
 				$dair = '';
453 453
 				$darr = '';
454
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
454
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
455 455
 				if ($n == 3) {
456 456
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457 457
 					//$icao = $Translation->checkTranslation($ident);
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 				}
462 462
 			}
463 463
 			if (!$found) {
464
-				$n = sscanf($message,'MET01%4c',$airport);
464
+				$n = sscanf($message, 'MET01%4c', $airport);
465 465
 				if ($n == 1) {
466 466
 					if ($globalDebug) echo 'airport name : '.$airport;
467 467
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -469,241 +469,241 @@  discard block
 block discarded – undo
469 469
 				}
470 470
 			}
471 471
 			if ($label == 'H1') {
472
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
473
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
472
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
473
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
474 474
 				}
475
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
476
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
475
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
476
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
477 477
 				}
478
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
479
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
478
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
479
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
480 480
 				}
481
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
482
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
481
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
482
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
483 483
 				}
484
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
485
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
484
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
485
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
486 486
 				}
487
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
488
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
487
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
488
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
489 489
 				}
490
-				elseif (preg_match(':^#M1AAEP:',$message)) {
491
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
490
+				elseif (preg_match(':^#M1AAEP:', $message)) {
491
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
492 492
 				}
493
-				elseif (preg_match(':^#M2APWD:',$message)) {
494
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
493
+				elseif (preg_match(':^#M2APWD:', $message)) {
494
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
495 495
 				}
496
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
497
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
496
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
497
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
498 498
 				}
499
-				elseif (preg_match(':^#CF:',$message)) {
500
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
499
+				elseif (preg_match(':^#CF:', $message)) {
500
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
501 501
 				}
502
-				elseif (preg_match(':^#DF:',$message)) {
503
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
502
+				elseif (preg_match(':^#DF:', $message)) {
503
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
504 504
 				}
505
-				elseif (preg_match(':^#EC:',$message)) {
506
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
505
+				elseif (preg_match(':^#EC:', $message)) {
506
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
507 507
 				}
508
-				elseif (preg_match(':^#EI:',$message)) {
509
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
508
+				elseif (preg_match(':^#EI:', $message)) {
509
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
510 510
 				}
511
-				elseif (preg_match(':^#H1:',$message)) {
512
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
511
+				elseif (preg_match(':^#H1:', $message)) {
512
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
513 513
 				}
514
-				elseif (preg_match(':^#H2:',$message)) {
515
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
514
+				elseif (preg_match(':^#H2:', $message)) {
515
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
516 516
 				}
517
-				elseif (preg_match(':^#HD:',$message)) {
518
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
517
+				elseif (preg_match(':^#HD:', $message)) {
518
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
519 519
 				}
520
-				elseif (preg_match(':^#M1:',$message)) {
521
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
520
+				elseif (preg_match(':^#M1:', $message)) {
521
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
522 522
 				}
523
-				elseif (preg_match(':^#M2:',$message)) {
524
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
523
+				elseif (preg_match(':^#M2:', $message)) {
524
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
525 525
 				}
526
-				elseif (preg_match(':^#M3:',$message)) {
527
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
526
+				elseif (preg_match(':^#M3:', $message)) {
527
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
528 528
 				}
529
-				elseif (preg_match(':^#MD:',$message)) {
530
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
529
+				elseif (preg_match(':^#MD:', $message)) {
530
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
531 531
 				}
532
-				elseif (preg_match(':^#PS:',$message)) {
533
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
532
+				elseif (preg_match(':^#PS:', $message)) {
533
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
534 534
 				}
535
-				elseif (preg_match(':^#S1:',$message)) {
536
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
535
+				elseif (preg_match(':^#S1:', $message)) {
536
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
537 537
 				}
538
-				elseif (preg_match(':^#S2:',$message)) {
539
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
538
+				elseif (preg_match(':^#S2:', $message)) {
539
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
540 540
 				}
541
-				elseif (preg_match(':^#SD:',$message)) {
542
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
541
+				elseif (preg_match(':^#SD:', $message)) {
542
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
543 543
 				}
544
-				elseif (preg_match(':^#T[0-8]:',$message)) {
545
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
544
+				elseif (preg_match(':^#T[0-8]:', $message)) {
545
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
546 546
 				}
547
-				elseif (preg_match(':^#WO:',$message)) {
548
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
547
+				elseif (preg_match(':^#WO:', $message)) {
548
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
549 549
 				}
550
-				elseif (preg_match(':^#A1:',$message)) {
551
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
550
+				elseif (preg_match(':^#A1:', $message)) {
551
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
552 552
 				}
553
-				elseif (preg_match(':^#A3:',$message)) {
554
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
553
+				elseif (preg_match(':^#A3:', $message)) {
554
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
555 555
 				}
556
-				elseif (preg_match(':^#A4:',$message)) {
557
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
556
+				elseif (preg_match(':^#A4:', $message)) {
557
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
558 558
 				}
559
-				elseif (preg_match(':^#A6:',$message)) {
560
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
559
+				elseif (preg_match(':^#A6:', $message)) {
560
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
561 561
 				}
562
-				elseif (preg_match(':^#A8:',$message)) {
563
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
562
+				elseif (preg_match(':^#A8:', $message)) {
563
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
564 564
 				}
565
-				elseif (preg_match(':^#A9:',$message)) {
566
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
565
+				elseif (preg_match(':^#A9:', $message)) {
566
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
567 567
 				}
568
-				elseif (preg_match(':^#A0:',$message)) {
569
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
568
+				elseif (preg_match(':^#A0:', $message)) {
569
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
570 570
 				}
571
-				elseif (preg_match(':^#AA:',$message)) {
572
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
571
+				elseif (preg_match(':^#AA:', $message)) {
572
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
573 573
 				}
574
-				elseif (preg_match(':^#AB:',$message)) {
575
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
574
+				elseif (preg_match(':^#AB:', $message)) {
575
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
576 576
 				}
577
-				elseif (preg_match(':^#AC:',$message)) {
578
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
577
+				elseif (preg_match(':^#AC:', $message)) {
578
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
579 579
 				}
580
-				elseif (preg_match(':^#AD:',$message)) {
581
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
580
+				elseif (preg_match(':^#AD:', $message)) {
581
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
582 582
 				}
583
-				elseif (preg_match(':^#AF:',$message)) {
584
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
583
+				elseif (preg_match(':^#AF:', $message)) {
584
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
585 585
 				}
586
-				elseif (preg_match(':^#B1:',$message)) {
587
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
586
+				elseif (preg_match(':^#B1:', $message)) {
587
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
588 588
 				}
589
-				elseif (preg_match(':^#B2:',$message)) {
590
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
589
+				elseif (preg_match(':^#B2:', $message)) {
590
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
591 591
 				}
592
-				elseif (preg_match(':^#B3:',$message)) {
593
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
592
+				elseif (preg_match(':^#B3:', $message)) {
593
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
594 594
 				}
595
-				elseif (preg_match(':^#B4:',$message)) {
596
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
595
+				elseif (preg_match(':^#B4:', $message)) {
596
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
597 597
 				}
598
-				elseif (preg_match(':^#B6:',$message)) {
599
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
598
+				elseif (preg_match(':^#B6:', $message)) {
599
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
600 600
 				}
601
-				elseif (preg_match(':^#B8:',$message)) {
602
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
601
+				elseif (preg_match(':^#B8:', $message)) {
602
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
603 603
 				}
604
-				elseif (preg_match(':^#B9:',$message)) {
605
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
604
+				elseif (preg_match(':^#B9:', $message)) {
605
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
606 606
 				}
607
-				elseif (preg_match(':^#B0:',$message)) {
608
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
607
+				elseif (preg_match(':^#B0:', $message)) {
608
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
609 609
 				}
610
-				elseif (preg_match(':^#BA:',$message)) {
611
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
610
+				elseif (preg_match(':^#BA:', $message)) {
611
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
612 612
 				}
613
-				elseif (preg_match(':^#BB:',$message)) {
614
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
613
+				elseif (preg_match(':^#BB:', $message)) {
614
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
615 615
 				}
616
-				elseif (preg_match(':^#BC:',$message)) {
617
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
616
+				elseif (preg_match(':^#BC:', $message)) {
617
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
618 618
 				}
619
-				elseif (preg_match(':^#BD:',$message)) {
620
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
619
+				elseif (preg_match(':^#BD:', $message)) {
620
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
621 621
 				}
622
-				elseif (preg_match(':^#BE:',$message)) {
623
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
622
+				elseif (preg_match(':^#BE:', $message)) {
623
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
624 624
 				}
625
-				elseif (preg_match(':^#BF:',$message)) {
626
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
625
+				elseif (preg_match(':^#BF:', $message)) {
626
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
627 627
 				}
628
-				elseif (preg_match(':^#H3:',$message)) {
629
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
628
+				elseif (preg_match(':^#H3:', $message)) {
629
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
630 630
 				}
631 631
 			}
632 632
 			if ($label == '10') {
633
-				if (preg_match(':^DTO01:',$message)) {
634
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
633
+				if (preg_match(':^DTO01:', $message)) {
634
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
635 635
 				}
636
-				elseif (preg_match(':^AIS01:',$message)) {
637
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
636
+				elseif (preg_match(':^AIS01:', $message)) {
637
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
638 638
 				}
639
-				elseif (preg_match(':^FTX01:',$message)) {
640
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
639
+				elseif (preg_match(':^FTX01:', $message)) {
640
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
641 641
 				}
642
-				elseif (preg_match(':^FPL01:',$message)) {
643
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
642
+				elseif (preg_match(':^FPL01:', $message)) {
643
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
644 644
 				}
645
-				elseif (preg_match(':^WAB01:',$message)) {
646
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
645
+				elseif (preg_match(':^WAB01:', $message)) {
646
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
647 647
 				}
648
-				elseif (preg_match(':^MET01:',$message)) {
649
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
648
+				elseif (preg_match(':^MET01:', $message)) {
649
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
650 650
 				}
651
-				elseif (preg_match(':^WAB02:',$message)) {
652
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
651
+				elseif (preg_match(':^WAB02:', $message)) {
652
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
653 653
 				}
654 654
 			}
655 655
 			if ($label == '15') {
656
-				if (preg_match(':^FST01:',$message)) {
657
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
656
+				if (preg_match(':^FST01:', $message)) {
657
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
658 658
 				}
659 659
 			}
660 660
 			if (!$found && $label == 'SA') {
661
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
661
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
662 662
 				if ($n == 4) {
663 663
 					$vsta = array('Version' => $version);
664 664
 					if ($state == 'E') {
665
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
665
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
666 666
 					}
667 667
 					elseif ($state == 'L') {
668
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
668
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
669 669
 					}
670 670
 					else {
671
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
671
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
672 672
 					}
673 673
 					if ($type == 'V') {
674
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
674
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
675 675
 					}
676 676
 					elseif ($type == 'S') {
677
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
677
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
678 678
 					}
679 679
 					elseif ($type == 'H') {
680
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
680
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
681 681
 					}
682 682
 					elseif ($type == 'G') {
683
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
683
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
684 684
 					}
685 685
 					elseif ($type == 'C') {
686
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
686
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
687 687
 					}
688 688
 					elseif ($type == '2') {
689
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
689
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
690 690
 					}
691 691
 					elseif ($type == 'X') {
692
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
692
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
693 693
 					}
694 694
 					elseif ($type == 'I') {
695
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
695
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
696 696
 					}
697 697
 					else {
698
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
698
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
699 699
 					}
700
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
701
-					$decode = array_merge($vsta,$decode);
700
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
701
+					$decode = array_merge($vsta, $decode);
702 702
 				}
703 703
 			}
704 704
 
705 705
 			$title = $this->getTitlefromLabel($label);
706
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
706
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
707 707
 			/*
708 708
 			// Business jets always use GS0001
709 709
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -731,13 +731,13 @@  discard block
 block discarded – undo
731 731
 		$Translation = new Translation($this->db);
732 732
 		$message = $this->parse($data);
733 733
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
734
-			$ident = (string)$message['ident'];
734
+			$ident = (string) $message['ident'];
735 735
 			$label = $message['label'];
736 736
 			$block_id = $message['block_id'];
737 737
 			$msg_no = $message['msg_no'];
738 738
 			$msg = $message['message'];
739 739
 			$decode = $message['decode'];
740
-			$registration = (string)$message['registration'];
740
+			$registration = (string) $message['registration'];
741 741
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
742 742
 			else $latitude = '';
743 743
 			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
@@ -751,20 +751,20 @@  discard block
 block discarded – undo
751 751
 				$Image->addSpotterImage($registration);
752 752
 			}
753 753
 			// Business jets always use GS0001
754
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
754
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
755 755
 			if ($globalDebug && isset($info) && $info != '') echo $info;
756 756
 			if (count($decode) > 0) $decode_json = json_encode($decode);
757 757
 			else $decode_json = '';
758 758
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
759
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
759
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
760 760
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
761
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
761
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
762 762
 			}
763
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
764
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
765
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
763
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
764
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
765
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
766 766
 			if ($globalDebug && count($decode) > 0) {
767
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
767
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
768 768
 			}
769 769
 		}
770 770
 	}
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	* @param String $msg_no Number of the ACARS message
780 780
 	* @param String $message ACARS message
781 781
 	*/
782
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
782
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
783 783
 		global $globalDebug;
784 784
 		date_default_timezone_set('UTC');
785 785
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -787,21 +787,21 @@  discard block
 block discarded – undo
787 787
 			$this->db = $Connection->db;
788 788
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
789 789
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
790
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
790
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
791 791
 			try {
792 792
 				$stht = $this->db->prepare($query_test);
793 793
 				$stht->execute($query_test_values);
794
-			} catch(PDOException $e) {
794
+			} catch (PDOException $e) {
795 795
 				return "error : ".$e->getMessage();
796 796
 			}
797 797
 			if ($stht->fetchColumn() == 0) {
798 798
 				if ($globalDebug) echo "Add Live ACARS data...";
799 799
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
800
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
800
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
801 801
 				try {
802 802
 					$sth = $this->db->prepare($query);
803 803
 					$sth->execute($query_values);
804
-				} catch(PDOException $e) {
804
+				} catch (PDOException $e) {
805 805
 					return "error : ".$e->getMessage();
806 806
 				}
807 807
 			} else {
@@ -823,10 +823,10 @@  discard block
 block discarded – undo
823 823
 	* @param String $msg_no Number of the ACARS message
824 824
 	* @param String $message ACARS message
825 825
 	*/
826
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
826
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
827 827
 		global $globalDebug;
828 828
 		date_default_timezone_set('UTC');
829
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
829
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
830 830
 			/*
831 831
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
832 832
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -841,11 +841,11 @@  discard block
 block discarded – undo
841 841
 			*/
842 842
 			if ($globalDebug) echo "Add Live ACARS data...";
843 843
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
844
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
844
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
845 845
 			try {
846 846
 				$sth = $this->db->prepare($query);
847 847
 				$sth->execute($query_values);
848
-			} catch(PDOException $e) {
848
+			} catch (PDOException $e) {
849 849
 				return "error : ".$e->getMessage();
850 850
 			}
851 851
 			if ($globalDebug) echo "Done\n";
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 		try {
867 867
 			$sth = $this->db->prepare($query);
868 868
 			$sth->execute($query_values);
869
-		} catch(PDOException $e) {
869
+		} catch (PDOException $e) {
870 870
 			echo "error : ".$e->getMessage();
871 871
 			return '';
872 872
 		}
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 		try {
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_values);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			echo "error : ".$e->getMessage();
891 891
 			return array();
892 892
 		}
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 		try {
908 908
 			$sth = $this->db->prepare($query);
909 909
 			$sth->execute($query_values);
910
-		} catch(PDOException $e) {
910
+		} catch (PDOException $e) {
911 911
 			echo "error : ".$e->getMessage();
912 912
 			return array();
913 913
 		}
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	*
922 922
 	* @return Array Return ACARS data in array
923 923
 	*/
924
-	public function getLatestAcarsData($limit = '',$label = '') {
924
+	public function getLatestAcarsData($limit = '', $label = '') {
925 925
 		global $globalURL, $globalDBdriver;
926 926
 		$Image = new Image($this->db);
927 927
 		$Spotter = new Spotter($this->db);
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 		if ($limit != "")
933 933
 		{
934 934
 			$limit_array = explode(",", $limit);
935
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
936
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
935
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
936
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
937 937
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
938 938
 			{
939 939
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -949,46 +949,46 @@  discard block
 block discarded – undo
949 949
 		try {
950 950
 			$sth = $this->db->prepare($query);
951 951
 			$sth->execute($query_values);
952
-		} catch(PDOException $e) {
952
+		} catch (PDOException $e) {
953 953
 			return "error : ".$e->getMessage();
954 954
 		}
955 955
 		$i = 0;
956 956
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
957 957
 			$data = array();
958 958
 			if ($row['registration'] != '') {
959
-				$row['registration'] = str_replace('.','',$row['registration']);
959
+				$row['registration'] = str_replace('.', '', $row['registration']);
960 960
 				$image_array = $Image->getSpotterImage($row['registration']);
961
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
962
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
963
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
961
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
962
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
963
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
964 964
 			if ($row['registration'] == '') $row['registration'] = 'NA';
965 965
 			if ($row['ident'] == '') $row['ident'] = 'NA';
966
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
966
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
967 967
 			if (isset($identicao[0])) {
968
-				if (substr($row['ident'],0,2) == 'AF') {
969
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
970
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
971
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
972
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
968
+				if (substr($row['ident'], 0, 2) == 'AF') {
969
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
970
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
971
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
972
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
973 973
 			} else $icao = $row['ident'];
974
-			$icao = $Translation->checkTranslation($icao,false);
975
-			$decode = json_decode($row['decode'],true);
974
+			$icao = $Translation->checkTranslation($icao, false);
975
+			$decode = json_decode($row['decode'], true);
976 976
 			$found = false;
977
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
977
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
978 978
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
979 979
 				if (isset($airport_info[0]['icao'])) {
980 980
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
981 981
 					$found = true;
982 982
 				}
983 983
 			}
984
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
984
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
985 985
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
986 986
 				if (isset($airport_info[0]['icao'])) {
987 987
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
988 988
 					$found = true;
989 989
 				}
990 990
 			}
991
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
991
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
992 992
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
993 993
 				if (isset($airport_info[0]['icao'])) {
994 994
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 				}
997 997
 			}
998 998
 			if ($found) $row['decode'] = json_encode($decode);
999
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
999
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1000 1000
 			$result[] = $data;
1001 1001
 			$i++;
1002 1002
 		}
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 	*
1013 1013
 	* @return Array Return ACARS data in array
1014 1014
 	*/
1015
-	public function getArchiveAcarsData($limit = '',$label = '') {
1015
+	public function getArchiveAcarsData($limit = '', $label = '') {
1016 1016
 		global $globalURL, $globalDBdriver;
1017 1017
 		$Image = new Image($this->db);
1018 1018
 		$Spotter = new Spotter($this->db);
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 		if ($limit != "")
1023 1023
 		{
1024 1024
 			$limit_array = explode(",", $limit);
1025
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1026
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1025
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1026
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1027 1027
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1028 1028
 			{
1029 1029
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1044,43 +1044,43 @@  discard block
 block discarded – undo
1044 1044
 		try {
1045 1045
 			$sth = $this->db->prepare($query);
1046 1046
 			$sth->execute($query_values);
1047
-		} catch(PDOException $e) {
1047
+		} catch (PDOException $e) {
1048 1048
 			return "error : ".$e->getMessage();
1049 1049
 		}
1050
-		$i=0;
1050
+		$i = 0;
1051 1051
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1052 1052
 			$data = array();
1053 1053
 			if ($row['registration'] != '') {
1054
-				$row['registration'] = str_replace('.','',$row['registration']);
1054
+				$row['registration'] = str_replace('.', '', $row['registration']);
1055 1055
 				$image_array = $Image->getSpotterImage($row['registration']);
1056
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1057
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1058
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1056
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1057
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1058
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1059 1059
 			$icao = '';
1060 1060
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1061 1061
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1062
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1062
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1063 1063
 			if (isset($identicao[0])) {
1064
-				if (substr($row['ident'],0,2) == 'AF') {
1065
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1066
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1067
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1068
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1064
+				if (substr($row['ident'], 0, 2) == 'AF') {
1065
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1066
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1067
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1068
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1069 1069
 			} else $icao = $row['ident'];
1070 1070
 			$icao = $Translation->checkTranslation($icao);
1071
-			$decode = json_decode($row['decode'],true);
1071
+			$decode = json_decode($row['decode'], true);
1072 1072
 			$found = false;
1073
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1073
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1074 1074
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1075 1075
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1076 1076
 				$found = true;
1077 1077
 			}
1078
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1078
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1079 1079
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1080 1080
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1081 1081
 				$found = true;
1082 1082
 			}
1083
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1083
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1084 1084
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1085 1085
 				if (isset($airport_info[0]['icao'])) {
1086 1086
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 				}
1089 1089
 			}
1090 1090
 			if ($found) $row['decode'] = json_encode($decode);
1091
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1091
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1092 1092
 			$result[] = $data;
1093 1093
 			$i++;
1094 1094
 		}
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 	* @param String $icao
1107 1107
 	* @param String $ICAOTypeCode
1108 1108
 	*/
1109
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1109
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1110 1110
 		global $globalDebug, $globalDBdriver;
1111 1111
 		$ident = trim($ident);
1112 1112
 		$Translation = new Translation($this->db);
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 			if ($globalDebug) echo "Ident or registration null, exit\n";
1120 1120
 			return '';
1121 1121
 		}
1122
-		$registration = str_replace('.','',$registration);
1122
+		$registration = str_replace('.', '', $registration);
1123 1123
 		$ident = $Translation->ident2icao($ident);
1124 1124
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1125 1125
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 		try {
1129 1129
 			$sthsi = $this->db->prepare($querysi);
1130 1130
 			$sthsi->execute($querysi_values);
1131
-		} catch(PDOException $e) {
1131
+		} catch (PDOException $e) {
1132 1132
 			if ($globalDebug) echo $e->getMessage();
1133 1133
 			return "error : ".$e->getMessage();
1134 1134
 		}
@@ -1138,8 +1138,8 @@  discard block
 block discarded – undo
1138 1138
 			$Translation = new Translation($this->db);
1139 1139
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1140 1140
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1141
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1142
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1141
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1142
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1143 1143
 		} else {
1144 1144
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1145 1145
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 				try {
1148 1148
 					$sth = $this->db->prepare($query);
1149 1149
 					$sth->execute($query_values);
1150
-				} catch(PDOException $e) {
1150
+				} catch (PDOException $e) {
1151 1151
 					if ($globalDebug) echo $e->getMessage();
1152 1152
 					return "error : ".$e->getMessage();
1153 1153
 				}
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 				$sth->closeCursor();
1156 1156
 				if (isset($result['modes'])) $hex = $result['modes'];
1157 1157
 				else $hex = '';
1158
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1158
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1159 1159
 				$this->SI->add($SI_data);
1160 1160
 			}
1161 1161
 		}
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 		try {
1166 1166
 			$sth = $this->db->prepare($query);
1167 1167
 			$sth->execute($query_values);
1168
-		} catch(PDOException $e) {
1168
+		} catch (PDOException $e) {
1169 1169
 			if ($globalDebug) echo $e->getMessage();
1170 1170
 			return "error : ".$e->getMessage();
1171 1171
 		}
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1176 1176
 			else $ModeS = '';
1177 1177
 			if ($ModeS == '') {
1178
-				$id = explode('-',$result['flightaware_id']);
1178
+				$id = explode('-', $result['flightaware_id']);
1179 1179
 				$ModeS = $id[0];
1180 1180
 			}
1181 1181
 			if ($ModeS != '') {
@@ -1185,20 +1185,20 @@  discard block
 block discarded – undo
1185 1185
 				try {
1186 1186
 					$sthc = $this->db->prepare($queryc);
1187 1187
 					$sthc->execute($queryc_values);
1188
-				} catch(PDOException $e) {
1188
+				} catch (PDOException $e) {
1189 1189
 					if ($globalDebug) echo $e->getMessage();
1190 1190
 					return "error : ".$e->getMessage();
1191 1191
 				}
1192 1192
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1193 1193
 				$sthc->closeCursor();
1194
-				if (count($row) ==  0) {
1194
+				if (count($row) == 0) {
1195 1195
 					if ($globalDebug) echo " Add to ModeS table - ";
1196 1196
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1197
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1197
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1198 1198
 					try {
1199 1199
 						$sthi = $this->db->prepare($queryi);
1200 1200
 						$sthi->execute($queryi_values);
1201
-					} catch(PDOException $e) {
1201
+					} catch (PDOException $e) {
1202 1202
 						if ($globalDebug) echo $e->getMessage();
1203 1203
 						return "error : ".$e->getMessage();
1204 1204
 					}
@@ -1206,15 +1206,15 @@  discard block
 block discarded – undo
1206 1206
 					if ($globalDebug) echo " Update ModeS table - ";
1207 1207
 					if ($ICAOTypeCode != '') {
1208 1208
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1209
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1209
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1210 1210
 					} else {
1211 1211
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1212
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1212
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1213 1213
 					}
1214 1214
 					try {
1215 1215
 						$sthi = $this->db->prepare($queryi);
1216 1216
 						$sthi->execute($queryi_values);
1217
-					} catch(PDOException $e) {
1217
+					} catch (PDOException $e) {
1218 1218
 						if ($globalDebug) echo $e->getMessage();
1219 1219
 						return "error : ".$e->getMessage();
1220 1220
 					}
@@ -1251,12 +1251,12 @@  discard block
 block discarded – undo
1251 1251
 					elseif ($globalDBdriver == 'pgsql') {
1252 1252
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1253 1253
 					}
1254
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1254
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1255 1255
 				}
1256 1256
 				try {
1257 1257
 					$sthi = $this->db->prepare($queryi);
1258 1258
 					$sthi->execute($queryi_values);
1259
-				} catch(PDOException $e) {
1259
+				} catch (PDOException $e) {
1260 1260
 					if ($globalDebug) echo $e->getMessage();
1261 1261
 					return "error : ".$e->getMessage();
1262 1262
 				}
Please login to merge, or discard this patch.
Braces   +409 added lines, -261 removed lines patch added patch discarded remove patch
@@ -23,14 +23,19 @@  discard block
 block discarded – undo
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
26
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
27
+				$icao = $ident;
28
+			} else {
29
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
30
+			}
28 31
 		} else {
29 32
 			$Spotter = new Spotter($this->db);
30 33
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
31 34
 			if (isset($identicao[0])) {
32 35
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
33
-			} else $icao = $ident;
36
+			} else {
37
+				$icao = $ident;
38
+			}
34 39
 		}
35 40
 		return $icao;
36 41
 	}
@@ -103,14 +108,24 @@  discard block
 block discarded – undo
103 108
 		$message = '';
104 109
 		$result = array();
105 110
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
111
+		if ($n == 0) {
112
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
113
+		}
114
+		if ($n == 0) {
115
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
116
+		}
117
+		if ($n == 0) {
118
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
119
+		}
109 120
 		if ($n != 0) {
110 121
 			$registration = str_replace('.','',$registration);
111 122
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
112
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113
-		} else $message = $data;
123
+			if ($globalDebug) {
124
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
125
+			}
126
+		} else {
127
+			$message = $data;
128
+		}
114 129
 		$decode = array();
115 130
 		$found = false;
116 131
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -130,12 +145,21 @@  discard block
 block discarded – undo
130 145
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131 146
 					$latitude = $la / 10000.0;
132 147
 					$longitude = $ln / 10000.0;
133
-					if ($lac == 'S') $latitude = '-'.$latitude;
134
-					if ($lnc == 'W') $longitude = '-'.$longitude;
148
+					if ($lac == 'S') {
149
+						$latitude = '-'.$latitude;
150
+					}
151
+					if ($lnc == 'W') {
152
+						$longitude = '-'.$longitude;
153
+					}
135 154
 					// Temp not always available
136
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
155
+					if ($globalDebug) {
156
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
157
+					}
158
+					if ($temp == '') {
159
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
160
+					} else {
161
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
162
+					}
139 163
 
140 164
 					//$icao = $Translation->checkTranslation($ident);
141 165
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -149,25 +173,35 @@  discard block
 block discarded – undo
149 173
 				$ahour = '';
150 174
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
151 175
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
176
+					if ($dhour != '') {
177
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+					}
179
+					if ($ahour != '') {
180
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
181
+					}
182
+					if ($globalDebug) {
183
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
184
+					}
155 185
 					//$icao = ACARS->ident2icao($ident);
156 186
 					//$icao = $Translation->checkTranslation($ident);
157 187
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 188
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 189
 					$found = true;
160
-				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
163
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
190
+				} elseif ($n == 2 || $n  == 4) {
191
+					if ($dhour != '') {
192
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
193
+					}
194
+					if ($globalDebug) {
195
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
196
+					}
164 197
 					//$icao = ACARS->ident2icao($ident);
165 198
 					//$icao = $Translation->checkTranslation($ident);
166 199
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
167 200
 					$found = true;
168
-				}
169
-				elseif ($n == 1) {
170
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
201
+				} elseif ($n == 1) {
202
+					if ($globalDebug) {
203
+						echo 'airport arrival : '.$darr."\n";
204
+					}
171 205
 					//$icao = ACARS->ident2icao($ident);
172 206
 					//$icao = $Translation->checkTranslation($ident);
173 207
 					$decode = array('Arrival airport' => $darr);
@@ -185,7 +219,9 @@  discard block
 block discarded – undo
185 219
 				$darr = '';
186 220
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
187 221
 				if ($n == 4) {
188
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
222
+					if ($globalDebug) {
223
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
224
+					}
189 225
 					//$icao = ACARS->ident2icao($ident);
190 226
 					//$icao = $Translation->checkTranslation($ident);
191 227
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -219,14 +255,23 @@  discard block
 block discarded – undo
219 255
 				$apiste = '';
220 256
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
221 257
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
258
+					if ($globalDebug) {
259
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
260
+					}
261
+					if ($dhour != '') {
262
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
263
+					}
264
+					if ($ahour != '') {
265
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
266
+					}
225 267
 					$icao = trim($aident);
226 268
 
227 269
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
228
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
229
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
270
+					if ($ahour == '') {
271
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
272
+					} else {
273
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
274
+					}
230 275
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
231 276
 					$decode['icao'] = $icao;
232 277
 					$found = true;
@@ -248,9 +293,15 @@  discard block
 block discarded – undo
248 293
 					$lns = $lns.'.'.$lns;
249 294
 					$latitude = $las / 1000.0;
250 295
 					$longitude = $lns / 1000.0;
251
-					if ($lac == 'S') $latitude = '-'.$latitude;
252
-					if ($lnc == 'W') $longitude = '-'.$longitude;
253
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
296
+					if ($lac == 'S') {
297
+						$latitude = '-'.$latitude;
298
+					}
299
+					if ($lnc == 'W') {
300
+						$longitude = '-'.$longitude;
301
+					}
302
+					if ($globalDebug) {
303
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
304
+					}
254 305
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
255 306
 					$found = true;
256 307
 				}
@@ -268,7 +319,9 @@  discard block
 block discarded – undo
268 319
 				$darr = '';
269 320
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
270 321
 				if ($n == 4) {
271
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
322
+					if ($globalDebug) {
323
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
324
+					}
272 325
 					//$icao = $Translation->checkTranslation($ident);
273 326
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
274 327
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -281,7 +334,9 @@  discard block
 block discarded – undo
281 334
 				$darr = '';
282 335
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
283 336
 				if ($n == 4) {
284
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
337
+					if ($globalDebug) {
338
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
339
+					}
285 340
 					//$icao = $Translation->checkTranslation($ident);
286 341
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
287 342
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -294,7 +349,9 @@  discard block
 block discarded – undo
294 349
 				$darr = '';
295 350
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
296 351
 				if ($n == 2) {
297
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
352
+					if ($globalDebug) {
353
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
354
+					}
298 355
 					//$icao = $Translation->checkTranslation($ident);
299 356
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
300 357
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -308,7 +365,9 @@  discard block
 block discarded – undo
308 365
 				$darr = '';
309 366
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
310 367
 				if ($n == 6) {
311
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
368
+					if ($globalDebug) {
369
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
370
+					}
312 371
 					//$icao = $Translation->checkTranslation($ident);
313 372
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
314 373
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -321,7 +380,9 @@  discard block
 block discarded – undo
321 380
 				$darr = '';
322 381
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
323 382
 				if ($n == 7) {
324
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
383
+					if ($globalDebug) {
384
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
385
+					}
325 386
 					//$icao = $Translation->checkTranslation($ident);
326 387
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
327 388
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -349,8 +410,12 @@  discard block
 block discarded – undo
349 410
 					$decode['icao'] = $icao;
350 411
 					$latitude = $las / 100.0;
351 412
 					$longitude = $lns / 100.0;
352
-					if ($lac == 'S') $latitude = '-'.$latitude;
353
-					if ($lnc == 'W') $longitude = '-'.$longitude;
413
+					if ($lac == 'S') {
414
+						$latitude = '-'.$latitude;
415
+					}
416
+					if ($lnc == 'W') {
417
+						$longitude = '-'.$longitude;
418
+					}
354 419
 
355 420
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
356 421
 					$found = true;
@@ -368,8 +433,12 @@  discard block
 block discarded – undo
368 433
 				if ($n == 4) {
369 434
 					$latitude = $las;
370 435
 					$longitude = $lns;
371
-					if ($lac == 'S') $latitude = '-'.$latitude;
372
-					if ($lnc == 'W') $longitude = '-'.$longitude;
436
+					if ($lac == 'S') {
437
+						$latitude = '-'.$latitude;
438
+					}
439
+					if ($lnc == 'W') {
440
+						$longitude = '-'.$longitude;
441
+					}
373 442
 
374 443
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
375 444
 					$found = true;
@@ -385,7 +454,9 @@  discard block
 block discarded – undo
385 454
 				$darr = '';
386 455
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
387 456
 				if ($n == 5) {
388
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457
+					if ($globalDebug) {
458
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459
+					}
389 460
 					//$icao = $Translation->checkTranslation($ident);
390 461
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
391 462
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -406,7 +477,9 @@  discard block
 block discarded – undo
406 477
 				$aident = '';
407 478
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 479
 				if ($n == 8) {
409
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
480
+					if ($globalDebug) {
481
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
482
+					}
410 483
 					$icao = trim($aident);
411 484
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
412 485
 					$decode['icao'] = $icao;
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$darr = '';
424 497
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
425 498
 				if ($n == 5) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					//$icao = $Translation->checkTranslation($ident);
428 503
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
429 504
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -438,7 +513,9 @@  discard block
 block discarded – undo
438 513
 				$darr = '';
439 514
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
440 515
 				if ($n == 3) {
441
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
516
+					if ($globalDebug) {
517
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
518
+					}
442 519
 					//$icao = $Translation->checkTranslation($ident);
443 520
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
444 521
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -453,7 +530,9 @@  discard block
 block discarded – undo
453 530
 				$darr = '';
454 531
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
455 532
 				if ($n == 3) {
456
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
533
+					if ($globalDebug) {
534
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					}
457 536
 					//$icao = $Translation->checkTranslation($ident);
458 537
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
459 538
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -463,7 +542,9 @@  discard block
 block discarded – undo
463 542
 			if (!$found) {
464 543
 				$n = sscanf($message,'MET01%4c',$airport);
465 544
 				if ($n == 1) {
466
-					if ($globalDebug) echo 'airport name : '.$airport;
545
+					if ($globalDebug) {
546
+						echo 'airport name : '.$airport;
547
+					}
467 548
 					$decode = array('Airport/Waypoint name' => $airport);
468 549
 					$found = true;
469 550
 				}
@@ -471,184 +552,126 @@  discard block
 block discarded – undo
471 552
 			if ($label == 'H1') {
472 553
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
473 554
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
474
-				}
475
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
555
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
476 556
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
477
-				}
478
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
557
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
479 558
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
480
-				}
481
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
559
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
482 560
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
483
-				}
484
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
561
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
485 562
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
486
-				}
487
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
563
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
488 564
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
489
-				}
490
-				elseif (preg_match(':^#M1AAEP:',$message)) {
565
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
491 566
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
492
-				}
493
-				elseif (preg_match(':^#M2APWD:',$message)) {
567
+				} elseif (preg_match(':^#M2APWD:',$message)) {
494 568
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
495
-				}
496
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
569
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
497 570
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
498
-				}
499
-				elseif (preg_match(':^#CF:',$message)) {
571
+				} elseif (preg_match(':^#CF:',$message)) {
500 572
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
501
-				}
502
-				elseif (preg_match(':^#DF:',$message)) {
573
+				} elseif (preg_match(':^#DF:',$message)) {
503 574
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
504
-				}
505
-				elseif (preg_match(':^#EC:',$message)) {
575
+				} elseif (preg_match(':^#EC:',$message)) {
506 576
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
507
-				}
508
-				elseif (preg_match(':^#EI:',$message)) {
577
+				} elseif (preg_match(':^#EI:',$message)) {
509 578
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
510
-				}
511
-				elseif (preg_match(':^#H1:',$message)) {
579
+				} elseif (preg_match(':^#H1:',$message)) {
512 580
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
513
-				}
514
-				elseif (preg_match(':^#H2:',$message)) {
581
+				} elseif (preg_match(':^#H2:',$message)) {
515 582
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
516
-				}
517
-				elseif (preg_match(':^#HD:',$message)) {
583
+				} elseif (preg_match(':^#HD:',$message)) {
518 584
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
519
-				}
520
-				elseif (preg_match(':^#M1:',$message)) {
585
+				} elseif (preg_match(':^#M1:',$message)) {
521 586
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
522
-				}
523
-				elseif (preg_match(':^#M2:',$message)) {
587
+				} elseif (preg_match(':^#M2:',$message)) {
524 588
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
525
-				}
526
-				elseif (preg_match(':^#M3:',$message)) {
589
+				} elseif (preg_match(':^#M3:',$message)) {
527 590
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
528
-				}
529
-				elseif (preg_match(':^#MD:',$message)) {
591
+				} elseif (preg_match(':^#MD:',$message)) {
530 592
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
531
-				}
532
-				elseif (preg_match(':^#PS:',$message)) {
593
+				} elseif (preg_match(':^#PS:',$message)) {
533 594
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
534
-				}
535
-				elseif (preg_match(':^#S1:',$message)) {
595
+				} elseif (preg_match(':^#S1:',$message)) {
536 596
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
537
-				}
538
-				elseif (preg_match(':^#S2:',$message)) {
597
+				} elseif (preg_match(':^#S2:',$message)) {
539 598
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
540
-				}
541
-				elseif (preg_match(':^#SD:',$message)) {
599
+				} elseif (preg_match(':^#SD:',$message)) {
542 600
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
543
-				}
544
-				elseif (preg_match(':^#T[0-8]:',$message)) {
601
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
545 602
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
546
-				}
547
-				elseif (preg_match(':^#WO:',$message)) {
603
+				} elseif (preg_match(':^#WO:',$message)) {
548 604
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
549
-				}
550
-				elseif (preg_match(':^#A1:',$message)) {
605
+				} elseif (preg_match(':^#A1:',$message)) {
551 606
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
552
-				}
553
-				elseif (preg_match(':^#A3:',$message)) {
607
+				} elseif (preg_match(':^#A3:',$message)) {
554 608
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
555
-				}
556
-				elseif (preg_match(':^#A4:',$message)) {
609
+				} elseif (preg_match(':^#A4:',$message)) {
557 610
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
558
-				}
559
-				elseif (preg_match(':^#A6:',$message)) {
611
+				} elseif (preg_match(':^#A6:',$message)) {
560 612
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
561
-				}
562
-				elseif (preg_match(':^#A8:',$message)) {
613
+				} elseif (preg_match(':^#A8:',$message)) {
563 614
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
564
-				}
565
-				elseif (preg_match(':^#A9:',$message)) {
615
+				} elseif (preg_match(':^#A9:',$message)) {
566 616
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
567
-				}
568
-				elseif (preg_match(':^#A0:',$message)) {
617
+				} elseif (preg_match(':^#A0:',$message)) {
569 618
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
570
-				}
571
-				elseif (preg_match(':^#AA:',$message)) {
619
+				} elseif (preg_match(':^#AA:',$message)) {
572 620
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
573
-				}
574
-				elseif (preg_match(':^#AB:',$message)) {
621
+				} elseif (preg_match(':^#AB:',$message)) {
575 622
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
576
-				}
577
-				elseif (preg_match(':^#AC:',$message)) {
623
+				} elseif (preg_match(':^#AC:',$message)) {
578 624
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
579
-				}
580
-				elseif (preg_match(':^#AD:',$message)) {
625
+				} elseif (preg_match(':^#AD:',$message)) {
581 626
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
582
-				}
583
-				elseif (preg_match(':^#AF:',$message)) {
627
+				} elseif (preg_match(':^#AF:',$message)) {
584 628
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
585
-				}
586
-				elseif (preg_match(':^#B1:',$message)) {
629
+				} elseif (preg_match(':^#B1:',$message)) {
587 630
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
588
-				}
589
-				elseif (preg_match(':^#B2:',$message)) {
631
+				} elseif (preg_match(':^#B2:',$message)) {
590 632
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
591
-				}
592
-				elseif (preg_match(':^#B3:',$message)) {
633
+				} elseif (preg_match(':^#B3:',$message)) {
593 634
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
594
-				}
595
-				elseif (preg_match(':^#B4:',$message)) {
635
+				} elseif (preg_match(':^#B4:',$message)) {
596 636
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
597
-				}
598
-				elseif (preg_match(':^#B6:',$message)) {
637
+				} elseif (preg_match(':^#B6:',$message)) {
599 638
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
600
-				}
601
-				elseif (preg_match(':^#B8:',$message)) {
639
+				} elseif (preg_match(':^#B8:',$message)) {
602 640
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
603
-				}
604
-				elseif (preg_match(':^#B9:',$message)) {
641
+				} elseif (preg_match(':^#B9:',$message)) {
605 642
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
606
-				}
607
-				elseif (preg_match(':^#B0:',$message)) {
643
+				} elseif (preg_match(':^#B0:',$message)) {
608 644
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
609
-				}
610
-				elseif (preg_match(':^#BA:',$message)) {
645
+				} elseif (preg_match(':^#BA:',$message)) {
611 646
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
612
-				}
613
-				elseif (preg_match(':^#BB:',$message)) {
647
+				} elseif (preg_match(':^#BB:',$message)) {
614 648
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
615
-				}
616
-				elseif (preg_match(':^#BC:',$message)) {
649
+				} elseif (preg_match(':^#BC:',$message)) {
617 650
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
618
-				}
619
-				elseif (preg_match(':^#BD:',$message)) {
651
+				} elseif (preg_match(':^#BD:',$message)) {
620 652
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
621
-				}
622
-				elseif (preg_match(':^#BE:',$message)) {
653
+				} elseif (preg_match(':^#BE:',$message)) {
623 654
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
624
-				}
625
-				elseif (preg_match(':^#BF:',$message)) {
655
+				} elseif (preg_match(':^#BF:',$message)) {
626 656
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
627
-				}
628
-				elseif (preg_match(':^#H3:',$message)) {
657
+				} elseif (preg_match(':^#H3:',$message)) {
629 658
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
630 659
 				}
631 660
 			}
632 661
 			if ($label == '10') {
633 662
 				if (preg_match(':^DTO01:',$message)) {
634 663
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
635
-				}
636
-				elseif (preg_match(':^AIS01:',$message)) {
664
+				} elseif (preg_match(':^AIS01:',$message)) {
637 665
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
638
-				}
639
-				elseif (preg_match(':^FTX01:',$message)) {
666
+				} elseif (preg_match(':^FTX01:',$message)) {
640 667
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
641
-				}
642
-				elseif (preg_match(':^FPL01:',$message)) {
668
+				} elseif (preg_match(':^FPL01:',$message)) {
643 669
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
644
-				}
645
-				elseif (preg_match(':^WAB01:',$message)) {
670
+				} elseif (preg_match(':^WAB01:',$message)) {
646 671
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
647
-				}
648
-				elseif (preg_match(':^MET01:',$message)) {
672
+				} elseif (preg_match(':^MET01:',$message)) {
649 673
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
650
-				}
651
-				elseif (preg_match(':^WAB02:',$message)) {
674
+				} elseif (preg_match(':^WAB02:',$message)) {
652 675
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
653 676
 				}
654 677
 			}
@@ -663,38 +686,28 @@  discard block
 block discarded – undo
663 686
 					$vsta = array('Version' => $version);
664 687
 					if ($state == 'E') {
665 688
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
666
-					}
667
-					elseif ($state == 'L') {
689
+					} elseif ($state == 'L') {
668 690
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
669
-					}
670
-					else {
691
+					} else {
671 692
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
672 693
 					}
673 694
 					if ($type == 'V') {
674 695
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
675
-					}
676
-					elseif ($type == 'S') {
696
+					} elseif ($type == 'S') {
677 697
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
678
-					}
679
-					elseif ($type == 'H') {
698
+					} elseif ($type == 'H') {
680 699
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
681
-					}
682
-					elseif ($type == 'G') {
700
+					} elseif ($type == 'G') {
683 701
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
684
-					}
685
-					elseif ($type == 'C') {
702
+					} elseif ($type == 'C') {
686 703
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
687
-					}
688
-					elseif ($type == '2') {
704
+					} elseif ($type == '2') {
689 705
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
690
-					}
691
-					elseif ($type == 'X') {
706
+					} elseif ($type == 'X') {
692 707
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
693
-					}
694
-					elseif ($type == 'I') {
708
+					} elseif ($type == 'I') {
695 709
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
696
-					}
697
-					else {
710
+					} else {
698 711
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
699 712
 					}
700 713
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -703,7 +716,9 @@  discard block
 block discarded – undo
703 716
 			}
704 717
 
705 718
 			$title = $this->getTitlefromLabel($label);
706
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
719
+			if ($title != '') {
720
+				$decode = array_merge(array('Message title' => $title),$decode);
721
+			}
707 722
 			/*
708 723
 			// Business jets always use GS0001
709 724
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -738,31 +753,54 @@  discard block
 block discarded – undo
738 753
 			$msg = $message['message'];
739 754
 			$decode = $message['decode'];
740 755
 			$registration = (string)$message['registration'];
741
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
742
-			else $latitude = '';
743
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
744
-			else $longitude = '';
745
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
746
-			else $airicao = '';
747
-			if (isset($decode['icao'])) $icao = $decode['icao'];
748
-			else $icao = $Translation->checkTranslation($ident);
756
+			if (isset($decode['latitude'])) {
757
+				$latitude = $decode['latitude'];
758
+			} else {
759
+				$latitude = '';
760
+			}
761
+			if (isset($decode['longitude'])) {
762
+				$longitude = $decode['longitude'];
763
+			} else {
764
+				$longitude = '';
765
+			}
766
+			if (isset($decode['airicao'])) {
767
+				$airicao = $decode['airicao'];
768
+			} else {
769
+				$airicao = '';
770
+			}
771
+			if (isset($decode['icao'])) {
772
+				$icao = $decode['icao'];
773
+			} else {
774
+				$icao = $Translation->checkTranslation($ident);
775
+			}
749 776
 			$image_array = $Image->getSpotterImage($registration);
750 777
 			if (!isset($image_array[0]['registration'])) {
751 778
 				$Image->addSpotterImage($registration);
752 779
 			}
753 780
 			// Business jets always use GS0001
754
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
755
-			if ($globalDebug && isset($info) && $info != '') echo $info;
756
-			if (count($decode) > 0) $decode_json = json_encode($decode);
757
-			else $decode_json = '';
781
+			if ($ident != 'GS0001') {
782
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
783
+			}
784
+			if ($globalDebug && isset($info) && $info != '') {
785
+				echo $info;
786
+			}
787
+			if (count($decode) > 0) {
788
+				$decode_json = json_encode($decode);
789
+			} else {
790
+				$decode_json = '';
791
+			}
758 792
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
759 793
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
760 794
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
761 795
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
762 796
 			}
763 797
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
764
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
765
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
798
+			if (!isset($globalACARSArchive)) {
799
+				$globalACARSArchive = array('10','80','81','82','3F');
800
+			}
801
+			if ($result && in_array($label,$globalACARSArchive)) {
802
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
803
+			}
766 804
 			if ($globalDebug && count($decode) > 0) {
767 805
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
768 806
 			}
@@ -785,7 +823,9 @@  discard block
 block discarded – undo
785 823
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
786 824
 			$Connection = new Connection($this->db);
787 825
 			$this->db = $Connection->db;
788
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
826
+			if ($globalDebug) {
827
+				echo "Test if not already in Live ACARS table...";
828
+			}
789 829
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
790 830
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
791 831
 			try {
@@ -795,7 +835,9 @@  discard block
 block discarded – undo
795 835
 				return "error : ".$e->getMessage();
796 836
 			}
797 837
 			if ($stht->fetchColumn() == 0) {
798
-				if ($globalDebug) echo "Add Live ACARS data...";
838
+				if ($globalDebug) {
839
+					echo "Add Live ACARS data...";
840
+				}
799 841
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
800 842
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
801 843
 				try {
@@ -805,10 +847,14 @@  discard block
 block discarded – undo
805 847
 					return "error : ".$e->getMessage();
806 848
 				}
807 849
 			} else {
808
-				if ($globalDebug) echo "Data already in DB...\n";
850
+				if ($globalDebug) {
851
+					echo "Data already in DB...\n";
852
+				}
809 853
 				return false;
810 854
 			}
811
-			if ($globalDebug) echo "Done\n";
855
+			if ($globalDebug) {
856
+				echo "Done\n";
857
+			}
812 858
 			return true;
813 859
 		}
814 860
 	}
@@ -839,7 +885,9 @@  discard block
 block discarded – undo
839 885
 			    	    }
840 886
 				    if ($stht->fetchColumn() == 0) {
841 887
 			*/
842
-			if ($globalDebug) echo "Add Live ACARS data...";
888
+			if ($globalDebug) {
889
+				echo "Add Live ACARS data...";
890
+			}
843 891
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
844 892
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
845 893
 			try {
@@ -848,7 +896,9 @@  discard block
 block discarded – undo
848 896
 			} catch(PDOException $e) {
849 897
 				return "error : ".$e->getMessage();
850 898
 			}
851
-			if ($globalDebug) echo "Done\n";
899
+			if ($globalDebug) {
900
+				echo "Done\n";
901
+			}
852 902
 		}
853 903
 	}
854 904
 
@@ -871,8 +921,11 @@  discard block
 block discarded – undo
871 921
 			return '';
872 922
 		}
873 923
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
874
-		if (count($row) > 0) return $row[0]['title'];
875
-		else return '';
924
+		if (count($row) > 0) {
925
+			return $row[0]['title'];
926
+		} else {
927
+			return '';
928
+		}
876 929
 	}
877 930
 
878 931
 	/**
@@ -891,8 +944,11 @@  discard block
 block discarded – undo
891 944
 			return array();
892 945
 		}
893 946
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
894
-		if (count($row) > 0) return $row;
895
-		else return array();
947
+		if (count($row) > 0) {
948
+			return $row;
949
+		} else {
950
+			return array();
951
+		}
896 952
 	}
897 953
 
898 954
 	/**
@@ -912,8 +968,11 @@  discard block
 block discarded – undo
912 968
 			return array();
913 969
 		}
914 970
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
915
-		if (count($row) > 0) return $row[0];
916
-		else return array();
971
+		if (count($row) > 0) {
972
+			return $row[0];
973
+		} else {
974
+			return array();
975
+		}
917 976
 	}
918 977
 
919 978
 	/**
@@ -958,19 +1017,35 @@  discard block
 block discarded – undo
958 1017
 			if ($row['registration'] != '') {
959 1018
 				$row['registration'] = str_replace('.','',$row['registration']);
960 1019
 				$image_array = $Image->getSpotterImage($row['registration']);
961
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
962
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
963
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
964
-			if ($row['registration'] == '') $row['registration'] = 'NA';
965
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1020
+				if (count($image_array) > 0) {
1021
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1022
+				} else {
1023
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1024
+				}
1025
+			} else {
1026
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1027
+			}
1028
+			if ($row['registration'] == '') {
1029
+				$row['registration'] = 'NA';
1030
+			}
1031
+			if ($row['ident'] == '') {
1032
+				$row['ident'] = 'NA';
1033
+			}
966 1034
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
967 1035
 			if (isset($identicao[0])) {
968 1036
 				if (substr($row['ident'],0,2) == 'AF') {
969
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
970
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
971
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1037
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1038
+						$icao = $row['ident'];
1039
+					} else {
1040
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1041
+					}
1042
+				} else {
1043
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1044
+				}
972 1045
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
973
-			} else $icao = $row['ident'];
1046
+			} else {
1047
+				$icao = $row['ident'];
1048
+			}
974 1049
 			$icao = $Translation->checkTranslation($icao,false);
975 1050
 			$decode = json_decode($row['decode'],true);
976 1051
 			$found = false;
@@ -995,7 +1070,9 @@  discard block
 block discarded – undo
995 1070
 					$found = true;
996 1071
 				}
997 1072
 			}
998
-			if ($found) $row['decode'] = json_encode($decode);
1073
+			if ($found) {
1074
+				$row['decode'] = json_encode($decode);
1075
+			}
999 1076
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1000 1077
 			$result[] = $data;
1001 1078
 			$i++;
@@ -1003,8 +1080,9 @@  discard block
 block discarded – undo
1003 1080
 		if (isset($result)) {
1004 1081
 			$result[0]['query_number_rows'] = $i;
1005 1082
 			return $result;
1083
+		} else {
1084
+			return array();
1006 1085
 		}
1007
-		else return array();
1008 1086
 	}
1009 1087
 
1010 1088
 	/**
@@ -1053,31 +1131,51 @@  discard block
 block discarded – undo
1053 1131
 			if ($row['registration'] != '') {
1054 1132
 				$row['registration'] = str_replace('.','',$row['registration']);
1055 1133
 				$image_array = $Image->getSpotterImage($row['registration']);
1056
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1057
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1058
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1134
+				if (count($image_array) > 0) {
1135
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1136
+				} else {
1137
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1138
+				}
1139
+			} else {
1140
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1141
+			}
1059 1142
 			$icao = '';
1060
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1061
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1143
+			if ($row['registration'] == '') {
1144
+				$row['registration'] = 'NA';
1145
+			}
1146
+			if ($row['ident'] == '') {
1147
+				$row['ident'] = 'NA';
1148
+			}
1062 1149
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1063 1150
 			if (isset($identicao[0])) {
1064 1151
 				if (substr($row['ident'],0,2) == 'AF') {
1065
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1066
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1067
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1152
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1153
+						$icao = $row['ident'];
1154
+					} else {
1155
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1156
+					}
1157
+				} else {
1158
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1159
+				}
1068 1160
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1069
-			} else $icao = $row['ident'];
1161
+			} else {
1162
+				$icao = $row['ident'];
1163
+			}
1070 1164
 			$icao = $Translation->checkTranslation($icao);
1071 1165
 			$decode = json_decode($row['decode'],true);
1072 1166
 			$found = false;
1073 1167
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1074 1168
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1075
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1169
+				if (isset($airport_info[0]['icao'])) {
1170
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1171
+				}
1076 1172
 				$found = true;
1077 1173
 			}
1078 1174
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1079 1175
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1080
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1176
+				if (isset($airport_info[0]['icao'])) {
1177
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1178
+				}
1081 1179
 				$found = true;
1082 1180
 			}
1083 1181
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1087,7 +1185,9 @@  discard block
 block discarded – undo
1087 1185
 					$found = true;
1088 1186
 				}
1089 1187
 			}
1090
-			if ($found) $row['decode'] = json_encode($decode);
1188
+			if ($found) {
1189
+				$row['decode'] = json_encode($decode);
1190
+			}
1091 1191
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1092 1192
 			$result[] = $data;
1093 1193
 			$i++;
@@ -1095,7 +1195,9 @@  discard block
 block discarded – undo
1095 1195
 		if (isset($result)) {
1096 1196
 			$result[0]['query_number_rows'] = $i;
1097 1197
 			return $result;
1098
-		} else return array();
1198
+		} else {
1199
+			return array();
1200
+		}
1099 1201
 	}
1100 1202
 
1101 1203
 	/**
@@ -1111,25 +1213,37 @@  discard block
 block discarded – undo
1111 1213
 		$ident = trim($ident);
1112 1214
 		$Translation = new Translation($this->db);
1113 1215
 		$Spotter = new Spotter($this->db);
1114
-		if ($globalDebug) echo "Test if we add ModeS data...";
1216
+		if ($globalDebug) {
1217
+			echo "Test if we add ModeS data...";
1218
+		}
1115 1219
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1116
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1117
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1220
+		if ($icao == '') {
1221
+			$icao = $Translation->checkTranslation($ident);
1222
+		}
1223
+		if ($globalDebug) {
1224
+			echo '- Ident : '.$icao.' - ';
1225
+		}
1118 1226
 		if ($ident == '' || $registration == '') {
1119
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1227
+			if ($globalDebug) {
1228
+				echo "Ident or registration null, exit\n";
1229
+			}
1120 1230
 			return '';
1121 1231
 		}
1122 1232
 		$registration = str_replace('.','',$registration);
1123 1233
 		$ident = $Translation->ident2icao($ident);
1124 1234
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1125
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1235
+		if ($globalDebug) {
1236
+			echo "Check if needed to add translation ".$ident.'... ';
1237
+		}
1126 1238
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1127 1239
 		$querysi_values = array(':registration' => $registration);
1128 1240
 		try {
1129 1241
 			$sthsi = $this->db->prepare($querysi);
1130 1242
 			$sthsi->execute($querysi_values);
1131 1243
 		} catch(PDOException $e) {
1132
-			if ($globalDebug) echo $e->getMessage();
1244
+			if ($globalDebug) {
1245
+				echo $e->getMessage();
1246
+			}
1133 1247
 			return "error : ".$e->getMessage();
1134 1248
 		}
1135 1249
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1137,9 +1251,14 @@  discard block
 block discarded – undo
1137 1251
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1138 1252
 			$Translation = new Translation($this->db);
1139 1253
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1140
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1141
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1142
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1254
+			if ($globalDebug) {
1255
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1256
+			}
1257
+			if ($ident != $trans_ident) {
1258
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1259
+			} elseif ($trans_ident == $ident) {
1260
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1261
+			}
1143 1262
 		} else {
1144 1263
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1145 1264
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1148,32 +1267,44 @@  discard block
 block discarded – undo
1148 1267
 					$sth = $this->db->prepare($query);
1149 1268
 					$sth->execute($query_values);
1150 1269
 				} catch(PDOException $e) {
1151
-					if ($globalDebug) echo $e->getMessage();
1270
+					if ($globalDebug) {
1271
+						echo $e->getMessage();
1272
+					}
1152 1273
 					return "error : ".$e->getMessage();
1153 1274
 				}
1154 1275
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1155 1276
 				$sth->closeCursor();
1156
-				if (isset($result['modes'])) $hex = $result['modes'];
1157
-				else $hex = '';
1277
+				if (isset($result['modes'])) {
1278
+					$hex = $result['modes'];
1279
+				} else {
1280
+					$hex = '';
1281
+				}
1158 1282
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1159 1283
 				$this->SI->add($SI_data);
1160 1284
 			}
1161 1285
 		}
1162
-		if ($globalDebug) echo 'Done'."\n";
1286
+		if ($globalDebug) {
1287
+			echo 'Done'."\n";
1288
+		}
1163 1289
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1164 1290
 		$query_values = array(':ident' => $icao);
1165 1291
 		try {
1166 1292
 			$sth = $this->db->prepare($query);
1167 1293
 			$sth->execute($query_values);
1168 1294
 		} catch(PDOException $e) {
1169
-			if ($globalDebug) echo $e->getMessage();
1295
+			if ($globalDebug) {
1296
+				echo $e->getMessage();
1297
+			}
1170 1298
 			return "error : ".$e->getMessage();
1171 1299
 		}
1172 1300
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1173 1301
 		$sth->closeCursor();
1174 1302
 		if (isset($result['flightaware_id'])) {
1175
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1176
-			else $ModeS = '';
1303
+			if (isset($result['ModeS'])) {
1304
+				$ModeS = $result['ModeS'];
1305
+			} else {
1306
+				$ModeS = '';
1307
+			}
1177 1308
 			if ($ModeS == '') {
1178 1309
 				$id = explode('-',$result['flightaware_id']);
1179 1310
 				$ModeS = $id[0];
@@ -1186,24 +1317,32 @@  discard block
 block discarded – undo
1186 1317
 					$sthc = $this->db->prepare($queryc);
1187 1318
 					$sthc->execute($queryc_values);
1188 1319
 				} catch(PDOException $e) {
1189
-					if ($globalDebug) echo $e->getMessage();
1320
+					if ($globalDebug) {
1321
+						echo $e->getMessage();
1322
+					}
1190 1323
 					return "error : ".$e->getMessage();
1191 1324
 				}
1192 1325
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1193 1326
 				$sthc->closeCursor();
1194 1327
 				if (count($row) ==  0) {
1195
-					if ($globalDebug) echo " Add to ModeS table - ";
1328
+					if ($globalDebug) {
1329
+						echo " Add to ModeS table - ";
1330
+					}
1196 1331
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1197 1332
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1198 1333
 					try {
1199 1334
 						$sthi = $this->db->prepare($queryi);
1200 1335
 						$sthi->execute($queryi_values);
1201 1336
 					} catch(PDOException $e) {
1202
-						if ($globalDebug) echo $e->getMessage();
1337
+						if ($globalDebug) {
1338
+							echo $e->getMessage();
1339
+						}
1203 1340
 						return "error : ".$e->getMessage();
1204 1341
 					}
1205 1342
 				} else {
1206
-					if ($globalDebug) echo " Update ModeS table - ";
1343
+					if ($globalDebug) {
1344
+						echo " Update ModeS table - ";
1345
+					}
1207 1346
 					if ($ICAOTypeCode != '') {
1208 1347
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1209 1348
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1215,7 +1354,9 @@  discard block
 block discarded – undo
1215 1354
 						$sthi = $this->db->prepare($queryi);
1216 1355
 						$sthi->execute($queryi_values);
1217 1356
 					} catch(PDOException $e) {
1218
-						if ($globalDebug) echo $e->getMessage();
1357
+						if ($globalDebug) {
1358
+							echo $e->getMessage();
1359
+						}
1219 1360
 						return "error : ".$e->getMessage();
1220 1361
 					}
1221 1362
 				}
@@ -1236,7 +1377,9 @@  discard block
 block discarded – undo
1236 1377
 					    return "error : ".$e->getMessage();
1237 1378
 				}
1238 1379
 				*/
1239
-				if ($globalDebug) echo " Update Spotter_output table - ";
1380
+				if ($globalDebug) {
1381
+					echo " Update Spotter_output table - ";
1382
+				}
1240 1383
 				if ($ICAOTypeCode != '') {
1241 1384
 					if ($globalDBdriver == 'mysql') {
1242 1385
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1247,8 +1390,7 @@  discard block
 block discarded – undo
1247 1390
 				} else {
1248 1391
 					if ($globalDBdriver == 'mysql') {
1249 1392
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1250
-					}
1251
-					elseif ($globalDBdriver == 'pgsql') {
1393
+					} elseif ($globalDBdriver == 'pgsql') {
1252 1394
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1253 1395
 					}
1254 1396
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1257,14 +1399,20 @@  discard block
 block discarded – undo
1257 1399
 					$sthi = $this->db->prepare($queryi);
1258 1400
 					$sthi->execute($queryi_values);
1259 1401
 				} catch(PDOException $e) {
1260
-					if ($globalDebug) echo $e->getMessage();
1402
+					if ($globalDebug) {
1403
+						echo $e->getMessage();
1404
+					}
1261 1405
 					return "error : ".$e->getMessage();
1262 1406
 				}
1263 1407
 			}
1264 1408
 		} else {
1265
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1409
+			if ($globalDebug) {
1410
+				echo " Can't find ModeS in spotter_output - ";
1411
+			}
1412
+		}
1413
+		if ($globalDebug) {
1414
+			echo "Done\n";
1266 1415
 		}
1267
-		if ($globalDebug) echo "Done\n";
1268 1416
 	}
1269 1417
 }
1270 1418
 ?>
Please login to merge, or discard this patch.