Completed
Push — master ( 213543...524718 )
by Yannick
10:07 queued 03:30
created
require/class.Connection.php 1 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 = 38;
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 $globalDBdriver, $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.
scripts/daemon-spotter.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 	    die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
48
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
49 49
     }
50 50
 }
51 51
 
52
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
52
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56 56
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
57
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
58 58
     else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60 60
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
61
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
62 62
     else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77 77
     if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
78
+    $SI = new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
82 82
     $SI->connect();
83 83
 */
84
-} else $SI=new SpotterImport($Connection->db);
84
+} else $SI = new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87 87
     $AIS = new AIS();
88 88
     $MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91
-$SBS=new SBS();
92
-$ACARS=new ACARS($Connection->db);
93
-$Common=new Common();
91
+$SBS = new SBS();
92
+$ACARS = new ACARS($Connection->db);
93
+$Common = new Common();
94 94
 date_default_timezone_set('UTC');
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
98
+    pcntl_signal(SIGINT, function() {
99 99
         global $sockets;
100 100
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101 101
         die("Bye!\n");
@@ -111,35 +111,35 @@  discard block
 block discarded – undo
111 111
 
112 112
 function connect_all($hosts) {
113 113
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
114
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
115 115
     $reset++;
116 116
     if ($globalDebug) echo 'Connect to all...'."\n";
117 117
     foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
121
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
+            if (preg_match('/deltadb.txt$/i', $host)) {
123 123
         	//$formats[$id] = 'deltadbtxt';
124 124
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 125
         	//$last_exec['deltadbtxt'] = 0;
126 126
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
127
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
128 128
         	//$formats[$id] = 'vatsimtxt';
129 129
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 130
         	//$last_exec['vatsimtxt'] = 0;
131 131
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
132
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
133 133
         	//$formats[$id] = 'aircraftlistjson';
134 134
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 135
         	//$last_exec['aircraftlistjson'] = 0;
136 136
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
137
+    	    } else if (preg_match('/opensky/i', $host)) {
138 138
         	//$formats[$id] = 'aircraftlistjson';
139 139
         	$globalSources[$id]['format'] = 'opensky';
140 140
         	//$last_exec['aircraftlistjson'] = 0;
141 141
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
142
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
143 143
         	//$formats[$id] = 'radarvirtueljson';
144 144
         	$globalSources[$id]['format'] = 'radarvirtueljson';
145 145
         	//$last_exec['radarvirtueljson'] = 0;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149 149
         	    exit(0);
150 150
         	}
151
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
151
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
152 152
         	//$formats[$id] = 'planeupdatefaa';
153 153
         	$globalSources[$id]['format'] = 'planeupdatefaa';
154 154
         	//$last_exec['planeupdatefaa'] = 0;
@@ -157,26 +157,26 @@  discard block
 block discarded – undo
157 157
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158 158
         	    exit(0);
159 159
         	}
160
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
160
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
161 161
         	//$formats[$id] = 'phpvmacars';
162 162
         	$globalSources[$id]['format'] = 'phpvmacars';
163 163
         	//$last_exec['phpvmacars'] = 0;
164 164
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
165
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'vam';
168 168
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
-            } else if (preg_match('/whazzup/i',$host)) {
169
+            } else if (preg_match('/whazzup/i', $host)) {
170 170
         	//$formats[$id] = 'whazzup';
171 171
         	$globalSources[$id]['format'] = 'whazzup';
172 172
         	//$last_exec['whazzup'] = 0;
173 173
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
-            } else if (preg_match('/recentpireps/i',$host)) {
174
+            } else if (preg_match('/recentpireps/i', $host)) {
175 175
         	//$formats[$id] = 'pirepsjson';
176 176
         	$globalSources[$id]['format'] = 'pirepsjson';
177 177
         	//$last_exec['pirepsjson'] = 0;
178 178
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
179
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
180 180
         	//$formats[$id] = 'fr24json';
181 181
         	$globalSources[$id]['format'] = 'fr24json';
182 182
         	//$last_exec['fr24json'] = 0;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186 186
         	    exit(0);
187 187
         	}
188
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
188
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
189 189
         	//$formats[$id] = 'fr24json';
190 190
         	$globalSources[$id]['format'] = 'myshiptracking';
191 191
         	//$last_exec['fr24json'] = 0;
@@ -195,22 +195,22 @@  discard block
 block discarded – undo
195 195
         	    exit(0);
196 196
         	}
197 197
             //} else if (preg_match('/10001/',$host)) {
198
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
198
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199 199
         	//$formats[$id] = 'tsv';
200 200
         	$globalSources[$id]['format'] = 'tsv';
201 201
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202 202
             }
203
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
203
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
204 204
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
205
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
206 206
     		    if ($idf !== false) {
207 207
     			$httpfeeds[$id] = $idf;
208 208
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209 209
     		    }
210 210
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211 211
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
-	    $hostport = explode(':',$host);
212
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
213
+	    $hostport = explode(':', $host);
214 214
 	    if (isset($hostport[1])) {
215 215
 		$port = $hostport[1];
216 216
 		$hostn = $hostport[0];
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
 	    }
221 221
 	    $Common = new Common();
222 222
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
223
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
224 224
     	    } else {
225
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
225
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
226 226
 	    }
227 227
 	    if ($s) {
228 228
     	        $sockets[$id] = $s;
229 229
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
230
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
231 231
 			//$formats[$id] = 'aprs';
232 232
 			$globalSources[$id]['format'] = 'aprs';
233 233
 			//$aprs_connect = 0;
234 234
 			//$use_aprs = true;
235
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
235
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
236 236
 			$globalSources[$id]['format'] = 'vrstcp';
237 237
     		    } elseif ($port == '10001') {
238 238
         		//$formats[$id] = 'tsv';
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
272 272
 else $timeout = 20;
273 273
 $errno = '';
274
-$errstr='';
274
+$errstr = '';
275 275
 
276 276
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
277 277
 /* Initiate connections to all the hosts simultaneously */
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 //connect_all($globalSources);
280 280
 
281 281
 if (isset($globalProxy) && $globalProxy) {
282
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
282
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
283 283
 } else {
284 284
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
285 285
 }
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 
307 307
 if ($use_aprs) {
308 308
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
309
-	$APRS=new APRS();
309
+	$APRS = new APRS();
310 310
 	$aprs_connect = 0;
311 311
 	$aprs_keep = 120;
312 312
 	$aprs_last_tx = time();
313 313
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
314
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
314
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
315 315
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
316
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
316
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
317 317
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
318
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
318
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
319 319
 	if ($aprs_full) $aprs_filter = '';
320 320
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
321 321
 	else $aprs_pass = '-1';
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
 sleep(1);
330 330
 if ($globalDebug) echo "SCAN MODE \n\n";
331 331
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
332
-$endtime = time()+$globalCronEnd;
332
+$endtime = time() + $globalCronEnd;
333 333
 $i = 1;
334 334
 $tt = array();
335 335
 // Delete all ATC
336 336
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
337
-	$ATC=new ATC($Connection->db);
337
+	$ATC = new ATC($Connection->db);
338 338
 }
339 339
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
340 340
 	$ATC->deleteAll();
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 344
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
345
+    if (!$globalDaemon) $i = $endtime - time();
346 346
     // Delete old ATC
347 347
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	}
358 358
 	if ($max != $globalMinFetch) {
359 359
 	    if ($globalDebug) echo 'Sleeping...'."\n";
360
-	    sleep($globalMinFetch-$max+2);
360
+	    sleep($globalMinFetch - $max + 2);
361 361
 	}
362 362
     }
363 363
 
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	    //$buffer = $Common->getData($hosts[$id]);
371 371
 	    $buffer = $Common->getData($value['host']);
372 372
 	    if ($buffer != '') $reset = 0;
373
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
-	    $buffer = explode('\n',$buffer);
373
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
374
+	    $buffer = explode('\n', $buffer);
375 375
 	    foreach ($buffer as $line) {
376 376
     		if ($line != '' && count($line) > 7) {
377 377
     		    $line = explode(',', $line);
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
     	    $last_exec[$id]['last'] = time();
400 400
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
401 401
 	    date_default_timezone_set('CET');
402
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
402
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
403 403
 	    date_default_timezone_set('UTC');
404 404
 	    if ($buffer != '') $reset = 0;
405
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
-	    $buffer = explode('\n',$buffer);
405
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
406
+	    $buffer = explode('\n', $buffer);
407 407
 	    foreach ($buffer as $line) {
408 408
 		if ($line != '') {
409 409
 		    echo "'".$line."'\n";
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422 422
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423 423
 		    if (isset($ais_data['timestamp'])) {
424
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
424
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
425 425
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
426 426
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427 427
 			    $add = true;
@@ -445,12 +445,12 @@  discard block
 block discarded – undo
445 445
 	    $w = $e = null;
446 446
 	    
447 447
 	    if (isset($arr[$id])) {
448
-		$nn = stream_select($arr,$w,$e,$timeout);
448
+		$nn = stream_select($arr, $w, $e, $timeout);
449 449
 		if ($nn > 0) {
450 450
 		    foreach ($httpfeeds as $feed) {
451
-			$buffer = stream_get_line($feed,2000,"\n");
452
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
453
-			$buffer = explode('\n',$buffer);
451
+			$buffer = stream_get_line($feed, 2000, "\n");
452
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
453
+			$buffer = explode('\n', $buffer);
454 454
 			foreach ($buffer as $line) {
455 455
 			    if ($line != '') {
456 456
 				$ais_data = $AIS->parse_line(trim($line));
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
467 467
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
468 468
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
469
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
469
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
470 470
 				if (isset($ais_data['timestamp'])) {
471
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
471
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
472 472
 				} else {
473 473
 				    $data['datetime'] = date('Y-m-d H:i:s');
474 474
 				}
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
 		}
494 494
 	    }
495 495
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
496
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
496
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
497 497
 	    if ($buffer != '') {
498 498
 		//echo $buffer;
499
-		$all_data = json_decode($buffer,true);
499
+		$all_data = json_decode($buffer, true);
500 500
 		//print_r($all_data);
501 501
 		if (isset($all_data[0]['DATA'])) {
502 502
 		foreach ($all_data[0]['DATA'] as $line) {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 			//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
512 512
 			$data['imo'] = $line['IMO'];
513 513
 			//$data['arrival_code'] = $ais_data['destination'];
514
-			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
514
+			$data['datetime'] = date('Y-m-d H:i:s', $line['T']);
515 515
 			$data['format_source'] = 'myshiptracking';
516 516
 			$data['id_source'] = $id_source;
517 517
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -524,9 +524,9 @@  discard block
 block discarded – undo
524 524
 	    }
525 525
     	    $last_exec[$id]['last'] = time();
526 526
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
527
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
527
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
528 528
 	    if ($buffer != '') {
529
-		$all_data = json_decode($buffer,true);
529
+		$all_data = json_decode($buffer, true);
530 530
 		if (isset($all_data[0]['mmsi'])) {
531 531
 		    foreach ($all_data as $line) {
532 532
 			if ($line != '') {
@@ -554,27 +554,27 @@  discard block
 block discarded – undo
554 554
     	    $last_exec[$id]['last'] = time();
555 555
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
556 556
 	    echo 'download...';
557
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
557
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
558 558
 	    echo 'done !'."\n";
559 559
 	    if ($buffer != '') $reset = 0;
560
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
561
-	    $buffer = explode('\n',$buffer);
560
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
561
+	    $buffer = explode('\n', $buffer);
562 562
 	    foreach ($buffer as $line) {
563 563
 		if ($line != '') {
564 564
 		    $data = array();
565
-		    $data['mmsi'] = (int)substr($line,0,9);
566
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
565
+		    $data['mmsi'] = (int) substr($line, 0, 9);
566
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
567 567
 		    //$data['status'] = substr($line,21,2);
568 568
 		    //$data['type'] = substr($line,24,3);
569
-		    $data['latitude'] = substr($line,29,9);
570
-		    $data['longitude'] = substr($line,41,9);
571
-		    $data['speed'] = round(substr($line,51,5));
569
+		    $data['latitude'] = substr($line, 29, 9);
570
+		    $data['longitude'] = substr($line, 41, 9);
571
+		    $data['speed'] = round(substr($line, 51, 5));
572 572
 		    //$data['course'] = substr($line,57,5);
573
-		    $data['heading'] = round(substr($line,63,3));
573
+		    $data['heading'] = round(substr($line, 63, 3));
574 574
 		    //$data['draft'] = substr($line,67,4);
575 575
 		    //$data['length'] = substr($line,72,3);
576 576
 		    //$data['beam'] = substr($line,76,2);
577
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
577
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
578 578
 		    //$data['callsign'] = trim(substr($line,100,7);
579 579
 		    //$data['dest'] = substr($line,108,20);
580 580
 		    //$data['etaDate'] = substr($line,129,5);
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
594 594
 	    //$buffer = $Common->getData($hosts[$id]);
595 595
 	    $buffer = $Common->getData($value['host']);
596
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
597
-	    $buffer = explode('\n',$buffer);
596
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
597
+	    $buffer = explode('\n', $buffer);
598 598
 	    $reset = 0;
599 599
 	    foreach ($buffer as $line) {
600 600
     		if ($line != '') {
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
606 606
 			$data['pilot_id'] = $line[1];
607 607
 			$data['pilot_name'] = $line[2];
608
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
608
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
609 609
 			$data['ident'] = $line[0]; // ident
610 610
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
611 611
 			$data['speed'] = $line[8]; // speed
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
622 622
 			//if (isset($line[37])) $data['last_update'] = $line[37];
623 623
 		        $data['departure_airport_icao'] = $line[11];
624
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
624
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
625 625
 		        $data['arrival_airport_icao'] = $line[13];
626 626
 			$data['frequency'] = $line[4];
627 627
 			$data['type'] = $line[18];
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
     			$data['id_source'] = $id_source;
631 631
 	    		//$data['arrival_airport_time'] = ;
632 632
 	    		if ($line[9] != '') {
633
-	    		    $aircraft_data = explode('/',$line[9]);
633
+	    		    $aircraft_data = explode('/', $line[9]);
634 634
 	    		    if (isset($aircraft_data[1])) {
635 635
 	    			$data['aircraft_icao'] = $aircraft_data[1];
636 636
 	    		    }
@@ -645,9 +645,9 @@  discard block
 block discarded – undo
645 645
     			if ($line[3] == 'PILOT') $SI->add($data);
646 646
 			elseif ($line[3] == 'ATC') {
647 647
 				//print_r($data);
648
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
649
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
650
-				$typec = substr($data['ident'],-3);
648
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
649
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
650
+				$typec = substr($data['ident'], -3);
651 651
 				if ($typec == 'APP') $data['type'] = 'Approach';
652 652
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
653 653
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
659 659
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
660 660
 				if (!isset($data['source_name'])) $data['source_name'] = '';
661
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
661
+				if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
662 662
 			}
663 663
     			unset($data);
664 664
     		    }
@@ -669,9 +669,9 @@  discard block
 block discarded – undo
669 669
     	    $last_exec[$id]['last'] = time();
670 670
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
671 671
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
672
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
672
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
673 673
 	    if ($buffer != '') {
674
-	    $all_data = json_decode($buffer,true);
674
+	    $all_data = json_decode($buffer, true);
675 675
 	    if (isset($all_data['acList'])) {
676 676
 		$reset = 0;
677 677
 		foreach ($all_data['acList'] as $line) {
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
730 730
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
731 731
 	    $buffer = $Common->getData($value['host']);
732
-	    $all_data = json_decode($buffer,true);
732
+	    $all_data = json_decode($buffer, true);
733 733
 	    if (isset($all_data['planes'])) {
734 734
 		$reset = 0;
735 735
 		foreach ($all_data['planes'] as $key => $line) {
@@ -746,12 +746,12 @@  discard block
 block discarded – undo
746 746
 		    $data['emergency'] = ''; // emergency
747 747
 		    $data['registration'] = $line[2];
748 748
 		    $data['aircraft_icao'] = $line[0];
749
-		    $deparr = explode('-',$line[1]);
749
+		    $deparr = explode('-', $line[1]);
750 750
 		    if (count($deparr) == 2) {
751 751
 			$data['departure_airport_icao'] = $deparr[0];
752 752
 			$data['arrival_airport_icao'] = $deparr[1];
753 753
 		    }
754
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
754
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
755 755
 	    	    $data['format_source'] = 'planeupdatefaa';
756 756
     		    $data['id_source'] = $id_source;
757 757
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
     	    $last_exec[$id]['last'] = time();
765 765
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
766 766
 	    $buffer = $Common->getData($value['host']);
767
-	    $all_data = json_decode($buffer,true);
767
+	    $all_data = json_decode($buffer, true);
768 768
 	    if (isset($all_data['states'])) {
769 769
 		$reset = 0;
770 770
 		foreach ($all_data['states'] as $key => $line) {
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 		    //$data['emergency'] = ''; // emergency
782 782
 		    //$data['registration'] = $line[2];
783 783
 		    //$data['aircraft_icao'] = $line[0];
784
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
784
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
785 785
 	    	    $data['format_source'] = 'opensky';
786 786
     		    $data['id_source'] = $id_source;
787 787
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
796 796
 	    //$buffer = $Common->getData($hosts[$id]);
797 797
 	    $buffer = $Common->getData($value['host']);
798
-	    $all_data = json_decode($buffer,true);
798
+	    $all_data = json_decode($buffer, true);
799 799
 	    if (!empty($all_data)) $reset = 0;
800 800
 	    foreach ($all_data as $key => $line) {
801 801
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -828,11 +828,11 @@  discard block
 block discarded – undo
828 828
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
829 829
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
830 830
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
831
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
831
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
832 832
 	    //echo $buffer;
833
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
834
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
835
-	    $all_data = json_decode($buffer,true);
833
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
834
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
835
+	    $all_data = json_decode($buffer, true);
836 836
 	    if (json_last_error() != JSON_ERROR_NONE) {
837 837
 		die(json_last_error_msg());
838 838
 	    }
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 			//$data['departure_airport_iata'] = $line[11];
856 856
 			//$data['arrival_airport_iata'] = $line[12];
857 857
 	    		//$data['emergency'] = ''; // emergency
858
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
858
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
859 859
 	    		$data['format_source'] = 'radarvirtueljson';
860 860
     			$data['id_source'] = $id_source;
861 861
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -871,14 +871,14 @@  discard block
 block discarded – undo
871 871
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
872 872
 	    //$buffer = $Common->getData($hosts[$id]);
873 873
 	    $buffer = $Common->getData($value['host'].'?'.time());
874
-	    $all_data = json_decode(utf8_encode($buffer),true);
874
+	    $all_data = json_decode(utf8_encode($buffer), true);
875 875
 	    
876 876
 	    if (isset($all_data['pireps'])) {
877 877
 		$reset = 0;
878 878
 	        foreach ($all_data['pireps'] as $line) {
879 879
 		    $data = array();
880 880
 		    $data['id'] = $line['id'];
881
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
881
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
882 882
 		    $data['ident'] = $line['callsign']; // ident
883 883
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
884 884
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -908,9 +908,9 @@  discard block
 block discarded – undo
908 908
 			$SI->add($data);
909 909
 		    //    print_r($data);
910 910
     		    } elseif ($line['icon'] == 'ct') {
911
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
912
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
913
-			$typec = substr($data['ident'],-3);
911
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
912
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
913
+			$typec = substr($data['ident'], -3);
914 914
 			$data['type'] = '';
915 915
 			if ($typec == 'APP') $data['type'] = 'Approach';
916 916
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
922 922
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
923 923
 			else $data['type'] = 'Observer';
924
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
924
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
925 925
 		    }
926 926
 		    unset($data);
927 927
 		}
@@ -933,14 +933,14 @@  discard block
 block discarded – undo
933 933
 	    //$buffer = $Common->getData($hosts[$id]);
934 934
 	    if ($globalDebug) echo 'Get Data...'."\n";
935 935
 	    $buffer = $Common->getData($value['host']);
936
-	    $all_data = json_decode($buffer,true);
936
+	    $all_data = json_decode($buffer, true);
937 937
 	    if ($buffer != '' && is_array($all_data)) {
938 938
 		$reset = 0;
939 939
 		foreach ($all_data as $line) {
940 940
 	    	    $data = array();
941 941
 	    	    //$data['id'] = $line['id']; // id not usable
942 942
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
943
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
943
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
944 944
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
945 945
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
946 946
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -964,14 +964,14 @@  discard block
 block discarded – undo
964 964
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
965 965
 		    if (isset($line['aircraftname'])) {
966 966
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
967
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
968
-	    		$aircraft_data = explode('-',$line['aircraftname']);
967
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
968
+	    		$aircraft_data = explode('-', $line['aircraftname']);
969 969
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
970 970
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
971 971
 	    		else {
972
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
973
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
974
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
972
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
973
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
974
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
975 975
 	    		}
976 976
 	    	    }
977 977
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -991,14 +991,14 @@  discard block
 block discarded – undo
991 991
 	    //$buffer = $Common->getData($hosts[$id]);
992 992
 	    if ($globalDebug) echo 'Get Data...'."\n";
993 993
 	    $buffer = $Common->getData($value['host']);
994
-	    $all_data = json_decode($buffer,true);
994
+	    $all_data = json_decode($buffer, true);
995 995
 	    if ($buffer != '' && is_array($all_data)) {
996 996
 		$reset = 0;
997 997
 		foreach ($all_data as $line) {
998 998
 	    	    $data = array();
999 999
 	    	    //$data['id'] = $line['id']; // id not usable
1000 1000
 	    	    $data['id'] = trim($line['flight_id']);
1001
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1001
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1002 1002
 	    	    $data['pilot_name'] = $line['pilot_name'];
1003 1003
 	    	    $data['pilot_id'] = $line['pilot_id'];
1004 1004
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1050,11 +1050,11 @@  discard block
 block discarded – undo
1050 1050
 		    //$value = $formats[$nb];
1051 1051
 		    $format = $globalSources[$nb]['format'];
1052 1052
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1053
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1053
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1054 1054
 		    } elseif ($format == 'vrstcp') {
1055 1055
 			$buffer = @socket_read($r, 6000);
1056 1056
 		    } else {
1057
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1057
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1058 1058
 		    }
1059 1059
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1060 1060
 		    //echo $buffer."\n";
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 		    $error = false;
1064 1064
 		    //$SI::del();
1065 1065
 		    if ($format == 'vrstcp') {
1066
-			$buffer = explode('},{',$buffer);
1067
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1066
+			$buffer = explode('},{', $buffer);
1067
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1068 1068
 		    // SBS format is CSV format
1069 1069
 		    if ($buffer !== FALSE && $buffer != '') {
1070 1070
 			$tt[$format] = 0;
@@ -1097,11 +1097,11 @@  discard block
 block discarded – undo
1097 1097
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1098 1098
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1099 1099
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1100
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1100
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1101 1101
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1102 1102
 
1103 1103
 			    if (isset($ais_data['timestamp'])) {
1104
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1104
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1105 1105
 			    } else {
1106 1106
 				$data['datetime'] = date('Y-m-d H:i:s');
1107 1107
 			    }
@@ -1112,10 +1112,10 @@  discard block
 block discarded – undo
1112 1112
                         } elseif ($format == 'flightgearsp') {
1113 1113
                     	    //echo $buffer."\n";
1114 1114
                     	    if (strlen($buffer) > 5) {
1115
-				$line = explode(',',$buffer);
1115
+				$line = explode(',', $buffer);
1116 1116
 				$data = array();
1117 1117
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1118
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1118
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1119 1119
 				$data['ident'] = $line[6];
1120 1120
 				$data['aircraft_name'] = $line[7];
1121 1121
 				$data['longitude'] = $line[1];
@@ -1127,21 +1127,21 @@  discard block
 block discarded – undo
1127 1127
 				$data['format_source'] = 'flightgearsp';
1128 1128
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1129 1129
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1130
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1130
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1131 1131
 			    }
1132 1132
                         } elseif ($format == 'acars') {
1133 1133
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1134 1134
 			    $ACARS->add(trim($buffer));
1135
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1135
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1136 1136
 			    $ACARS->deleteLiveAcarsData();
1137 1137
 			} elseif ($format == 'flightgearmp') {
1138
-			    if (substr($buffer,0,1) != '#') {
1138
+			    if (substr($buffer, 0, 1) != '#') {
1139 1139
 				$data = array();
1140 1140
 				//echo $buffer."\n";
1141
-				$line = explode(' ',$buffer);
1141
+				$line = explode(' ', $buffer);
1142 1142
 				if (count($line) == 11) {
1143
-				    $userserver = explode('@',$line[0]);
1144
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1143
+				    $userserver = explode('@', $line[0]);
1144
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1145 1145
 				    $data['ident'] = $userserver[0];
1146 1146
 				    $data['registration'] = $userserver[0];
1147 1147
 				    $data['latitude'] = $line[4];
@@ -1149,8 +1149,8 @@  discard block
 block discarded – undo
1149 1149
 				    $data['altitude'] = $line[6];
1150 1150
 				    $data['datetime'] = date('Y-m-d H:i:s');
1151 1151
 				    $aircraft_type = $line[10];
1152
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1153
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1152
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1153
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1154 1154
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1155 1155
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1156 1156
 				}
@@ -1159,8 +1159,8 @@  discard block
 block discarded – undo
1159 1159
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1160 1160
 			    die;
1161 1161
 			} elseif ($format == 'vrstcp') {
1162
-			    foreach($buffer as $all_data) {
1163
-				$line = json_decode('{'.$all_data.'}',true);
1162
+			    foreach ($buffer as $all_data) {
1163
+				$line = json_decode('{'.$all_data.'}', true);
1164 1164
 				$data = array();
1165 1165
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1166 1166
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1186,16 +1186,16 @@  discard block
 block discarded – undo
1186 1186
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1187 1187
 				unset($data);
1188 1188
 			    }
1189
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1189
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1190 1190
 			    $line = explode("\t", $buffer);
1191
-			    for($k = 0; $k < count($line); $k=$k+2) {
1191
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1192 1192
 				$key = $line[$k];
1193
-			        $lined[$key] = $line[$k+1];
1193
+			        $lined[$key] = $line[$k + 1];
1194 1194
 			    }
1195 1195
     			    if (count($lined) > 3) {
1196 1196
     				$data['hex'] = $lined['hexid'];
1197 1197
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1198
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1198
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1199 1199
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1200 1200
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1201 1201
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1214,22 +1214,22 @@  discard block
 block discarded – undo
1214 1214
     			    } else $error = true;
1215 1215
 			} elseif ($format == 'aprs' && $use_aprs) {
1216 1216
 			    if ($aprs_connect == 0) {
1217
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1217
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1218 1218
 				$aprs_connect = 1;
1219 1219
 			    }
1220 1220
 			    
1221
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1221
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1222 1222
 				$aprs_last_tx = time();
1223 1223
 				$data_aprs = "# Keep alive";
1224
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1224
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1225 1225
 			    }
1226 1226
 			    
1227 1227
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1228 1228
 			    //echo 'APRS data : '.$buffer."\n";
1229
-			    $buffer = str_replace('APRS <- ','',$buffer);
1230
-			    $buffer = str_replace('APRS -> ','',$buffer);
1229
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1230
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1231 1231
 			    //echo $buffer."\n";
1232
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1232
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1233 1233
 				$line = $APRS->parse($buffer);
1234 1234
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1235 1235
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 				    //print_r($line);
1239 1239
 				    if (isset($line['address'])) $data['hex'] = $line['address'];
1240 1240
 				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1241
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1241
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1242 1242
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1243 1243
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1244 1244
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 				    $currentdate = date('Y-m-d H:i:s');
1266 1266
 				    $aprsdate = strtotime($data['datetime']);
1267 1267
 				    // Accept data if time <= system time + 20s
1268
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1268
+				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1269 1269
 					$send = $SI->add($data);
1270 1270
 				    } elseif ($data['source_type'] == 'ais') {
1271 1271
 					echo 'add...'."\n";
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 				connect_all($sourceee);
1367 1367
 				$sourceee = array();
1368 1368
 				//connect_all($globalSources);
1369
-				$tt[$format]=0;
1369
+				$tt[$format] = 0;
1370 1370
 				break;
1371 1371
 			    }
1372 1372
 			}
@@ -1375,14 +1375,14 @@  discard block
 block discarded – undo
1375 1375
 	    } else {
1376 1376
 		$error = socket_strerror(socket_last_error());
1377 1377
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1378
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1378
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1379 1379
 			if (isset($globalDebug)) echo "Restarting...\n";
1380 1380
 			// Restart the script if possible
1381 1381
 			if (is_array($sockets)) {
1382 1382
 			    if ($globalDebug) echo "Shutdown all sockets...";
1383 1383
 			    
1384 1384
 			    foreach ($sockets as $sock) {
1385
-				@socket_shutdown($sock,2);
1385
+				@socket_shutdown($sock, 2);
1386 1386
 				@socket_close($sock);
1387 1387
 			    }
1388 1388
 			    
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Spacing   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		fclose($fp);
25 25
 	}
26 26
 
27
-	public static function gunzip($in_file,$out_file_name = '') {
27
+	public static function gunzip($in_file, $out_file_name = '') {
28 28
 		//echo $in_file.' -> '.$out_file_name."\n";
29 29
 		$buffer_size = 4096; // read 4kb at a time
30 30
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
31 31
 		if ($in_file != '' && file_exists($in_file)) {
32 32
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
33
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
34
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
35 35
 			else {
36 36
 				echo 'gzopen not available';
37 37
 				die;
38 38
 			}
39 39
 			$out_file = fopen($out_file_name, 'wb'); 
40
-			while(!gzeof($file)) {
40
+			while (!gzeof($file)) {
41 41
 				fwrite($out_file, gzread($file, $buffer_size));
42 42
 			}  
43 43
 			fclose($out_file);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		try {
62 62
 			self::$db_sqlite = new PDO('sqlite:'.$database);
63 63
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
64
-		} catch(PDOException $e) {
64
+		} catch (PDOException $e) {
65 65
 			return "error : ".$e->getMessage();
66 66
 		}
67 67
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78 78
                         $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		try {
88 88
                         $sth = update_db::$db_sqlite->prepare($query);
89 89
                         $sth->execute();
90
-                } catch(PDOException $e) {
90
+                } catch (PDOException $e) {
91 91
                         return "error : ".$e->getMessage();
92 92
                 }
93 93
 		//$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)';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99 99
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$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);
101
-				$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);
101
+				$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 102
 				$sth_dest->execute($query_dest_values);
103 103
             		}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120 120
                         $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
121
+                } catch (PDOException $e) {
122 122
                         return "error : ".$e->getMessage();
123 123
                 }
124 124
 
125 125
     		if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128
-		if ($fh = fopen($database_file,"r")) {
128
+		if ($fh = fopen($database_file, "r")) {
129 129
 			$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)';
130 130
 			$Connection = new Connection();
131 131
 			$sth_dest = $Connection->db->prepare($query_dest);
132 132
 			if ($globalTransaction) $Connection->db->beginTransaction();
133 133
 			while (!feof($fh)) {
134
-				$line = fgetcsv($fh,9999,',');
134
+				$line = fgetcsv($fh, 9999, ',');
135 135
 				if ($line[0] != '') {
136 136
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
137 137
 						try {
138
-							$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');
138
+							$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 139
 							$sth_dest->execute($query_dest_values);
140
-						} catch(PDOException $e) {
140
+						} catch (PDOException $e) {
141 141
 							if ($globalTransaction) $Connection->db->rollBack(); 
142 142
 							return "error : ".$e->getMessage();
143 143
 						}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161 161
                         $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error : ".$e->getMessage();
164 164
                 }
165 165
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
170
-		if ($fh = fopen($database_file,"r")) {
170
+		if ($fh = fopen($database_file, "r")) {
171 171
 			$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)';
172 172
 			$Connection = new Connection();
173 173
 			$sth_dest = $Connection->db->prepare($query_dest);
174 174
 			try {
175 175
 				if ($globalTransaction) $Connection->db->beginTransaction();
176 176
 				while (!feof($fh)) {
177
-					$line = fgetcsv($fh,9999,',');
177
+					$line = fgetcsv($fh, 9999, ',');
178 178
 					if ($line[0] != '') {
179
-						$datebe = explode('  -  ',$line[2]);
179
+						$datebe = explode('  -  ', $line[2]);
180 180
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
181
-							$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');
181
+							$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 182
 							$sth_dest->execute($query_dest_values);
183 183
 						}
184 184
 					}
185 185
 				}
186 186
 				if ($globalTransaction) $Connection->db->commit();
187
-			} catch(PDOException $e) {
187
+			} catch (PDOException $e) {
188 188
 				if ($globalTransaction) $Connection->db->rollBack(); 
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201 201
                         $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
202
+                } catch (PDOException $e) {
203 203
                         return "error : ".$e->getMessage();
204 204
                 }
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209 209
                         $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
210
+                } catch (PDOException $e) {
211 211
                         return "error : ".$e->getMessage();
212 212
                 }
213 213
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		try {
217 217
                         $sth = update_db::$db_sqlite->prepare($query);
218 218
                         $sth->execute();
219
-                } catch(PDOException $e) {
219
+                } catch (PDOException $e) {
220 220
                         return "error : ".$e->getMessage();
221 221
                 }
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 			//$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']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
236
+				$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 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
239
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
240 240
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242 242
             		}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244
-		} catch(PDOException $e) {
244
+		} catch (PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
246 246
 		}
247 247
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253 253
                         $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
254
+                } catch (PDOException $e) {
255 255
                         return "error : ".$e->getMessage();
256 256
                 }
257 257
 		return '';
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268 268
                         $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
269
+                } catch (PDOException $e) {
270 270
                         return "error : ".$e->getMessage();
271 271
                 }
272 272
 		
273
-		if ($fh = fopen($database_file,"r")) {
273
+		if ($fh = fopen($database_file, "r")) {
274 274
 			//$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)';
275 275
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
276 276
 		
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281 281
             			while (!feof($fh)) {
282 282
             				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
283
+            				$line = $Common->hex2str(fgets($fh, 9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
285
+            				$values['ModeS'] = substr($line, 0, 6);
286
+            				$values['Registration'] = trim(substr($line, 69, 6));
287
+            				$aircraft_name = trim(substr($line, 48, 6));
288 288
             				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
289
+            				$aircraft_name_split = explode(' ', $aircraft_name);
290 290
             				$search_more = '';
291 291
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292 292
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 	            				if (isset($result['icao']) && $result['icao'] != '') {
299 299
 	            				    $values['ICAOTypeCode'] = $result['icao'];
300 300
 	            				} 
301
-					} catch(PDOException $e) {
301
+					} catch (PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
304 304
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
305 305
 					// Add data to db
306 306
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 307
 						//$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']);
308
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
308
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
309 309
 						//print_r($query_dest_values);
310 310
 						$sth_dest->execute($query_dest_values);
311 311
 					}
312 312
 				}
313 313
 				if ($globalTransaction) $Connection->db->commit();
314
-			} catch(PDOException $e) {
314
+			} catch (PDOException $e) {
315 315
 				return "error : ".$e->getMessage();
316 316
 			}
317 317
 		}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323 323
                         $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
324
+                } catch (PDOException $e) {
325 325
                         return "error : ".$e->getMessage();
326 326
                 }
327 327
 		return '';
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337 337
                         $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
338
+                } catch (PDOException $e) {
339 339
                         return "error : ".$e->getMessage();
340 340
                 }
341 341
 		
342
-		if ($fh = fopen($database_file,"r")) {
342
+		if ($fh = fopen($database_file, "r")) {
343 343
 			//$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)';
344 344
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
345 345
 		
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 			$sth_dest = $Connection->db->prepare($query_dest);
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350
-				$tmp = fgetcsv($fh,9999,',',"'");
350
+				$tmp = fgetcsv($fh, 9999, ',', "'");
351 351
             			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
352
+            				$line = fgetcsv($fh, 9999, ',', "'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             				$values['Registration'] = $line[3];
358 358
             				$aircraft_name = $line[2];
359 359
             				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
360
+            				$aircraft_name_split = explode(' ', $aircraft_name);
361 361
             				$search_more = '';
362 362
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363 363
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
                                     		$sth_search->execute();
367 367
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368 368
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369
-					} catch(PDOException $e) {
369
+					} catch (PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
372 372
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
373 373
 					// Add data to db
374 374
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
375 375
 						//$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']);
376
-						$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');
376
+						$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');
377 377
 						//print_r($query_dest_values);
378 378
 						$sth_dest->execute($query_dest_values);
379 379
 					}
380 380
 				}
381 381
 				if ($globalTransaction) $Connection->db->commit();
382
-			} catch(PDOException $e) {
382
+			} catch (PDOException $e) {
383 383
 				return "error : ".$e->getMessage();
384 384
 			}
385 385
 		}
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391 391
                         $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
392
+                } catch (PDOException $e) {
393 393
                         return "error : ".$e->getMessage();
394 394
                 }
395 395
 		return '';
396 396
 	}
397 397
 
398
-	public static function retrieve_owner($database_file,$country = 'F') {
398
+	public static function retrieve_owner($database_file, $country = 'F') {
399 399
 		global $globalTransaction, $globalMasterSource;
400 400
 		//$query = 'TRUNCATE TABLE aircraft_modes';
401 401
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405 405
                         $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
406
+                } catch (PDOException $e) {
407 407
                         return "error : ".$e->getMessage();
408 408
                 }
409 409
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
410 410
 		$Spotter = new Spotter();
411
-		if ($fh = fopen($database_file,"r")) {
411
+		if ($fh = fopen($database_file, "r")) {
412 412
 			//$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)';
413 413
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
414 414
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 			$sth_modes = $Connection->db->prepare($query_modes);
419 419
 			try {
420 420
 				if ($globalTransaction) $Connection->db->beginTransaction();
421
-				$tmp = fgetcsv($fh,9999,',','"');
421
+				$tmp = fgetcsv($fh, 9999, ',', '"');
422 422
             			while (!feof($fh)) {
423
-            				$line = fgetcsv($fh,9999,',','"');
423
+            				$line = fgetcsv($fh, 9999, ',', '"');
424 424
             				$values = array();
425 425
             				//print_r($line);
426 426
             				if ($country == 'F') {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
             				    $values['base'] = $line[4];
429 429
             				    $values['owner'] = $line[5];
430 430
             				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
431
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
432 432
 					    $values['cancel'] = $line[7];
433 433
 					} elseif ($country == 'EI') {
434 434
 					    // TODO : add modeS & reg to aircraft_modes
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
             				    $values['base'] = $line[3];
437 437
             				    $values['owner'] = $line[2];
438 438
             				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
439
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
440 440
 					    $values['cancel'] = '';
441 441
 					    $values['modes'] = $line[7];
442 442
 					    $values['icao'] = $line[8];
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             				    $values['base'] = null;
457 457
             				    $values['owner'] = $line[5];
458 458
             				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
459
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
460 460
 					    $values['cancel'] = '';
461 461
 					} elseif ($country == 'VH') {
462 462
 					    // TODO : add modeS & reg to aircraft_modes
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
             				    $values['base'] = null;
465 465
             				    $values['owner'] = $line[12];
466 466
             				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
467
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
468 468
 
469 469
 					    $values['cancel'] = $line[39];
470 470
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -484,28 +484,28 @@  discard block
 block discarded – undo
484 484
             				    $values['base'] = null;
485 485
             				    $values['owner'] = $line[8];
486 486
             				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
487
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
488 488
 					    $values['cancel'] = '';
489 489
 					} elseif ($country == 'PP') {
490 490
             				    $values['registration'] = $line[0];
491 491
             				    $values['base'] = null;
492 492
             				    $values['owner'] = $line[4];
493 493
             				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
494
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
495 495
 					    $values['cancel'] = $line[7];
496 496
 					} elseif ($country == 'E7') {
497 497
             				    $values['registration'] = $line[0];
498 498
             				    $values['base'] = null;
499 499
             				    $values['owner'] = $line[4];
500 500
             				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
501
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
502 502
 					    $values['cancel'] = '';
503 503
 					} elseif ($country == '8Q') {
504 504
             				    $values['registration'] = $line[0];
505 505
             				    $values['base'] = null;
506 506
             				    $values['owner'] = $line[3];
507 507
             				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
508
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
509 509
 					    $values['cancel'] = '';
510 510
 					} elseif ($country == 'ZK') {
511 511
             				    $values['registration'] = $line[0];
@@ -519,18 +519,18 @@  discard block
 block discarded – undo
519 519
             				    $values['registration'] = $line[0];
520 520
             				    $values['base'] = null;
521 521
             				    $values['owner'] = $line[6];
522
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
522
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
523
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
524 524
 					    $values['modes'] = $line[4];
525 525
 					    $values['icao'] = $line[10];
526 526
 					} elseif ($country == 'OY') {
527 527
             				    $values['registration'] = $line[0];
528
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
528
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
529 529
 					    $values['modes'] = $line[5];
530 530
 					    $values['icao'] = $line[6];
531 531
 					} elseif ($country == 'PH') {
532 532
             				    $values['registration'] = $line[0];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
533
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
534 534
 					    $values['modes'] = $line[4];
535 535
 					    $values['icao'] = $line[5];
536 536
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -541,17 +541,17 @@  discard block
 block discarded – undo
541 541
 					    $values['cancel'] = '';
542 542
 					}
543 543
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
544
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
544
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
545 545
 						$sth_dest->execute($query_dest_values);
546 546
 					}
547 547
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
548 548
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
549
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
549
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
550 550
 						$sth_modes->execute($query_modes_values);
551 551
 					}
552 552
 				}
553 553
 				if ($globalTransaction) $Connection->db->commit();
554
-			} catch(PDOException $e) {
554
+			} catch (PDOException $e) {
555 555
 				return "error : ".$e->getMessage();
556 556
 			}
557 557
 		}
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 			$Connection = new Connection();
667 667
 			$sth = $Connection->db->prepare($query);
668 668
                         $sth->execute();
669
-                } catch(PDOException $e) {
669
+                } catch (PDOException $e) {
670 670
                         return "error : ".$e->getMessage();
671 671
                 }
672 672
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			$Connection = new Connection();
677 677
 			$sth = $Connection->db->prepare($query);
678 678
                         $sth->execute();
679
-                } catch(PDOException $e) {
679
+                } catch (PDOException $e) {
680 680
                         return "error : ".$e->getMessage();
681 681
                 }
682 682
 
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 		if ($globalTransaction) $Connection->db->beginTransaction();
688 688
   
689 689
 		$i = 0;
690
-		while($row = sparql_fetch_array($result))
690
+		while ($row = sparql_fetch_array($result))
691 691
 		{
692 692
 			if ($i >= 1) {
693 693
 			//print_r($row);
@@ -707,31 +707,31 @@  discard block
 block discarded – undo
707 707
 				$row['image'] = '';
708 708
 				$row['image_thumb'] = '';
709 709
 			} else {
710
-				$image = str_replace(' ','_',$row['image']);
710
+				$image = str_replace(' ', '_', $row['image']);
711 711
 				$digest = md5($image);
712
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
713
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
714
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
715
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
712
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
713
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
714
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
715
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
716 716
 			}
717 717
 			
718
-			$country = explode('-',$row['country']);
718
+			$country = explode('-', $row['country']);
719 719
 			$row['country'] = $country[0];
720 720
 			
721 721
 			$row['type'] = trim($row['type']);
722
-			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'])) {
722
+			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'])) {
723 723
 				$row['type'] = 'Military';
724 724
 			} 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') {
725 725
 				$row['type'] = 'small_airport';
726 726
 			}
727 727
 			
728
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
729
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
728
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
729
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
730 730
 			//print_r($query_dest_values);
731 731
 			
732 732
 			try {
733 733
 				$sth_dest->execute($query_dest_values);
734
-			} catch(PDOException $e) {
734
+			} catch (PDOException $e) {
735 735
 				return "error : ".$e->getMessage();
736 736
 			}
737 737
 			}
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 			$Connection = new Connection();
746 746
 			$sth = $Connection->db->prepare($query);
747 747
                         $sth->execute();
748
-                } catch(PDOException $e) {
748
+                } catch (PDOException $e) {
749 749
                         return "error : ".$e->getMessage();
750 750
                 }
751 751
 
@@ -753,12 +753,12 @@  discard block
 block discarded – undo
753 753
 		if ($globalDebug) echo "Insert Not available Airport...\n";
754 754
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
755 755
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
756
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
756
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
757 757
 		try {
758 758
 			$Connection = new Connection();
759 759
 			$sth = $Connection->db->prepare($query);
760 760
                         $sth->execute($query_values);
761
-                } catch(PDOException $e) {
761
+                } catch (PDOException $e) {
762 762
                         return "error : ".$e->getMessage();
763 763
                 }
764 764
 		$i++;
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		echo "Download data from ourairports.com...\n";
777 777
 		$delimiter = ',';
778 778
 		$out_file = $tmp_dir.'airports.csv';
779
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
779
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
780 780
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
781 781
 		echo "Add data from ourairports.com...\n";
782 782
 
@@ -787,32 +787,32 @@  discard block
 block discarded – undo
787 787
 			//$Connection->db->beginTransaction();
788 788
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
789 789
 			{
790
-				if(!$header) $header = $row;
790
+				if (!$header) $header = $row;
791 791
 				else {
792 792
 					$data = array();
793 793
 					$data = array_combine($header, $row);
794 794
 					try {
795 795
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
796 796
 						$sth->execute(array(':icao' => $data['gps_code']));
797
-					} catch(PDOException $e) {
797
+					} catch (PDOException $e) {
798 798
 						return "error : ".$e->getMessage();
799 799
 					}
800 800
 					if ($sth->fetchColumn() > 0) {
801 801
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
802 802
 						try {
803 803
 							$sth = $Connection->db->prepare($query);
804
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
805
-						} catch(PDOException $e) {
804
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
805
+						} catch (PDOException $e) {
806 806
 							return "error : ".$e->getMessage();
807 807
 						}
808 808
 					} else {
809 809
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
810 810
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
811
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
811
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
812 812
 						try {
813 813
 							$sth = $Connection->db->prepare($query);
814 814
 							$sth->execute($query_values);
815
-						} catch(PDOException $e) {
815
+						} catch (PDOException $e) {
816 816
 							return "error : ".$e->getMessage();
817 817
 						}
818 818
 						$i++;
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 
826 826
 		echo "Download data from another free database...\n";
827 827
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
828
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
828
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
829 829
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
830 830
 		update_db::unzip($out_file);
831 831
 		$header = NULL;
@@ -837,15 +837,15 @@  discard block
 block discarded – undo
837 837
 			//$Connection->db->beginTransaction();
838 838
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
839 839
 			{
840
-				if(!$header) $header = $row;
840
+				if (!$header) $header = $row;
841 841
 				else {
842 842
 					$data = $row;
843 843
 
844 844
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
845 845
 					try {
846 846
 						$sth = $Connection->db->prepare($query);
847
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
848
-					} catch(PDOException $e) {
847
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
848
+					} catch (PDOException $e) {
849 849
 						return "error : ".$e->getMessage();
850 850
 					}
851 851
 				}
@@ -859,15 +859,15 @@  discard block
 block discarded – undo
859 859
 		try {
860 860
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
861 861
 			$sth->execute();
862
-		} catch(PDOException $e) {
862
+		} catch (PDOException $e) {
863 863
 			return "error : ".$e->getMessage();
864 864
 		}
865 865
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
866 866
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
867 867
 			try {
868 868
 				$sth2 = $Connection->db->prepare($query2);
869
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
870
-			} catch(PDOException $e) {
869
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
870
+			} catch (PDOException $e) {
871 871
 				return "error : ".$e->getMessage();
872 872
 			}
873 873
 		}
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 			$Connection = new Connection();
892 892
 			$sth = $Connection->db->prepare($query);
893 893
                         $sth->execute(array(':source' => 'translation.csv'));
894
-                } catch(PDOException $e) {
894
+                } catch (PDOException $e) {
895 895
                         return "error : ".$e->getMessage();
896 896
                 }
897 897
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
909 909
 			{
910 910
 				$i++;
911
-				if($i > 12) {
911
+				if ($i > 12) {
912 912
 					$data = $row;
913 913
 					$operator = $data[2];
914 914
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
                                                 //echo substr($operator, 0, 2)."\n";;
917 917
                                                 if (count($airline_array) > 0) {
918 918
 							//print_r($airline_array);
919
-							$operator = $airline_array[0]['icao'].substr($operator,2);
919
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
920 920
                                                 }
921 921
                                         }
922 922
 					
@@ -924,14 +924,14 @@  discard block
 block discarded – undo
924 924
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
925 925
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926 926
                                                 if (count($airline_array) > 0) {
927
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
927
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
928 928
                                             	}
929 929
                                         }
930 930
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
931 931
 					try {
932 932
 						$sth = $Connection->db->prepare($query);
933
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
934
-					} catch(PDOException $e) {
933
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
934
+					} catch (PDOException $e) {
935 935
 						return "error : ".$e->getMessage();
936 936
 					}
937 937
 				}
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953 953
                         $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
954
+                } catch (PDOException $e) {
955 955
                         return "error : ".$e->getMessage();
956 956
                 }
957 957
 
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
972 972
 					try {
973 973
 						$sth = $Connection->db->prepare($query);
974
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
975
-					} catch(PDOException $e) {
974
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
975
+					} catch (PDOException $e) {
976 976
 						return "error : ".$e->getMessage();
977 977
 					}
978 978
 				}
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 			$Connection = new Connection();
996 996
 			$sth = $Connection->db->prepare($query);
997 997
                         $sth->execute(array(':source' => 'website_faa'));
998
-                } catch(PDOException $e) {
998
+                } catch (PDOException $e) {
999 999
                         return "error : ".$e->getMessage();
1000 1000
                 }
1001 1001
 
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 			$Connection = new Connection();
1005 1005
 			$sth = $Connection->db->prepare($query);
1006 1006
                         $sth->execute(array(':source' => 'website_faa'));
1007
-                } catch(PDOException $e) {
1007
+                } catch (PDOException $e) {
1008 1008
                         return "error : ".$e->getMessage();
1009 1009
                 }
1010 1010
 
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1022 1022
 					try {
1023 1023
 						$sths = $Connection->db->prepare($query_search);
1024
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1025
-					} catch(PDOException $e) {
1024
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1025
+					} catch (PDOException $e) {
1026 1026
 						return "error s : ".$e->getMessage();
1027 1027
 					}
1028 1028
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 							//}
1036 1036
 						try {
1037 1037
 							$sthi = $Connection->db->prepare($queryi);
1038
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1039
-						} catch(PDOException $e) {
1038
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1039
+						} catch (PDOException $e) {
1040 1040
 							return "error u : ".$e->getMessage();
1041 1041
 						}
1042 1042
 					} else {
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 						try {
1045 1045
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1046 1046
 							$sthsm->execute(array(':mfr' => $data[2]));
1047
-						} catch(PDOException $e) {
1047
+						} catch (PDOException $e) {
1048 1048
 							return "error mfr : ".$e->getMessage();
1049 1049
 						}
1050 1050
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1055 1055
 							try {
1056 1056
 								$sthf = $Connection->db->prepare($queryf);
1057
-								$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'));
1058
-							} catch(PDOException $e) {
1057
+								$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'));
1058
+							} catch (PDOException $e) {
1059 1059
 								return "error f : ".$e->getMessage();
1060 1060
 							}
1061 1061
 						}
@@ -1065,13 +1065,13 @@  discard block
 block discarded – undo
1065 1065
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1066 1066
 						try {
1067 1067
 							$sth = $Connection->db->prepare($query);
1068
-							$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'));
1069
-						} catch(PDOException $e) {
1068
+							$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'));
1069
+						} catch (PDOException $e) {
1070 1070
 							return "error i : ".$e->getMessage();
1071 1071
 						}
1072 1072
 					}
1073 1073
 				}
1074
-				if ($i % 90 == 0) {
1074
+				if ($i%90 == 0) {
1075 1075
 					if ($globalTransaction) $Connection->db->commit();
1076 1076
 					if ($globalTransaction) $Connection->db->beginTransaction();
1077 1077
 				}
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			$Connection = new Connection();
1091 1091
 			$sth = $Connection->db->prepare($query);
1092 1092
                         $sth->execute(array(':source' => 'website_fam'));
1093
-                } catch(PDOException $e) {
1093
+                } catch (PDOException $e) {
1094 1094
                         return "error : ".$e->getMessage();
1095 1095
                 }
1096 1096
 
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1112 1112
 					try {
1113 1113
 						$sth = $Connection->db->prepare($query);
1114
-						$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'));
1115
-					} catch(PDOException $e) {
1114
+						$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'));
1115
+					} catch (PDOException $e) {
1116 1116
 						return "error : ".$e->getMessage();
1117 1117
 					}
1118 1118
 				}
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 			$Connection = new Connection();
1132 1132
 			$sth = $Connection->db->prepare($query);
1133 1133
                         $sth->execute(array(':source' => 'website_fam'));
1134
-                } catch(PDOException $e) {
1134
+                } catch (PDOException $e) {
1135 1135
                         return "error : ".$e->getMessage();
1136 1136
                 }
1137 1137
 
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1148 1148
 					try {
1149 1149
 						$sth = $Connection->db->prepare($query);
1150
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1151
-					} catch(PDOException $e) {
1150
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1151
+					} catch (PDOException $e) {
1152 1152
 						print_r($data);
1153 1153
 						return "error : ".$e->getMessage();
1154 1154
 					}
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			$Connection = new Connection();
1169 1169
 			$sth = $Connection->db->prepare($query);
1170 1170
                         $sth->execute(array(':source' => 'website_fam'));
1171
-                } catch(PDOException $e) {
1171
+                } catch (PDOException $e) {
1172 1172
                         return "error : ".$e->getMessage();
1173 1173
                 }
1174 1174
 
@@ -1188,8 +1188,8 @@  discard block
 block discarded – undo
1188 1188
 					$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)';
1189 1189
 					try {
1190 1190
 						$sth = $Connection->db->prepare($query);
1191
-						$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'));
1192
-					} catch(PDOException $e) {
1191
+						$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'));
1192
+					} catch (PDOException $e) {
1193 1193
 						return "error : ".$e->getMessage();
1194 1194
 					}
1195 1195
 				}
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 			$Connection = new Connection();
1209 1209
 			$sth = $Connection->db->prepare($query);
1210 1210
                         $sth->execute();
1211
-                } catch(PDOException $e) {
1211
+                } catch (PDOException $e) {
1212 1212
                         return "error : ".$e->getMessage();
1213 1213
                 }
1214 1214
 
@@ -1228,8 +1228,8 @@  discard block
 block discarded – undo
1228 1228
 					$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)';
1229 1229
 					try {
1230 1230
 						$sth = $Connection->db->prepare($query);
1231
-						$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]));
1232
-					} catch(PDOException $e) {
1231
+						$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]));
1232
+					} catch (PDOException $e) {
1233 1233
 						return "error : ".$e->getMessage();
1234 1234
 					}
1235 1235
 				}
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 			$Connection = new Connection();
1249 1249
 			$sth = $Connection->db->prepare($query);
1250 1250
 			$sth->execute();
1251
-		} catch(PDOException $e) {
1251
+		} catch (PDOException $e) {
1252 1252
 			return "error : ".$e->getMessage();
1253 1253
 		}
1254 1254
 
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
 					try {
1265 1265
 						$sth = $Connection->db->prepare($query);
1266 1266
 						$sth->execute(array(':icao' => $icao));
1267
-					} catch(PDOException $e) {
1267
+					} catch (PDOException $e) {
1268 1268
 						return "error : ".$e->getMessage();
1269 1269
 					}
1270 1270
 				}
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 		return '';
1276 1276
         }
1277 1277
 
1278
-	public static function tle($filename,$tletype) {
1278
+	public static function tle($filename, $tletype) {
1279 1279
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1280 1280
 		global $tmp_dir, $globalTransaction;
1281 1281
 		//$Spotter = new Spotter();
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 			$Connection = new Connection();
1286 1286
 			$sth = $Connection->db->prepare($query);
1287 1287
                         $sth->execute(array(':source' => $filename));
1288
-                } catch(PDOException $e) {
1288
+                } catch (PDOException $e) {
1289 1289
                         return "error : ".$e->getMessage();
1290 1290
                 }
1291 1291
 		
@@ -1310,8 +1310,8 @@  discard block
 block discarded – undo
1310 1310
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1311 1311
 					try {
1312 1312
 						$sth = $Connection->db->prepare($query);
1313
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1314
-					} catch(PDOException $e) {
1313
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1314
+					} catch (PDOException $e) {
1315 1315
 						return "error : ".$e->getMessage();
1316 1316
 					}
1317 1317
 
@@ -1331,28 +1331,28 @@  discard block
 block discarded – undo
1331 1331
         */
1332 1332
         private static function table2array($data) {
1333 1333
                 $html = str_get_html($data);
1334
-                $tabledata=array();
1335
-                foreach($html->find('tr') as $element)
1334
+                $tabledata = array();
1335
+                foreach ($html->find('tr') as $element)
1336 1336
                 {
1337 1337
                         $td = array();
1338
-                        foreach( $element->find('th') as $row)
1338
+                        foreach ($element->find('th') as $row)
1339 1339
                         {
1340 1340
                                 $td [] = trim($row->plaintext);
1341 1341
                         }
1342
-                        $td=array_filter($td);
1342
+                        $td = array_filter($td);
1343 1343
                         $tabledata[] = $td;
1344 1344
 
1345 1345
                         $td = array();
1346 1346
                         $tdi = array();
1347
-                        foreach( $element->find('td') as $row)
1347
+                        foreach ($element->find('td') as $row)
1348 1348
                         {
1349 1349
                                 $td [] = trim($row->plaintext);
1350 1350
                                 $tdi [] = trim($row->innertext);
1351 1351
                         }
1352
-                        $td=array_filter($td);
1353
-                        $tdi=array_filter($tdi);
1352
+                        $td = array_filter($td);
1353
+                        $tdi = array_filter($tdi);
1354 1354
                     //    $tabledata[]=array_merge($td,$tdi);
1355
-                        $tabledata[]=$td;
1355
+                        $tabledata[] = $td;
1356 1356
                 }
1357 1357
                 return(array_filter($tabledata));
1358 1358
         }
@@ -1425,13 +1425,13 @@  discard block
 block discarded – undo
1425 1425
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1426 1426
 			{
1427 1427
 				$i++;
1428
-				if($i > 3 && count($row) > 2) {
1428
+				if ($i > 3 && count($row) > 2) {
1429 1429
 					$data = array_values(array_filter($row));
1430 1430
 					$cntdata = count($data);
1431 1431
 					if ($cntdata > 10) {
1432 1432
 						$value = $data[9];
1433 1433
 						
1434
-						for ($i =10;$i < $cntdata;$i++) {
1434
+						for ($i = 10; $i < $cntdata; $i++) {
1435 1435
 							$value .= ' '.$data[$i];
1436 1436
 						}
1437 1437
 						$data[9] = $value;
@@ -1441,8 +1441,8 @@  discard block
 block discarded – undo
1441 1441
 						$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)';
1442 1442
 						try {
1443 1443
 							$sth = $Connection->db->prepare($query);
1444
-							$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]));
1445
-						} catch(PDOException $e) {
1444
+							$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]));
1445
+						} catch (PDOException $e) {
1446 1446
 							return "error : ".$e->getMessage();
1447 1447
 						}
1448 1448
 					}
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
 			$Connection = new Connection();
1464 1464
 			$sth = $Connection->db->prepare($query);
1465 1465
                         $sth->execute();
1466
-                } catch(PDOException $e) {
1466
+                } catch (PDOException $e) {
1467 1467
                         return "error : ".$e->getMessage();
1468 1468
                 }
1469 1469
 
@@ -1475,12 +1475,12 @@  discard block
 block discarded – undo
1475 1475
 			if ($globalTransaction) $Connection->db->beginTransaction();
1476 1476
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1477 1477
 			{
1478
-				if(count($row) > 1) {
1478
+				if (count($row) > 1) {
1479 1479
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1480 1480
 					try {
1481 1481
 						$sth = $Connection->db->prepare($query);
1482
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1483
-					} catch(PDOException $e) {
1482
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1483
+					} catch (PDOException $e) {
1484 1484
 						return "error : ".$e->getMessage();
1485 1485
 					}
1486 1486
 				}
@@ -1500,21 +1500,21 @@  discard block
 block discarded – undo
1500 1500
 			try {
1501 1501
 				$sth = $Connection->db->prepare($query);
1502 1502
                     		$sth->execute();
1503
-	                } catch(PDOException $e) {
1503
+	                } catch (PDOException $e) {
1504 1504
 				return "error : ".$e->getMessage();
1505 1505
 	                }
1506 1506
 	        }
1507 1507
 
1508 1508
 
1509
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1509
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1510 1510
 		else {
1511
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1511
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1512 1512
 			$query = "CREATE EXTENSION postgis";
1513
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1513
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1514 1514
 			try {
1515 1515
 				$sth = $Connection->db->prepare($query);
1516 1516
 				$sth->execute();
1517
-			} catch(PDOException $e) {
1517
+			} catch (PDOException $e) {
1518 1518
 				return "error : ".$e->getMessage();
1519 1519
 			}
1520 1520
 		}
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 		include_once('class.create_db.php');
1528 1528
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1529 1529
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1530
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1530
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1531 1531
 		$error = '';
1532 1532
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1533 1533
 			if ($globalDebug) echo "Gunzip...";
@@ -1559,14 +1559,14 @@  discard block
 block discarded – undo
1559 1559
 			try {
1560 1560
 				$sth = $Connection->db->prepare($query);
1561 1561
             	        	$sth->execute();
1562
-	                } catch(PDOException $e) {
1562
+	                } catch (PDOException $e) {
1563 1563
     	                	echo "error : ".$e->getMessage();
1564 1564
 	                }
1565 1565
 		}
1566 1566
 		if ($globalDBdriver == 'mysql') {
1567
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1567
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1568 1568
 		} else {
1569
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1569
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1570 1570
 		}
1571 1571
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1572 1572
 		return $error;
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1580 1580
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1581 1581
 //		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');
1582
-		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');
1582
+		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');
1583 1583
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1584 1584
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1585 1585
 		return $error;
@@ -1599,7 +1599,7 @@  discard block
 block discarded – undo
1599 1599
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1600 1600
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1601 1601
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1602
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1602
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1603 1603
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1604 1604
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1605 1605
 		if ($error != '') {
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 		global $tmp_dir, $globalDebug;
1613 1613
 		$error = '';
1614 1614
 		if ($globalDebug) echo "Routes : Download...";
1615
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1615
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1616 1616
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1617 1617
 			if ($globalDebug) echo "Gunzip...";
1618 1618
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 		global $tmp_dir, $globalDebug;
1629 1629
 		$error = '';
1630 1630
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1631
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1631
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1632 1632
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1633 1633
 			if ($globalDebug) echo "Gunzip...";
1634 1634
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1644,7 +1644,7 @@  discard block
 block discarded – undo
1644 1644
 		global $tmp_dir, $globalDebug;
1645 1645
 		$error = '';
1646 1646
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1647
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1647
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1648 1648
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1649 1649
 			if ($globalDebug) echo "Gunzip...";
1650 1650
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 */
1673 1673
 		if ($globalDebug) echo "Modes : Download...";
1674 1674
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1675
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1675
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1676 1676
 
1677 1677
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1678 1678
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
 	public static function update_ModeS_faa() {
1693 1693
 		global $tmp_dir, $globalDebug;
1694 1694
 		if ($globalDebug) echo "Modes FAA: Download...";
1695
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1695
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1696 1696
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1697 1697
 			if ($globalDebug) echo "Unzip...";
1698 1698
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
 	public static function update_ModeS_flarm() {
1709 1709
 		global $tmp_dir, $globalDebug;
1710 1710
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1711
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1711
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1712 1712
 		if (file_exists($tmp_dir.'data.fln')) {
1713 1713
 			if ($globalDebug) echo "Add to DB...";
1714 1714
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1722,7 +1722,7 @@  discard block
 block discarded – undo
1722 1722
 	public static function update_ModeS_ogn() {
1723 1723
 		global $tmp_dir, $globalDebug;
1724 1724
 		if ($globalDebug) echo "Modes OGN: Download...";
1725
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1725
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1726 1726
 		if (file_exists($tmp_dir.'ogn.csv')) {
1727 1727
 			if ($globalDebug) echo "Add to DB...";
1728 1728
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1737,201 +1737,201 @@  discard block
 block discarded – undo
1737 1737
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1738 1738
 		
1739 1739
 		if ($globalDebug) echo "Owner France: Download...";
1740
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1740
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1741 1741
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1742 1742
 			if ($globalDebug) echo "Add to DB...";
1743
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1743
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1744 1744
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1745 1745
 		if ($error != '') {
1746 1746
 			return $error;
1747 1747
 		} elseif ($globalDebug) echo "Done\n";
1748 1748
 		
1749 1749
 		if ($globalDebug) echo "Owner Ireland: Download...";
1750
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1750
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1751 1751
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1752 1752
 			if ($globalDebug) echo "Add to DB...";
1753
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1753
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1754 1754
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1755 1755
 		if ($error != '') {
1756 1756
 			return $error;
1757 1757
 		} elseif ($globalDebug) echo "Done\n";
1758 1758
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1759
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1759
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1760 1760
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1761 1761
 			if ($globalDebug) echo "Add to DB...";
1762
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1762
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1763 1763
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1764 1764
 		if ($error != '') {
1765 1765
 			return $error;
1766 1766
 		} elseif ($globalDebug) echo "Done\n";
1767 1767
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1768
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1768
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1769 1769
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1770 1770
 			if ($globalDebug) echo "Add to DB...";
1771
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1771
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1772 1772
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1773 1773
 		if ($error != '') {
1774 1774
 			return $error;
1775 1775
 		} elseif ($globalDebug) echo "Done\n";
1776 1776
 		if ($globalDebug) echo "Owner Australia: Download...";
1777
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1777
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1778 1778
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1779 1779
 			if ($globalDebug) echo "Add to DB...";
1780
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1780
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1781 1781
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1782 1782
 		if ($error != '') {
1783 1783
 			return $error;
1784 1784
 		} elseif ($globalDebug) echo "Done\n";
1785 1785
 		if ($globalDebug) echo "Owner Austria: Download...";
1786
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1786
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1787 1787
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1788 1788
 			if ($globalDebug) echo "Add to DB...";
1789
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1789
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1790 1790
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1791 1791
 		if ($error != '') {
1792 1792
 			return $error;
1793 1793
 		} elseif ($globalDebug) echo "Done\n";
1794 1794
 		if ($globalDebug) echo "Owner Chile: Download...";
1795
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1795
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1796 1796
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1797 1797
 			if ($globalDebug) echo "Add to DB...";
1798
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1798
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1799 1799
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1800 1800
 		if ($error != '') {
1801 1801
 			return $error;
1802 1802
 		} elseif ($globalDebug) echo "Done\n";
1803 1803
 		if ($globalDebug) echo "Owner Colombia: Download...";
1804
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1804
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1805 1805
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1806 1806
 			if ($globalDebug) echo "Add to DB...";
1807
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1807
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1808 1808
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1809 1809
 		if ($error != '') {
1810 1810
 			return $error;
1811 1811
 		} elseif ($globalDebug) echo "Done\n";
1812 1812
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1813
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1813
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1814 1814
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1815 1815
 			if ($globalDebug) echo "Add to DB...";
1816
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1816
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1817 1817
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1818 1818
 		if ($error != '') {
1819 1819
 			return $error;
1820 1820
 		} elseif ($globalDebug) echo "Done\n";
1821 1821
 		if ($globalDebug) echo "Owner Brazil: Download...";
1822
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1822
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1823 1823
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1824 1824
 			if ($globalDebug) echo "Add to DB...";
1825
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1825
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1826 1826
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1827 1827
 		if ($error != '') {
1828 1828
 			return $error;
1829 1829
 		} elseif ($globalDebug) echo "Done\n";
1830 1830
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1831
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1831
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1832 1832
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1833 1833
 			if ($globalDebug) echo "Add to DB...";
1834
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1834
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1835 1835
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1836 1836
 		if ($error != '') {
1837 1837
 			return $error;
1838 1838
 		} elseif ($globalDebug) echo "Done\n";
1839 1839
 		if ($globalDebug) echo "Owner Croatia: Download...";
1840
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1840
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1841 1841
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1842 1842
 			if ($globalDebug) echo "Add to DB...";
1843
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1843
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1844 1844
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1845 1845
 		if ($error != '') {
1846 1846
 			return $error;
1847 1847
 		} elseif ($globalDebug) echo "Done\n";
1848 1848
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1849
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1849
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1850 1850
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1851 1851
 			if ($globalDebug) echo "Add to DB...";
1852
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1852
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1853 1853
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1854 1854
 		if ($error != '') {
1855 1855
 			return $error;
1856 1856
 		} elseif ($globalDebug) echo "Done\n";
1857 1857
 		if ($globalDebug) echo "Owner Maldives: Download...";
1858
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1858
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1859 1859
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1860 1860
 			if ($globalDebug) echo "Add to DB...";
1861
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1861
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1862 1862
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1863 1863
 		if ($error != '') {
1864 1864
 			return $error;
1865 1865
 		} elseif ($globalDebug) echo "Done\n";
1866 1866
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1867
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1867
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1868 1868
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1869 1869
 			if ($globalDebug) echo "Add to DB...";
1870
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1870
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1871 1871
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1872 1872
 		if ($error != '') {
1873 1873
 			return $error;
1874 1874
 		} elseif ($globalDebug) echo "Done\n";
1875 1875
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1876
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1876
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1877 1877
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1878 1878
 			if ($globalDebug) echo "Add to DB...";
1879
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1879
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1880 1880
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1881 1881
 		if ($error != '') {
1882 1882
 			return $error;
1883 1883
 		} elseif ($globalDebug) echo "Done\n";
1884 1884
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1885
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1885
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1886 1886
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1887 1887
 			if ($globalDebug) echo "Add to DB...";
1888
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1888
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1889 1889
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1890 1890
 		if ($error != '') {
1891 1891
 			return $error;
1892 1892
 		} elseif ($globalDebug) echo "Done\n";
1893 1893
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1894
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1894
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1895 1895
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1896 1896
 			if ($globalDebug) echo "Add to DB...";
1897
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1897
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1898 1898
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1899 1899
 		if ($error != '') {
1900 1900
 			return $error;
1901 1901
 		} elseif ($globalDebug) echo "Done\n";
1902 1902
 		if ($globalDebug) echo "Owner Iceland: Download...";
1903
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1903
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1904 1904
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1905 1905
 			if ($globalDebug) echo "Add to DB...";
1906
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1906
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1907 1907
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1908 1908
 		if ($error != '') {
1909 1909
 			return $error;
1910 1910
 		} elseif ($globalDebug) echo "Done\n";
1911 1911
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1912
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1912
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1913 1913
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1914 1914
 			if ($globalDebug) echo "Add to DB...";
1915
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1915
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1916 1916
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1917 1917
 		if ($error != '') {
1918 1918
 			return $error;
1919 1919
 		} elseif ($globalDebug) echo "Done\n";
1920 1920
 		if ($globalMasterSource) {
1921 1921
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1922
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1922
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1923 1923
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1924 1924
 				if ($globalDebug) echo "Add to DB...";
1925
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1925
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1926 1926
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1927 1927
 			if ($error != '') {
1928 1928
 				return $error;
1929 1929
 			} elseif ($globalDebug) echo "Done\n";
1930 1930
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1931
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1931
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1932 1932
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1933 1933
 				if ($globalDebug) echo "Add to DB...";
1934
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1934
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1935 1935
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1936 1936
 			if ($error != '') {
1937 1937
 				return $error;
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
 		global $tmp_dir, $globalDebug;
1945 1945
 		$error = '';
1946 1946
 		if ($globalDebug) echo "Translation : Download...";
1947
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1947
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1948 1948
 		if (file_exists($tmp_dir.'translation.zip')) {
1949 1949
 			if ($globalDebug) echo "Unzip...";
1950 1950
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
 	public static function update_translation_fam() {
1961 1961
 		global $tmp_dir, $globalDebug;
1962 1962
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1963
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1963
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1964 1964
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1965 1965
 			if ($globalDebug) echo "Gunzip...";
1966 1966
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
 	public static function update_ModeS_fam() {
1976 1976
 		global $tmp_dir, $globalDebug;
1977 1977
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1978
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1978
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1979 1979
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1980 1980
 			if ($globalDebug) echo "Gunzip...";
1981 1981
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1991,9 +1991,9 @@  discard block
 block discarded – undo
1991 1991
 		global $tmp_dir, $globalDebug, $globalOwner;
1992 1992
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1993 1993
 		if ($globalOwner === TRUE) {
1994
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1994
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1995 1995
 		} else {
1996
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1996
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
1997 1997
 		}
1998 1998
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1999 1999
 			if ($globalDebug) echo "Gunzip...";
@@ -2009,7 +2009,7 @@  discard block
 block discarded – undo
2009 2009
 	public static function update_routes_fam() {
2010 2010
 		global $tmp_dir, $globalDebug;
2011 2011
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2012
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2012
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2013 2013
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2014 2014
 			if ($globalDebug) echo "Gunzip...";
2015 2015
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2023,13 +2023,13 @@  discard block
 block discarded – undo
2023 2023
 	}
2024 2024
 	public static function update_marine_identity_fam() {
2025 2025
 		global $tmp_dir, $globalDebug;
2026
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2026
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2027 2027
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2028
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2028
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2029 2029
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2030 2030
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2031 2031
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2032
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2032
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2033 2033
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2034 2034
 					if ($globalDebug) echo "Gunzip...";
2035 2035
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
 	public static function update_banned_fam() {
2050 2050
 		global $tmp_dir, $globalDebug;
2051 2051
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2052
-		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
2052
+		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv', $tmp_dir.'ban_eu.csv');
2053 2053
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2054 2054
 			//if ($globalDebug) echo "Gunzip...";
2055 2055
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2068,18 +2068,18 @@  discard block
 block discarded – undo
2068 2068
 		$error = '';
2069 2069
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2070 2070
 		if ($globalDBdriver == 'mysql') {
2071
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2071
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2072 2072
 		} else {
2073
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2073
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2074 2074
 		}
2075 2075
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2076
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2076
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2077 2077
 			$airspace_md5 = $airspace_md5_file[0];
2078 2078
 			if (!update_db::check_airspace_version($airspace_md5)) {
2079 2079
 				if ($globalDBdriver == 'mysql') {
2080
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2080
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2081 2081
 				} else {
2082
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2082
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2083 2083
 				}
2084 2084
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2085 2085
 					if ($globalDebug) echo "Gunzip...";
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
 						try {
2092 2092
 							$sth = $Connection->db->prepare($query);
2093 2093
     	    	    					$sth->execute();
2094
-			            		} catch(PDOException $e) {
2094
+			            		} catch (PDOException $e) {
2095 2095
 							return "error : ".$e->getMessage();
2096 2096
 		            			}
2097 2097
 		    			}
@@ -2109,15 +2109,15 @@  discard block
 block discarded – undo
2109 2109
 	public static function update_tle() {
2110 2110
 		global $tmp_dir, $globalDebug;
2111 2111
 		if ($globalDebug) echo "Download TLE : Download...";
2112
-		$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',
2113
-		'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',
2114
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2112
+		$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',
2113
+		'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',
2114
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2115 2115
 		foreach ($alltle as $filename) {
2116 2116
 			if ($globalDebug) echo "downloading ".$filename.'...';
2117
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2117
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2118 2118
 			if (file_exists($tmp_dir.$filename)) {
2119 2119
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2120
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2120
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2121 2121
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2122 2122
 			if ($error != '') {
2123 2123
 				echo $error."\n";
@@ -2130,32 +2130,32 @@  discard block
 block discarded – undo
2130 2130
 		global $tmp_dir, $globalDebug;
2131 2131
 		$error = '';
2132 2132
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2133
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2133
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2134 2134
 		if (file_exists($tmp_dir.'models.md5sum')) {
2135 2135
 			if ($globalDebug) echo "Check files...\n";
2136 2136
 			$newmodelsdb = array();
2137
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2138
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2137
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2138
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2139 2139
 					$model = trim($row[2]);
2140 2140
 					$newmodelsdb[$model] = trim($row[0]);
2141 2141
 				}
2142 2142
 			}
2143 2143
 			$modelsdb = array();
2144 2144
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2145
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2146
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2145
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2146
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2147 2147
 						$model = trim($row[2]);
2148 2148
 						$modelsdb[$model] = trim($row[0]);
2149 2149
 					}
2150 2150
 				}
2151 2151
 			}
2152
-			$diff = array_diff($newmodelsdb,$modelsdb);
2152
+			$diff = array_diff($newmodelsdb, $modelsdb);
2153 2153
 			foreach ($diff as $key => $value) {
2154 2154
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2155
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2155
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2156 2156
 				
2157 2157
 			}
2158
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2158
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2159 2159
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2160 2160
 		if ($error != '') {
2161 2161
 			return $error;
@@ -2167,32 +2167,32 @@  discard block
 block discarded – undo
2167 2167
 		global $tmp_dir, $globalDebug;
2168 2168
 		$error = '';
2169 2169
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2170
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2170
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2171 2171
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2172 2172
 			if ($globalDebug) echo "Check files...\n";
2173 2173
 			$newmodelsdb = array();
2174
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2175
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2174
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2175
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2176 2176
 					$model = trim($row[2]);
2177 2177
 					$newmodelsdb[$model] = trim($row[0]);
2178 2178
 				}
2179 2179
 			}
2180 2180
 			$modelsdb = array();
2181 2181
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2182
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2183
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2182
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2183
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2184 2184
 						$model = trim($row[2]);
2185 2185
 						$modelsdb[$model] = trim($row[0]);
2186 2186
 					}
2187 2187
 				}
2188 2188
 			}
2189
-			$diff = array_diff($newmodelsdb,$modelsdb);
2189
+			$diff = array_diff($newmodelsdb, $modelsdb);
2190 2190
 			foreach ($diff as $key => $value) {
2191 2191
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2192
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2192
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2193 2193
 				
2194 2194
 			}
2195
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2195
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2196 2196
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2197 2197
 		if ($error != '') {
2198 2198
 			return $error;
@@ -2204,32 +2204,32 @@  discard block
 block discarded – undo
2204 2204
 		global $tmp_dir, $globalDebug;
2205 2205
 		$error = '';
2206 2206
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2207
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2207
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2208 2208
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2209 2209
 			if ($globalDebug) echo "Check files...\n";
2210 2210
 			$newmodelsdb = array();
2211
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2212
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2211
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2212
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2213 2213
 					$model = trim($row[2]);
2214 2214
 					$newmodelsdb[$model] = trim($row[0]);
2215 2215
 				}
2216 2216
 			}
2217 2217
 			$modelsdb = array();
2218 2218
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2219
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2220
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2219
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2220
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2221 2221
 						$model = trim($row[2]);
2222 2222
 						$modelsdb[$model] = trim($row[0]);
2223 2223
 					}
2224 2224
 				}
2225 2225
 			}
2226
-			$diff = array_diff($newmodelsdb,$modelsdb);
2226
+			$diff = array_diff($newmodelsdb, $modelsdb);
2227 2227
 			foreach ($diff as $key => $value) {
2228 2228
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2229
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2229
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2230 2230
 				
2231 2231
 			}
2232
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2232
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2233 2233
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2234 2234
 		if ($error != '') {
2235 2235
 			return $error;
@@ -2252,8 +2252,8 @@  discard block
 block discarded – undo
2252 2252
 		*/
2253 2253
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2254 2254
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2255
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2256
-		    $result = fread($fh,100000000);
2255
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2256
+		    $result = fread($fh, 100000000);
2257 2257
 		    //echo $result;
2258 2258
 		    //var_dump(str_get_html($result));
2259 2259
 		    //print_r(self::table2array($result));
@@ -2271,23 +2271,23 @@  discard block
 block discarded – undo
2271 2271
 			$Connection = new Connection();
2272 2272
 			$sth = $Connection->db->prepare($query);
2273 2273
                         $sth->execute();
2274
-                } catch(PDOException $e) {
2274
+                } catch (PDOException $e) {
2275 2275
                         return "error : ".$e->getMessage();
2276 2276
                 }
2277 2277
 
2278 2278
 		$error = '';
2279 2279
 		if ($globalDebug) echo "Notam : Download...";
2280
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2280
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2281 2281
 		if (file_exists($tmp_dir.'notam.rss')) {
2282
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2282
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2283 2283
 			foreach ($notams['channel']['item'] as $notam) {
2284
-				$title = explode(':',$notam['title']);
2284
+				$title = explode(':', $notam['title']);
2285 2285
 				$data['ref'] = trim($title[0]);
2286 2286
 				unset($title[0]);
2287
-				$data['title'] = trim(implode(':',$title));
2288
-				$description = strip_tags($notam['description'],'<pre>');
2289
-				preg_match(':^(.*?)<pre>:',$description,$match);
2290
-				$q = explode('/',$match[1]);
2287
+				$data['title'] = trim(implode(':', $title));
2288
+				$description = strip_tags($notam['description'], '<pre>');
2289
+				preg_match(':^(.*?)<pre>:', $description, $match);
2290
+				$q = explode('/', $match[1]);
2291 2291
 				$data['fir'] = $q[0];
2292 2292
 				$data['code'] = $q[1];
2293 2293
 				$ifrvfr = $q[2];
@@ -2303,30 +2303,30 @@  discard block
 block discarded – undo
2303 2303
 				$data['lower_limit'] = $q[5];
2304 2304
 				$data['upper_limit'] = $q[6];
2305 2305
 				$latlonrad = $q[7];
2306
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2307
-				$latitude = $Common->convertDec($las,'latitude');
2308
-				$longitude = $Common->convertDec($lns,'longitude');
2306
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2307
+				$latitude = $Common->convertDec($las, 'latitude');
2308
+				$longitude = $Common->convertDec($lns, 'longitude');
2309 2309
 				if ($lac == 'S') $latitude = '-'.$latitude;
2310 2310
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2311 2311
 				$data['center_latitude'] = $latitude;
2312 2312
 				$data['center_longitude'] = $longitude;
2313 2313
 				$data['radius'] = intval($radius);
2314 2314
 				
2315
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2315
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2316 2316
 				$data['text'] = $match[1];
2317
-				preg_match(':</pre>(.*?)$:',$description,$match);
2317
+				preg_match(':</pre>(.*?)$:', $description, $match);
2318 2318
 				$fromto = $match[1];
2319
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2319
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2320 2320
 				$fromall = trim($match[1]);
2321
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2321
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2322 2322
 				$from = trim($match[1]);
2323
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2324
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2323
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2324
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2325 2325
 				$toall = trim($match[1]);
2326
-				if (!preg_match(':Permanent:',$toall)) {
2327
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2326
+				if (!preg_match(':Permanent:', $toall)) {
2327
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2328 2328
 					$to = trim($match[1]);
2329
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2329
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2330 2330
 					$data['permanent'] = 0;
2331 2331
 				} else {
2332 2332
 				    $data['date_end'] = NULL;
@@ -2334,7 +2334,7 @@  discard block
 block discarded – undo
2334 2334
 				}
2335 2335
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2336 2336
 				$NOTAM = new NOTAM();
2337
-				$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']);
2337
+				$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']);
2338 2338
 				unset($data);
2339 2339
 			} 
2340 2340
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2357,16 +2357,16 @@  discard block
 block discarded – undo
2357 2357
 				$Connection = new Connection();
2358 2358
 				$sth = $Connection->db->prepare($query);
2359 2359
 				$sth->execute();
2360
-			} catch(PDOException $e) {
2360
+			} catch (PDOException $e) {
2361 2361
 				return "error : ".$e->getMessage();
2362 2362
 			}
2363 2363
 		}
2364 2364
 		$Common = new Common();
2365 2365
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2366
-		$airspace_json = json_decode($airspace_lst,true);
2366
+		$airspace_json = json_decode($airspace_lst, true);
2367 2367
 		foreach ($airspace_json['records'] as $airspace) {
2368 2368
 			if ($globalDebug) echo $airspace['name']."...\n";
2369
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2369
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2370 2370
 			if (file_exists($tmp_dir.$airspace['name'])) {
2371 2371
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2372 2372
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 				$Connection = new Connection();
2389 2389
 				$sth = $Connection->db->prepare($query);
2390 2390
 				$sth->execute(array(':new' => $new, ':old' => $old));
2391
-			} catch(PDOException $e) {
2391
+			} catch (PDOException $e) {
2392 2392
 				return "error : ".$e->getMessage();
2393 2393
 			}
2394 2394
 		}
@@ -2405,7 +2405,7 @@  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
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2420,7 +2420,7 @@  discard block
 block discarded – undo
2420 2420
 			$Connection = new Connection();
2421 2421
 			$sth = $Connection->db->prepare($query);
2422 2422
                         $sth->execute();
2423
-                } catch(PDOException $e) {
2423
+                } catch (PDOException $e) {
2424 2424
                         return "error : ".$e->getMessage();
2425 2425
                 }
2426 2426
 	}
@@ -2431,7 +2431,7 @@  discard block
 block discarded – undo
2431 2431
 			$Connection = new Connection();
2432 2432
 			$sth = $Connection->db->prepare($query);
2433 2433
                         $sth->execute(array(':version' => $version));
2434
-                } catch(PDOException $e) {
2434
+                } catch (PDOException $e) {
2435 2435
                         return "error : ".$e->getMessage();
2436 2436
                 }
2437 2437
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2445,7 +2445,7 @@  discard block
 block discarded – undo
2445 2445
 			$Connection = new Connection();
2446 2446
 			$sth = $Connection->db->prepare($query);
2447 2447
                         $sth->execute(array(':version' => $version));
2448
-                } catch(PDOException $e) {
2448
+                } catch (PDOException $e) {
2449 2449
                         return "error : ".$e->getMessage();
2450 2450
                 }
2451 2451
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
 			$Connection = new Connection();
2462 2462
 			$sth = $Connection->db->prepare($query);
2463 2463
                         $sth->execute(array(':version' => $version));
2464
-                } catch(PDOException $e) {
2464
+                } catch (PDOException $e) {
2465 2465
                         return "error : ".$e->getMessage();
2466 2466
                 }
2467 2467
 	}
@@ -2473,7 +2473,7 @@  discard block
 block discarded – undo
2473 2473
 			$Connection = new Connection();
2474 2474
 			$sth = $Connection->db->prepare($query);
2475 2475
                         $sth->execute(array(':version' => $version));
2476
-                } catch(PDOException $e) {
2476
+                } catch (PDOException $e) {
2477 2477
                         return "error : ".$e->getMessage();
2478 2478
                 }
2479 2479
 	}
@@ -2489,7 +2489,7 @@  discard block
 block discarded – undo
2489 2489
 			$Connection = new Connection();
2490 2490
 			$sth = $Connection->db->prepare($query);
2491 2491
                         $sth->execute();
2492
-                } catch(PDOException $e) {
2492
+                } catch (PDOException $e) {
2493 2493
                         return "error : ".$e->getMessage();
2494 2494
                 }
2495 2495
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2504,7 +2504,7 @@  discard block
 block discarded – undo
2504 2504
 			$Connection = new Connection();
2505 2505
 			$sth = $Connection->db->prepare($query);
2506 2506
                         $sth->execute();
2507
-                } catch(PDOException $e) {
2507
+                } catch (PDOException $e) {
2508 2508
                         return "error : ".$e->getMessage();
2509 2509
                 }
2510 2510
 	}
@@ -2519,7 +2519,7 @@  discard block
 block discarded – undo
2519 2519
 			$Connection = new Connection();
2520 2520
 			$sth = $Connection->db->prepare($query);
2521 2521
                         $sth->execute();
2522
-                } catch(PDOException $e) {
2522
+                } catch (PDOException $e) {
2523 2523
                         return "error : ".$e->getMessage();
2524 2524
                 }
2525 2525
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2534,7 +2534,7 @@  discard block
 block discarded – undo
2534 2534
 			$Connection = new Connection();
2535 2535
 			$sth = $Connection->db->prepare($query);
2536 2536
                         $sth->execute();
2537
-                } catch(PDOException $e) {
2537
+                } catch (PDOException $e) {
2538 2538
                         return "error : ".$e->getMessage();
2539 2539
                 }
2540 2540
 	}
@@ -2550,7 +2550,7 @@  discard block
 block discarded – undo
2550 2550
 			$Connection = new Connection();
2551 2551
 			$sth = $Connection->db->prepare($query);
2552 2552
                         $sth->execute();
2553
-                } catch(PDOException $e) {
2553
+                } catch (PDOException $e) {
2554 2554
                         return "error : ".$e->getMessage();
2555 2555
                 }
2556 2556
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2565,7 +2565,7 @@  discard block
 block discarded – undo
2565 2565
 			$Connection = new Connection();
2566 2566
 			$sth = $Connection->db->prepare($query);
2567 2567
                         $sth->execute();
2568
-                } catch(PDOException $e) {
2568
+                } catch (PDOException $e) {
2569 2569
                         return "error : ".$e->getMessage();
2570 2570
                 }
2571 2571
 	}
@@ -2580,7 +2580,7 @@  discard block
 block discarded – undo
2580 2580
 			$Connection = new Connection();
2581 2581
 			$sth = $Connection->db->prepare($query);
2582 2582
                         $sth->execute();
2583
-                } catch(PDOException $e) {
2583
+                } catch (PDOException $e) {
2584 2584
                         return "error : ".$e->getMessage();
2585 2585
                 }
2586 2586
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
 			$Connection = new Connection();
2596 2596
 			$sth = $Connection->db->prepare($query);
2597 2597
                         $sth->execute();
2598
-                } catch(PDOException $e) {
2598
+                } catch (PDOException $e) {
2599 2599
                         return "error : ".$e->getMessage();
2600 2600
                 }
2601 2601
 	}
@@ -2610,7 +2610,7 @@  discard block
 block discarded – undo
2610 2610
 			$Connection = new Connection();
2611 2611
 			$sth = $Connection->db->prepare($query);
2612 2612
                         $sth->execute();
2613
-                } catch(PDOException $e) {
2613
+                } catch (PDOException $e) {
2614 2614
                         return "error : ".$e->getMessage();
2615 2615
                 }
2616 2616
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -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
 	}
@@ -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
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
 			$Connection = new Connection();
2656 2656
 			$sth = $Connection->db->prepare($query);
2657 2657
                         $sth->execute();
2658
-                } catch(PDOException $e) {
2658
+                } catch (PDOException $e) {
2659 2659
                         return "error : ".$e->getMessage();
2660 2660
                 }
2661 2661
 	}
@@ -2670,7 +2670,7 @@  discard block
 block discarded – undo
2670 2670
 			$Connection = new Connection();
2671 2671
 			$sth = $Connection->db->prepare($query);
2672 2672
                         $sth->execute();
2673
-                } catch(PDOException $e) {
2673
+                } catch (PDOException $e) {
2674 2674
                         return "error : ".$e->getMessage();
2675 2675
                 }
2676 2676
 	}
@@ -2685,7 +2685,7 @@  discard block
 block discarded – undo
2685 2685
 			$Connection = new Connection();
2686 2686
 			$sth = $Connection->db->prepare($query);
2687 2687
                         $sth->execute();
2688
-                } catch(PDOException $e) {
2688
+                } catch (PDOException $e) {
2689 2689
                         return "error : ".$e->getMessage();
2690 2690
                 }
2691 2691
 	}
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Spacing   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 		global $globalDBdriver;
1109 1109
 		$Connection = new Connection();
1110 1110
 		$error = '';
1111
-		if (!$Connection->checkColumnName('atc','format_source')) {
1111
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1112 1112
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1113 1113
 			try {
1114 1114
 				$sth = $Connection->db->prepare($query);
1115 1115
 				$sth->execute();
1116
-			} catch(PDOException $e) {
1116
+			} catch (PDOException $e) {
1117 1117
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1118 1118
 			}
1119 1119
 		}
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $Connection->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1126 1126
 		}
1127 1127
 		return $error;
@@ -1131,13 +1131,13 @@  discard block
 block discarded – undo
1131 1131
 		global $globalDBdriver;
1132 1132
 		$Connection = new Connection();
1133 1133
 		$error = '';
1134
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1134
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1135 1135
 			// Add forsource to airlines
1136 1136
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1137 1137
 			try {
1138 1138
 				$sth = $Connection->db->prepare($query);
1139 1139
 				$sth->execute();
1140
-			} catch(PDOException $e) {
1140
+			} catch (PDOException $e) {
1141 1141
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1142 1142
 			}
1143 1143
 			// Add unique key
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			try {
1150 1150
 				$sth = $Connection->db->prepare($query);
1151 1151
 				$sth->execute();
1152
-			} catch(PDOException $e) {
1152
+			} catch (PDOException $e) {
1153 1153
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1154 1154
 			}
1155 1155
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		try {
1158 1158
 			$sth = $Connection->db->prepare($query);
1159 1159
 			$sth->execute();
1160
-		} catch(PDOException $e) {
1160
+		} catch (PDOException $e) {
1161 1161
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1162 1162
 		}
1163 1163
 		return $error;
@@ -1167,23 +1167,23 @@  discard block
 block discarded – undo
1167 1167
 		global $globalDBdriver;
1168 1168
 		$Connection = new Connection();
1169 1169
 		$error = '';
1170
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1170
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1171 1171
 			// Add unique key
1172 1172
 			$query = "alter table spotter_live add index(latitude,longitude)";
1173 1173
 			try {
1174 1174
 				$sth = $Connection->db->prepare($query);
1175 1175
 				$sth->execute();
1176
-			} catch(PDOException $e) {
1176
+			} catch (PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179 1179
                 }
1180
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1180
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1183 1183
 			try {
1184 1184
 				$sth = $Connection->db->prepare($query);
1185 1185
 				$sth->execute();
1186
-			} catch(PDOException $e) {
1186
+			} catch (PDOException $e) {
1187 1187
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1188 1188
 			}
1189 1189
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		try {
1200 1200
 			$sth = $Connection->db->prepare($query);
1201 1201
 			$sth->execute();
1202
-		} catch(PDOException $e) {
1202
+		} catch (PDOException $e) {
1203 1203
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1204 1204
 		}
1205 1205
 		return $error;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 		global $globalDBdriver;
1210 1210
 		$Connection = new Connection();
1211 1211
 		$error = '';
1212
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1212
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1213 1213
 			// drop mfr to aircraft
1214 1214
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1215 1215
 			try {
1216 1216
 				$sth = $Connection->db->prepare($query);
1217 1217
 				$sth->execute();
1218
-			} catch(PDOException $e) {
1218
+			} catch (PDOException $e) {
1219 1219
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1220 1220
 			}
1221 1221
 		}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		try {
1232 1232
 			$sth = $Connection->db->prepare($query);
1233 1233
 			$sth->execute();
1234
-		} catch(PDOException $e) {
1234
+		} catch (PDOException $e) {
1235 1235
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1236 1236
 		}
1237 1237
 		return $error;
@@ -1241,33 +1241,33 @@  discard block
 block discarded – undo
1241 1241
 		global $globalDBdriver;
1242 1242
 		$Connection = new Connection();
1243 1243
 		$error = '';
1244
-		if (!$Connection->indexExists('notam','ref_idx')) {
1244
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1245 1245
 			// Add index key
1246 1246
 			$query = "create index ref_idx on notam (ref)";
1247 1247
 			try {
1248 1248
 				$sth = $Connection->db->prepare($query);
1249 1249
 				$sth->execute();
1250
-			} catch(PDOException $e) {
1250
+			} catch (PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253 1253
                 }
1254
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1254
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
1257 1257
 			try {
1258 1258
 				$sth = $Connection->db->prepare($query);
1259 1259
 				$sth->execute();
1260
-			} catch(PDOException $e) {
1260
+			} catch (PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263 1263
                 }
1264
-		if (!$Connection->indexExists('accidents','rdts')) {
1264
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
1267 1267
 			try {
1268 1268
 				$sth = $Connection->db->prepare($query);
1269 1269
 				$sth->execute();
1270
-			} catch(PDOException $e) {
1270
+			} catch (PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273 1273
                 }
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		try {
1277 1277
 			$sth = $Connection->db->prepare($query);
1278 1278
 			$sth->execute();
1279
-		} catch(PDOException $e) {
1279
+		} catch (PDOException $e) {
1280 1280
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1281 1281
 		}
1282 1282
 		return $error;
@@ -1286,23 +1286,23 @@  discard block
 block discarded – undo
1286 1286
 		global $globalDBdriver;
1287 1287
 		$Connection = new Connection();
1288 1288
 		$error = '';
1289
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1289
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1290 1290
 			// Add airline_name to accidents
1291 1291
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1292 1292
 			try {
1293 1293
 				$sth = $Connection->db->prepare($query);
1294 1294
 				$sth->execute();
1295
-			} catch(PDOException $e) {
1295
+			} catch (PDOException $e) {
1296 1296
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1297 1297
 			}
1298 1298
 		}
1299
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1299
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1300 1300
 			// Add airline_icao to accidents
1301 1301
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1302 1302
 			try {
1303 1303
 				$sth = $Connection->db->prepare($query);
1304 1304
 				$sth->execute();
1305
-			} catch(PDOException $e) {
1305
+			} catch (PDOException $e) {
1306 1306
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1307 1307
 			}
1308 1308
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		try {
1311 1311
 			$sth = $Connection->db->prepare($query);
1312 1312
 			$sth->execute();
1313
-		} catch(PDOException $e) {
1313
+		} catch (PDOException $e) {
1314 1314
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1315 1315
 		}
1316 1316
 		return $error;
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1321 1321
 		$Connection = new Connection();
1322 1322
 		$error = '';
1323
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1323
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1324 1324
 			// Add alliance to airlines
1325 1325
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1326 1326
 			try {
1327 1327
 				$sth = $Connection->db->prepare($query);
1328 1328
 				$sth->execute();
1329
-			} catch(PDOException $e) {
1329
+			} catch (PDOException $e) {
1330 1330
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1331 1331
 			}
1332 1332
 		}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		try {
1354 1354
 			$sth = $Connection->db->prepare($query);
1355 1355
 			$sth->execute();
1356
-		} catch(PDOException $e) {
1356
+		} catch (PDOException $e) {
1357 1357
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1358 1358
 		}
1359 1359
 		return $error;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1364 1364
 		$Connection = new Connection();
1365 1365
 		$error = '';
1366
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1366
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1367 1367
 			// Add ban_eu to airlines
1368 1368
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1369 1369
 			try {
1370 1370
 				$sth = $Connection->db->prepare($query);
1371 1371
 				$sth->execute();
1372
-			} catch(PDOException $e) {
1372
+			} catch (PDOException $e) {
1373 1373
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1374 1374
 			}
1375 1375
 		}
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		try {
1378 1378
 			$sth = $Connection->db->prepare($query);
1379 1379
 			$sth->execute();
1380
-		} catch(PDOException $e) {
1380
+		} catch (PDOException $e) {
1381 1381
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1382 1382
 		}
1383 1383
 		return $error;
@@ -1388,19 +1388,19 @@  discard block
 block discarded – undo
1388 1388
 		$Connection = new Connection();
1389 1389
 		$error = '';
1390 1390
 		if ($globalDBdriver == 'mysql') {
1391
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1391
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1392 1392
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1393 1393
 				try {
1394 1394
 					$sth = $Connection->db->prepare($query);
1395 1395
 					$sth->execute();
1396
-				} catch(PDOException $e) {
1396
+				} catch (PDOException $e) {
1397 1397
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1398 1398
 				}
1399 1399
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1400 1400
 				try {
1401 1401
 					$sth = $Connection->db->prepare($query);
1402 1402
 					$sth->execute();
1403
-				} catch(PDOException $e) {
1403
+				} catch (PDOException $e) {
1404 1404
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1405 1405
 				}
1406 1406
 				
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 				try {
1409 1409
 					$sth = $Connection->db->prepare($query);
1410 1410
 					$sth->execute();
1411
-				} catch(PDOException $e) {
1411
+				} catch (PDOException $e) {
1412 1412
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1413 1413
 				}
1414 1414
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 				try {
1460 1460
 					$sth = $Connection->db->prepare($query);
1461 1461
 					$sth->execute();
1462
-				} catch(PDOException $e) {
1462
+				} catch (PDOException $e) {
1463 1463
 					return "error (fix date) : ".$e->getMessage()."\n";
1464 1464
 				}
1465 1465
 			}
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 		try {
1545 1545
 			$sth = $Connection->db->prepare($query);
1546 1546
 			$sth->execute();
1547
-		} catch(PDOException $e) {
1547
+		} catch (PDOException $e) {
1548 1548
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1549 1549
 		}
1550 1550
 		return $error;
@@ -1553,13 +1553,13 @@  discard block
 block discarded – undo
1553 1553
 		global $globalDBdriver;
1554 1554
 		$Connection = new Connection();
1555 1555
 		$error = '';
1556
-		if (!$Connection->indexExists('accidents','type')) {
1556
+		if (!$Connection->indexExists('accidents', 'type')) {
1557 1557
 			// Add index key
1558 1558
 			$query = "create index type on accidents (type,date)";
1559 1559
 			try {
1560 1560
 				$sth = $Connection->db->prepare($query);
1561 1561
 				$sth->execute();
1562
-			} catch(PDOException $e) {
1562
+			} catch (PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565 1565
                 }
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
1569 1569
 			$sth->execute();
1570
-		} catch(PDOException $e) {
1570
+		} catch (PDOException $e) {
1571 1571
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1572 1572
 		}
1573 1573
 		return $error;
@@ -1577,12 +1577,12 @@  discard block
 block discarded – undo
1577 1577
 		global $globalDBdriver;
1578 1578
 		$Connection = new Connection();
1579 1579
 		$error = '';
1580
-		if (!$Connection->checkColumnName('aircraft_modes','source_type')) {
1580
+		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) {
1581 1581
 			$query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'";
1582 1582
 			try {
1583 1583
 				$sth = $Connection->db->prepare($query);
1584 1584
 				$sth->execute();
1585
-			} catch(PDOException $e) {
1585
+			} catch (PDOException $e) {
1586 1586
 				return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n";
1587 1587
 			}
1588 1588
 		}
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 		try {
1649 1649
 			$sth = $Connection->db->prepare($query);
1650 1650
 			$sth->execute();
1651
-		} catch(PDOException $e) {
1651
+		} catch (PDOException $e) {
1652 1652
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1653 1653
 		}
1654 1654
 		return $error;
@@ -1691,13 +1691,13 @@  discard block
 block discarded – undo
1691 1691
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1692 1692
 			if ($error != '') return $error;
1693 1693
 		}
1694
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1694
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1695 1695
 			// Add index key
1696 1696
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1697 1697
 			try {
1698 1698
 				$sth = $Connection->db->prepare($query);
1699 1699
 				$sth->execute();
1700
-			} catch(PDOException $e) {
1700
+			} catch (PDOException $e) {
1701 1701
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1702 1702
 			}
1703 1703
                 }
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 		try {
1706 1706
 			$sth = $Connection->db->prepare($query);
1707 1707
 			$sth->execute();
1708
-		} catch(PDOException $e) {
1708
+		} catch (PDOException $e) {
1709 1709
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1710 1710
 		}
1711 1711
 		return $error;
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 		    try {
1728 1728
             		$sth = $Connection->db->prepare($query);
1729 1729
 		        $sth->execute();
1730
-		    } catch(PDOException $e) {
1730
+		    } catch (PDOException $e) {
1731 1731
 			return "error : ".$e->getMessage()."\n";
1732 1732
     		    }
1733 1733
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.