Completed
Push — master ( 4b9f50...005bcb )
by Yannick
28:37
created
scripts/daemon-spotter.php 1 patch
Indentation   +954 added lines, -954 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 if (isset($options['idsource'])) $id_source = $options['idsource'];
80 80
 else $id_source = 1;
81 81
 if (isset($globalServer) && $globalServer) {
82
-    if ($globalDebug) echo "Using Server Mode\n";
83
-    $SI=new SpotterServer();
82
+	if ($globalDebug) echo "Using Server Mode\n";
83
+	$SI=new SpotterServer();
84 84
 /*
85 85
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
86 86
     $SI = new adsb2aprs();
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 } else $SI=new SpotterImport($Connection->db);
90 90
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
91 91
 if (isset($globalMarine) && $globalMarine) {
92
-    $AIS = new AIS();
93
-    $MI = new MarineImport($Connection->db);
92
+	$AIS = new AIS();
93
+	$MI = new MarineImport($Connection->db);
94 94
 }
95 95
 //$APRS=new APRS($Connection->db);
96 96
 $SBS=new SBS();
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 //$servertz = system('date +%Z');
102 102
 // signal handler - playing nice with sockets and dump1090
103 103
 if (function_exists('pcntl_fork')) {
104
-    pcntl_signal(SIGINT,  function() {
105
-        global $sockets;
106
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
107
-        die("Bye!\n");
108
-    });
109
-    pcntl_signal_dispatch();
104
+	pcntl_signal(SIGINT,  function() {
105
+		global $sockets;
106
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
107
+		die("Bye!\n");
108
+	});
109
+	pcntl_signal_dispatch();
110 110
 }
111 111
 
112 112
 // let's try and connect
@@ -116,36 +116,36 @@  discard block
 block discarded – undo
116 116
 $reset = 0;
117 117
 
118 118
 function connect_all($hosts) {
119
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
120
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
121
-    $reset++;
122
-    if ($globalDebug) echo 'Connect to all...'."\n";
123
-    foreach ($hosts as $id => $value) {
119
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
120
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
121
+	$reset++;
122
+	if ($globalDebug) echo 'Connect to all...'."\n";
123
+	foreach ($hosts as $id => $value) {
124 124
 	$host = $value['host'];
125 125
 	$globalSources[$id]['last_exec'] = 0;
126 126
 	// Here we check type of source(s)
127 127
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
128
-            if (preg_match('/deltadb.txt$/i',$host)) {
129
-        	//$formats[$id] = 'deltadbtxt';
130
-        	$globalSources[$id]['format'] = 'deltadbtxt';
131
-        	//$last_exec['deltadbtxt'] = 0;
132
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
133
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
134
-        	//$formats[$id] = 'vatsimtxt';
135
-        	$globalSources[$id]['format'] = 'vatsimtxt';
136
-        	//$last_exec['vatsimtxt'] = 0;
137
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
138
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
139
-        	//$formats[$id] = 'aircraftlistjson';
140
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
141
-        	//$last_exec['aircraftlistjson'] = 0;
142
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
143
-    	    } else if (preg_match('/opensky/i',$host)) {
144
-        	//$formats[$id] = 'aircraftlistjson';
145
-        	$globalSources[$id]['format'] = 'opensky';
146
-        	//$last_exec['aircraftlistjson'] = 0;
147
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
148
-    	    /*
128
+			if (preg_match('/deltadb.txt$/i',$host)) {
129
+			//$formats[$id] = 'deltadbtxt';
130
+			$globalSources[$id]['format'] = 'deltadbtxt';
131
+			//$last_exec['deltadbtxt'] = 0;
132
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
133
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
134
+			//$formats[$id] = 'vatsimtxt';
135
+			$globalSources[$id]['format'] = 'vatsimtxt';
136
+			//$last_exec['vatsimtxt'] = 0;
137
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
138
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
139
+			//$formats[$id] = 'aircraftlistjson';
140
+			$globalSources[$id]['format'] = 'aircraftlistjson';
141
+			//$last_exec['aircraftlistjson'] = 0;
142
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
143
+			} else if (preg_match('/opensky/i',$host)) {
144
+			//$formats[$id] = 'aircraftlistjson';
145
+			$globalSources[$id]['format'] = 'opensky';
146
+			//$last_exec['aircraftlistjson'] = 0;
147
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
148
+			/*
149 149
     	    // Disabled for now, site change source format
150 150
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
151 151
         	//$formats[$id] = 'radarvirtueljson';
@@ -157,121 +157,121 @@  discard block
 block discarded – undo
157 157
         	    exit(0);
158 158
         	}
159 159
     	    */
160
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
161
-        	//$formats[$id] = 'planeupdatefaa';
162
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
163
-        	//$last_exec['planeupdatefaa'] = 0;
164
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
165
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
166
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
167
-        	    exit(0);
168
-        	}
169
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
170
-        	//$formats[$id] = 'phpvmacars';
171
-        	$globalSources[$id]['format'] = 'phpvmacars';
172
-        	//$last_exec['phpvmacars'] = 0;
173
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
174
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
175
-        	//$formats[$id] = 'phpvmacars';
176
-        	$globalSources[$id]['format'] = 'vam';
177
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
178
-            } else if (preg_match('/whazzup/i',$host)) {
179
-        	//$formats[$id] = 'whazzup';
180
-        	$globalSources[$id]['format'] = 'whazzup';
181
-        	//$last_exec['whazzup'] = 0;
182
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
183
-            } else if (preg_match('/blitzortung/i',$host)) {
184
-        	$globalSources[$id]['format'] = 'blitzortung';
185
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
186
-            } else if (preg_match('/airwhere/i',$host)) {
187
-        	$globalSources[$id]['format'] = 'airwhere';
188
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
189
-            } else if (preg_match('/recentpireps/i',$host)) {
190
-        	//$formats[$id] = 'pirepsjson';
191
-        	$globalSources[$id]['format'] = 'pirepsjson';
192
-        	//$last_exec['pirepsjson'] = 0;
193
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
194
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
195
-        	//$formats[$id] = 'fr24json';
196
-        	$globalSources[$id]['format'] = 'fr24json';
197
-        	//$last_exec['fr24json'] = 0;
198
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
199
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
200
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
201
-        	    exit(0);
202
-        	}
203
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
204
-        	//$formats[$id] = 'fr24json';
205
-        	$globalSources[$id]['format'] = 'myshiptracking';
206
-        	//$last_exec['fr24json'] = 0;
207
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            //} else if (preg_match('/10001/',$host)) {
213
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
214
-        	//$formats[$id] = 'tsv';
215
-        	$globalSources[$id]['format'] = 'tsv';
216
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
217
-            }
218
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
219
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
220
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
221
-    		    if ($idf !== false) {
222
-    			$httpfeeds[$id] = $idf;
223
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
224
-    		    }
225
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
226
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
227
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
228
-	    $hostport = explode(':',$host);
229
-	    if (isset($hostport[1])) {
160
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
161
+			//$formats[$id] = 'planeupdatefaa';
162
+			$globalSources[$id]['format'] = 'planeupdatefaa';
163
+			//$last_exec['planeupdatefaa'] = 0;
164
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
165
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
166
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
167
+				exit(0);
168
+			}
169
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
170
+			//$formats[$id] = 'phpvmacars';
171
+			$globalSources[$id]['format'] = 'phpvmacars';
172
+			//$last_exec['phpvmacars'] = 0;
173
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
174
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
175
+			//$formats[$id] = 'phpvmacars';
176
+			$globalSources[$id]['format'] = 'vam';
177
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
178
+			} else if (preg_match('/whazzup/i',$host)) {
179
+			//$formats[$id] = 'whazzup';
180
+			$globalSources[$id]['format'] = 'whazzup';
181
+			//$last_exec['whazzup'] = 0;
182
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
183
+			} else if (preg_match('/blitzortung/i',$host)) {
184
+			$globalSources[$id]['format'] = 'blitzortung';
185
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
186
+			} else if (preg_match('/airwhere/i',$host)) {
187
+			$globalSources[$id]['format'] = 'airwhere';
188
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
189
+			} else if (preg_match('/recentpireps/i',$host)) {
190
+			//$formats[$id] = 'pirepsjson';
191
+			$globalSources[$id]['format'] = 'pirepsjson';
192
+			//$last_exec['pirepsjson'] = 0;
193
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
194
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
195
+			//$formats[$id] = 'fr24json';
196
+			$globalSources[$id]['format'] = 'fr24json';
197
+			//$last_exec['fr24json'] = 0;
198
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
199
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
200
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
201
+				exit(0);
202
+			}
203
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
204
+			//$formats[$id] = 'fr24json';
205
+			$globalSources[$id]['format'] = 'myshiptracking';
206
+			//$last_exec['fr24json'] = 0;
207
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			//} else if (preg_match('/10001/',$host)) {
213
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
214
+			//$formats[$id] = 'tsv';
215
+			$globalSources[$id]['format'] = 'tsv';
216
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
217
+			}
218
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
219
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
220
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
221
+				if ($idf !== false) {
222
+				$httpfeeds[$id] = $idf;
223
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
224
+				}
225
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
226
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
227
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
228
+		$hostport = explode(':',$host);
229
+		if (isset($hostport[1])) {
230 230
 		$port = $hostport[1];
231 231
 		$hostn = $hostport[0];
232
-	    } else {
232
+		} else {
233 233
 		$port = $globalSources[$id]['port'];
234 234
 		$hostn = $globalSources[$id]['host'];
235
-	    }
236
-	    $Common = new Common();
237
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
238
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
239
-    	    } else {
240
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
241
-	    }
242
-	    if ($s) {
243
-    	        $sockets[$id] = $s;
244
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
245
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
235
+		}
236
+		$Common = new Common();
237
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
238
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
239
+			} else {
240
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
241
+		}
242
+		if ($s) {
243
+				$sockets[$id] = $s;
244
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
245
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
246 246
 			//$formats[$id] = 'aprs';
247 247
 			$globalSources[$id]['format'] = 'aprs';
248 248
 			//$aprs_connect = 0;
249 249
 			//$use_aprs = true;
250
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
250
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
251 251
 			$globalSources[$id]['format'] = 'vrstcp';
252
-    		    } elseif ($port == '10001') {
253
-        		//$formats[$id] = 'tsv';
254
-        		$globalSources[$id]['format'] = 'tsv';
255
-		    } elseif ($port == '30002') {
256
-        		//$formats[$id] = 'raw';
257
-        		$globalSources[$id]['format'] = 'raw';
258
-		    } elseif ($port == '5001') {
259
-        		//$formats[$id] = 'raw';
260
-        		$globalSources[$id]['format'] = 'flightgearmp';
261
-		    } elseif ($port == '30005') {
252
+				} elseif ($port == '10001') {
253
+				//$formats[$id] = 'tsv';
254
+				$globalSources[$id]['format'] = 'tsv';
255
+			} elseif ($port == '30002') {
256
+				//$formats[$id] = 'raw';
257
+				$globalSources[$id]['format'] = 'raw';
258
+			} elseif ($port == '5001') {
259
+				//$formats[$id] = 'raw';
260
+				$globalSources[$id]['format'] = 'flightgearmp';
261
+			} elseif ($port == '30005') {
262 262
 			// Not yet supported
263
-        		//$formats[$id] = 'beast';
264
-        		$globalSources[$id]['format'] = 'beast';
265
-		    //} else $formats[$id] = 'sbs';
266
-		    } else $globalSources[$id]['format'] = 'sbs';
267
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
263
+				//$formats[$id] = 'beast';
264
+				$globalSources[$id]['format'] = 'beast';
265
+			//} else $formats[$id] = 'sbs';
266
+			} else $globalSources[$id]['format'] = 'sbs';
267
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
268 268
 		}
269 269
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
270
-            } else {
270
+			} else {
271 271
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
272
-    	    }
273
-        }
274
-    }
272
+			}
273
+		}
274
+	}
275 275
 }
276 276
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
277 277
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 //connect_all($globalSources);
295 295
 
296 296
 if (isset($globalProxy) && $globalProxy) {
297
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
297
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
298 298
 } else {
299
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
299
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
300 300
 }
301 301
 
302 302
 // APRS Configuration
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
 	die;
306 306
 }
307 307
 foreach ($globalSources as $key => $source) {
308
-    if (!isset($source['format'])) {
309
-        $globalSources[$key]['format'] = 'auto';
310
-    }
311
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
312
-        unset($globalSources[$key]);
313
-    }
308
+	if (!isset($source['format'])) {
309
+		$globalSources[$key]['format'] = 'auto';
310
+	}
311
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
312
+		unset($globalSources[$key]);
313
+	}
314 314
 }
315 315
 connect_all($globalSources);
316 316
 foreach ($globalSources as $key => $source) {
317
-    if (isset($source['format']) && $source['format'] == 'aprs') {
317
+	if (isset($source['format']) && $source['format'] == 'aprs') {
318 318
 	$aprs_connect = 0;
319 319
 	$use_aprs = true;
320 320
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
321 321
 	break;
322
-    }
322
+	}
323 323
 }
324 324
 
325 325
 if ($use_aprs) {
@@ -360,126 +360,126 @@  discard block
 block discarded – undo
360 360
 
361 361
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
362 362
 while ($i > 0) {
363
-    if (!$globalDaemon) $i = $endtime-time();
364
-    // Delete old ATC
365
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
363
+	if (!$globalDaemon) $i = $endtime-time();
364
+	// Delete old ATC
365
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
366 366
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
367
-        $ATC->deleteOldATC();
368
-    }
367
+		$ATC->deleteOldATC();
368
+	}
369 369
     
370
-    if (count($last_exec) == count($globalSources)) {
370
+	if (count($last_exec) == count($globalSources)) {
371 371
 	$max = $globalMinFetch;
372 372
 	foreach ($last_exec as $last) {
373
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
373
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
374 374
 	}
375 375
 	if ($max != $globalMinFetch) {
376
-	    if ($globalDebug) echo 'Sleeping...'."\n";
377
-	    sleep($globalMinFetch-$max+2);
376
+		if ($globalDebug) echo 'Sleeping...'."\n";
377
+		sleep($globalMinFetch-$max+2);
378
+	}
378 379
 	}
379
-    }
380 380
 
381 381
     
382
-    //foreach ($formats as $id => $value) {
383
-    foreach ($globalSources as $id => $value) {
382
+	//foreach ($formats as $id => $value) {
383
+	foreach ($globalSources as $id => $value) {
384 384
 	date_default_timezone_set('UTC');
385 385
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
386 386
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
387 387
 	if ($value['format'] == 'deltadbtxt' && 
388
-	    (
388
+		(
389 389
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
390 390
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
391
-	    )
391
+		)
392 392
 	) {
393
-	    //$buffer = $Common->getData($hosts[$id]);
394
-	    $buffer = $Common->getData($value['host']);
395
-	    if ($buffer != '') $reset = 0;
396
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
397
-	    $buffer = explode('\n',$buffer);
398
-	    foreach ($buffer as $line) {
399
-    		if ($line != '' && count($line) > 7) {
400
-    		    $line = explode(',', $line);
401
-	            $data = array();
402
-	            $data['hex'] = $line[1]; // hex
403
-	            $data['ident'] = $line[2]; // ident
404
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
405
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
406
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
407
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
408
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
409
-	            $data['verticalrate'] = ''; // vertical rate
410
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
411
-	            $data['emergency'] = ''; // emergency
412
-		    $data['datetime'] = date('Y-m-d H:i:s');
413
-		    $data['format_source'] = 'deltadbtxt';
414
-    		    $data['id_source'] = $id_source;
415
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
417
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
418
-    		    $SI->add($data);
419
-		    unset($data);
420
-    		}
421
-    	    }
422
-    	    $last_exec[$id]['last'] = time();
393
+		//$buffer = $Common->getData($hosts[$id]);
394
+		$buffer = $Common->getData($value['host']);
395
+		if ($buffer != '') $reset = 0;
396
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
397
+		$buffer = explode('\n',$buffer);
398
+		foreach ($buffer as $line) {
399
+			if ($line != '' && count($line) > 7) {
400
+				$line = explode(',', $line);
401
+				$data = array();
402
+				$data['hex'] = $line[1]; // hex
403
+				$data['ident'] = $line[2]; // ident
404
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
405
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
406
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
407
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
408
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
409
+				$data['verticalrate'] = ''; // vertical rate
410
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
411
+				$data['emergency'] = ''; // emergency
412
+			$data['datetime'] = date('Y-m-d H:i:s');
413
+			$data['format_source'] = 'deltadbtxt';
414
+				$data['id_source'] = $id_source;
415
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
417
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
418
+				$SI->add($data);
419
+			unset($data);
420
+			}
421
+			}
422
+			$last_exec[$id]['last'] = time();
423 423
 	} elseif ($value['format'] == 'aisnmeatxt' && 
424
-	    (
424
+		(
425 425
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
426 426
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
427
-	    )
427
+		)
428 428
 	) {
429
-	    date_default_timezone_set('CET');
430
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
431
-	    date_default_timezone_set('UTC');
432
-	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
435
-	    foreach ($buffer as $line) {
429
+		date_default_timezone_set('CET');
430
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
431
+		date_default_timezone_set('UTC');
432
+		if ($buffer != '') $reset = 0;
433
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
+		$buffer = explode('\n',$buffer);
435
+		foreach ($buffer as $line) {
436 436
 		if ($line != '') {
437
-		    //echo "'".$line."'\n";
438
-		    $add = false;
439
-		    $ais_data = $AIS->parse_line(trim($line));
440
-		    $data = array();
441
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
442
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
443
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
444
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
445
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
446
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
447
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
448
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
449
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
450
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
451
-		    if (isset($ais_data['timestamp'])) {
437
+			//echo "'".$line."'\n";
438
+			$add = false;
439
+			$ais_data = $AIS->parse_line(trim($line));
440
+			$data = array();
441
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
442
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
443
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
444
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
445
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
446
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
447
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
448
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
449
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
450
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
451
+			if (isset($ais_data['timestamp'])) {
452 452
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
453 453
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
454
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
455
-			    $add = true;
454
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
455
+				$add = true;
456 456
 			}
457
-		    } else {
457
+			} else {
458 458
 			$data['datetime'] = date('Y-m-d H:i:s');
459 459
 			$add = true;
460
-		    }
461
-		    $data['format_source'] = 'aisnmeatxt';
462
-    		    $data['id_source'] = $id_source;
463
-		    //print_r($data);
464
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
465
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
466
-		    unset($data);
460
+			}
461
+			$data['format_source'] = 'aisnmeatxt';
462
+				$data['id_source'] = $id_source;
463
+			//print_r($data);
464
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
465
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
466
+			unset($data);
467 467
 		}
468
-    	    }
469
-    	    $last_exec[$id]['last'] = time();
468
+			}
469
+			$last_exec[$id]['last'] = time();
470 470
 	} elseif ($value['format'] == 'aisnmeahttp') {
471
-	    $arr = $httpfeeds;
472
-	    $w = $e = null;
471
+		$arr = $httpfeeds;
472
+		$w = $e = null;
473 473
 	    
474
-	    if (isset($arr[$id])) {
474
+		if (isset($arr[$id])) {
475 475
 		$nn = stream_select($arr,$w,$e,$timeout);
476 476
 		if ($nn > 0) {
477
-		    foreach ($httpfeeds as $feed) {
477
+			foreach ($httpfeeds as $feed) {
478 478
 			$buffer = stream_get_line($feed,2000,"\n");
479 479
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
480 480
 			$buffer = explode('\n',$buffer);
481 481
 			foreach ($buffer as $line) {
482
-			    if ($line != '') {
482
+				if ($line != '') {
483 483
 				$ais_data = $AIS->parse_line(trim($line));
484 484
 				$data = array();
485 485
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -497,111 +497,111 @@  discard block
 block discarded – undo
497 497
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
498 498
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
499 499
 				if (isset($ais_data['timestamp'])) {
500
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
500
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
501 501
 				} else {
502
-				    $data['datetime'] = date('Y-m-d H:i:s');
502
+					$data['datetime'] = date('Y-m-d H:i:s');
503 503
 				}
504 504
 				$data['format_source'] = 'aisnmeahttp';
505 505
 				$data['id_source'] = $id_source;
506 506
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
507 507
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
508 508
 				unset($data);
509
-			    }
509
+				}
510
+			}
510 511
 			}
511
-		    }
512 512
 		} else {
513
-		    $format = $value['format'];
514
-		    if (isset($tt[$format])) $tt[$format]++;
515
-		    else $tt[$format] = 0;
516
-		    if ($tt[$format] > 30) {
513
+			$format = $value['format'];
514
+			if (isset($tt[$format])) $tt[$format]++;
515
+			else $tt[$format] = 0;
516
+			if ($tt[$format] > 30) {
517 517
 			if ($globalDebug) echo 'Reconnect...'."\n";
518 518
 			sleep(2);
519 519
 			$sourceeen[] = $value;
520 520
 			connect_all($sourceeen);
521 521
 			$sourceeen = array();
522
-		    }
522
+			}
523
+		}
523 524
 		}
524
-	    }
525 525
 	} elseif ($value['format'] == 'myshiptracking' && 
526
-	    (
526
+		(
527 527
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
528 528
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
529
-	    )
529
+		)
530 530
 	) {
531
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
532
-	    if ($buffer != '') {
531
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
532
+		if ($buffer != '') {
533 533
 		//echo $buffer;
534 534
 		$all_data = json_decode($buffer,true);
535 535
 		//print_r($all_data);
536 536
 		if (isset($all_data[0]['DATA'])) {
537
-		    foreach ($all_data[0]['DATA'] as $line) {
537
+			foreach ($all_data[0]['DATA'] as $line) {
538 538
 			if ($line != '') {
539
-			    $data = array();
540
-			    $data['ident'] = $line['NAME'];
541
-			    $data['mmsi'] = $line['MMSI'];
542
-			    $data['speed'] = $line['SOG'];
543
-			    $data['heading'] = $line['COG'];
544
-			    $data['latitude'] = $line['LAT'];
545
-			    $data['longitude'] = $line['LNG'];
546
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
547
-			    $data['imo'] = $line['IMO'];
548
-			    //$data['arrival_code'] = $ais_data['destination'];
549
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
550
-			    $data['format_source'] = 'myshiptracking';
551
-			    $data['id_source'] = $id_source;
552
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
553
-			    $MI->add($data);
554
-			    unset($data);
539
+				$data = array();
540
+				$data['ident'] = $line['NAME'];
541
+				$data['mmsi'] = $line['MMSI'];
542
+				$data['speed'] = $line['SOG'];
543
+				$data['heading'] = $line['COG'];
544
+				$data['latitude'] = $line['LAT'];
545
+				$data['longitude'] = $line['LNG'];
546
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
547
+				$data['imo'] = $line['IMO'];
548
+				//$data['arrival_code'] = $ais_data['destination'];
549
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
550
+				$data['format_source'] = 'myshiptracking';
551
+				$data['id_source'] = $id_source;
552
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
553
+				$MI->add($data);
554
+				unset($data);
555
+			}
555 556
 			}
556
-		    }
557 557
 		}
558
-	    }
559
-	    $last_exec[$id]['last'] = time();
558
+		}
559
+		$last_exec[$id]['last'] = time();
560 560
 	} elseif ($value['format'] == 'boatbeaconapp' && 
561
-	    (
561
+		(
562 562
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
563 563
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
564
-	    )
564
+		)
565 565
 	) {
566
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
567
-	    if ($buffer != '') {
566
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
567
+		if ($buffer != '') {
568 568
 		$all_data = json_decode($buffer,true);
569 569
 		if (isset($all_data[0]['mmsi'])) {
570
-		    foreach ($all_data as $line) {
570
+			foreach ($all_data as $line) {
571 571
 			if ($line != '') {
572
-			    $data = array();
573
-			    $data['ident'] = $line['shipname'];
574
-			    $data['callsign'] = $line['callsign'];
575
-			    $data['mmsi'] = $line['mmsi'];
576
-			    $data['speed'] = $line['sog'];
577
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
578
-			    $data['latitude'] = $line['latitude'];
579
-			    $data['longitude'] = $line['longitude'];
580
-			    $data['type_id'] = $line['shiptype'];
581
-			    $data['arrival_code'] = $line['destination'];
582
-			    $data['datetime'] = $line['time'];
583
-			    $data['format_source'] = 'boatbeaconapp';
584
-			    $data['id_source'] = $id_source;
585
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
-			    $MI->add($data);
587
-			    unset($data);
572
+				$data = array();
573
+				$data['ident'] = $line['shipname'];
574
+				$data['callsign'] = $line['callsign'];
575
+				$data['mmsi'] = $line['mmsi'];
576
+				$data['speed'] = $line['sog'];
577
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
578
+				$data['latitude'] = $line['latitude'];
579
+				$data['longitude'] = $line['longitude'];
580
+				$data['type_id'] = $line['shiptype'];
581
+				$data['arrival_code'] = $line['destination'];
582
+				$data['datetime'] = $line['time'];
583
+				$data['format_source'] = 'boatbeaconapp';
584
+				$data['id_source'] = $id_source;
585
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
+				$MI->add($data);
587
+				unset($data);
588
+			}
588 589
 			}
589
-		    }
590 590
 		}
591 591
 		
592
-	    }
593
-    	    $last_exec[$id]['last'] = time();
592
+		}
593
+			$last_exec[$id]['last'] = time();
594 594
 	} elseif ($value['format'] == 'boatnerd' && 
595
-	    (
595
+		(
596 596
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
597 597
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
598
-	    )
598
+		)
599 599
 	) {
600
-	    $buffer = $Common->getData($value['host']);
601
-	    if ($buffer != '') {
600
+		$buffer = $Common->getData($value['host']);
601
+		if ($buffer != '') {
602 602
 		$all_data = json_decode($buffer,true);
603 603
 		if (isset($all_data['features'][0]['id'])) {
604
-		    foreach ($all_data['features'] as $line) {
604
+			foreach ($all_data['features'] as $line) {
605 605
 			$data = array();
606 606
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
607 607
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -620,78 +620,78 @@  discard block
 block discarded – undo
620 620
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
621 621
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
622 622
 			unset($data);
623
-		    }
623
+			}
624 624
 		}
625 625
 		
626
-	    }
627
-    	    $last_exec[$id]['last'] = time();
626
+		}
627
+			$last_exec[$id]['last'] = time();
628 628
 	} elseif ($value['format'] == 'shipplotter' && 
629
-	    (
629
+		(
630 630
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
631 631
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
632
-	    )
632
+		)
633 633
 	) {
634
-	    echo 'download...';
635
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
636
-	    echo 'done !'."\n";
637
-	    if ($buffer != '') $reset = 0;
638
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
639
-	    $buffer = explode('\n',$buffer);
640
-	    foreach ($buffer as $line) {
634
+		echo 'download...';
635
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
636
+		echo 'done !'."\n";
637
+		if ($buffer != '') $reset = 0;
638
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
639
+		$buffer = explode('\n',$buffer);
640
+		foreach ($buffer as $line) {
641 641
 		if ($line != '') {
642
-		    $data = array();
643
-		    $data['mmsi'] = (int)substr($line,0,9);
644
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
645
-		    //$data['status'] = substr($line,21,2);
646
-		    //$data['type'] = substr($line,24,3);
647
-		    $data['latitude'] = substr($line,29,9);
648
-		    $data['longitude'] = substr($line,41,9);
649
-		    $data['speed'] = round(substr($line,51,5));
650
-		    //$data['course'] = substr($line,57,5);
651
-		    $data['heading'] = round(substr($line,63,3));
652
-		    //$data['draft'] = substr($line,67,4);
653
-		    //$data['length'] = substr($line,72,3);
654
-		    //$data['beam'] = substr($line,76,2);
655
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
656
-		    //$data['callsign'] = trim(substr($line,100,7);
657
-		    //$data['dest'] = substr($line,108,20);
658
-		    //$data['etaDate'] = substr($line,129,5);
659
-		    //$data['etaTime'] = substr($line,135,5);
660
-		    $data['format_source'] = 'shipplotter';
661
-    		    $data['id_source'] = $id_source;
662
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
663
-		    //print_r($data);
664
-		    echo 'Add...'."\n";
665
-		    $MI->add($data);
666
-		    unset($data);
642
+			$data = array();
643
+			$data['mmsi'] = (int)substr($line,0,9);
644
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
645
+			//$data['status'] = substr($line,21,2);
646
+			//$data['type'] = substr($line,24,3);
647
+			$data['latitude'] = substr($line,29,9);
648
+			$data['longitude'] = substr($line,41,9);
649
+			$data['speed'] = round(substr($line,51,5));
650
+			//$data['course'] = substr($line,57,5);
651
+			$data['heading'] = round(substr($line,63,3));
652
+			//$data['draft'] = substr($line,67,4);
653
+			//$data['length'] = substr($line,72,3);
654
+			//$data['beam'] = substr($line,76,2);
655
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
656
+			//$data['callsign'] = trim(substr($line,100,7);
657
+			//$data['dest'] = substr($line,108,20);
658
+			//$data['etaDate'] = substr($line,129,5);
659
+			//$data['etaTime'] = substr($line,135,5);
660
+			$data['format_source'] = 'shipplotter';
661
+				$data['id_source'] = $id_source;
662
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
663
+			//print_r($data);
664
+			echo 'Add...'."\n";
665
+			$MI->add($data);
666
+			unset($data);
667 667
 		}
668
-    	    }
669
-    	    $last_exec[$id]['last'] = time();
668
+			}
669
+			$last_exec[$id]['last'] = time();
670 670
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
671 671
 	} elseif (
672
-	    (
672
+		(
673 673
 		$value['format'] == 'whazzup' && 
674 674
 		(
675
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
676
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
675
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
676
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
677 677
 		)
678
-	    ) || (
678
+		) || (
679 679
 		$value['format'] == 'vatsimtxt' && 
680 680
 		(
681
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
682
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
681
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
682
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
683
+		)
683 684
 		)
684
-	    )
685 685
 	) {
686
-	    //$buffer = $Common->getData($hosts[$id]);
687
-	    $buffer = $Common->getData($value['host']);
688
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
689
-	    $buffer = explode('\n',$buffer);
690
-	    $reset = 0;
691
-	    foreach ($buffer as $line) {
692
-    		if ($line != '') {
693
-    		    $line = explode(':', $line);
694
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
686
+		//$buffer = $Common->getData($hosts[$id]);
687
+		$buffer = $Common->getData($value['host']);
688
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
689
+		$buffer = explode('\n',$buffer);
690
+		$reset = 0;
691
+		foreach ($buffer as $line) {
692
+			if ($line != '') {
693
+				$line = explode(':', $line);
694
+				if (count($line) > 30 && $line[0] != 'callsign') {
695 695
 			$data = array();
696 696
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
697 697
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -704,37 +704,37 @@  discard block
 block discarded – undo
704 704
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
705 705
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
706 706
 			$data['latitude'] = $line[5]; // lat
707
-	        	$data['longitude'] = $line[6]; // long
708
-	        	$data['verticalrate'] = ''; // vertical rate
709
-	        	$data['squawk'] = ''; // squawk
710
-	        	$data['emergency'] = ''; // emergency
711
-	        	$data['waypoints'] = $line[30];
707
+				$data['longitude'] = $line[6]; // long
708
+				$data['verticalrate'] = ''; // vertical rate
709
+				$data['squawk'] = ''; // squawk
710
+				$data['emergency'] = ''; // emergency
711
+				$data['waypoints'] = $line[30];
712 712
 			$data['datetime'] = date('Y-m-d H:i:s');
713 713
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
714 714
 			//if (isset($line[37])) $data['last_update'] = $line[37];
715
-		        $data['departure_airport_icao'] = $line[11];
716
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
717
-		        $data['arrival_airport_icao'] = $line[13];
715
+				$data['departure_airport_icao'] = $line[11];
716
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
717
+				$data['arrival_airport_icao'] = $line[13];
718 718
 			$data['frequency'] = $line[4];
719 719
 			$data['type'] = $line[18];
720 720
 			$data['range'] = $line[19];
721 721
 			if (isset($line[35])) $data['info'] = $line[35];
722
-    			$data['id_source'] = $id_source;
723
-	    		//$data['arrival_airport_time'] = ;
724
-	    		if ($line[9] != '') {
725
-	    		    $aircraft_data = explode('/',$line[9]);
726
-	    		    if (isset($aircraft_data[1])) {
727
-	    			$data['aircraft_icao'] = $aircraft_data[1];
728
-	    		    }
729
-        		}
730
-	    		/*
722
+				$data['id_source'] = $id_source;
723
+				//$data['arrival_airport_time'] = ;
724
+				if ($line[9] != '') {
725
+					$aircraft_data = explode('/',$line[9]);
726
+					if (isset($aircraft_data[1])) {
727
+					$data['aircraft_icao'] = $aircraft_data[1];
728
+					}
729
+				}
730
+				/*
731 731
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
732 732
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
733 733
 	    		*/
734
-	    		$data['format_source'] = $value['format'];
734
+				$data['format_source'] = $value['format'];
735 735
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
736 736
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
737
-    			if ($line[3] == 'PILOT') $SI->add($data);
737
+				if ($line[3] == 'PILOT') $SI->add($data);
738 738
 			elseif ($line[3] == 'ATC') {
739 739
 				//print_r($data);
740 740
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -755,21 +755,21 @@  discard block
 block discarded – undo
755 755
 					else 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']);
756 756
 				}
757 757
 			}
758
-    			unset($data);
759
-    		    }
760
-    		}
761
-    	    }
762
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
763
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
764
-    	    $last_exec[$id]['last'] = time();
765
-    	} elseif ($value['format'] == 'airwhere' && 
766
-    	    (
767
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
768
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
769
-    	    )
770
-    	) {
771
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
772
-	    if ($buffer != '') {
758
+				unset($data);
759
+				}
760
+			}
761
+			}
762
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
763
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
764
+			$last_exec[$id]['last'] = time();
765
+		} elseif ($value['format'] == 'airwhere' && 
766
+			(
767
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
768
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
769
+			)
770
+		) {
771
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
772
+		if ($buffer != '') {
773 773
 		$all_data = simplexml_load_string($buffer);
774 774
 		foreach($all_data->children() as $childdata) {
775 775
 			$data = array();
@@ -791,10 +791,10 @@  discard block
 block discarded – undo
791 791
 			$SI->add($data);
792 792
 			unset($data);
793 793
 		}
794
-	    }
795
-	    $Source->deleteOldLocationByType('gs');
796
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
797
-	    if ($buffer != '') {
794
+		}
795
+		$Source->deleteOldLocationByType('gs');
796
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
797
+		if ($buffer != '') {
798 798
 		$all_data = simplexml_load_string($buffer);
799 799
 		foreach($all_data->children() as $childdata) {
800 800
 			$data = array();
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 			}
813 813
 			unset($data);
814 814
 		}
815
-	    }
816
-	    $last_exec[$id]['last'] = time();
815
+		}
816
+		$last_exec[$id]['last'] = time();
817 817
 	/*
818 818
 	} if ($value['format'] == 'aircraftlistjson') {
819 819
 	    print_r($globalSources);
@@ -821,17 +821,17 @@  discard block
 block discarded – undo
821 821
 	    echo $globalMinFetch;
822 822
 	*/
823 823
 	} elseif ($value['format'] == 'aircraftlistjson' && 
824
-	    (
824
+		(
825 825
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
826 826
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827
-	    )
827
+		)
828 828
 	) {
829
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
830
-	    if ($buffer != '') {
831
-	        $all_data = json_decode($buffer,true);
829
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
830
+		if ($buffer != '') {
831
+			$all_data = json_decode($buffer,true);
832 832
 		if (isset($all_data['acList'])) {
833
-		    $reset = 0;
834
-		    foreach ($all_data['acList'] as $line) {
833
+			$reset = 0;
834
+			foreach ($all_data['acList'] as $line) {
835 835
 			$data = array();
836 836
 			$data['hex'] = $line['Icao']; // hex
837 837
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -854,10 +854,10 @@  discard block
 block discarded – undo
854 854
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
855 855
 			if (isset($data['latitude'])) $SI->add($data);
856 856
 			unset($data);
857
-		    }
857
+			}
858 858
 		} elseif (is_array($all_data)) {
859
-		    $reset = 0;
860
-		    foreach ($all_data as $line) {
859
+			$reset = 0;
860
+			foreach ($all_data as $line) {
861 861
 			$data = array();
862 862
 			$data['hex'] = $line['hex']; // hex
863 863
 			$data['ident'] = $line['flight']; // ident
@@ -877,218 +877,218 @@  discard block
 block discarded – undo
877 877
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
878 878
 			$SI->add($data);
879 879
 			unset($data);
880
-		    }
880
+			}
881 881
 		}
882
-	    } elseif ($globalDebug) echo 'No data'."\n";
883
-    	    //$last_exec['aircraftlistjson'] = time();
884
-    	    $last_exec[$id]['last'] = time();
885
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
886
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
887
-    	    (
888
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
889
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
890
-    	    )
891
-    	) {
892
-	    $buffer = $Common->getData($value['host']);
893
-	    $all_data = json_decode($buffer,true);
894
-	    if (isset($all_data['planes'])) {
882
+		} elseif ($globalDebug) echo 'No data'."\n";
883
+			//$last_exec['aircraftlistjson'] = time();
884
+			$last_exec[$id]['last'] = time();
885
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
886
+		} elseif ($value['format'] == 'planeupdatefaa' && 
887
+			(
888
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
889
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
890
+			)
891
+		) {
892
+		$buffer = $Common->getData($value['host']);
893
+		$all_data = json_decode($buffer,true);
894
+		if (isset($all_data['planes'])) {
895 895
 		$reset = 0;
896 896
 		foreach ($all_data['planes'] as $key => $line) {
897
-		    $data = array();
898
-		    $data['hex'] = $key; // hex
899
-		    $data['ident'] = $line[3]; // ident
900
-		    $data['altitude'] = $line[6]; // altitude
901
-		    $data['speed'] = $line[8]; // speed
902
-		    $data['heading'] = $line[7]; // heading
903
-		    $data['latitude'] = $line[4]; // lat
904
-		    $data['longitude'] = $line[5]; // long
905
-		    //$data['verticalrate'] = $line[]; // verticale rate
906
-		    $data['squawk'] = $line[10]; // squawk
907
-		    $data['emergency'] = ''; // emergency
908
-		    $data['registration'] = $line[2];
909
-		    $data['aircraft_icao'] = $line[0];
910
-		    $deparr = explode('-',$line[1]);
911
-		    if (count($deparr) == 2) {
897
+			$data = array();
898
+			$data['hex'] = $key; // hex
899
+			$data['ident'] = $line[3]; // ident
900
+			$data['altitude'] = $line[6]; // altitude
901
+			$data['speed'] = $line[8]; // speed
902
+			$data['heading'] = $line[7]; // heading
903
+			$data['latitude'] = $line[4]; // lat
904
+			$data['longitude'] = $line[5]; // long
905
+			//$data['verticalrate'] = $line[]; // verticale rate
906
+			$data['squawk'] = $line[10]; // squawk
907
+			$data['emergency'] = ''; // emergency
908
+			$data['registration'] = $line[2];
909
+			$data['aircraft_icao'] = $line[0];
910
+			$deparr = explode('-',$line[1]);
911
+			if (count($deparr) == 2) {
912 912
 			$data['departure_airport_icao'] = $deparr[0];
913 913
 			$data['arrival_airport_icao'] = $deparr[1];
914
-		    }
915
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
916
-	    	    $data['format_source'] = 'planeupdatefaa';
917
-    		    $data['id_source'] = $id_source;
918
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
-		    $SI->add($data);
921
-		    unset($data);
914
+			}
915
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
916
+				$data['format_source'] = 'planeupdatefaa';
917
+				$data['id_source'] = $id_source;
918
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
+			$SI->add($data);
921
+			unset($data);
922
+		}
922 923
 		}
923
-	    }
924
-	    //$last_exec['planeupdatefaa'] = time();
925
-	    $last_exec[$id]['last'] = time();
924
+		//$last_exec['planeupdatefaa'] = time();
925
+		$last_exec[$id]['last'] = time();
926 926
 	} elseif ($value['format'] == 'opensky' && 
927
-	    (
927
+		(
928 928
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
929 929
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
930
-	    )
930
+		)
931 931
 	) {
932
-	    $buffer = $Common->getData($value['host']);
933
-	    $all_data = json_decode($buffer,true);
934
-	    if (isset($all_data['states'])) {
932
+		$buffer = $Common->getData($value['host']);
933
+		$all_data = json_decode($buffer,true);
934
+		if (isset($all_data['states'])) {
935 935
 		$reset = 0;
936 936
 		foreach ($all_data['states'] as $key => $line) {
937
-		    $data = array();
938
-		    $data['hex'] = $line[0]; // hex
939
-		    $data['ident'] = trim($line[1]); // ident
940
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
941
-		    $data['speed'] = round($line[9]*1.94384); // speed
942
-		    $data['heading'] = round($line[10]); // heading
943
-		    $data['latitude'] = $line[6]; // lat
944
-		    $data['longitude'] = $line[5]; // long
945
-		    $data['verticalrate'] = $line[11]; // verticale rate
946
-		    //$data['squawk'] = $line[10]; // squawk
947
-		    //$data['emergency'] = ''; // emergency
948
-		    //$data['registration'] = $line[2];
949
-		    //$data['aircraft_icao'] = $line[0];
950
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
951
-		    $data['format_source'] = 'opensky';
952
-		    $data['id_source'] = $id_source;
953
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
954
-		    $SI->add($data);
955
-		    unset($data);
937
+			$data = array();
938
+			$data['hex'] = $line[0]; // hex
939
+			$data['ident'] = trim($line[1]); // ident
940
+			$data['altitude'] = round($line[7]*3.28084); // altitude
941
+			$data['speed'] = round($line[9]*1.94384); // speed
942
+			$data['heading'] = round($line[10]); // heading
943
+			$data['latitude'] = $line[6]; // lat
944
+			$data['longitude'] = $line[5]; // long
945
+			$data['verticalrate'] = $line[11]; // verticale rate
946
+			//$data['squawk'] = $line[10]; // squawk
947
+			//$data['emergency'] = ''; // emergency
948
+			//$data['registration'] = $line[2];
949
+			//$data['aircraft_icao'] = $line[0];
950
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
951
+			$data['format_source'] = 'opensky';
952
+			$data['id_source'] = $id_source;
953
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
954
+			$SI->add($data);
955
+			unset($data);
956 956
 		}
957
-	    }
958
-	    //$last_exec['planeupdatefaa'] = time();
959
-	    $last_exec[$id]['last'] = time();
957
+		}
958
+		//$last_exec['planeupdatefaa'] = time();
959
+		$last_exec[$id]['last'] = time();
960 960
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
961 961
 	} elseif ($value['format'] == 'fr24json' && 
962
-	    (
962
+		(
963 963
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
964 964
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
965
-	    )
965
+		)
966 966
 	) {
967
-	    //$buffer = $Common->getData($hosts[$id]);
968
-	    $buffer = $Common->getData($value['host']);
969
-	    $all_data = json_decode($buffer,true);
970
-	    if (!empty($all_data)) $reset = 0;
971
-	    foreach ($all_data as $key => $line) {
967
+		//$buffer = $Common->getData($hosts[$id]);
968
+		$buffer = $Common->getData($value['host']);
969
+		$all_data = json_decode($buffer,true);
970
+		if (!empty($all_data)) $reset = 0;
971
+		foreach ($all_data as $key => $line) {
972 972
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
973
-		    $data = array();
974
-		    $data['hex'] = $line[0];
975
-		    $data['ident'] = $line[16]; //$line[13]
976
-	    	    $data['altitude'] = $line[4]; // altitude
977
-	    	    $data['speed'] = $line[5]; // speed
978
-	    	    $data['heading'] = $line[3]; // heading
979
-	    	    $data['latitude'] = $line[1]; // lat
980
-	    	    $data['longitude'] = $line[2]; // long
981
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
982
-	    	    $data['squawk'] = $line[6]; // squawk
983
-	    	    $data['aircraft_icao'] = $line[8];
984
-	    	    $data['registration'] = $line[9];
985
-		    $data['departure_airport_iata'] = $line[11];
986
-		    $data['arrival_airport_iata'] = $line[12];
987
-	    	    $data['emergency'] = ''; // emergency
988
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
989
-	    	    $data['format_source'] = 'fr24json';
990
-    		    $data['id_source'] = $id_source;
991
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
992
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
993
-		    $SI->add($data);
994
-		    unset($data);
973
+			$data = array();
974
+			$data['hex'] = $line[0];
975
+			$data['ident'] = $line[16]; //$line[13]
976
+				$data['altitude'] = $line[4]; // altitude
977
+				$data['speed'] = $line[5]; // speed
978
+				$data['heading'] = $line[3]; // heading
979
+				$data['latitude'] = $line[1]; // lat
980
+				$data['longitude'] = $line[2]; // long
981
+				$data['verticalrate'] = $line[15]; // verticale rate
982
+				$data['squawk'] = $line[6]; // squawk
983
+				$data['aircraft_icao'] = $line[8];
984
+				$data['registration'] = $line[9];
985
+			$data['departure_airport_iata'] = $line[11];
986
+			$data['arrival_airport_iata'] = $line[12];
987
+				$data['emergency'] = ''; // emergency
988
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
989
+				$data['format_source'] = 'fr24json';
990
+				$data['id_source'] = $id_source;
991
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
992
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
993
+			$SI->add($data);
994
+			unset($data);
995 995
 		}
996
-	    }
997
-	    //$last_exec['fr24json'] = time();
998
-	    $last_exec[$id]['last'] = time();
996
+		}
997
+		//$last_exec['fr24json'] = time();
998
+		$last_exec[$id]['last'] = time();
999 999
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1000 1000
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1001
-	    (
1001
+		(
1002 1002
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1003 1003
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1004
-	    )
1004
+		)
1005 1005
 	) {
1006
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1007
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1008
-	    //echo $buffer;
1009
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1010
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1011
-	    $all_data = json_decode($buffer,true);
1012
-	    if (json_last_error() != JSON_ERROR_NONE) {
1006
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1007
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1008
+		//echo $buffer;
1009
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1010
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1011
+		$all_data = json_decode($buffer,true);
1012
+		if (json_last_error() != JSON_ERROR_NONE) {
1013 1013
 		die(json_last_error_msg());
1014
-	    }
1015
-	    if (isset($all_data['mrkrs'])) {
1014
+		}
1015
+		if (isset($all_data['mrkrs'])) {
1016 1016
 		$reset = 0;
1017 1017
 		foreach ($all_data['mrkrs'] as $key => $line) {
1018
-		    if (isset($line['inf'])) {
1018
+			if (isset($line['inf'])) {
1019 1019
 			$data = array();
1020 1020
 			$data['hex'] = $line['inf']['ia'];
1021 1021
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1022
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1023
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1024
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1025
-	    		$data['latitude'] = $line['pt'][0]; // lat
1026
-	    		$data['longitude'] = $line['pt'][1]; // long
1027
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1028
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1029
-	    		//$data['aircraft_icao'] = $line[8];
1030
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1022
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1023
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1024
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1025
+				$data['latitude'] = $line['pt'][0]; // lat
1026
+				$data['longitude'] = $line['pt'][1]; // long
1027
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1028
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1029
+				//$data['aircraft_icao'] = $line[8];
1030
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1031 1031
 			//$data['departure_airport_iata'] = $line[11];
1032 1032
 			//$data['arrival_airport_iata'] = $line[12];
1033
-	    		//$data['emergency'] = ''; // emergency
1033
+				//$data['emergency'] = ''; // emergency
1034 1034
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1035
-	    		$data['format_source'] = 'radarvirtueljson';
1036
-    			$data['id_source'] = $id_source;
1035
+				$data['format_source'] = 'radarvirtueljson';
1036
+				$data['id_source'] = $id_source;
1037 1037
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1038 1038
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1039 1039
 			$SI->add($data);
1040 1040
 			unset($data);
1041
-		    }
1041
+			}
1042
+		}
1042 1043
 		}
1043
-	    }
1044
-	    //$last_exec['radarvirtueljson'] = time();
1045
-	    $last_exec[$id]['last'] = time();
1044
+		//$last_exec['radarvirtueljson'] = time();
1045
+		$last_exec[$id]['last'] = time();
1046 1046
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1047 1047
 	} elseif ($value['format'] == 'pirepsjson' && 
1048
-	    (
1048
+		(
1049 1049
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1050 1050
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1051
-	    )
1051
+		)
1052 1052
 	) {
1053
-	    //$buffer = $Common->getData($hosts[$id]);
1054
-	    $buffer = $Common->getData($value['host'].'?'.time());
1055
-	    $all_data = json_decode(utf8_encode($buffer),true);
1053
+		//$buffer = $Common->getData($hosts[$id]);
1054
+		$buffer = $Common->getData($value['host'].'?'.time());
1055
+		$all_data = json_decode(utf8_encode($buffer),true);
1056 1056
 	    
1057
-	    if (isset($all_data['pireps'])) {
1057
+		if (isset($all_data['pireps'])) {
1058 1058
 		$reset = 0;
1059
-	        foreach ($all_data['pireps'] as $line) {
1060
-		    $data = array();
1061
-		    $data['id'] = $line['id'];
1062
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1063
-		    $data['ident'] = $line['callsign']; // ident
1064
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1065
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1066
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1067
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1068
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1069
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1070
-		    $data['latitude'] = $line['lat']; // lat
1071
-		    $data['longitude'] = $line['lon']; // long
1072
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1073
-		    //$data['squawk'] = $line['squawk']; // squawk
1074
-		    //$data['emergency'] = ''; // emergency
1075
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1076
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1077
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1078
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1079
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1080
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1081
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1082
-		    else $data['info'] = '';
1083
-		    $data['format_source'] = 'pireps';
1084
-    		    $data['id_source'] = $id_source;
1085
-		    $data['datetime'] = date('Y-m-d H:i:s');
1086
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1087
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1088
-		    if ($line['icon'] == 'plane') {
1059
+			foreach ($all_data['pireps'] as $line) {
1060
+			$data = array();
1061
+			$data['id'] = $line['id'];
1062
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1063
+			$data['ident'] = $line['callsign']; // ident
1064
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1065
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1066
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1067
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1068
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1069
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1070
+			$data['latitude'] = $line['lat']; // lat
1071
+			$data['longitude'] = $line['lon']; // long
1072
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1073
+			//$data['squawk'] = $line['squawk']; // squawk
1074
+			//$data['emergency'] = ''; // emergency
1075
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1076
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1077
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1078
+			//$data['arrival_airport_time'] = $line['arrtime'];
1079
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1080
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1081
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1082
+			else $data['info'] = '';
1083
+			$data['format_source'] = 'pireps';
1084
+				$data['id_source'] = $id_source;
1085
+			$data['datetime'] = date('Y-m-d H:i:s');
1086
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1087
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1088
+			if ($line['icon'] == 'plane') {
1089 1089
 			$SI->add($data);
1090
-		    //    print_r($data);
1091
-    		    } elseif ($line['icon'] == 'ct') {
1090
+			//    print_r($data);
1091
+				} elseif ($line['icon'] == 'ct') {
1092 1092
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1093 1093
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1094 1094
 			$typec = substr($data['ident'],-3);
@@ -1103,148 +1103,148 @@  discard block
 block discarded – undo
1103 1103
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1104 1104
 			else $data['type'] = 'Observer';
1105 1105
 			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']);
1106
-		    }
1107
-		    unset($data);
1106
+			}
1107
+			unset($data);
1108
+		}
1108 1109
 		}
1109
-	    }
1110
-	    //$last_exec['pirepsjson'] = time();
1111
-	    $last_exec[$id]['last'] = time();
1110
+		//$last_exec['pirepsjson'] = time();
1111
+		$last_exec[$id]['last'] = time();
1112 1112
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1113 1113
 	} elseif ($value['format'] == 'phpvmacars' && 
1114
-	    (
1114
+		(
1115 1115
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1116 1116
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1117
-	    )
1117
+		)
1118 1118
 	) {
1119
-	    //$buffer = $Common->getData($hosts[$id]);
1120
-	    if ($globalDebug) echo 'Get Data...'."\n";
1121
-	    $buffer = $Common->getData($value['host']);
1122
-	    $all_data = json_decode($buffer,true);
1123
-	    if ($buffer != '' && is_array($all_data)) {
1119
+		//$buffer = $Common->getData($hosts[$id]);
1120
+		if ($globalDebug) echo 'Get Data...'."\n";
1121
+		$buffer = $Common->getData($value['host']);
1122
+		$all_data = json_decode($buffer,true);
1123
+		if ($buffer != '' && is_array($all_data)) {
1124 1124
 		$reset = 0;
1125 1125
 		foreach ($all_data as $line) {
1126
-	    	    $data = array();
1127
-	    	    //$data['id'] = $line['id']; // id not usable
1128
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1129
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1130
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1131
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1132
-	    	    $data['ident'] = $line['flightnum']; // ident
1133
-	    	    $data['altitude'] = $line['alt']; // altitude
1134
-	    	    $data['speed'] = $line['gs']; // speed
1135
-	    	    $data['heading'] = $line['heading']; // heading
1136
-	    	    $data['latitude'] = $line['lat']; // lat
1137
-	    	    $data['longitude'] = $line['lng']; // long
1138
-	    	    $data['verticalrate'] = ''; // verticale rate
1139
-	    	    $data['squawk'] = ''; // squawk
1140
-	    	    $data['emergency'] = ''; // emergency
1141
-	    	    //$data['datetime'] = $line['lastupdate'];
1142
-	    	    //$data['last_update'] = $line['lastupdate'];
1143
-	    	    if (isset($value['timezone'])) {
1144
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1145
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1146
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1147
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1148
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1149
-	    	    $data['departure_airport_time'] = $line['deptime'];
1150
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1151
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1152
-    		    $data['registration'] = $line['aircraft'];
1153
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1154
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1155
-		    if (isset($line['aircraftname'])) {
1126
+				$data = array();
1127
+				//$data['id'] = $line['id']; // id not usable
1128
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1129
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1130
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1131
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1132
+				$data['ident'] = $line['flightnum']; // ident
1133
+				$data['altitude'] = $line['alt']; // altitude
1134
+				$data['speed'] = $line['gs']; // speed
1135
+				$data['heading'] = $line['heading']; // heading
1136
+				$data['latitude'] = $line['lat']; // lat
1137
+				$data['longitude'] = $line['lng']; // long
1138
+				$data['verticalrate'] = ''; // verticale rate
1139
+				$data['squawk'] = ''; // squawk
1140
+				$data['emergency'] = ''; // emergency
1141
+				//$data['datetime'] = $line['lastupdate'];
1142
+				//$data['last_update'] = $line['lastupdate'];
1143
+				if (isset($value['timezone'])) {
1144
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1145
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1146
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1147
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1148
+				$data['departure_airport_icao'] = $line['depicao'];
1149
+				$data['departure_airport_time'] = $line['deptime'];
1150
+				$data['arrival_airport_icao'] = $line['arricao'];
1151
+				$data['arrival_airport_time'] = $line['arrtime'];
1152
+				$data['registration'] = $line['aircraft'];
1153
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1154
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1155
+			if (isset($line['aircraftname'])) {
1156 1156
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1157 1157
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1158
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1159
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1160
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1161
-	    		else {
1162
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1163
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1164
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1165
-	    		}
1166
-	    	    }
1167
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1168
-    		    $data['id_source'] = $id_source;
1169
-	    	    $data['format_source'] = 'phpvmacars';
1170
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1171
-		    $SI->add($data);
1172
-		    unset($data);
1158
+				$aircraft_data = explode('-',$line['aircraftname']);
1159
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1160
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1161
+				else {
1162
+					$aircraft_data = explode(' ',$line['aircraftname']);
1163
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1164
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1165
+				}
1166
+				}
1167
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1168
+				$data['id_source'] = $id_source;
1169
+				$data['format_source'] = 'phpvmacars';
1170
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1171
+			$SI->add($data);
1172
+			unset($data);
1173 1173
 		}
1174 1174
 		if ($globalDebug) echo 'No more data...'."\n";
1175 1175
 		unset($buffer);
1176 1176
 		unset($all_data);
1177
-	    }
1178
-	    //$last_exec['phpvmacars'] = time();
1179
-	    $last_exec[$id]['last'] = time();
1177
+		}
1178
+		//$last_exec['phpvmacars'] = time();
1179
+		$last_exec[$id]['last'] = time();
1180 1180
 	} elseif ($value['format'] == 'vam' && 
1181
-	    (
1181
+		(
1182 1182
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1183 1183
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1184
-	    )
1184
+		)
1185 1185
 	) {
1186
-	    //$buffer = $Common->getData($hosts[$id]);
1187
-	    if ($globalDebug) echo 'Get Data...'."\n";
1188
-	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1190
-	    if ($buffer != '' && is_array($all_data)) {
1186
+		//$buffer = $Common->getData($hosts[$id]);
1187
+		if ($globalDebug) echo 'Get Data...'."\n";
1188
+		$buffer = $Common->getData($value['host']);
1189
+		$all_data = json_decode($buffer,true);
1190
+		if ($buffer != '' && is_array($all_data)) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data as $line) {
1193
-	    	    $data = array();
1194
-	    	    //$data['id'] = $line['id']; // id not usable
1195
-	    	    $data['id'] = trim($line['flight_id']);
1196
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1197
-	    	    $data['pilot_name'] = $line['pilot_name'];
1198
-	    	    $data['pilot_id'] = $line['pilot_id'];
1199
-	    	    $data['ident'] = trim($line['callsign']); // ident
1200
-	    	    $data['altitude'] = $line['altitude']; // altitude
1201
-	    	    $data['speed'] = $line['gs']; // speed
1202
-	    	    $data['heading'] = $line['heading']; // heading
1203
-	    	    $data['latitude'] = $line['latitude']; // lat
1204
-	    	    $data['longitude'] = $line['longitude']; // long
1205
-	    	    $data['verticalrate'] = ''; // verticale rate
1206
-	    	    $data['squawk'] = ''; // squawk
1207
-	    	    $data['emergency'] = ''; // emergency
1208
-	    	    //$data['datetime'] = $line['lastupdate'];
1209
-	    	    $data['last_update'] = $line['last_update'];
1210
-		    $data['datetime'] = date('Y-m-d H:i:s');
1211
-	    	    $data['departure_airport_icao'] = $line['departure'];
1212
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1213
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1214
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1215
-    		    //$data['registration'] = $line['aircraft'];
1216
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1217
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1218
-    		    $data['id_source'] = $id_source;
1219
-	    	    $data['format_source'] = 'vam';
1220
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1221
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1222
-		    $SI->add($data);
1223
-		    unset($data);
1193
+				$data = array();
1194
+				//$data['id'] = $line['id']; // id not usable
1195
+				$data['id'] = trim($line['flight_id']);
1196
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1197
+				$data['pilot_name'] = $line['pilot_name'];
1198
+				$data['pilot_id'] = $line['pilot_id'];
1199
+				$data['ident'] = trim($line['callsign']); // ident
1200
+				$data['altitude'] = $line['altitude']; // altitude
1201
+				$data['speed'] = $line['gs']; // speed
1202
+				$data['heading'] = $line['heading']; // heading
1203
+				$data['latitude'] = $line['latitude']; // lat
1204
+				$data['longitude'] = $line['longitude']; // long
1205
+				$data['verticalrate'] = ''; // verticale rate
1206
+				$data['squawk'] = ''; // squawk
1207
+				$data['emergency'] = ''; // emergency
1208
+				//$data['datetime'] = $line['lastupdate'];
1209
+				$data['last_update'] = $line['last_update'];
1210
+			$data['datetime'] = date('Y-m-d H:i:s');
1211
+				$data['departure_airport_icao'] = $line['departure'];
1212
+				//$data['departure_airport_time'] = $line['departure_time'];
1213
+				$data['arrival_airport_icao'] = $line['arrival'];
1214
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1215
+				//$data['registration'] = $line['aircraft'];
1216
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1217
+				$data['aircraft_icao'] = $line['plane_type'];
1218
+				$data['id_source'] = $id_source;
1219
+				$data['format_source'] = 'vam';
1220
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1221
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1222
+			$SI->add($data);
1223
+			unset($data);
1224 1224
 		}
1225 1225
 		if ($globalDebug) echo 'No more data...'."\n";
1226 1226
 		unset($buffer);
1227 1227
 		unset($all_data);
1228
-	    }
1229
-	    //$last_exec['phpvmacars'] = time();
1230
-	    $last_exec[$id]['last'] = time();
1228
+		}
1229
+		//$last_exec['phpvmacars'] = time();
1230
+		$last_exec[$id]['last'] = time();
1231 1231
 	} elseif ($value['format'] == 'blitzortung' && 
1232
-	    (
1232
+		(
1233 1233
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1234 1234
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1235
-	    )
1235
+		)
1236 1236
 	) {
1237
-	    //$buffer = $Common->getData($hosts[$id]);
1238
-	    if ($globalDebug) echo 'Get Data...'."\n";
1239
-	    $buffer = $Common->getData($value['host']);
1240
-	    $all_data = json_decode($buffer,true);
1241
-	    if ($buffer != '') {
1237
+		//$buffer = $Common->getData($hosts[$id]);
1238
+		if ($globalDebug) echo 'Get Data...'."\n";
1239
+		$buffer = $Common->getData($value['host']);
1240
+		$all_data = json_decode($buffer,true);
1241
+		if ($buffer != '') {
1242 1242
 		$Source->deleteLocationBySource('blitzortung');
1243 1243
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1244 1244
 		$buffer = explode('\n',$buffer);
1245 1245
 		foreach ($buffer as $buffer_line) {
1246
-		    $line = json_decode($buffer_line,true);
1247
-		    if (isset($line['time'])) {
1246
+			$line = json_decode($buffer_line,true);
1247
+			if (isset($line['time'])) {
1248 1248
 			$data = array();
1249 1249
 			$data['altitude'] = $line['alt']; // altitude
1250 1250
 			$data['latitude'] = $line['lat']; // lat
@@ -1256,94 +1256,94 @@  discard block
 block discarded – undo
1256 1256
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1257 1257
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1258 1258
 			unset($data);
1259
-		    }
1259
+			}
1260 1260
 		}
1261 1261
 		if ($globalDebug) echo 'No more data...'."\n";
1262 1262
 		unset($buffer);
1263
-	    }
1264
-	    $last_exec[$id]['last'] = time();
1263
+		}
1264
+		$last_exec[$id]['last'] = time();
1265 1265
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1266 1266
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1267
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1268
-    	    //$last_exec[$id]['last'] = time();
1267
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1268
+			//$last_exec[$id]['last'] = time();
1269 1269
 
1270
-	    //$read = array( $sockets[$id] );
1271
-	    $read = $sockets;
1272
-	    $write = NULL;
1273
-	    $e = NULL;
1274
-	    $n = socket_select($read, $write, $e, $timeout);
1275
-	    if ($e != NULL) var_dump($e);
1276
-	    if ($n > 0) {
1270
+		//$read = array( $sockets[$id] );
1271
+		$read = $sockets;
1272
+		$write = NULL;
1273
+		$e = NULL;
1274
+		$n = socket_select($read, $write, $e, $timeout);
1275
+		if ($e != NULL) var_dump($e);
1276
+		if ($n > 0) {
1277 1277
 		$reset = 0;
1278 1278
 		foreach ($read as $nb => $r) {
1279
-		    //$value = $formats[$nb];
1280
-		    $format = $globalSources[$nb]['format'];
1281
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1279
+			//$value = $formats[$nb];
1280
+			$format = $globalSources[$nb]['format'];
1281
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1282 1282
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1283
-		    } elseif ($format == 'vrstcp') {
1283
+			} elseif ($format == 'vrstcp') {
1284 1284
 			$buffer = @socket_read($r, 6000);
1285
-		    } else {
1285
+			} else {
1286 1286
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1287
-		    }
1288
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1289
-		    //echo $buffer."\n";
1290
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1291
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1292
-		    $error = false;
1293
-		    //$SI::del();
1294
-		    if ($format == 'vrstcp') {
1287
+			}
1288
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1289
+			//echo $buffer."\n";
1290
+			// lets play nice and handle signals such as ctrl-c/kill properly
1291
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1292
+			$error = false;
1293
+			//$SI::del();
1294
+			if ($format == 'vrstcp') {
1295 1295
 			$buffer = explode('},{',$buffer);
1296
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1297
-		    // SBS format is CSV format
1298
-		    if ($buffer !== FALSE && $buffer != '') {
1296
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1297
+			// SBS format is CSV format
1298
+			if ($buffer !== FALSE && $buffer != '') {
1299 1299
 			$tt[$format] = 0;
1300 1300
 			if ($format == 'acarssbs3') {
1301
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1302
-			    $ACARS->add(trim($buffer));
1303
-			    $ACARS->deleteLiveAcarsData();
1301
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1302
+				$ACARS->add(trim($buffer));
1303
+				$ACARS->deleteLiveAcarsData();
1304 1304
 			} elseif ($format == 'raw') {
1305
-			    // AVR format
1306
-			    $data = $SBS->parse($buffer);
1307
-			    if (is_array($data)) {
1305
+				// AVR format
1306
+				$data = $SBS->parse($buffer);
1307
+				if (is_array($data)) {
1308 1308
 				$data['datetime'] = date('Y-m-d H:i:s');
1309 1309
 				$data['format_source'] = 'raw';
1310 1310
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1311 1311
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1312 1312
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1313 1313
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1314
-			    }
1314
+				}
1315 1315
 			} elseif ($format == 'ais') {
1316
-			    $ais_data = $AIS->parse_line(trim($buffer));
1317
-			    $data = array();
1318
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1319
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1320
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1321
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1322
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1323
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1324
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1325
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1326
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1327
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1328
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1329
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1330
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1331
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1332
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1333
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1316
+				$ais_data = $AIS->parse_line(trim($buffer));
1317
+				$data = array();
1318
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1319
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1320
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1321
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1322
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1323
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1324
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1325
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1326
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1327
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1328
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1329
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1330
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1331
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1332
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1333
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1334 1334
 
1335
-			    if (isset($ais_data['timestamp'])) {
1335
+				if (isset($ais_data['timestamp'])) {
1336 1336
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1337
-			    } else {
1337
+				} else {
1338 1338
 				$data['datetime'] = date('Y-m-d H:i:s');
1339
-			    }
1340
-			    $data['format_source'] = 'aisnmea';
1341
-    			    $data['id_source'] = $id_source;
1342
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1343
-			    unset($data);
1344
-                        } elseif ($format == 'flightgearsp') {
1345
-                    	    //echo $buffer."\n";
1346
-                    	    if (strlen($buffer) > 5) {
1339
+				}
1340
+				$data['format_source'] = 'aisnmea';
1341
+					$data['id_source'] = $id_source;
1342
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1343
+				unset($data);
1344
+						} elseif ($format == 'flightgearsp') {
1345
+							//echo $buffer."\n";
1346
+							if (strlen($buffer) > 5) {
1347 1347
 				$line = explode(',',$buffer);
1348 1348
 				$data = array();
1349 1349
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1360,38 +1360,38 @@  discard block
 block discarded – undo
1360 1360
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1361 1361
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1362 1362
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1363
-			    }
1364
-                        } elseif ($format == 'acars') {
1365
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1366
-			    $ACARS->add(trim($buffer));
1367
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1368
-			    $ACARS->deleteLiveAcarsData();
1363
+				}
1364
+						} elseif ($format == 'acars') {
1365
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1366
+				$ACARS->add(trim($buffer));
1367
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1368
+				$ACARS->deleteLiveAcarsData();
1369 1369
 			} elseif ($format == 'flightgearmp') {
1370
-			    if (substr($buffer,0,1) != '#') {
1370
+				if (substr($buffer,0,1) != '#') {
1371 1371
 				$data = array();
1372 1372
 				//echo $buffer."\n";
1373 1373
 				$line = explode(' ',$buffer);
1374 1374
 				if (count($line) == 11) {
1375
-				    $userserver = explode('@',$line[0]);
1376
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1377
-				    $data['ident'] = $userserver[0];
1378
-				    $data['registration'] = $userserver[0];
1379
-				    $data['latitude'] = $line[4];
1380
-				    $data['longitude'] = $line[5];
1381
-				    $data['altitude'] = $line[6];
1382
-				    $data['datetime'] = date('Y-m-d H:i:s');
1383
-				    $aircraft_type = $line[10];
1384
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1385
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1386
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1387
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1375
+					$userserver = explode('@',$line[0]);
1376
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1377
+					$data['ident'] = $userserver[0];
1378
+					$data['registration'] = $userserver[0];
1379
+					$data['latitude'] = $line[4];
1380
+					$data['longitude'] = $line[5];
1381
+					$data['altitude'] = $line[6];
1382
+					$data['datetime'] = date('Y-m-d H:i:s');
1383
+					$aircraft_type = $line[10];
1384
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1385
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1386
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1387
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1388
+				}
1388 1389
 				}
1389
-			    }
1390 1390
 			} elseif ($format == 'beast') {
1391
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1392
-			    die;
1391
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1392
+				die;
1393 1393
 			} elseif ($format == 'vrstcp') {
1394
-			    foreach($buffer as $all_data) {
1394
+				foreach($buffer as $all_data) {
1395 1395
 				$line = json_decode('{'.$all_data.'}',true);
1396 1396
 				$data = array();
1397 1397
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1411,148 +1411,148 @@  discard block
 block discarded – undo
1411 1411
 				*/
1412 1412
 				$data['datetime'] = date('Y-m-d H:i:s');
1413 1413
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1414
-		    		$data['format_source'] = 'vrstcp';
1414
+					$data['format_source'] = 'vrstcp';
1415 1415
 				$data['id_source'] = $id_source;
1416 1416
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1417 1417
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1418 1418
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1419 1419
 				unset($data);
1420
-			    }
1420
+				}
1421 1421
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1422
-			    $line = explode("\t", $buffer);
1423
-			    for($k = 0; $k < count($line); $k=$k+2) {
1422
+				$line = explode("\t", $buffer);
1423
+				for($k = 0; $k < count($line); $k=$k+2) {
1424 1424
 				$key = $line[$k];
1425
-			        $lined[$key] = $line[$k+1];
1426
-			    }
1427
-    			    if (count($lined) > 3) {
1428
-    				$data['hex'] = $lined['hexid'];
1429
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1430
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1431
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1432
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1433
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1434
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1435
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1436
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1437
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1438
-    				$data['id_source'] = $id_source;
1439
-    				$data['format_source'] = 'tsv';
1440
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1441
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1425
+					$lined[$key] = $line[$k+1];
1426
+				}
1427
+					if (count($lined) > 3) {
1428
+					$data['hex'] = $lined['hexid'];
1429
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1430
+					$data['datetime'] = date('Y-m-d H:i:s');;
1431
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1432
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1433
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1434
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1435
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1436
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1437
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1438
+					$data['id_source'] = $id_source;
1439
+					$data['format_source'] = 'tsv';
1440
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1441
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1442 1442
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1443
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1444
-    				unset($lined);
1445
-    				unset($data);
1446
-    			    } else $error = true;
1443
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1444
+					unset($lined);
1445
+					unset($data);
1446
+					} else $error = true;
1447 1447
 			} elseif ($format == 'aprs' && $use_aprs) {
1448
-			    if ($aprs_connect == 0) {
1448
+				if ($aprs_connect == 0) {
1449 1449
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1450 1450
 				$aprs_connect = 1;
1451
-			    }
1451
+				}
1452 1452
 			    
1453
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1453
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1454 1454
 				$aprs_last_tx = time();
1455 1455
 				$data_aprs = "# Keep alive";
1456 1456
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1457
-			    }
1457
+				}
1458 1458
 			    
1459
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1460
-			    //echo 'APRS data : '.$buffer."\n";
1461
-			    $buffer = str_replace('APRS <- ','',$buffer);
1462
-			    $buffer = str_replace('APRS -> ','',$buffer);
1463
-			    //echo $buffer."\n";
1464
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1459
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1460
+				//echo 'APRS data : '.$buffer."\n";
1461
+				$buffer = str_replace('APRS <- ','',$buffer);
1462
+				$buffer = str_replace('APRS -> ','',$buffer);
1463
+				//echo $buffer."\n";
1464
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1465 1465
 				$line = $APRS->parse($buffer);
1466 1466
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1467 1467
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1468
-				    $aprs_last_tx = time();
1469
-				    $data = array();
1470
-				    //print_r($line);
1471
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1472
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1473
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1474
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1475
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1476
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1477
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1478
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1479
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1480
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1481
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1482
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1483
-				    $data['latitude'] = $line['latitude'];
1484
-				    $data['longitude'] = $line['longitude'];
1485
-				    //$data['verticalrate'] = $line[16];
1486
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1487
-				    //else $data['speed'] = 0;
1488
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1489
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1490
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1491
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1492
-				    //else $data['heading'] = 0;
1493
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1494
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1495
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1496
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1497
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1498
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1499
-    				    $data['id_source'] = $id_source;
1500
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1501
-				    else $data['format_source'] = 'aprs';
1502
-				    $data['source_name'] = $line['source'];
1503
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1504
-				    else $data['source_type'] = 'flarm';
1505
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1506
-				    $currentdate = date('Y-m-d H:i:s');
1507
-				    $aprsdate = strtotime($data['datetime']);
1508
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1509
-				    // Accept data if time <= system time + 20s
1510
-				    //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'])))) {
1511
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1468
+					$aprs_last_tx = time();
1469
+					$data = array();
1470
+					//print_r($line);
1471
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1472
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1473
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1474
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1475
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1476
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1477
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1478
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1479
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1480
+					else $data['datetime'] = date('Y-m-d H:i:s');
1481
+					//$data['datetime'] = date('Y-m-d H:i:s');
1482
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1483
+					$data['latitude'] = $line['latitude'];
1484
+					$data['longitude'] = $line['longitude'];
1485
+					//$data['verticalrate'] = $line[16];
1486
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1487
+					//else $data['speed'] = 0;
1488
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1489
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1490
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1491
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1492
+					//else $data['heading'] = 0;
1493
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1494
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1495
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1496
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1497
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1498
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1499
+						$data['id_source'] = $id_source;
1500
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1501
+					else $data['format_source'] = 'aprs';
1502
+					$data['source_name'] = $line['source'];
1503
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1504
+					else $data['source_type'] = 'flarm';
1505
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1506
+					$currentdate = date('Y-m-d H:i:s');
1507
+					$aprsdate = strtotime($data['datetime']);
1508
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1509
+					// Accept data if time <= system time + 20s
1510
+					//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'])))) {
1511
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1512 1512
 					$send = $SI->add($data);
1513
-				    } elseif ($data['source_type'] == 'ais') {
1513
+					} elseif ($data['source_type'] == 'ais') {
1514 1514
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1515
-				    } elseif (isset($line['stealth'])) {
1515
+					} elseif (isset($line['stealth'])) {
1516 1516
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1517 1517
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1518
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1519
-					    //$line['symbol'] == 'Balloon' ||
1520
-					    $line['symbol'] == 'Glider' || 
1521
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1522
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1523
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1524
-					    $send = $SI->add($data);
1525
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1526
-					    $line['symbol'] == 'Yacht (Sail)' || 
1527
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1528
-					    $send = $MI->add($data);
1529
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1530
-					    $line['symbol'] == 'Car' || 
1531
-					    $line['symbol'] == 'Ambulance' || 
1532
-					    $line['symbol'] == 'Van' || 
1533
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1534
-					    $line['symbol'] == 'Motorcycle' || 
1535
-					    $line['symbol'] == 'Tractor' || 
1536
-					    $line['symbol'] == 'Police' || 
1537
-					    $line['symbol'] == 'Bike' || 
1538
-					    $line['symbol'] == 'Jogger' || 
1539
-					    $line['symbol'] == 'Horse' || 
1540
-					    $line['symbol'] == 'Bus' || 
1541
-					    $line['symbol'] == 'Jeep' || 
1542
-					    $line['symbol'] == 'Recreational Vehicle' || 
1543
-					    $line['symbol'] == 'Yacht (Sail)' || 
1544
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1545
-					    $line['symbol'] == 'Firetruck' || 
1546
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1547
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1548
-					    $line['symbol'] == 'SUV' ||
1549
-					    $line['symbol'] == 'Snowmobile' ||
1550
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1551
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1518
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1519
+						//$line['symbol'] == 'Balloon' ||
1520
+						$line['symbol'] == 'Glider' || 
1521
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1522
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1523
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1524
+						$send = $SI->add($data);
1525
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1526
+						$line['symbol'] == 'Yacht (Sail)' || 
1527
+						$line['symbol'] == 'Ship (Power Boat)')) {
1528
+						$send = $MI->add($data);
1529
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1530
+						$line['symbol'] == 'Car' || 
1531
+						$line['symbol'] == 'Ambulance' || 
1532
+						$line['symbol'] == 'Van' || 
1533
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1534
+						$line['symbol'] == 'Motorcycle' || 
1535
+						$line['symbol'] == 'Tractor' || 
1536
+						$line['symbol'] == 'Police' || 
1537
+						$line['symbol'] == 'Bike' || 
1538
+						$line['symbol'] == 'Jogger' || 
1539
+						$line['symbol'] == 'Horse' || 
1540
+						$line['symbol'] == 'Bus' || 
1541
+						$line['symbol'] == 'Jeep' || 
1542
+						$line['symbol'] == 'Recreational Vehicle' || 
1543
+						$line['symbol'] == 'Yacht (Sail)' || 
1544
+						$line['symbol'] == 'Ship (Power Boat)' || 
1545
+						$line['symbol'] == 'Firetruck' || 
1546
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1547
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1548
+						$line['symbol'] == 'SUV' ||
1549
+						$line['symbol'] == 'Snowmobile' ||
1550
+						$line['symbol'] == 'Mobile Satellite Station')) {
1551
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1552 1552
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1553 1553
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1554 1554
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1555
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1555
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1556 1556
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1557 1557
 					$Source->deleteOldLocationByType('gs');
1558 1558
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
 					} else {
1561 1561
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1562 1562
 					}
1563
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1563
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1564 1564
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1565 1565
 					if ($globalDebug) echo '# Weather Station added'."\n";
1566 1566
 					$Source->deleteOldLocationByType('wx');
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
 					} else {
1571 1571
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1572 1572
 					}
1573
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1573
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1574 1574
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1575 1575
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1576 1576
 					$Source->deleteOldLocationByType('lightning');
@@ -1579,11 +1579,11 @@  discard block
 block discarded – undo
1579 1579
 					} else {
1580 1580
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1581 1581
 					}
1582
-				    } elseif ($globalDebug) {
1583
-				    	echo '/!\ Not added: '.$buffer."\n";
1584
-				    	print_r($line);
1585
-				    }
1586
-				    unset($data);
1582
+					} elseif ($globalDebug) {
1583
+						echo '/!\ Not added: '.$buffer."\n";
1584
+						print_r($line);
1585
+					}
1586
+					unset($data);
1587 1587
 				}
1588 1588
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1589 1589
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1602,12 +1602,12 @@  discard block
 block discarded – undo
1602 1602
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1603 1603
 					$globalSources[$nb]['last_weather_clean'] = time();
1604 1604
 				}
1605
-			    }
1605
+				}
1606 1606
 			} else {
1607
-			    $line = explode(',', $buffer);
1608
-    			    if (count($line) > 20) {
1609
-    			    	$data['hex'] = $line[4];
1610
-    				/*
1607
+				$line = explode(',', $buffer);
1608
+					if (count($line) > 20) {
1609
+						$data['hex'] = $line[4];
1610
+					/*
1611 1611
     				$data['datetime'] = $line[6].' '.$line[7];
1612 1612
     					date_default_timezone_set($globalTimezone);
1613 1613
     					$datetime = new DateTime($data['datetime']);
@@ -1615,30 +1615,30 @@  discard block
 block discarded – undo
1615 1615
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1616 1616
     					date_default_timezone_set('UTC');
1617 1617
     				*/
1618
-    				// Force datetime to current UTC datetime
1619
-    				date_default_timezone_set('UTC');
1620
-    				$data['datetime'] = date('Y-m-d H:i:s');
1621
-    				$data['ident'] = trim($line[10]);
1622
-    				$data['latitude'] = $line[14];
1623
-    				$data['longitude'] = $line[15];
1624
-    				$data['verticalrate'] = $line[16];
1625
-    				$data['emergency'] = $line[20];
1626
-    				$data['speed'] = $line[12];
1627
-    				$data['squawk'] = $line[17];
1628
-    				$data['altitude'] = $line[11];
1629
-    				$data['heading'] = $line[13];
1630
-    				$data['ground'] = $line[21];
1631
-    				$data['emergency'] = $line[19];
1632
-    				$data['format_source'] = 'sbs';
1618
+					// Force datetime to current UTC datetime
1619
+					date_default_timezone_set('UTC');
1620
+					$data['datetime'] = date('Y-m-d H:i:s');
1621
+					$data['ident'] = trim($line[10]);
1622
+					$data['latitude'] = $line[14];
1623
+					$data['longitude'] = $line[15];
1624
+					$data['verticalrate'] = $line[16];
1625
+					$data['emergency'] = $line[20];
1626
+					$data['speed'] = $line[12];
1627
+					$data['squawk'] = $line[17];
1628
+					$data['altitude'] = $line[11];
1629
+					$data['heading'] = $line[13];
1630
+					$data['ground'] = $line[21];
1631
+					$data['emergency'] = $line[19];
1632
+					$data['format_source'] = 'sbs';
1633 1633
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1634
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1634
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1635 1635
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1636
-    				$data['id_source'] = $id_source;
1637
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1638
-    				else $error = true;
1639
-    				unset($data);
1640
-    			    } else $error = true;
1641
-			    if ($error) {
1636
+					$data['id_source'] = $id_source;
1637
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1638
+					else $error = true;
1639
+					unset($data);
1640
+					} else $error = true;
1641
+				if ($error) {
1642 1642
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1643 1643
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1644 1644
 				} else {
@@ -1654,13 +1654,13 @@  discard block
 block discarded – undo
1654 1654
 					connect_all($sourceer);
1655 1655
 					$sourceer = array();
1656 1656
 				}
1657
-			    }
1657
+				}
1658 1658
 			}
1659 1659
 			// Sleep for xxx microseconds
1660 1660
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1661
-		    } else {
1661
+			} else {
1662 1662
 			if ($format == 'flightgearmp') {
1663
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1663
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1664 1664
 				//@socket_close($r);
1665 1665
 				sleep($globalMinFetch);
1666 1666
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1669,9 +1669,9 @@  discard block
 block discarded – undo
1669 1669
 				break;
1670 1670
 				
1671 1671
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1672
-			    if (isset($tt[$format])) $tt[$format]++;
1673
-			    else $tt[$format] = 0;
1674
-			    if ($tt[$format] > 30) {
1672
+				if (isset($tt[$format])) $tt[$format]++;
1673
+				else $tt[$format] = 0;
1674
+				if ($tt[$format] > 30) {
1675 1675
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1676 1676
 				//@socket_close($r);
1677 1677
 				sleep(2);
@@ -1682,23 +1682,23 @@  discard block
 block discarded – undo
1682 1682
 				//connect_all($globalSources);
1683 1683
 				$tt[$format]=0;
1684 1684
 				break;
1685
-			    }
1685
+				}
1686
+			}
1686 1687
 			}
1687
-		    }
1688 1688
 		}
1689
-	    } else {
1689
+		} else {
1690 1690
 		$error = socket_strerror(socket_last_error());
1691 1691
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1692 1692
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1693 1693
 			if (isset($globalDebug)) echo "Restarting...\n";
1694 1694
 			// Restart the script if possible
1695 1695
 			if (is_array($sockets)) {
1696
-			    if ($globalDebug) echo "Shutdown all sockets...";
1696
+				if ($globalDebug) echo "Shutdown all sockets...";
1697 1697
 			    
1698
-			    foreach ($sockets as $sock) {
1698
+				foreach ($sockets as $sock) {
1699 1699
 				@socket_shutdown($sock,2);
1700 1700
 				@socket_close($sock);
1701
-			    }
1701
+				}
1702 1702
 			    
1703 1703
 			}
1704 1704
 			if ($globalDebug) echo "Waiting...";
@@ -1713,15 +1713,15 @@  discard block
 block discarded – undo
1713 1713
 			if ($globalDebug) echo "Restart all connections...";
1714 1714
 			connect_all($globalSources);
1715 1715
 		}
1716
-	    }
1716
+		}
1717 1717
 	}
1718 1718
 	if ($globalDaemon === false) {
1719
-	    if ($globalDebug) echo 'Check all...'."\n";
1720
-	    if (isset($SI)) $SI->checkAll();
1721
-	    if (isset($TI)) $TI->checkAll();
1722
-	    if (isset($MI)) $MI->checkAll();
1719
+		if ($globalDebug) echo 'Check all...'."\n";
1720
+		if (isset($SI)) $SI->checkAll();
1721
+		if (isset($TI)) $TI->checkAll();
1722
+		if (isset($MI)) $MI->checkAll();
1723
+	}
1723 1724
 	}
1724
-    }
1725 1725
 }
1726 1726
 
1727 1727
 ?>
Please login to merge, or discard this patch.
install/index.php 2 patches
Spacing   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 require_once(dirname(__FILE__).'/class.create_db.php');
11 11
 require_once(dirname(__FILE__).'/class.update_schema.php');
12 12
 require_once(dirname(__FILE__).'/class.settings.php');
13
-$title="Install";
13
+$title = "Install";
14 14
 require(dirname(__FILE__).'/../require/settings.php');
15 15
 require(dirname(__FILE__).'/header.php');
16 16
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 if (!extension_loaded('curl')) {
70 70
 	$error[] = "Curl is not loaded.";
71 71
 }
72
-if(function_exists('apache_get_modules') ){
73
-	if(!in_array('mod_rewrite',apache_get_modules())) {
72
+if (function_exists('apache_get_modules')) {
73
+	if (!in_array('mod_rewrite', apache_get_modules())) {
74 74
 		$error[] = "mod_rewrite is not available.";
75 75
 	}
76 76
 /*
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
87 87
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
88 88
 	if (function_exists('get_headers')) {
89
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
90
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
89
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
90
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
91 91
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
92 92
 		}
93 93
 	}
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
 ?>
455 455
 							<tr>
456 456
 								<?php
457
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
457
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
458 458
 								?>
459 459
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
460 460
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
461 461
 								<?php
462 462
 								    } else {
463
-									$hostport = explode(':',$source['host']);
463
+									$hostport = explode(':', $source['host']);
464 464
 									if (isset($hostport[1])) {
465 465
 										$host = $hostport[0];
466 466
 										$port = $hostport[1];
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 									<select name="timezones[]" id="timezones">
508 508
 								<?php
509 509
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
510
-									foreach($timezonelist as $timezones){
510
+									foreach ($timezonelist as $timezones) {
511 511
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
512 512
 											print '<option selected>'.$timezones.'</option>';
513 513
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 									<select name="timezones[]" id="timezones">
560 560
 								<?php
561 561
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
562
-									foreach($timezonelist as $timezones){
562
+									foreach ($timezonelist as $timezones) {
563 563
 										if ($timezones == 'UTC') {
564 564
 											print '<option selected>'.$timezones.'</option>';
565 565
 										} else print '<option>'.$timezones.'</option>';
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 			<br />
877 877
 			<p>
878 878
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
879
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
879
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
880 880
 			</p>
881 881
 			<br />
882 882
 			<p>
@@ -932,14 +932,14 @@  discard block
 block discarded – undo
932 932
 $error = '';
933 933
 
934 934
 if (isset($_POST['dbtype'])) {
935
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
936
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
937
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
938
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
939
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
940
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
941
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
942
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
935
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
936
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
937
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
938
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
939
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
940
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
941
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
942
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
943 943
 
944 944
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
945 945
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -959,49 +959,49 @@  discard block
 block discarded – undo
959 959
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
960 960
 	*/
961 961
 	
962
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
962
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
963 963
 
964
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
965
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
966
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
967
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
968
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
964
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
965
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
966
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
967
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
968
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
969 969
 
970
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
971
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
972
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
973
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
974
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
975
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
976
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
977
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
978
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
979
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
970
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
971
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
972
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
973
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
974
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
975
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
976
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
977
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
978
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
979
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
980 980
 	
981
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
982
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
983
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
984
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
985
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
986
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
981
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
982
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
983
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
984
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
985
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
986
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
987 987
 
988
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
989
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
988
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
989
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
990 990
 
991
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
992
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
993
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
991
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
992
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
993
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
994 994
 
995
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
995
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
996 996
 	if ($acars == 'acars') {
997
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
997
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
998 998
 	} else {
999
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
999
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1000 1000
 	}
1001 1001
 
1002
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1003
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1004
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1002
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1003
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1004
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1005 1005
 	
1006 1006
 	$source_name = $_POST['source_name'];
1007 1007
 	$source_latitude = $_POST['source_latitude'];
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
 	
1016 1016
 	$sources = array();
1017 1017
 	foreach ($source_name as $keys => $name) {
1018
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1019
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1018
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
1019
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
1020 1020
 	}
1021 1021
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1022 1022
 
@@ -1029,27 +1029,27 @@  discard block
 block discarded – undo
1029 1029
 	$sbsurl = $_POST['sbsurl'];
1030 1030
 	*/
1031 1031
 
1032
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1033
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1034
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1035
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1036
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1037
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1038
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1039
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1032
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1033
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1034
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1035
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1036
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1037
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1038
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1039
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1040 1040
 
1041
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1042
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1043
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1044
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1045
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1046
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1047
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1048
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1049
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1050
-	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1051
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1052
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1041
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1042
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1043
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1044
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1045
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1046
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1047
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1048
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1049
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1050
+	$globalsatellite = filter_input(INPUT_POST, 'globalsatellite', FILTER_SANITIZE_STRING);
1051
+	if ($globalsatellite == 'satellite') $settings = array_merge($settings, array('globalSatellite' => 'TRUE'));
1052
+	else $settings = array_merge($settings, array('globalSatellite' => 'FALSE'));
1053 1053
 
1054 1054
 /*	
1055 1055
 	$globalSBS1Hosts = array();
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 	}
1066 1066
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1067 1067
 */
1068
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1068
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1069 1069
 	$host = $_POST['host'];
1070 1070
 	$port = $_POST['port'];
1071 1071
 	$name = $_POST['name'];
@@ -1082,104 +1082,104 @@  discard block
 block discarded – undo
1082 1082
 		else $cov = 'FALSE';
1083 1083
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1084 1084
 		else $arch = 'FALSE';
1085
-		if (strpos($format[$key],'_callback')) {
1086
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1085
+		if (strpos($format[$key], '_callback')) {
1086
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1087 1087
 		} elseif ($h != '' || $name[$key] != '') {
1088
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1088
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1089 1089
 		}
1090 1090
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1091 1091
 	}
1092
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1092
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1093 1093
 
1094 1094
 /*
1095 1095
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1096 1096
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1097 1097
 */
1098
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1099
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1100
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1098
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1099
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1100
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1101 1101
 
1102
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1103
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1102
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1103
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1104 1104
 
1105
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1106
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1105
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1106
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1107 1107
 
1108
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1109
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1110
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1111
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1108
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1109
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1110
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1111
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1112 1112
 
1113
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1114
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1115
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1113
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1114
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1115
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1116 1116
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1117
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1118
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1117
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1118
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1119 1119
 
1120
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1121
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1122
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1123
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1124
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1125
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1126
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1127
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1120
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1121
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1122
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1123
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1124
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1125
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1126
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1127
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1128 1128
 
1129
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1130
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1129
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1130
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1131 1131
 
1132
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1133
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1132
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1133
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1134 1134
 	
1135
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1135
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1136 1136
 	if ($archiveyear == "archiveyear") {
1137
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1137
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1138 1138
 	} else {
1139
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1139
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1140 1140
 	}
1141
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1142
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1143
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1144
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1141
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1142
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1143
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1144
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1145 1145
 
1146
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1147
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1148
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1149
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1146
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1147
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1148
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1149
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1150 1150
 
1151
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1152
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1153
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1151
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1152
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1153
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1154 1154
 
1155 1155
 	// Create in settings.php keys not yet configurable if not already here
1156 1156
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1157
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1157
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1158 1158
 
1159
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1159
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1160 1160
 	if ($resetyearstats == 'resetyearstats') {
1161
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1161
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1162 1162
 	} else {
1163
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1163
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1164 1164
 	}
1165 1165
 
1166
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1166
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1167 1167
 	if ($archive == 'archive') {
1168
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1168
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1169 1169
 	} else {
1170
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1170
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1171 1171
 	}
1172
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1172
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1173 1173
 	if ($daemon == 'daemon') {
1174
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1174
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1175 1175
 	} else {
1176
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1176
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1177 1177
 	}
1178
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1178
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1179 1179
 	if ($schedules == 'schedules') {
1180
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1180
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1181 1181
 	} else {
1182
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1182
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1183 1183
 	}
1184 1184
 
1185 1185
 /*
@@ -1190,227 +1190,227 @@  discard block
 block discarded – undo
1190 1190
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1191 1191
 	}
1192 1192
 */
1193
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1194
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1195
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1196
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1197
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1193
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1194
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1195
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1196
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1197
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1198 1198
 	$va = false;
1199 1199
 	if ($globalivao == 'ivao') {
1200
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1200
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1201 1201
 		$va = true;
1202
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1202
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1203 1203
 	if ($globalvatsim == 'vatsim') {
1204
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1204
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1205 1205
 		$va = true;
1206
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1206
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1207 1207
 	if ($globalphpvms == 'phpvms') {
1208
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1208
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1209 1209
 		$va = true;
1210
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1210
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1211 1211
 	if ($globalvam == 'vam') {
1212
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1212
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1213 1213
 		$va = true;
1214
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1214
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1215 1215
 	if ($va) {
1216
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1217
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1216
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1217
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1218 1218
 	if ($globalva == 'va' || $va) {
1219
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1220
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1219
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1220
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1221 1221
 	} else {
1222
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1223
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1224
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1222
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1223
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1224
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1225 1225
 	}
1226 1226
 	
1227 1227
 	
1228 1228
 
1229
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1229
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1230 1230
 	if ($notam == 'notam') {
1231
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1231
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1232 1232
 	} else {
1233
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1233
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1234 1234
 	}
1235
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1235
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1236 1236
 	if ($owner == 'owner') {
1237
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1237
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1238 1238
 	} else {
1239
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1239
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1240 1240
 	}
1241
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1241
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1242 1242
 	if ($map3d == 'map3d') {
1243
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1243
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1244 1244
 	} else {
1245
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1245
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1246 1246
 	}
1247
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1247
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1248 1248
 	if ($crash == 'crash') {
1249
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1249
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1250 1250
 	} else {
1251
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1251
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1252 1252
 	}
1253
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1253
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1254 1254
 	if ($mapsatellites == 'mapsatellites') {
1255
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1255
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1256 1256
 	} else {
1257
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1257
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1258 1258
 	}
1259
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1259
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1260 1260
 	if ($map3ddefault == 'map3ddefault') {
1261
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1261
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1262 1262
 	} else {
1263
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1263
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1264 1264
 	}
1265
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1265
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1266 1266
 	if ($translate == 'translate') {
1267
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1267
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1268 1268
 	} else {
1269
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1269
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1270 1270
 	}
1271
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1271
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1272 1272
 	if ($realairlines == 'realairlines') {
1273
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1273
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1274 1274
 	} else {
1275
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1275
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1276 1276
 	}
1277
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1277
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1278 1278
 	if ($estimation == 'estimation') {
1279
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1279
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1280 1280
 	} else {
1281
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1281
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1282 1282
 	}
1283
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1283
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1284 1284
 	if ($metar == 'metar') {
1285
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1285
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1286 1286
 	} else {
1287
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1287
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1288 1288
 	}
1289
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1289
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1290 1290
 	if ($metarcycle == 'metarcycle') {
1291
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1291
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1292 1292
 	} else {
1293
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1293
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1294 1294
 	}
1295
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1295
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1296 1296
 	if ($fork == 'fork') {
1297
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1297
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1298 1298
 	} else {
1299
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1299
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1300 1300
 	}
1301 1301
 
1302
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1302
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1303 1303
 	if ($colormap == 'colormap') {
1304
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1304
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1305 1305
 	} else {
1306
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1306
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1307 1307
 	}
1308 1308
 	
1309 1309
 	if (isset($_POST['aircrafticoncolor'])) {
1310
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1311
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1310
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1311
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1312 1312
 	}
1313 1313
 
1314
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1315
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1314
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1315
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1316 1316
 
1317
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1318
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1319
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1320
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1321
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1322
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1317
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1318
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1319
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1320
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1321
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1322
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1323 1323
 
1324
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1324
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1325 1325
 	if ($mappopup == 'mappopup') {
1326
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1326
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1327 1327
 	} else {
1328
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1328
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1329 1329
 	}
1330
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1330
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1331 1331
 	if ($airportpopup == 'airportpopup') {
1332
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1332
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1333 1333
 	} else {
1334
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1334
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1335 1335
 	}
1336
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1336
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1337 1337
 	if ($maphistory == 'maphistory') {
1338
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1338
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1339 1339
 	} else {
1340
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1340
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1341 1341
 	}
1342
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1342
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1343 1343
 	if ($maptooltip == 'maptooltip') {
1344
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1344
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1345 1345
 	} else {
1346
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1346
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1347 1347
 	}
1348
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1348
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1349 1349
 	if ($flightroute == 'flightroute') {
1350
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1350
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1351 1351
 	} else {
1352
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1352
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1353 1353
 	}
1354
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1354
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1355 1355
 	if ($flightremainingroute == 'flightremainingroute') {
1356
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1356
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1357 1357
 	} else {
1358
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1358
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1359 1359
 	}
1360
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1360
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1361 1361
 	if ($allflights == 'allflights') {
1362
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1362
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1363 1363
 	} else {
1364
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1364
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1365 1365
 	}
1366
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1366
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1367 1367
 	if ($bbox == 'bbox') {
1368
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1368
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1369 1369
 	} else {
1370
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1370
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1371 1371
 	}
1372
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1372
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1373 1373
 	if ($groundaltitude == 'groundaltitude') {
1374
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1374
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1375 1375
 	} else {
1376
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1376
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1377 1377
 	}
1378
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1378
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1379 1379
 	if ($waypoints == 'waypoints') {
1380
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1380
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1381 1381
 	} else {
1382
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1382
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1383 1383
 	}
1384
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1384
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1385 1385
 	if ($geoid == 'geoid') {
1386
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1386
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1387 1387
 	} else {
1388
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1388
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1389 1389
 	}
1390
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1391
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1390
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1391
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1392 1392
 
1393
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1393
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1394 1394
 	if ($noairlines == 'noairlines') {
1395
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1395
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1396 1396
 	} else {
1397
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1397
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1398 1398
 	}
1399 1399
 
1400
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1400
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1401 1401
 
1402 1402
 	// Set some defaults values...
1403 1403
 	if (!isset($globalAircraftImageSources)) {
1404
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1405
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1404
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1405
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1406 1406
 	}
1407 1407
 
1408 1408
 	if (!isset($globalSchedulesSources)) {
1409
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1410
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1409
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1410
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1411 1411
     	}
1412 1412
 
1413
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1413
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1414 1414
 
1415 1415
 	if ($error == '') settings::modify_settings($settings);
1416 1416
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
Braces   +506 added lines, -136 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -238,7 +286,10 @@  discard block
 block discarded – undo
238 286
 			<div id="openweathermap_data">
239 287
 				<p>
240 288
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
241
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
289
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
290
+	print $globalOpenWeatherMapKey;
291
+}
292
+?>" />
242 293
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
243 294
 				</p>
244 295
 			</div>
@@ -248,42 +299,86 @@  discard block
 block discarded – undo
248 299
 			<legend>Coverage area</legend>
249 300
 			<p>
250 301
 				<label for="latitudemax">The maximum latitude (north)</label>
251
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
302
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
303
+	print $globalLatitudeMax;
304
+}
305
+?>" />
252 306
 			</p>
253 307
 			<p>
254 308
 				<label for="latitudemin">The minimum latitude (south)</label>
255
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
309
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
310
+	print $globalLatitudeMin;
311
+}
312
+?>" />
256 313
 			</p>
257 314
 			<p>
258 315
 				<label for="longitudemax">The maximum longitude (west)</label>
259
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
316
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
317
+	print $globalLongitudeMax;
318
+}
319
+?>" />
260 320
 			</p>
261 321
 			<p>
262 322
 				<label for="longitudemin">The minimum longitude (east)</label>
263
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
323
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
324
+	print $globalLongitudeMin;
325
+}
326
+?>" />
264 327
 			</p>
265 328
 			<p>
266 329
 				<label for="latitudecenter">The latitude center</label>
267
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
330
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
331
+	print $globalCenterLatitude;
332
+}
333
+?>" />
268 334
 			</p>
269 335
 			<p>
270 336
 				<label for="longitudecenter">The longitude center</label>
271
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
337
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
338
+	print $globalCenterLongitude;
339
+}
340
+?>" />
272 341
 			</p>
273 342
 			<p>
274 343
 				<label for="livezoom">Default Zoom on live map</label>
275
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
344
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
345
+	print $globalLiveZoom;
346
+} else {
347
+	print '9';
348
+}
349
+?>" />
276 350
 			</p>
277 351
 			<p>
278 352
 				<label for="squawk_country">Country for squawk usage</label>
279 353
 				<select name="squawk_country" id="squawk_country">
280
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
281
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
282
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
283
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
284
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
285
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
286
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
354
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
355
+	print ' selected ';
356
+}
357
+?>>UK</option>
358
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
359
+	print ' selected ';
360
+}
361
+?>>NZ</option>
362
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
363
+	print ' selected ';
364
+}
365
+?>>US</option>
366
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
367
+	print ' selected ';
368
+}
369
+?>>AU</option>
370
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
371
+	print ' selected ';
372
+}
373
+?>>NL</option>
374
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
375
+	print ' selected ';
376
+}
377
+?>>FR</option>
378
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
379
+	print ' selected ';
380
+}
381
+?>>TR</option>
287 382
 				</select>
288 383
 			</p>
289 384
 		</fieldset>
@@ -292,15 +387,24 @@  discard block
 block discarded – undo
292 387
 			<p><i>Only put in DB flights that are inside a circle</i></p>
293 388
 			<p>
294 389
 				<label for="latitude">Center latitude</label>
295
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
390
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
391
+	echo $globalDistanceIgnore['latitude'];
392
+}
393
+?>" />
296 394
 			</p>
297 395
 			<p>
298 396
 				<label for="longitude">Center longitude</label>
299
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
397
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
398
+	echo $globalDistanceIgnore['longitude'];
399
+}
400
+?>" />
300 401
 			</p>
301 402
 			<p>
302 403
 				<label for="Distance">Distance (in km)</label>
303
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
404
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
405
+	echo $globalDistanceIgnore['distance'];
406
+}
407
+?>" />
304 408
 			</p>
305 409
 		</fieldset>
306 410
 		<fieldset id="sourceloc">
@@ -411,11 +515,17 @@  discard block
 block discarded – undo
411 515
 			<div id="flightaware_data">
412 516
 				<p>
413 517
 					<label for="flightawareusername">FlightAware username</label>
414
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
518
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
519
+	print $globalFlightAwareUsername;
520
+}
521
+?>" />
415 522
 				</p>
416 523
 				<p>
417 524
 					<label for="flightawarepassword">FlightAware password/API key</label>
418
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
525
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
526
+	print $globalFlightAwarePassword;
527
+}
528
+?>" />
419 529
 				</p>
420 530
 			</div>
421 531
 -->
@@ -457,7 +567,10 @@  discard block
 block discarded – undo
457 567
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
458 568
 								?>
459 569
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
460
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
570
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
571
+	print $source['port'];
572
+}
573
+?>" /></td>
461 574
 								<?php
462 575
 								    } else {
463 576
 									$hostport = explode(':',$source['host']);
@@ -476,33 +589,102 @@  discard block
 block discarded – undo
476 589
 								?>
477 590
 								<td>
478 591
 									<select name="format[]" id="format">
479
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
480
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
481
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
482
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
483
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
484
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
485
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
486
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
487
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
488
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
489
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
490
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
491
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
492
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
493
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
494
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
495
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
496
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
497
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
498
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
592
+										<option value="auto" <?php if (!isset($source['format'])) {
593
+	print 'selected';
594
+}
595
+?>>Auto</option>
596
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
597
+	print 'selected';
598
+}
599
+?>>SBS</option>
600
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
601
+	print 'selected';
602
+}
603
+?>>TSV</option>
604
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
605
+	print 'selected';
606
+}
607
+?>>Raw</option>
608
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
609
+	print 'selected';
610
+}
611
+?>>APRS</option>
612
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
613
+	print 'selected';
614
+}
615
+?>>Radarcape deltadb.txt</option>
616
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
617
+	print 'selected';
618
+}
619
+?>>Vatsim</option>
620
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
621
+	print 'selected';
622
+}
623
+?>>Virtual Radar Server AircraftList.json</option>
624
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
625
+	print 'selected';
626
+}
627
+?>>Virtual Radar Server TCP</option>
628
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
629
+	print 'selected';
630
+}
631
+?>>phpVMS</option>
632
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
633
+	print 'selected';
634
+}
635
+?>>Virtual Airlines Manager</option>
636
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
637
+	print 'selected';
638
+}
639
+?>>IVAO</option>
640
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
641
+	print 'selected';
642
+}
643
+?>>FlightGear Multiplayer</option>
644
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
645
+	print 'selected';
646
+}
647
+?>>FlightGear Singleplayer</option>
648
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
649
+	print 'selected';
650
+}
651
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
652
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
653
+	print 'selected';
654
+}
655
+?>>ACARS SBS-3 over TCP</option>
656
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
657
+	print 'selected';
658
+}
659
+?>>NMEA AIS over TCP</option>
660
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
661
+	print 'selected';
662
+}
663
+?>>AirWhere website</option>
664
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
665
+	print 'selected';
666
+}
667
+?>>HidnSeek Callback</option>
668
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
669
+	print 'selected';
670
+}
671
+?>>Blitzortung</option>
499 672
 									</select>
500 673
 								</td>
501 674
 								<td>
502
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
675
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
676
+	print $source['name'];
677
+}
678
+?>" />
503 679
 								</td>
504
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
505
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
680
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
681
+	print 'checked';
682
+}
683
+?> /></td>
684
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
685
+	print 'checked';
686
+}
687
+?> /></td>
506 688
 								<td>
507 689
 									<select name="timezones[]" id="timezones">
508 690
 								<?php
@@ -512,7 +694,9 @@  discard block
 block discarded – undo
512 694
 											print '<option selected>'.$timezones.'</option>';
513 695
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
514 696
 											print '<option selected>'.$timezones.'</option>';
515
-										} else print '<option>'.$timezones.'</option>';
697
+										} else {
698
+											print '<option>'.$timezones.'</option>';
699
+										}
516 700
 									}
517 701
 								?>
518 702
 									</select>
@@ -562,7 +746,9 @@  discard block
 block discarded – undo
562 746
 									foreach($timezonelist as $timezones){
563 747
 										if ($timezones == 'UTC') {
564 748
 											print '<option selected>'.$timezones.'</option>';
565
-										} else print '<option>'.$timezones.'</option>';
749
+										} else {
750
+											print '<option>'.$timezones.'</option>';
751
+										}
566 752
 									}
567 753
 								?>
568 754
 									</select>
@@ -585,11 +771,17 @@  discard block
 block discarded – undo
585 771
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
586 772
 					<p>
587 773
 						<label for="acarshost">ACARS UDP host</label>
588
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
774
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
775
+	print $globalACARSHost;
776
+}
777
+?>" />
589 778
 					</p>
590 779
 					<p>
591 780
 						<label for="acarsport">ACARS UDP port</label>
592
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
781
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
782
+	print $globalACARSPort;
783
+}
784
+?>" />
593 785
 					</p>
594 786
 				</fieldset>
595 787
 			</div>
@@ -671,13 +863,19 @@  discard block
 block discarded – undo
671 863
 			<div id="schedules_options">
672 864
 				<p>
673 865
 					<label for="britishairways">British Airways API Key</label>
674
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
866
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
867
+	print $globalBritishAirwaysKey;
868
+}
869
+?>" />
675 870
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
676 871
 				</p>
677 872
 				<!--
678 873
 				<p>
679 874
 					<label for="transavia">Transavia Test API Consumer Key</label>
680
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
875
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
876
+	print $globalTransaviaKey;
877
+}
878
+?>" />
681 879
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
682 880
 				</p>
683 881
 				-->
@@ -686,10 +884,16 @@  discard block
 block discarded – undo
686 884
 						<b>Lufthansa API Key</b>
687 885
 						<p>
688 886
 							<label for="lufthansakey">Key</label>
689
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
887
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
888
+	print $globalLufthansaKey['key'];
889
+}
890
+?>" />
690 891
 						</p><p>
691 892
 							<label for="lufthansasecret">Secret</label>
692
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
893
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
894
+	print $globalLufthansaKey['secret'];
895
+}
896
+?>" />
693 897
 						</p>
694 898
 					</div>
695 899
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -709,7 +913,10 @@  discard block
 block discarded – undo
709 913
 			</p>
710 914
 			<p>
711 915
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
712
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
916
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
917
+	print $globalNOTAMSource;
918
+}
919
+?>" />
713 920
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
714 921
 			</p>
715 922
 			<br />
@@ -725,14 +932,20 @@  discard block
 block discarded – undo
725 932
 			<div id="metarsrc">
726 933
 				<p>
727 934
 					<label for="metarsource">URL of your METAR source</label>
728
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
935
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
936
+	print $globalMETARurl;
937
+}
938
+?>" />
729 939
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
730 940
 				</p>
731 941
 			</div>
732 942
 			<br />
733 943
 			<p>
734 944
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
735
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
945
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
946
+	print $globalBitlyAccessToken;
947
+}
948
+?>" />
736 949
 			</p>
737 950
 			<br />
738 951
 			<p>
@@ -748,11 +961,26 @@  discard block
 block discarded – undo
748 961
 			<p>
749 962
 				<label for="geoid_source">Geoid Source</label>
750 963
 				<select name="geoid_source" id="geoid_source">
751
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
752
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
753
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
754
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
755
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
964
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
965
+	print ' selected="selected"';
966
+}
967
+?>>EGM96 15' (2.1MB)</option>
968
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
969
+	print ' selected="selected"';
970
+}
971
+?>>EGM96 5' (19MB)</option>
972
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
973
+	print ' selected="selected"';
974
+}
975
+?>>EGM2008 5' (19MB)</option>
976
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
977
+	print ' selected="selected"';
978
+}
979
+?>>EGM2008 2.5' (75MB)</option>
980
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
981
+	print ' selected="selected"';
982
+}
983
+?>>EGM2008 1' (470MB)</option>
756 984
 				</select>
757 985
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
758 986
 			</p>
@@ -770,7 +998,12 @@  discard block
 block discarded – undo
770 998
 			</p>
771 999
 			<p>
772 1000
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
773
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1001
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1002
+	print $globalArchiveMonths;
1003
+} else {
1004
+	echo '1';
1005
+}
1006
+?>" />
774 1007
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
775 1008
 			</p>
776 1009
 			<p>
@@ -780,12 +1013,22 @@  discard block
 block discarded – undo
780 1013
 			</p>
781 1014
 			<p>
782 1015
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
783
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1016
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1017
+	print $globalArchiveKeepMonths;
1018
+} else {
1019
+	echo '1';
1020
+}
1021
+?>" />
784 1022
 				<p class="help-block">0 to disable</p>
785 1023
 			</p>
786 1024
 			<p>
787 1025
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
788
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1026
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1027
+	print $globalArchiveKeepTrackMonths;
1028
+} else {
1029
+	echo '1';
1030
+}
1031
+?>" />
789 1032
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
790 1033
 			</p>
791 1034
 			<br />
@@ -795,7 +1038,12 @@  discard block
 block discarded – undo
795 1038
 				<p class="help-block">Uncheck if the script is running as cron job</p>
796 1039
 				<div id="cronends"> 
797 1040
 					<label for="cronend">Run script for xx seconds</label>
798
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1041
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1042
+	print $globalCronEnd;
1043
+} else {
1044
+	print '0';
1045
+}
1046
+?>" />
799 1047
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
800 1048
 				</div>
801 1049
 			</p>
@@ -848,15 +1096,30 @@  discard block
 block discarded – undo
848 1096
 			<br />
849 1097
 			<p>
850 1098
 				<label for="refresh">Show flights detected since xxx seconds</label>
851
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1099
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1100
+	echo $globalLiveInterval;
1101
+} else {
1102
+	echo '200';
1103
+}
1104
+?>" />
852 1105
 			</p>
853 1106
 			<p>
854 1107
 				<label for="maprefresh">Live map refresh (in seconds)</label>
855
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1108
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1109
+	echo $globalMapRefresh;
1110
+} else {
1111
+	echo '30';
1112
+}
1113
+?>" />
856 1114
 			</p>
857 1115
 			<p>
858 1116
 				<label for="mapidle">Map idle timeout (in minutes)</label>
859
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1117
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1118
+	echo $globalMapIdleTimeout;
1119
+} else {
1120
+	echo '30';
1121
+}
1122
+?>" />
860 1123
 				<p class="help-block">0 to disable</p>
861 1124
 			</p>
862 1125
 			<p>
@@ -871,12 +1134,20 @@  discard block
 block discarded – undo
871 1134
 			<br />
872 1135
 			<p>
873 1136
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
874
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1137
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1138
+	echo $globalClosestMinDist;
1139
+} else {
1140
+	echo '50';
1141
+}
1142
+?>" />
875 1143
 			</p>
876 1144
 			<br />
877 1145
 			<p>
878 1146
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
879
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1147
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1148
+	echo $globalAircraftSize;
1149
+}
1150
+?>" />
880 1151
 			</p>
881 1152
 			<br />
882 1153
 			<p>
@@ -889,7 +1160,12 @@  discard block
 block discarded – undo
889 1160
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
890 1161
 			?>
891 1162
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
892
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1163
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1164
+	echo $globalAircraftIconColor;
1165
+} else {
1166
+	echo '1a3151';
1167
+}
1168
+?>" />
893 1169
 			<?php
894 1170
 				if (!is_writable('../cache')) {
895 1171
 			?>
@@ -907,14 +1183,27 @@  discard block
 block discarded – undo
907 1183
 			<p>
908 1184
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
909 1185
 				<div class="range">
910
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
911
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1186
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1187
+	echo $globalAirportZoom;
1188
+} else {
1189
+	echo '7';
1190
+}
1191
+?>" />
1192
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1193
+	echo $globalAirportZoom;
1194
+} else {
1195
+	echo '7';
1196
+}
1197
+?></output>
912 1198
 				</div>
913 1199
 			</p>
914 1200
 			<br />
915 1201
 			<p>
916 1202
 				<label for="customcss">Custom CSS web path</label>
917
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1203
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1204
+	echo $globalCustomCSS;
1205
+}
1206
+?>" />
918 1207
 			</p>
919 1208
 		</fieldset>
920 1209
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -941,8 +1230,12 @@  discard block
 block discarded – undo
941 1230
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
942 1231
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
943 1232
 
944
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
945
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1233
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1234
+		$error .= 'Mysql driver for PDO must be loaded';
1235
+	}
1236
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1237
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1238
+	}
946 1239
 	
947 1240
 	$_SESSION['database_root'] = $dbroot;
948 1241
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1010,15 +1303,23 @@  discard block
 block discarded – undo
1010 1303
 	$source_city = $_POST['source_city'];
1011 1304
 	$source_country = $_POST['source_country'];
1012 1305
 	$source_ref = $_POST['source_ref'];
1013
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1014
-	else $source_id = array();
1306
+	if (isset($source_id)) {
1307
+		$source_id = $_POST['source_id'];
1308
+	} else {
1309
+		$source_id = array();
1310
+	}
1015 1311
 	
1016 1312
 	$sources = array();
1017 1313
 	foreach ($source_name as $keys => $name) {
1018
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1019
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1314
+	    if (isset($source_id[$keys])) {
1315
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1316
+	    } else {
1317
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1318
+	    }
1319
+	}
1320
+	if (count($sources) > 0) {
1321
+		$_SESSION['sources'] = $sources;
1020 1322
 	}
1021
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1022 1323
 
1023 1324
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1024 1325
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1039,17 +1340,29 @@  discard block
 block discarded – undo
1039 1340
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1040 1341
 
1041 1342
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1042
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1043
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1343
+	if ($globalaircraft == 'aircraft') {
1344
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1345
+	} else {
1346
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1347
+	}
1044 1348
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1045
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1046
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1349
+	if ($globaltracker == 'tracker') {
1350
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1351
+	} else {
1352
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1353
+	}
1047 1354
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1048
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1049
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1355
+	if ($globalmarine == 'marine') {
1356
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1357
+	} else {
1358
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1359
+	}
1050 1360
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1051
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1052
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1361
+	if ($globalsatellite == 'satellite') {
1362
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1363
+	} else {
1364
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1365
+	}
1053 1366
 
1054 1367
 /*	
1055 1368
 	$globalSBS1Hosts = array();
@@ -1071,23 +1384,37 @@  discard block
 block discarded – undo
1071 1384
 	$name = $_POST['name'];
1072 1385
 	$format = $_POST['format'];
1073 1386
 	$timezones = $_POST['timezones'];
1074
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1075
-	else $sourcestats = array();
1076
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1077
-	else $noarchive = array();
1387
+	if (isset($_POST['sourcestats'])) {
1388
+		$sourcestats = $_POST['sourcestats'];
1389
+	} else {
1390
+		$sourcestats = array();
1391
+	}
1392
+	if (isset($_POST['noarchive'])) {
1393
+		$noarchive = $_POST['noarchive'];
1394
+	} else {
1395
+		$noarchive = array();
1396
+	}
1078 1397
 	$gSources = array();
1079 1398
 	$forcepilots = false;
1080 1399
 	foreach ($host as $key => $h) {
1081
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1082
-		else $cov = 'FALSE';
1083
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1084
-		else $arch = 'FALSE';
1400
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1401
+			$cov = 'TRUE';
1402
+		} else {
1403
+			$cov = 'FALSE';
1404
+		}
1405
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1406
+			$arch = 'TRUE';
1407
+		} else {
1408
+			$arch = 'FALSE';
1409
+		}
1085 1410
 		if (strpos($format[$key],'_callback')) {
1086 1411
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1087 1412
 		} elseif ($h != '' || $name[$key] != '') {
1088 1413
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1089 1414
 		}
1090
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1415
+		if ($format[$key] == 'airwhere') {
1416
+			$forcepilots = true;
1417
+		}
1091 1418
 	}
1092 1419
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1093 1420
 
@@ -1115,7 +1442,9 @@  discard block
 block discarded – undo
1115 1442
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1116 1443
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1117 1444
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1118
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1445
+	} else {
1446
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1447
+	}
1119 1448
 
1120 1449
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1121 1450
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1154,7 +1483,9 @@  discard block
 block discarded – undo
1154 1483
 
1155 1484
 	// Create in settings.php keys not yet configurable if not already here
1156 1485
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1157
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1486
+	if (!isset($globalDebug)) {
1487
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1488
+	}
1158 1489
 
1159 1490
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1160 1491
 	if ($resetyearstats == 'resetyearstats') {
@@ -1191,37 +1522,56 @@  discard block
 block discarded – undo
1191 1522
 	}
1192 1523
 */
1193 1524
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1194
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1195
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1196
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1197
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1525
+	if ($globalsbs == 'sbs') {
1526
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1527
+	} else {
1528
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1529
+	}
1530
+	if ($globalaprs == 'aprs') {
1531
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1532
+	} else {
1533
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1534
+	}
1198 1535
 	$va = false;
1199 1536
 	if ($globalivao == 'ivao') {
1200 1537
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1201 1538
 		$va = true;
1202
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1539
+	} else {
1540
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1541
+	}
1203 1542
 	if ($globalvatsim == 'vatsim') {
1204 1543
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1205 1544
 		$va = true;
1206
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1545
+	} else {
1546
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1547
+	}
1207 1548
 	if ($globalphpvms == 'phpvms') {
1208 1549
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1209 1550
 		$va = true;
1210
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1551
+	} else {
1552
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1553
+	}
1211 1554
 	if ($globalvam == 'vam') {
1212 1555
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1213 1556
 		$va = true;
1214
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1557
+	} else {
1558
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1559
+	}
1215 1560
 	if ($va) {
1216 1561
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1217
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1562
+	} else {
1563
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1564
+	}
1218 1565
 	if ($globalva == 'va' || $va) {
1219 1566
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1220 1567
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1221 1568
 	} else {
1222 1569
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1223
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1224
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1570
+		if ($forcepilots) {
1571
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1572
+		} else {
1573
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1574
+		}
1225 1575
 	}
1226 1576
 	
1227 1577
 	
@@ -1397,7 +1747,9 @@  discard block
 block discarded – undo
1397 1747
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1398 1748
 	}
1399 1749
 
1400
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1750
+	if (!isset($globalTransaction)) {
1751
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1752
+	}
1401 1753
 
1402 1754
 	// Set some defaults values...
1403 1755
 	if (!isset($globalAircraftImageSources)) {
@@ -1412,15 +1764,23 @@  discard block
 block discarded – undo
1412 1764
 
1413 1765
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1414 1766
 
1415
-	if ($error == '') settings::modify_settings($settings);
1416
-	if ($error == '') settings::comment_settings($settings_comment);
1767
+	if ($error == '') {
1768
+		settings::modify_settings($settings);
1769
+	}
1770
+	if ($error == '') {
1771
+		settings::comment_settings($settings_comment);
1772
+	}
1417 1773
 	if ($error != '') {
1418 1774
 		print '<div class="info column">'.$error.'</div>';
1419 1775
 		require('../footer.php');
1420 1776
 		exit;
1421 1777
 	} else {
1422
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1423
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1778
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1779
+			$_SESSION['waypoints'] = 1;
1780
+		}
1781
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1782
+			$_SESSION['owner'] = 1;
1783
+		}
1424 1784
 		if (isset($_POST['createdb'])) {
1425 1785
 			$_SESSION['install'] = 'database_create';
1426 1786
 		} else {
@@ -1456,10 +1816,18 @@  discard block
 block discarded – undo
1456 1816
 	$popw = false;
1457 1817
 	foreach ($_SESSION['done'] as $done) {
1458 1818
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1459
-	    if ($done == 'Create database') $pop = true;
1460
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1461
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1462
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1819
+	    if ($done == 'Create database') {
1820
+	    	$pop = true;
1821
+	    }
1822
+	    if ($_SESSION['install'] == 'database_create') {
1823
+	    	$pop = true;
1824
+	    }
1825
+	    if ($_SESSION['install'] == 'database_import') {
1826
+	    	$popi = true;
1827
+	    }
1828
+	    if ($_SESSION['install'] == 'waypoints') {
1829
+	    	$popw = true;
1830
+	    }
1463 1831
 	}
1464 1832
 	if ($pop) {
1465 1833
 	    sleep(5);
@@ -1470,7 +1838,9 @@  discard block
 block discarded – undo
1470 1838
 	} else if ($popw) {
1471 1839
 	    sleep(5);
1472 1840
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1473
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1841
+	} else {
1842
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1843
+	}
1474 1844
 	print '</div></ul>';
1475 1845
 	print '<div id="error"></div>';
1476 1846
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +647 added lines, -647 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
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
-    	    }
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']);
22
-    	    }
19
+			}
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']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
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
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
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);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
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
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
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
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
289
-			$sth->execute();
290
-    		    } catch(PDOException $e) {
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289
+			$sth->execute();
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
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";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
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";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
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)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
431
-			$sth->execute();
432
-    		    } catch(PDOException $e) {
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)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431
+			$sth->execute();
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
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";
445
-            	    }
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";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
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";
445
+					}
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";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
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)";
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)";
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
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
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
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
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
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
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 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
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 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 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
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
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 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
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 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
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 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			} catch(PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565
-                }
1565
+				}
1566 1566
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
 			} catch(PDOException $e) {
1724 1724
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1725 1725
 			}
1726
-                }
1726
+				}
1727 1727
 		$query = "UPDATE config SET value = '38' WHERE name = 'schema_version'";
1728 1728
 		try {
1729 1729
 			$sth = $Connection->db->prepare($query);
@@ -2152,210 +2152,210 @@  discard block
 block discarded – undo
2152 2152
 
2153 2153
 
2154 2154
 
2155
-    	public static function check_version($update = false) {
2156
-    	    global $globalDBname;
2157
-    	    $version = 0;
2158
-    	    $Connection = new Connection();
2159
-    	    if ($Connection->tableExists('aircraft')) {
2160
-    		if (!$Connection->tableExists('config')) {
2161
-    		    $version = '1';
2162
-    		    if ($update) return self::update_from_1();
2163
-    		    else return $version;
2155
+		public static function check_version($update = false) {
2156
+			global $globalDBname;
2157
+			$version = 0;
2158
+			$Connection = new Connection();
2159
+			if ($Connection->tableExists('aircraft')) {
2160
+			if (!$Connection->tableExists('config')) {
2161
+				$version = '1';
2162
+				if ($update) return self::update_from_1();
2163
+				else return $version;
2164 2164
 		} else {
2165
-    		    $Connection = new Connection();
2166
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2167
-		    try {
2168
-            		$sth = $Connection->db->prepare($query);
2169
-		        $sth->execute();
2170
-		    } catch(PDOException $e) {
2165
+				$Connection = new Connection();
2166
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2167
+			try {
2168
+					$sth = $Connection->db->prepare($query);
2169
+				$sth->execute();
2170
+			} catch(PDOException $e) {
2171 2171
 			return "error : ".$e->getMessage()."\n";
2172
-    		    }
2173
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
2174
-    		    if ($update) {
2175
-    			if ($result['value'] == '2') {
2176
-    			    $error = self::update_from_2();
2177
-    			    if ($error != '') return $error;
2178
-    			    else return self::check_version(true);
2179
-    			} elseif ($result['value'] == '3') {
2180
-    			    $error = self::update_from_3();
2181
-    			    if ($error != '') return $error;
2182
-    			    else return self::check_version(true);
2183
-    			} elseif ($result['value'] == '4') {
2184
-    			    $error = self::update_from_4();
2185
-    			    if ($error != '') return $error;
2186
-    			    else return self::check_version(true);
2187
-    			} elseif ($result['value'] == '5') {
2188
-    			    $error = self::update_from_5();
2189
-    			    if ($error != '') return $error;
2190
-    			    else return self::check_version(true);
2191
-    			} elseif ($result['value'] == '6') {
2192
-    			    $error = self::update_from_6();
2193
-    			    if ($error != '') return $error;
2194
-    			    else return self::check_version(true);
2195
-    			} elseif ($result['value'] == '7') {
2196
-    			    $error = self::update_from_7();
2197
-    			    if ($error != '') return $error;
2198
-    			    else return self::check_version(true);
2199
-    			} elseif ($result['value'] == '8') {
2200
-    			    $error = self::update_from_8();
2201
-    			    if ($error != '') return $error;
2202
-    			    else return self::check_version(true);
2203
-    			} elseif ($result['value'] == '9') {
2204
-    			    $error = self::update_from_9();
2205
-    			    if ($error != '') return $error;
2206
-    			    else return self::check_version(true);
2207
-    			} elseif ($result['value'] == '10') {
2208
-    			    $error = self::update_from_10();
2209
-    			    if ($error != '') return $error;
2210
-    			    else return self::check_version(true);
2211
-    			} elseif ($result['value'] == '11') {
2212
-    			    $error = self::update_from_11();
2213
-    			    if ($error != '') return $error;
2214
-    			    else return self::check_version(true);
2215
-    			} elseif ($result['value'] == '12') {
2216
-    			    $error = self::update_from_12();
2217
-    			    if ($error != '') return $error;
2218
-    			    else return self::check_version(true);
2219
-    			} elseif ($result['value'] == '13') {
2220
-    			    $error = self::update_from_13();
2221
-    			    if ($error != '') return $error;
2222
-    			    else return self::check_version(true);
2223
-    			} elseif ($result['value'] == '14') {
2224
-    			    $error = self::update_from_14();
2225
-    			    if ($error != '') return $error;
2226
-    			    else return self::check_version(true);
2227
-    			} elseif ($result['value'] == '15') {
2228
-    			    $error = self::update_from_15();
2229
-    			    if ($error != '') return $error;
2230
-    			    else return self::check_version(true);
2231
-    			} elseif ($result['value'] == '16') {
2232
-    			    $error = self::update_from_16();
2233
-    			    if ($error != '') return $error;
2234
-    			    else return self::check_version(true);
2235
-    			} elseif ($result['value'] == '17') {
2236
-    			    $error = self::update_from_17();
2237
-    			    if ($error != '') return $error;
2238
-    			    else return self::check_version(true);
2239
-    			} elseif ($result['value'] == '18') {
2240
-    			    $error = self::update_from_18();
2241
-    			    if ($error != '') return $error;
2242
-    			    else return self::check_version(true);
2243
-    			} elseif ($result['value'] == '19') {
2244
-    			    $error = self::update_from_19();
2245
-    			    if ($error != '') return $error;
2246
-    			    else return self::check_version(true);
2247
-    			} elseif ($result['value'] == '20') {
2248
-    			    $error = self::update_from_20();
2249
-    			    if ($error != '') return $error;
2250
-    			    else return self::check_version(true);
2251
-    			} elseif ($result['value'] == '21') {
2252
-    			    $error = self::update_from_21();
2253
-    			    if ($error != '') return $error;
2254
-    			    else return self::check_version(true);
2255
-    			} elseif ($result['value'] == '22') {
2256
-    			    $error = self::update_from_22();
2257
-    			    if ($error != '') return $error;
2258
-    			    else return self::check_version(true);
2259
-    			} elseif ($result['value'] == '23') {
2260
-    			    $error = self::update_from_23();
2261
-    			    if ($error != '') return $error;
2262
-    			    else return self::check_version(true);
2263
-    			} elseif ($result['value'] == '24') {
2264
-    			    $error = self::update_from_24();
2265
-    			    if ($error != '') return $error;
2266
-    			    else return self::check_version(true);
2267
-    			} elseif ($result['value'] == '25') {
2268
-    			    $error = self::update_from_25();
2269
-    			    if ($error != '') return $error;
2270
-    			    else return self::check_version(true);
2271
-    			} elseif ($result['value'] == '26') {
2272
-    			    $error = self::update_from_26();
2273
-    			    if ($error != '') return $error;
2274
-    			    else return self::check_version(true);
2275
-    			} elseif ($result['value'] == '27') {
2276
-    			    $error = self::update_from_27();
2277
-    			    if ($error != '') return $error;
2278
-    			    else return self::check_version(true);
2279
-    			} elseif ($result['value'] == '28') {
2280
-    			    $error = self::update_from_28();
2281
-    			    if ($error != '') return $error;
2282
-    			    else return self::check_version(true);
2283
-    			} elseif ($result['value'] == '29') {
2284
-    			    $error = self::update_from_29();
2285
-    			    if ($error != '') return $error;
2286
-    			    else return self::check_version(true);
2287
-    			} elseif ($result['value'] == '30') {
2288
-    			    $error = self::update_from_30();
2289
-    			    if ($error != '') return $error;
2290
-    			    else return self::check_version(true);
2291
-    			} elseif ($result['value'] == '31') {
2292
-    			    $error = self::update_from_31();
2293
-    			    if ($error != '') return $error;
2294
-    			    else return self::check_version(true);
2295
-    			} elseif ($result['value'] == '32') {
2296
-    			    $error = self::update_from_32();
2297
-    			    if ($error != '') return $error;
2298
-    			    else return self::check_version(true);
2299
-    			} elseif ($result['value'] == '33') {
2300
-    			    $error = self::update_from_33();
2301
-    			    if ($error != '') return $error;
2302
-    			    else return self::check_version(true);
2303
-    			} elseif ($result['value'] == '34') {
2304
-    			    $error = self::update_from_34();
2305
-    			    if ($error != '') return $error;
2306
-    			    else return self::check_version(true);
2307
-    			} elseif ($result['value'] == '35') {
2308
-    			    $error = self::update_from_35();
2309
-    			    if ($error != '') return $error;
2310
-    			    else return self::check_version(true);
2311
-    			} elseif ($result['value'] == '36') {
2312
-    			    $error = self::update_from_36();
2313
-    			    if ($error != '') return $error;
2314
-    			    else return self::check_version(true);
2315
-    			} elseif ($result['value'] == '37') {
2316
-    			    $error = self::update_from_37();
2317
-    			    if ($error != '') return $error;
2318
-    			    else return self::check_version(true);
2319
-    			} elseif ($result['value'] == '38') {
2320
-    			    $error = self::update_from_38();
2321
-    			    if ($error != '') return $error;
2322
-    			    else return self::check_version(true);
2323
-    			} elseif ($result['value'] == '39') {
2324
-    			    $error = self::update_from_39();
2325
-    			    if ($error != '') return $error;
2326
-    			    else return self::check_version(true);
2327
-    			} elseif ($result['value'] == '40') {
2328
-    			    $error = self::update_from_40();
2329
-    			    if ($error != '') return $error;
2330
-    			    else return self::check_version(true);
2331
-    			} elseif ($result['value'] == '41') {
2332
-    			    $error = self::update_from_41();
2333
-    			    if ($error != '') return $error;
2334
-    			    else return self::check_version(true);
2335
-    			} elseif ($result['value'] == '42') {
2336
-    			    $error = self::update_from_42();
2337
-    			    if ($error != '') return $error;
2338
-    			    else return self::check_version(true);
2339
-    			} elseif ($result['value'] == '43') {
2340
-    			    $error = self::update_from_43();
2341
-    			    if ($error != '') return $error;
2342
-    			    else return self::check_version(true);
2343
-    			} elseif ($result['value'] == '44') {
2344
-    			    $error = self::update_from_44();
2345
-    			    if ($error != '') return $error;
2346
-    			    else return self::check_version(true);
2347
-    			} elseif ($result['value'] == '45') {
2348
-    			    $error = self::update_from_45();
2349
-    			    if ($error != '') return $error;
2350
-    			    else return self::check_version(true);
2351
-    			} else return '';
2352
-    		    } else {
2353
-    			if (isset($result['value']) && $result['value'] != '') return $result['value'];
2354
-    			else return 0;
2172
+				}
2173
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
2174
+				if ($update) {
2175
+				if ($result['value'] == '2') {
2176
+					$error = self::update_from_2();
2177
+					if ($error != '') return $error;
2178
+					else return self::check_version(true);
2179
+				} elseif ($result['value'] == '3') {
2180
+					$error = self::update_from_3();
2181
+					if ($error != '') return $error;
2182
+					else return self::check_version(true);
2183
+				} elseif ($result['value'] == '4') {
2184
+					$error = self::update_from_4();
2185
+					if ($error != '') return $error;
2186
+					else return self::check_version(true);
2187
+				} elseif ($result['value'] == '5') {
2188
+					$error = self::update_from_5();
2189
+					if ($error != '') return $error;
2190
+					else return self::check_version(true);
2191
+				} elseif ($result['value'] == '6') {
2192
+					$error = self::update_from_6();
2193
+					if ($error != '') return $error;
2194
+					else return self::check_version(true);
2195
+				} elseif ($result['value'] == '7') {
2196
+					$error = self::update_from_7();
2197
+					if ($error != '') return $error;
2198
+					else return self::check_version(true);
2199
+				} elseif ($result['value'] == '8') {
2200
+					$error = self::update_from_8();
2201
+					if ($error != '') return $error;
2202
+					else return self::check_version(true);
2203
+				} elseif ($result['value'] == '9') {
2204
+					$error = self::update_from_9();
2205
+					if ($error != '') return $error;
2206
+					else return self::check_version(true);
2207
+				} elseif ($result['value'] == '10') {
2208
+					$error = self::update_from_10();
2209
+					if ($error != '') return $error;
2210
+					else return self::check_version(true);
2211
+				} elseif ($result['value'] == '11') {
2212
+					$error = self::update_from_11();
2213
+					if ($error != '') return $error;
2214
+					else return self::check_version(true);
2215
+				} elseif ($result['value'] == '12') {
2216
+					$error = self::update_from_12();
2217
+					if ($error != '') return $error;
2218
+					else return self::check_version(true);
2219
+				} elseif ($result['value'] == '13') {
2220
+					$error = self::update_from_13();
2221
+					if ($error != '') return $error;
2222
+					else return self::check_version(true);
2223
+				} elseif ($result['value'] == '14') {
2224
+					$error = self::update_from_14();
2225
+					if ($error != '') return $error;
2226
+					else return self::check_version(true);
2227
+				} elseif ($result['value'] == '15') {
2228
+					$error = self::update_from_15();
2229
+					if ($error != '') return $error;
2230
+					else return self::check_version(true);
2231
+				} elseif ($result['value'] == '16') {
2232
+					$error = self::update_from_16();
2233
+					if ($error != '') return $error;
2234
+					else return self::check_version(true);
2235
+				} elseif ($result['value'] == '17') {
2236
+					$error = self::update_from_17();
2237
+					if ($error != '') return $error;
2238
+					else return self::check_version(true);
2239
+				} elseif ($result['value'] == '18') {
2240
+					$error = self::update_from_18();
2241
+					if ($error != '') return $error;
2242
+					else return self::check_version(true);
2243
+				} elseif ($result['value'] == '19') {
2244
+					$error = self::update_from_19();
2245
+					if ($error != '') return $error;
2246
+					else return self::check_version(true);
2247
+				} elseif ($result['value'] == '20') {
2248
+					$error = self::update_from_20();
2249
+					if ($error != '') return $error;
2250
+					else return self::check_version(true);
2251
+				} elseif ($result['value'] == '21') {
2252
+					$error = self::update_from_21();
2253
+					if ($error != '') return $error;
2254
+					else return self::check_version(true);
2255
+				} elseif ($result['value'] == '22') {
2256
+					$error = self::update_from_22();
2257
+					if ($error != '') return $error;
2258
+					else return self::check_version(true);
2259
+				} elseif ($result['value'] == '23') {
2260
+					$error = self::update_from_23();
2261
+					if ($error != '') return $error;
2262
+					else return self::check_version(true);
2263
+				} elseif ($result['value'] == '24') {
2264
+					$error = self::update_from_24();
2265
+					if ($error != '') return $error;
2266
+					else return self::check_version(true);
2267
+				} elseif ($result['value'] == '25') {
2268
+					$error = self::update_from_25();
2269
+					if ($error != '') return $error;
2270
+					else return self::check_version(true);
2271
+				} elseif ($result['value'] == '26') {
2272
+					$error = self::update_from_26();
2273
+					if ($error != '') return $error;
2274
+					else return self::check_version(true);
2275
+				} elseif ($result['value'] == '27') {
2276
+					$error = self::update_from_27();
2277
+					if ($error != '') return $error;
2278
+					else return self::check_version(true);
2279
+				} elseif ($result['value'] == '28') {
2280
+					$error = self::update_from_28();
2281
+					if ($error != '') return $error;
2282
+					else return self::check_version(true);
2283
+				} elseif ($result['value'] == '29') {
2284
+					$error = self::update_from_29();
2285
+					if ($error != '') return $error;
2286
+					else return self::check_version(true);
2287
+				} elseif ($result['value'] == '30') {
2288
+					$error = self::update_from_30();
2289
+					if ($error != '') return $error;
2290
+					else return self::check_version(true);
2291
+				} elseif ($result['value'] == '31') {
2292
+					$error = self::update_from_31();
2293
+					if ($error != '') return $error;
2294
+					else return self::check_version(true);
2295
+				} elseif ($result['value'] == '32') {
2296
+					$error = self::update_from_32();
2297
+					if ($error != '') return $error;
2298
+					else return self::check_version(true);
2299
+				} elseif ($result['value'] == '33') {
2300
+					$error = self::update_from_33();
2301
+					if ($error != '') return $error;
2302
+					else return self::check_version(true);
2303
+				} elseif ($result['value'] == '34') {
2304
+					$error = self::update_from_34();
2305
+					if ($error != '') return $error;
2306
+					else return self::check_version(true);
2307
+				} elseif ($result['value'] == '35') {
2308
+					$error = self::update_from_35();
2309
+					if ($error != '') return $error;
2310
+					else return self::check_version(true);
2311
+				} elseif ($result['value'] == '36') {
2312
+					$error = self::update_from_36();
2313
+					if ($error != '') return $error;
2314
+					else return self::check_version(true);
2315
+				} elseif ($result['value'] == '37') {
2316
+					$error = self::update_from_37();
2317
+					if ($error != '') return $error;
2318
+					else return self::check_version(true);
2319
+				} elseif ($result['value'] == '38') {
2320
+					$error = self::update_from_38();
2321
+					if ($error != '') return $error;
2322
+					else return self::check_version(true);
2323
+				} elseif ($result['value'] == '39') {
2324
+					$error = self::update_from_39();
2325
+					if ($error != '') return $error;
2326
+					else return self::check_version(true);
2327
+				} elseif ($result['value'] == '40') {
2328
+					$error = self::update_from_40();
2329
+					if ($error != '') return $error;
2330
+					else return self::check_version(true);
2331
+				} elseif ($result['value'] == '41') {
2332
+					$error = self::update_from_41();
2333
+					if ($error != '') return $error;
2334
+					else return self::check_version(true);
2335
+				} elseif ($result['value'] == '42') {
2336
+					$error = self::update_from_42();
2337
+					if ($error != '') return $error;
2338
+					else return self::check_version(true);
2339
+				} elseif ($result['value'] == '43') {
2340
+					$error = self::update_from_43();
2341
+					if ($error != '') return $error;
2342
+					else return self::check_version(true);
2343
+				} elseif ($result['value'] == '44') {
2344
+					$error = self::update_from_44();
2345
+					if ($error != '') return $error;
2346
+					else return self::check_version(true);
2347
+				} elseif ($result['value'] == '45') {
2348
+					$error = self::update_from_45();
2349
+					if ($error != '') return $error;
2350
+					else return self::check_version(true);
2351
+				} else return '';
2352
+				} else {
2353
+				if (isset($result['value']) && $result['value'] != '') return $result['value'];
2354
+				else return 0;
2355 2355
 		}
2356 2356
 		
2357
-	    } else return $version;
2358
-    	}
2357
+		} else return $version;
2358
+		}
2359 2359
     	
2360 2360
 }
2361 2361
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +234 added lines, -234 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;
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 			try {
1701 1701
 				$sth = $Connection->db->prepare($query);
1702 1702
 				$sth->execute();
1703
-			} catch(PDOException $e) {
1703
+			} catch (PDOException $e) {
1704 1704
 				return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
1705 1705
 			}
1706 1706
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1709,18 +1709,18 @@  discard block
 block discarded – undo
1709 1709
 				try {
1710 1710
 					$sth = $Connection->db->prepare($query);
1711 1711
 					$sth->execute();
1712
-				} catch(PDOException $e) {
1712
+				} catch (PDOException $e) {
1713 1713
 					return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n";
1714 1714
 				}
1715 1715
 			}
1716 1716
 		}
1717
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1717
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1718 1718
 			// Add index key
1719 1719
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1720 1720
 			try {
1721 1721
 				$sth = $Connection->db->prepare($query);
1722 1722
 				$sth->execute();
1723
-			} catch(PDOException $e) {
1723
+			} catch (PDOException $e) {
1724 1724
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1725 1725
 			}
1726 1726
                 }
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
 		try {
1729 1729
 			$sth = $Connection->db->prepare($query);
1730 1730
 			$sth->execute();
1731
-		} catch(PDOException $e) {
1731
+		} catch (PDOException $e) {
1732 1732
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1733 1733
 		}
1734 1734
 		return $error;
@@ -1739,148 +1739,148 @@  discard block
 block discarded – undo
1739 1739
 		$Connection = new Connection();
1740 1740
 		$error = '';
1741 1741
 		if ($globalDBdriver == 'mysql') {
1742
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1742
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1743 1743
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL";
1744 1744
 				try {
1745 1745
 					$sth = $Connection->db->prepare($query);
1746 1746
 					$sth->execute();
1747
-				} catch(PDOException $e) {
1747
+				} catch (PDOException $e) {
1748 1748
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1749 1749
 				}
1750 1750
 			}
1751
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1751
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1752 1752
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL";
1753 1753
 				try {
1754 1754
 					$sth = $Connection->db->prepare($query);
1755 1755
 					$sth->execute();
1756
-				} catch(PDOException $e) {
1756
+				} catch (PDOException $e) {
1757 1757
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1758 1758
 				}
1759 1759
 			}
1760
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1760
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1761 1761
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL";
1762 1762
 				try {
1763 1763
 					$sth = $Connection->db->prepare($query);
1764 1764
 					$sth->execute();
1765
-				} catch(PDOException $e) {
1765
+				} catch (PDOException $e) {
1766 1766
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1767 1767
 				}
1768 1768
 			}
1769
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1769
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1770 1770
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL";
1771 1771
 				try {
1772 1772
 					$sth = $Connection->db->prepare($query);
1773 1773
 					$sth->execute();
1774
-				} catch(PDOException $e) {
1774
+				} catch (PDOException $e) {
1775 1775
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1776 1776
 				}
1777 1777
 			}
1778
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1778
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1779 1779
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL";
1780 1780
 				try {
1781 1781
 					$sth = $Connection->db->prepare($query);
1782 1782
 					$sth->execute();
1783
-				} catch(PDOException $e) {
1783
+				} catch (PDOException $e) {
1784 1784
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1785 1785
 				}
1786 1786
 			}
1787
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1787
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1788 1788
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL";
1789 1789
 				try {
1790 1790
 					$sth = $Connection->db->prepare($query);
1791 1791
 					$sth->execute();
1792
-				} catch(PDOException $e) {
1792
+				} catch (PDOException $e) {
1793 1793
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1794 1794
 				}
1795 1795
 			}
1796
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1796
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1797 1797
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL";
1798 1798
 				try {
1799 1799
 					$sth = $Connection->db->prepare($query);
1800 1800
 					$sth->execute();
1801
-				} catch(PDOException $e) {
1801
+				} catch (PDOException $e) {
1802 1802
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1803 1803
 				}
1804 1804
 			}
1805
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1805
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1806 1806
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL";
1807 1807
 				try {
1808 1808
 					$sth = $Connection->db->prepare($query);
1809 1809
 					$sth->execute();
1810
-				} catch(PDOException $e) {
1810
+				} catch (PDOException $e) {
1811 1811
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1812 1812
 				}
1813 1813
 			}
1814 1814
 		} else {
1815
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1815
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1816 1816
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL";
1817 1817
 				try {
1818 1818
 					$sth = $Connection->db->prepare($query);
1819 1819
 					$sth->execute();
1820
-				} catch(PDOException $e) {
1820
+				} catch (PDOException $e) {
1821 1821
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1822 1822
 				}
1823 1823
 			}
1824
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1824
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1825 1825
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL";
1826 1826
 				try {
1827 1827
 					$sth = $Connection->db->prepare($query);
1828 1828
 					$sth->execute();
1829
-				} catch(PDOException $e) {
1829
+				} catch (PDOException $e) {
1830 1830
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1831 1831
 				}
1832 1832
 			}
1833
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1833
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1834 1834
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL";
1835 1835
 				try {
1836 1836
 					$sth = $Connection->db->prepare($query);
1837 1837
 					$sth->execute();
1838
-				} catch(PDOException $e) {
1838
+				} catch (PDOException $e) {
1839 1839
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1840 1840
 				}
1841 1841
 			}
1842
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1842
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1843 1843
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL";
1844 1844
 				try {
1845 1845
 					$sth = $Connection->db->prepare($query);
1846 1846
 					$sth->execute();
1847
-				} catch(PDOException $e) {
1847
+				} catch (PDOException $e) {
1848 1848
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1849 1849
 				}
1850 1850
 			}
1851
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1851
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1852 1852
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL";
1853 1853
 				try {
1854 1854
 					$sth = $Connection->db->prepare($query);
1855 1855
 					$sth->execute();
1856
-				} catch(PDOException $e) {
1856
+				} catch (PDOException $e) {
1857 1857
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1858 1858
 				}
1859 1859
 			}
1860
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1860
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1861 1861
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL";
1862 1862
 				try {
1863 1863
 					$sth = $Connection->db->prepare($query);
1864 1864
 					$sth->execute();
1865
-				} catch(PDOException $e) {
1865
+				} catch (PDOException $e) {
1866 1866
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1867 1867
 				}
1868 1868
 			}
1869
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1869
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1870 1870
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL";
1871 1871
 				try {
1872 1872
 					$sth = $Connection->db->prepare($query);
1873 1873
 					$sth->execute();
1874
-				} catch(PDOException $e) {
1874
+				} catch (PDOException $e) {
1875 1875
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1876 1876
 				}
1877 1877
 			}
1878
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1878
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1879 1879
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL";
1880 1880
 				try {
1881 1881
 					$sth = $Connection->db->prepare($query);
1882 1882
 					$sth->execute();
1883
-				} catch(PDOException $e) {
1883
+				} catch (PDOException $e) {
1884 1884
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1885 1885
 				}
1886 1886
 			}
@@ -1889,7 +1889,7 @@  discard block
 block discarded – undo
1889 1889
 		try {
1890 1890
 			$sth = $Connection->db->prepare($query);
1891 1891
 			$sth->execute();
1892
-		} catch(PDOException $e) {
1892
+		} catch (PDOException $e) {
1893 1893
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1894 1894
 		}
1895 1895
 		return $error;
@@ -1904,14 +1904,14 @@  discard block
 block discarded – undo
1904 1904
 			try {
1905 1905
 				$sth = $Connection->db->prepare($query);
1906 1906
 				$sth->execute();
1907
-			} catch(PDOException $e) {
1907
+			} catch (PDOException $e) {
1908 1908
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1909 1909
 			}
1910 1910
 			$query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL";
1911 1911
 			try {
1912 1912
 				$sth = $Connection->db->prepare($query);
1913 1913
 				$sth->execute();
1914
-			} catch(PDOException $e) {
1914
+			} catch (PDOException $e) {
1915 1915
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1916 1916
 			}
1917 1917
 		} else {
@@ -1919,14 +1919,14 @@  discard block
 block discarded – undo
1919 1919
 			try {
1920 1920
 				$sth = $Connection->db->prepare($query);
1921 1921
 				$sth->execute();
1922
-			} catch(PDOException $e) {
1922
+			} catch (PDOException $e) {
1923 1923
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1924 1924
 			}
1925 1925
 			$query = "alter table marine_identity alter column mmsi type varchar(255)";
1926 1926
 			try {
1927 1927
 				$sth = $Connection->db->prepare($query);
1928 1928
 				$sth->execute();
1929
-			} catch(PDOException $e) {
1929
+			} catch (PDOException $e) {
1930 1930
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1931 1931
 			}
1932 1932
 		}
@@ -1934,7 +1934,7 @@  discard block
 block discarded – undo
1934 1934
 		try {
1935 1935
 			$sth = $Connection->db->prepare($query);
1936 1936
 			$sth->execute();
1937
-		} catch(PDOException $e) {
1937
+		} catch (PDOException $e) {
1938 1938
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1939 1939
 		}
1940 1940
 		return $error;
@@ -1944,32 +1944,32 @@  discard block
 block discarded – undo
1944 1944
 		global $globalDBdriver;
1945 1945
 		$Connection = new Connection();
1946 1946
 		$error = '';
1947
-		if (!$Connection->checkColumnName('source_location','last_seen')) {
1947
+		if (!$Connection->checkColumnName('source_location', 'last_seen')) {
1948 1948
 			$query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL";
1949 1949
 			try {
1950 1950
 				$sth = $Connection->db->prepare($query);
1951 1951
 				$sth->execute();
1952
-			} catch(PDOException $e) {
1952
+			} catch (PDOException $e) {
1953 1953
 				return "error (add column last_seen in source_location) : ".$e->getMessage()."\n";
1954 1954
 			}
1955 1955
 		}
1956 1956
 		if ($globalDBdriver == 'mysql') {
1957
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1957
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1958 1958
 				$query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL";
1959 1959
 				try {
1960 1960
 					$sth = $Connection->db->prepare($query);
1961 1961
 					$sth->execute();
1962
-				} catch(PDOException $e) {
1962
+				} catch (PDOException $e) {
1963 1963
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1964 1964
 				}
1965 1965
 			}
1966 1966
 		} else {
1967
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1967
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1968 1968
 				$query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL";
1969 1969
 				try {
1970 1970
 					$sth = $Connection->db->prepare($query);
1971 1971
 					$sth->execute();
1972
-				} catch(PDOException $e) {
1972
+				} catch (PDOException $e) {
1973 1973
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1974 1974
 				}
1975 1975
 			}
@@ -1978,7 +1978,7 @@  discard block
 block discarded – undo
1978 1978
 		try {
1979 1979
 			$sth = $Connection->db->prepare($query);
1980 1980
 			$sth->execute();
1981
-		} catch(PDOException $e) {
1981
+		} catch (PDOException $e) {
1982 1982
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1983 1983
 		}
1984 1984
 		return $error;
@@ -1988,12 +1988,12 @@  discard block
 block discarded – undo
1988 1988
 		global $globalDBdriver;
1989 1989
 		$Connection = new Connection();
1990 1990
 		$error = '';
1991
-		if (!$Connection->checkColumnName('source_location','description')) {
1991
+		if (!$Connection->checkColumnName('source_location', 'description')) {
1992 1992
 			$query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL";
1993 1993
 			try {
1994 1994
 				$sth = $Connection->db->prepare($query);
1995 1995
 				$sth->execute();
1996
-			} catch(PDOException $e) {
1996
+			} catch (PDOException $e) {
1997 1997
 				return "error (add column description in source_location) : ".$e->getMessage()."\n";
1998 1998
 			}
1999 1999
 		}
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 		try {
2002 2002
 			$sth = $Connection->db->prepare($query);
2003 2003
 			$sth->execute();
2004
-		} catch(PDOException $e) {
2004
+		} catch (PDOException $e) {
2005 2005
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2006 2006
 		}
2007 2007
 		return $error;
@@ -2011,39 +2011,39 @@  discard block
 block discarded – undo
2011 2011
 		global $globalDBdriver;
2012 2012
 		$Connection = new Connection();
2013 2013
 		$error = '';
2014
-		if (!$Connection->checkColumnName('spotter_live','real_altitude')) {
2014
+		if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) {
2015 2015
 			$query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL";
2016 2016
 			try {
2017 2017
 				$sth = $Connection->db->prepare($query);
2018 2018
 				$sth->execute();
2019
-			} catch(PDOException $e) {
2019
+			} catch (PDOException $e) {
2020 2020
 				return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n";
2021 2021
 			}
2022 2022
 		}
2023
-		if (!$Connection->checkColumnName('spotter_output','real_altitude')) {
2023
+		if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) {
2024 2024
 			$query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL";
2025 2025
 			try {
2026 2026
 				$sth = $Connection->db->prepare($query);
2027 2027
 				$sth->execute();
2028
-			} catch(PDOException $e) {
2028
+			} catch (PDOException $e) {
2029 2029
 				return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n";
2030 2030
 			}
2031 2031
 		}
2032
-		if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) {
2032
+		if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) {
2033 2033
 			$query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL";
2034 2034
 			try {
2035 2035
 				$sth = $Connection->db->prepare($query);
2036 2036
 				$sth->execute();
2037
-			} catch(PDOException $e) {
2037
+			} catch (PDOException $e) {
2038 2038
 				return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n";
2039 2039
 			}
2040 2040
 		}
2041
-		if (!$Connection->checkColumnName('spotter_archive','real_altitude')) {
2041
+		if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) {
2042 2042
 			$query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL";
2043 2043
 			try {
2044 2044
 				$sth = $Connection->db->prepare($query);
2045 2045
 				$sth->execute();
2046
-			} catch(PDOException $e) {
2046
+			} catch (PDOException $e) {
2047 2047
 				return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n";
2048 2048
 			}
2049 2049
 		}
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
 		try {
2052 2052
 			$sth = $Connection->db->prepare($query);
2053 2053
 			$sth->execute();
2054
-		} catch(PDOException $e) {
2054
+		} catch (PDOException $e) {
2055 2055
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2056 2056
 		}
2057 2057
 		return $error;
@@ -2073,14 +2073,14 @@  discard block
 block discarded – undo
2073 2073
 		try {
2074 2074
 			$sth = $Connection->db->prepare($query);
2075 2075
 			$sth->execute();
2076
-		} catch(PDOException $e) {
2076
+		} catch (PDOException $e) {
2077 2077
 			return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n";
2078 2078
 		}
2079 2079
 		$query = "UPDATE config SET value = '44' WHERE name = 'schema_version'";
2080 2080
 		try {
2081 2081
 			$sth = $Connection->db->prepare($query);
2082 2082
 			$sth->execute();
2083
-		} catch(PDOException $e) {
2083
+		} catch (PDOException $e) {
2084 2084
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2085 2085
 		}
2086 2086
 		return $error;
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
 		try {
2122 2122
 			$sth = $Connection->db->prepare($query);
2123 2123
 			$sth->execute();
2124
-		} catch(PDOException $e) {
2124
+		} catch (PDOException $e) {
2125 2125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2126 2126
 		}
2127 2127
 		return $error;
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 		try {
2145 2145
 			$sth = $Connection->db->prepare($query);
2146 2146
 			$sth->execute();
2147
-		} catch(PDOException $e) {
2147
+		} catch (PDOException $e) {
2148 2148
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2149 2149
 		}
2150 2150
 		return $error;
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
 		    try {
2168 2168
             		$sth = $Connection->db->prepare($query);
2169 2169
 		        $sth->execute();
2170
-		    } catch(PDOException $e) {
2170
+		    } catch (PDOException $e) {
2171 2171
 			return "error : ".$e->getMessage()."\n";
2172 2172
     		    }
2173 2173
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +428 added lines, -158 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1608,41 +1674,65 @@  discard block
 block discarded – undo
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			if (!$Connection->tableExists('tracker_output')) {
1610 1676
 				$error .= create_db::import_file('../db/tracker_output.sql');
1611
-				if ($error != '') return $error;
1677
+				if ($error != '') {
1678
+					return $error;
1679
+				}
1612 1680
 			}
1613 1681
 			if (!$Connection->tableExists('tracker_live')) {
1614 1682
 				$error .= create_db::import_file('../db/tracker_live.sql');
1615
-				if ($error != '') return $error;
1683
+				if ($error != '') {
1684
+					return $error;
1685
+				}
1616 1686
 			}
1617 1687
 			if (!$Connection->tableExists('marine_output')) {
1618 1688
 				$error .= create_db::import_file('../db/marine_output.sql');
1619
-				if ($error != '') return $error;
1689
+				if ($error != '') {
1690
+					return $error;
1691
+				}
1620 1692
 			}
1621 1693
 			if (!$Connection->tableExists('marine_live')) {
1622 1694
 				$error .= create_db::import_file('../db/marine_live.sql');
1623
-				if ($error != '') return $error;
1695
+				if ($error != '') {
1696
+					return $error;
1697
+				}
1624 1698
 			}
1625 1699
 			if (!$Connection->tableExists('marine_identity')) {
1626 1700
 				$error .= create_db::import_file('../db/marine_identity.sql');
1627
-				if ($error != '') return $error;
1701
+				if ($error != '') {
1702
+					return $error;
1703
+				}
1628 1704
 			}
1629 1705
 			if (!$Connection->tableExists('marine_mid')) {
1630 1706
 				$error .= create_db::import_file('../db/marine_mid.sql');
1631
-				if ($error != '') return $error;
1707
+				if ($error != '') {
1708
+					return $error;
1709
+				}
1632 1710
 			}
1633 1711
 		} else {
1634 1712
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1635
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1636 1716
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1637
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1638 1720
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1639
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1640 1724
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1641
-			if ($error != '') return $error;
1725
+			if ($error != '') {
1726
+				return $error;
1727
+			}
1642 1728
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1643
-			if ($error != '') return $error;
1729
+			if ($error != '') {
1730
+				return $error;
1731
+			}
1644 1732
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1645
-			if ($error != '') return $error;
1733
+			if ($error != '') {
1734
+				return $error;
1735
+			}
1646 1736
 		}
1647 1737
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1648 1738
 		try {
@@ -1661,39 +1751,61 @@  discard block
 block discarded – undo
1661 1751
 		if ($globalDBdriver == 'mysql') {
1662 1752
 			if (!$Connection->tableExists('marine_image')) {
1663 1753
 				$error .= create_db::import_file('../db/marine_image.sql');
1664
-				if ($error != '') return $error;
1754
+				if ($error != '') {
1755
+					return $error;
1756
+				}
1665 1757
 			}
1666 1758
 			if (!$Connection->tableExists('marine_archive')) {
1667 1759
 				$error .= create_db::import_file('../db/marine_archive.sql');
1668
-				if ($error != '') return $error;
1760
+				if ($error != '') {
1761
+					return $error;
1762
+				}
1669 1763
 			}
1670 1764
 			if (!$Connection->tableExists('marine_archive_output')) {
1671 1765
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1672
-				if ($error != '') return $error;
1766
+				if ($error != '') {
1767
+					return $error;
1768
+				}
1673 1769
 			}
1674 1770
 			if (!$Connection->tableExists('tracker_archive')) {
1675 1771
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1676
-				if ($error != '') return $error;
1772
+				if ($error != '') {
1773
+					return $error;
1774
+				}
1677 1775
 			}
1678 1776
 			if (!$Connection->tableExists('tracker_archive_output')) {
1679 1777
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1680
-				if ($error != '') return $error;
1778
+				if ($error != '') {
1779
+					return $error;
1780
+				}
1681 1781
 			}
1682 1782
 			if (!$Connection->tableExists('marine_archive_output')) {
1683 1783
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1684
-				if ($error != '') return $error;
1784
+				if ($error != '') {
1785
+					return $error;
1786
+				}
1685 1787
 			}
1686 1788
 		} else {
1687 1789
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1688
-			if ($error != '') return $error;
1790
+			if ($error != '') {
1791
+				return $error;
1792
+			}
1689 1793
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1690
-			if ($error != '') return $error;
1794
+			if ($error != '') {
1795
+				return $error;
1796
+			}
1691 1797
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1692
-			if ($error != '') return $error;
1798
+			if ($error != '') {
1799
+				return $error;
1800
+			}
1693 1801
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1694
-			if ($error != '') return $error;
1802
+			if ($error != '') {
1803
+				return $error;
1804
+			}
1695 1805
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1696
-			if ($error != '') return $error;
1806
+			if ($error != '') {
1807
+				return $error;
1808
+			}
1697 1809
 		}
1698 1810
 		if ($globalDBdriver == 'mysql') {
1699 1811
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2064,7 +2176,9 @@  discard block
 block discarded – undo
2064 2176
 		if ($globalDBdriver == 'mysql') {
2065 2177
 			if (!$Connection->tableExists('tracker_archive_output')) {
2066 2178
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2067
-				if ($error != '') return $error;
2179
+				if ($error != '') {
2180
+					return $error;
2181
+				}
2068 2182
 			}
2069 2183
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2070 2184
 		} else {
@@ -2092,14 +2206,22 @@  discard block
 block discarded – undo
2092 2206
 		$error = '';
2093 2207
 		if ($globalDBdriver == 'mysql') {
2094 2208
 			$error .= create_db::import_file('../db/airport.sql');
2095
-			if ($error != '') return $error;
2209
+			if ($error != '') {
2210
+				return $error;
2211
+			}
2096 2212
 			$error .= create_db::import_file('../db/airlines.sql');
2097
-			if ($error != '') return $error;
2213
+			if ($error != '') {
2214
+				return $error;
2215
+			}
2098 2216
 		} else {
2099 2217
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2100
-			if ($error != '') return $error;
2218
+			if ($error != '') {
2219
+				return $error;
2220
+			}
2101 2221
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2102
-			if ($error != '') return $error;
2222
+			if ($error != '') {
2223
+				return $error;
2224
+			}
2103 2225
 		}
2104 2226
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2105 2227
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2116,7 +2238,9 @@  discard block
 block discarded – undo
2116 2238
 				$error .= update_db::update_vatsim();
2117 2239
 			}
2118 2240
 		}
2119
-		if ($error != '') return $error;
2241
+		if ($error != '') {
2242
+			return $error;
2243
+		}
2120 2244
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2121 2245
 		try {
2122 2246
 			$sth = $Connection->db->prepare($query);
@@ -2134,10 +2258,14 @@  discard block
 block discarded – undo
2134 2258
 		if (!$Connection->tableExists('satellite')) {
2135 2259
 			if ($globalDBdriver == 'mysql') {
2136 2260
 				$error .= create_db::import_file('../db/satellite.sql');
2137
-				if ($error != '') return $error;
2261
+				if ($error != '') {
2262
+					return $error;
2263
+				}
2138 2264
 			} else {
2139 2265
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2140
-				if ($error != '') return $error;
2266
+				if ($error != '') {
2267
+					return $error;
2268
+				}
2141 2269
 			}
2142 2270
 		}
2143 2271
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2159,8 +2287,11 @@  discard block
 block discarded – undo
2159 2287
     	    if ($Connection->tableExists('aircraft')) {
2160 2288
     		if (!$Connection->tableExists('config')) {
2161 2289
     		    $version = '1';
2162
-    		    if ($update) return self::update_from_1();
2163
-    		    else return $version;
2290
+    		    if ($update) {
2291
+    		    	return self::update_from_1();
2292
+    		    } else {
2293
+    		    	return $version;
2294
+    		    }
2164 2295
 		} else {
2165 2296
     		    $Connection = new Connection();
2166 2297
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -2174,187 +2305,326 @@  discard block
 block discarded – undo
2174 2305
     		    if ($update) {
2175 2306
     			if ($result['value'] == '2') {
2176 2307
     			    $error = self::update_from_2();
2177
-    			    if ($error != '') return $error;
2178
-    			    else return self::check_version(true);
2308
+    			    if ($error != '') {
2309
+    			    	return $error;
2310
+    			    } else {
2311
+    			    	return self::check_version(true);
2312
+    			    }
2179 2313
     			} elseif ($result['value'] == '3') {
2180 2314
     			    $error = self::update_from_3();
2181
-    			    if ($error != '') return $error;
2182
-    			    else return self::check_version(true);
2315
+    			    if ($error != '') {
2316
+    			    	return $error;
2317
+    			    } else {
2318
+    			    	return self::check_version(true);
2319
+    			    }
2183 2320
     			} elseif ($result['value'] == '4') {
2184 2321
     			    $error = self::update_from_4();
2185
-    			    if ($error != '') return $error;
2186
-    			    else return self::check_version(true);
2322
+    			    if ($error != '') {
2323
+    			    	return $error;
2324
+    			    } else {
2325
+    			    	return self::check_version(true);
2326
+    			    }
2187 2327
     			} elseif ($result['value'] == '5') {
2188 2328
     			    $error = self::update_from_5();
2189
-    			    if ($error != '') return $error;
2190
-    			    else return self::check_version(true);
2329
+    			    if ($error != '') {
2330
+    			    	return $error;
2331
+    			    } else {
2332
+    			    	return self::check_version(true);
2333
+    			    }
2191 2334
     			} elseif ($result['value'] == '6') {
2192 2335
     			    $error = self::update_from_6();
2193
-    			    if ($error != '') return $error;
2194
-    			    else return self::check_version(true);
2336
+    			    if ($error != '') {
2337
+    			    	return $error;
2338
+    			    } else {
2339
+    			    	return self::check_version(true);
2340
+    			    }
2195 2341
     			} elseif ($result['value'] == '7') {
2196 2342
     			    $error = self::update_from_7();
2197
-    			    if ($error != '') return $error;
2198
-    			    else return self::check_version(true);
2343
+    			    if ($error != '') {
2344
+    			    	return $error;
2345
+    			    } else {
2346
+    			    	return self::check_version(true);
2347
+    			    }
2199 2348
     			} elseif ($result['value'] == '8') {
2200 2349
     			    $error = self::update_from_8();
2201
-    			    if ($error != '') return $error;
2202
-    			    else return self::check_version(true);
2350
+    			    if ($error != '') {
2351
+    			    	return $error;
2352
+    			    } else {
2353
+    			    	return self::check_version(true);
2354
+    			    }
2203 2355
     			} elseif ($result['value'] == '9') {
2204 2356
     			    $error = self::update_from_9();
2205
-    			    if ($error != '') return $error;
2206
-    			    else return self::check_version(true);
2357
+    			    if ($error != '') {
2358
+    			    	return $error;
2359
+    			    } else {
2360
+    			    	return self::check_version(true);
2361
+    			    }
2207 2362
     			} elseif ($result['value'] == '10') {
2208 2363
     			    $error = self::update_from_10();
2209
-    			    if ($error != '') return $error;
2210
-    			    else return self::check_version(true);
2364
+    			    if ($error != '') {
2365
+    			    	return $error;
2366
+    			    } else {
2367
+    			    	return self::check_version(true);
2368
+    			    }
2211 2369
     			} elseif ($result['value'] == '11') {
2212 2370
     			    $error = self::update_from_11();
2213
-    			    if ($error != '') return $error;
2214
-    			    else return self::check_version(true);
2371
+    			    if ($error != '') {
2372
+    			    	return $error;
2373
+    			    } else {
2374
+    			    	return self::check_version(true);
2375
+    			    }
2215 2376
     			} elseif ($result['value'] == '12') {
2216 2377
     			    $error = self::update_from_12();
2217
-    			    if ($error != '') return $error;
2218
-    			    else return self::check_version(true);
2378
+    			    if ($error != '') {
2379
+    			    	return $error;
2380
+    			    } else {
2381
+    			    	return self::check_version(true);
2382
+    			    }
2219 2383
     			} elseif ($result['value'] == '13') {
2220 2384
     			    $error = self::update_from_13();
2221
-    			    if ($error != '') return $error;
2222
-    			    else return self::check_version(true);
2385
+    			    if ($error != '') {
2386
+    			    	return $error;
2387
+    			    } else {
2388
+    			    	return self::check_version(true);
2389
+    			    }
2223 2390
     			} elseif ($result['value'] == '14') {
2224 2391
     			    $error = self::update_from_14();
2225
-    			    if ($error != '') return $error;
2226
-    			    else return self::check_version(true);
2392
+    			    if ($error != '') {
2393
+    			    	return $error;
2394
+    			    } else {
2395
+    			    	return self::check_version(true);
2396
+    			    }
2227 2397
     			} elseif ($result['value'] == '15') {
2228 2398
     			    $error = self::update_from_15();
2229
-    			    if ($error != '') return $error;
2230
-    			    else return self::check_version(true);
2399
+    			    if ($error != '') {
2400
+    			    	return $error;
2401
+    			    } else {
2402
+    			    	return self::check_version(true);
2403
+    			    }
2231 2404
     			} elseif ($result['value'] == '16') {
2232 2405
     			    $error = self::update_from_16();
2233
-    			    if ($error != '') return $error;
2234
-    			    else return self::check_version(true);
2406
+    			    if ($error != '') {
2407
+    			    	return $error;
2408
+    			    } else {
2409
+    			    	return self::check_version(true);
2410
+    			    }
2235 2411
     			} elseif ($result['value'] == '17') {
2236 2412
     			    $error = self::update_from_17();
2237
-    			    if ($error != '') return $error;
2238
-    			    else return self::check_version(true);
2413
+    			    if ($error != '') {
2414
+    			    	return $error;
2415
+    			    } else {
2416
+    			    	return self::check_version(true);
2417
+    			    }
2239 2418
     			} elseif ($result['value'] == '18') {
2240 2419
     			    $error = self::update_from_18();
2241
-    			    if ($error != '') return $error;
2242
-    			    else return self::check_version(true);
2420
+    			    if ($error != '') {
2421
+    			    	return $error;
2422
+    			    } else {
2423
+    			    	return self::check_version(true);
2424
+    			    }
2243 2425
     			} elseif ($result['value'] == '19') {
2244 2426
     			    $error = self::update_from_19();
2245
-    			    if ($error != '') return $error;
2246
-    			    else return self::check_version(true);
2427
+    			    if ($error != '') {
2428
+    			    	return $error;
2429
+    			    } else {
2430
+    			    	return self::check_version(true);
2431
+    			    }
2247 2432
     			} elseif ($result['value'] == '20') {
2248 2433
     			    $error = self::update_from_20();
2249
-    			    if ($error != '') return $error;
2250
-    			    else return self::check_version(true);
2434
+    			    if ($error != '') {
2435
+    			    	return $error;
2436
+    			    } else {
2437
+    			    	return self::check_version(true);
2438
+    			    }
2251 2439
     			} elseif ($result['value'] == '21') {
2252 2440
     			    $error = self::update_from_21();
2253
-    			    if ($error != '') return $error;
2254
-    			    else return self::check_version(true);
2441
+    			    if ($error != '') {
2442
+    			    	return $error;
2443
+    			    } else {
2444
+    			    	return self::check_version(true);
2445
+    			    }
2255 2446
     			} elseif ($result['value'] == '22') {
2256 2447
     			    $error = self::update_from_22();
2257
-    			    if ($error != '') return $error;
2258
-    			    else return self::check_version(true);
2448
+    			    if ($error != '') {
2449
+    			    	return $error;
2450
+    			    } else {
2451
+    			    	return self::check_version(true);
2452
+    			    }
2259 2453
     			} elseif ($result['value'] == '23') {
2260 2454
     			    $error = self::update_from_23();
2261
-    			    if ($error != '') return $error;
2262
-    			    else return self::check_version(true);
2455
+    			    if ($error != '') {
2456
+    			    	return $error;
2457
+    			    } else {
2458
+    			    	return self::check_version(true);
2459
+    			    }
2263 2460
     			} elseif ($result['value'] == '24') {
2264 2461
     			    $error = self::update_from_24();
2265
-    			    if ($error != '') return $error;
2266
-    			    else return self::check_version(true);
2462
+    			    if ($error != '') {
2463
+    			    	return $error;
2464
+    			    } else {
2465
+    			    	return self::check_version(true);
2466
+    			    }
2267 2467
     			} elseif ($result['value'] == '25') {
2268 2468
     			    $error = self::update_from_25();
2269
-    			    if ($error != '') return $error;
2270
-    			    else return self::check_version(true);
2469
+    			    if ($error != '') {
2470
+    			    	return $error;
2471
+    			    } else {
2472
+    			    	return self::check_version(true);
2473
+    			    }
2271 2474
     			} elseif ($result['value'] == '26') {
2272 2475
     			    $error = self::update_from_26();
2273
-    			    if ($error != '') return $error;
2274
-    			    else return self::check_version(true);
2476
+    			    if ($error != '') {
2477
+    			    	return $error;
2478
+    			    } else {
2479
+    			    	return self::check_version(true);
2480
+    			    }
2275 2481
     			} elseif ($result['value'] == '27') {
2276 2482
     			    $error = self::update_from_27();
2277
-    			    if ($error != '') return $error;
2278
-    			    else return self::check_version(true);
2483
+    			    if ($error != '') {
2484
+    			    	return $error;
2485
+    			    } else {
2486
+    			    	return self::check_version(true);
2487
+    			    }
2279 2488
     			} elseif ($result['value'] == '28') {
2280 2489
     			    $error = self::update_from_28();
2281
-    			    if ($error != '') return $error;
2282
-    			    else return self::check_version(true);
2490
+    			    if ($error != '') {
2491
+    			    	return $error;
2492
+    			    } else {
2493
+    			    	return self::check_version(true);
2494
+    			    }
2283 2495
     			} elseif ($result['value'] == '29') {
2284 2496
     			    $error = self::update_from_29();
2285
-    			    if ($error != '') return $error;
2286
-    			    else return self::check_version(true);
2497
+    			    if ($error != '') {
2498
+    			    	return $error;
2499
+    			    } else {
2500
+    			    	return self::check_version(true);
2501
+    			    }
2287 2502
     			} elseif ($result['value'] == '30') {
2288 2503
     			    $error = self::update_from_30();
2289
-    			    if ($error != '') return $error;
2290
-    			    else return self::check_version(true);
2504
+    			    if ($error != '') {
2505
+    			    	return $error;
2506
+    			    } else {
2507
+    			    	return self::check_version(true);
2508
+    			    }
2291 2509
     			} elseif ($result['value'] == '31') {
2292 2510
     			    $error = self::update_from_31();
2293
-    			    if ($error != '') return $error;
2294
-    			    else return self::check_version(true);
2511
+    			    if ($error != '') {
2512
+    			    	return $error;
2513
+    			    } else {
2514
+    			    	return self::check_version(true);
2515
+    			    }
2295 2516
     			} elseif ($result['value'] == '32') {
2296 2517
     			    $error = self::update_from_32();
2297
-    			    if ($error != '') return $error;
2298
-    			    else return self::check_version(true);
2518
+    			    if ($error != '') {
2519
+    			    	return $error;
2520
+    			    } else {
2521
+    			    	return self::check_version(true);
2522
+    			    }
2299 2523
     			} elseif ($result['value'] == '33') {
2300 2524
     			    $error = self::update_from_33();
2301
-    			    if ($error != '') return $error;
2302
-    			    else return self::check_version(true);
2525
+    			    if ($error != '') {
2526
+    			    	return $error;
2527
+    			    } else {
2528
+    			    	return self::check_version(true);
2529
+    			    }
2303 2530
     			} elseif ($result['value'] == '34') {
2304 2531
     			    $error = self::update_from_34();
2305
-    			    if ($error != '') return $error;
2306
-    			    else return self::check_version(true);
2532
+    			    if ($error != '') {
2533
+    			    	return $error;
2534
+    			    } else {
2535
+    			    	return self::check_version(true);
2536
+    			    }
2307 2537
     			} elseif ($result['value'] == '35') {
2308 2538
     			    $error = self::update_from_35();
2309
-    			    if ($error != '') return $error;
2310
-    			    else return self::check_version(true);
2539
+    			    if ($error != '') {
2540
+    			    	return $error;
2541
+    			    } else {
2542
+    			    	return self::check_version(true);
2543
+    			    }
2311 2544
     			} elseif ($result['value'] == '36') {
2312 2545
     			    $error = self::update_from_36();
2313
-    			    if ($error != '') return $error;
2314
-    			    else return self::check_version(true);
2546
+    			    if ($error != '') {
2547
+    			    	return $error;
2548
+    			    } else {
2549
+    			    	return self::check_version(true);
2550
+    			    }
2315 2551
     			} elseif ($result['value'] == '37') {
2316 2552
     			    $error = self::update_from_37();
2317
-    			    if ($error != '') return $error;
2318
-    			    else return self::check_version(true);
2553
+    			    if ($error != '') {
2554
+    			    	return $error;
2555
+    			    } else {
2556
+    			    	return self::check_version(true);
2557
+    			    }
2319 2558
     			} elseif ($result['value'] == '38') {
2320 2559
     			    $error = self::update_from_38();
2321
-    			    if ($error != '') return $error;
2322
-    			    else return self::check_version(true);
2560
+    			    if ($error != '') {
2561
+    			    	return $error;
2562
+    			    } else {
2563
+    			    	return self::check_version(true);
2564
+    			    }
2323 2565
     			} elseif ($result['value'] == '39') {
2324 2566
     			    $error = self::update_from_39();
2325
-    			    if ($error != '') return $error;
2326
-    			    else return self::check_version(true);
2567
+    			    if ($error != '') {
2568
+    			    	return $error;
2569
+    			    } else {
2570
+    			    	return self::check_version(true);
2571
+    			    }
2327 2572
     			} elseif ($result['value'] == '40') {
2328 2573
     			    $error = self::update_from_40();
2329
-    			    if ($error != '') return $error;
2330
-    			    else return self::check_version(true);
2574
+    			    if ($error != '') {
2575
+    			    	return $error;
2576
+    			    } else {
2577
+    			    	return self::check_version(true);
2578
+    			    }
2331 2579
     			} elseif ($result['value'] == '41') {
2332 2580
     			    $error = self::update_from_41();
2333
-    			    if ($error != '') return $error;
2334
-    			    else return self::check_version(true);
2581
+    			    if ($error != '') {
2582
+    			    	return $error;
2583
+    			    } else {
2584
+    			    	return self::check_version(true);
2585
+    			    }
2335 2586
     			} elseif ($result['value'] == '42') {
2336 2587
     			    $error = self::update_from_42();
2337
-    			    if ($error != '') return $error;
2338
-    			    else return self::check_version(true);
2588
+    			    if ($error != '') {
2589
+    			    	return $error;
2590
+    			    } else {
2591
+    			    	return self::check_version(true);
2592
+    			    }
2339 2593
     			} elseif ($result['value'] == '43') {
2340 2594
     			    $error = self::update_from_43();
2341
-    			    if ($error != '') return $error;
2342
-    			    else return self::check_version(true);
2595
+    			    if ($error != '') {
2596
+    			    	return $error;
2597
+    			    } else {
2598
+    			    	return self::check_version(true);
2599
+    			    }
2343 2600
     			} elseif ($result['value'] == '44') {
2344 2601
     			    $error = self::update_from_44();
2345
-    			    if ($error != '') return $error;
2346
-    			    else return self::check_version(true);
2602
+    			    if ($error != '') {
2603
+    			    	return $error;
2604
+    			    } else {
2605
+    			    	return self::check_version(true);
2606
+    			    }
2347 2607
     			} elseif ($result['value'] == '45') {
2348 2608
     			    $error = self::update_from_45();
2349
-    			    if ($error != '') return $error;
2350
-    			    else return self::check_version(true);
2351
-    			} else return '';
2609
+    			    if ($error != '') {
2610
+    			    	return $error;
2611
+    			    } else {
2612
+    			    	return self::check_version(true);
2613
+    			    }
2614
+    			} else {
2615
+    				return '';
2616
+    			}
2352 2617
     		    } else {
2353
-    			if (isset($result['value']) && $result['value'] != '') return $result['value'];
2354
-    			else return 0;
2618
+    			if (isset($result['value']) && $result['value'] != '') {
2619
+    				return $result['value'];
2620
+    			} else {
2621
+    				return 0;
2622
+    			}
2355 2623
 		}
2356 2624
 		
2357
-	    } else return $version;
2625
+	    } else {
2626
+	    	return $version;
2627
+	    }
2358 2628
     	}
2359 2629
     	
2360 2630
 }
Please login to merge, or discard this patch.
statistics.php 2 patches
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 }
24 24
 
25 25
 if (!isset($filter_name)) $filter_name = '';
26
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
26
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
27 27
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28 28
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29 29
 }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
33 33
 	if (isset($airline_info[0]['name'])) {
34 34
 		$airline_name = $airline_info[0]['name'];
35
-	} elseif (strpos($airline_icao,'alliance_') !== FALSE) {
35
+	} elseif (strpos($airline_icao, 'alliance_') !== FALSE) {
36 36
 		$alliance_name = $airline_icao;
37 37
 	}
38 38
 }
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	$title = _("Statistics");
43 43
 }
44 44
 
45
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
45
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
46
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
47 47
 
48 48
 require_once('header.php');
49 49
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		date_default_timezone_set('UTC');
71 71
 		$lastupdate = strtotime($last_update[0]['value']);
72 72
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
73
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
73
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
74 74
 	}
75 75
 }
76 76
 ?>
@@ -82,31 +82,31 @@  discard block
 block discarded – undo
82 82
 <?php
83 83
 if ($type == 'aircraft') {
84 84
 ?>
85
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
86
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
87
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
88
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
85
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
86
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
87
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
88
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
89 89
 <?php
90 90
 	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
91 91
 ?>
92
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
93
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
92
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
93
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
94 94
 <?php
95 95
 	}
96 96
 	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
97 97
 ?>
98
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
99
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
98
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
99
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
100 100
 <?php
101 101
 	}
102 102
 ?>
103
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
104
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
103
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
104
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
105 105
 <?php
106 106
 	if ($airline_icao == '') {
107 107
 ?>
108
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
109
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
108
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
109
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
110 110
 <?php
111 111
 	}
112 112
 ?>
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	if (!(isset($globalVA) && $globalVA) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS) && !(isset($globalVAM) && $globalVAM)) {
115 115
 		if ($airline_icao == '' || $airline_icao == 'all') {
116 116
 ?>
117
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
118
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
117
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
118
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
119 119
 <?php
120 120
 		}
121 121
 	}
@@ -123,22 +123,22 @@  discard block
 block discarded – undo
123 123
 <?php
124 124
 } elseif ($type == 'marine') {
125 125
 ?>
126
-	<span><span class="badge"><?php print number_format($Marine->countOverallMarine(array(),$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
127
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
128
-	<span><span class="badge"><?php print number_format($Marine->countOverallMarineTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
129
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
126
+	<span><span class="badge"><?php print number_format($Marine->countOverallMarine(array(), $year, $month)); ?></span> <?php echo _("Vessels"); ?></span>
127
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
128
+	<span><span class="badge"><?php print number_format($Marine->countOverallMarineTypes(array(), $year, $month)); ?></span> <?php echo _("Types"); ?></span>
129
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
130 130
 <?php
131 131
 } elseif ($type == 'tracker') {
132 132
 ?>
133
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker(array(),$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
134
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
135
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(),$year,$month)); ?></span> <?php echo _("Types"); ?></span>
136
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
133
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker(array(), $year, $month)); ?></span> <?php echo _("Trackers"); ?></span>
134
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
135
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes(array(), $year, $month)); ?></span> <?php echo _("Types"); ?></span>
136
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
137 137
 <?php
138 138
 }
139 139
 ?>
140 140
     </p>
141
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
141
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
142 142
     <div class="specific-stats">
143 143
 <?php
144 144
 if ($type == 'aircraft') {
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
             <div class="col-md-6">
148 148
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
149 149
 <?php
150
-	$aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
150
+	$aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
151 151
 	if (count($aircraft_array) == 0) {
152 152
 		print _("No data available");
153 153
 	} else {
154 154
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
155 155
 		$aircraft_data = '';
156
-		foreach($aircraft_array as $aircraft_item) {
156
+		foreach ($aircraft_array as $aircraft_item) {
157 157
 			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
158 158
 			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
159 159
 		}
@@ -182,16 +182,16 @@  discard block
 block discarded – undo
182 182
 ?>
183 183
                 </div>
184 184
             </div>
185
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
185
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
186 186
 <?php
187 187
 	if ($airline_icao == '' || $airline_icao == 'all') {
188
-		$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
188
+		$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
189 189
 		if (count($airline_array) > 0) {
190 190
 			print '<div class="col-md-6">';
191 191
 			print '<h2>'._("Top 10 Most Common Airline").'</h2>';
192 192
 			print '<div id="chart2" class="chart" width="100%"></div><script>';
193 193
 			$airline_data = '';
194
-			foreach($airline_array as $airline_item) {
194
+			foreach ($airline_array as $airline_item) {
195 195
 				$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
196 196
 			}
197 197
 			$airline_data = substr($airline_data, 0, -1);
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 ?>
218 218
         </div>
219
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
219
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
220 220
 <?php
221 221
 	}
222 222
 }
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
             <div class="col-md-6">
229 229
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
230 230
 <?php
231
-	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
231
+	$marine_array = $Marine->countAllMarineTypes(true, 0, '', array(), $year, $month);
232 232
 	if (count($marine_array) == 0) print _("No data available");
233 233
 	else {
234 234
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
235 235
 		$marine_data = '';
236
-		foreach($marine_array as $marine_item) {
236
+		foreach ($marine_array as $marine_item) {
237 237
 			$marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],';
238 238
 		}
239 239
 		$marine_data = substr($marine_data, 0, -1);
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             	    ?>
264 264
                 </div>
265 265
             </div>
266
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
266
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
267 267
 <!--	</div>-->
268 268
 <?php
269 269
 }
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
             <div class="col-md-6">
274 274
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
275 275
 <?php
276
-	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
276
+	$tracker_array = $Tracker->countAllTrackerTypes(true, 0, '', array(), $year, $month);
277 277
 	if (count($tracker_array) == 0) print _("No data available");
278 278
 	else {
279 279
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
280 280
 		$tracker_data = '';
281
-		foreach($tracker_array as $tracker_item) {
281
+		foreach ($tracker_array as $tracker_item) {
282 282
 			$tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],';
283 283
 		}
284 284
 		$tracker_data = substr($tracker_data, 0, -1);
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             	    ?>
309 309
                 </div>
310 310
             </div>
311
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
311
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
312 312
 <!--	</div>-->
313 313
 <?php
314 314
 }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		else {
324 324
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
325 325
 			$owner_data = '';
326
-			foreach($owner_array as $owner_item) {
326
+			foreach ($owner_array as $owner_item) {
327 327
 				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
328 328
 			}
329 329
 			$owner_data = substr($owner_data, 0, -1);
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
                 </div>
344 344
                 -->
345 345
             </div>
346
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
346
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
347 347
             <div class="col-md-6">
348 348
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
349 349
 <?php
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 		else {
353 353
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
354 354
 			$owner_data = '';
355
-			foreach($countries_array as $owner_item) {
355
+			foreach ($countries_array as $owner_item) {
356 356
 				$owner_data .= '["'.$owner_item['country_name'].'",'.$owner_item['country_count'].'],';
357 357
 			}
358 358
 			$owner_data = substr($owner_data, 0, -1);
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
                 -->
374 374
             </div>
375 375
             
376
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
376
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
377 377
 ²	</div>
378 378
         <div class="row column">
379 379
             <div class="col-md-6">
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		else {
385 385
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
386 386
 			$launch_site_data = '';
387
-			foreach($launch_site_array as $launch_site_item) {
387
+			foreach ($launch_site_array as $launch_site_item) {
388 388
 				$launch_site_data .= '["'.$launch_site_item['launch_site'].'",'.$launch_site_item['launch_site_count'].'],';
389 389
 			}
390 390
 			$launch_site_data = substr($launch_site_data, 0, -1);
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 ?>
412 412
         <div class="row column">
413 413
 <?php
414
-	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
414
+	$flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
415 415
 	//if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
416 416
 	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
417 417
 		if (empty($flightover_array)) {
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
 ?>
423 423
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
424 424
 <?php
425
-		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
425
+		$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
426 426
 		if (count($pilot_array) == 0) print _("No data available");
427 427
 		else {
428 428
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
429 429
 			$pilot_data = '';
430
-			foreach($pilot_array as $pilot_item) {
430
+			foreach ($pilot_array as $pilot_item) {
431 431
 				$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
432 432
 			}
433 433
 			$pilot_data = substr($pilot_data, 0, -1);
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 ?>
449 449
             </div>
450 450
 
451
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
451
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
452 452
 <?php
453 453
 	}
454 454
 	// else {
@@ -457,12 +457,12 @@  discard block
 block discarded – undo
457 457
             <div class="col-md-6">
458 458
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
459 459
 <?php
460
-		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
460
+		$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
461 461
 		if (count($owner_array) == 0) print _("No data available");
462 462
 		else {
463 463
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
464 464
 			$owner_data = '';
465
-			foreach($owner_array as $owner_item) {
465
+			foreach ($owner_array as $owner_item) {
466 466
 				$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
467 467
 			}
468 468
 			$owner_data = substr($owner_data, 0, -1);
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
                 </div>
482 482
             </div>
483 483
         
484
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
484
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
485 485
 <?php
486 486
 	}
487 487
 	if (!empty($flightover_array)) {
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
496 496
 			print 'var series = [';
497 497
 			$flightover_data = '';
498
-			foreach($flightover_array as $flightover_item) {
498
+			foreach ($flightover_array as $flightover_item) {
499 499
 				$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
500 500
 			}
501 501
 			$flightover_data = substr($flightover_data, 0, -1);
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	}
541 541
 ?>
542 542
         </div>
543
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
543
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
544 544
         </div>
545 545
 <?php
546 546
 }
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
557 557
 		print 'var series = [';
558 558
 		$flightover_data = '';
559
-		foreach($flightover_array as $flightover_item) {
559
+		foreach ($flightover_array as $flightover_item) {
560 560
 			$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
561 561
 		}
562 562
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
614 614
 		print 'var series = [';
615 615
 		$flightover_data = '';
616
-		foreach($flightover_array as $flightover_item) {
616
+		foreach ($flightover_array as $flightover_item) {
617 617
 			$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
618 618
 		}
619 619
 		$flightover_data = substr($flightover_data, 0, -1);
@@ -663,14 +663,14 @@  discard block
 block discarded – undo
663 663
         <div class="row column">
664 664
             <div class="col-md-6">
665 665
 <?php
666
-	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
666
+	$airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
667 667
 	if (count($airport_airport_array) > 0) {
668 668
 		print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
669 669
 		print '<div id="chart3" class="chart" width="100%"></div><script>';
670 670
 		print "\n";
671 671
 		print 'var series = [';
672 672
 		$airport_data = '';
673
-		foreach($airport_airport_array as $airport_item) {
673
+		foreach ($airport_airport_array as $airport_item) {
674 674
 			$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
675 675
 		}
676 676
 		$airport_data = substr($airport_data, 0, -1);
@@ -720,18 +720,18 @@  discard block
 block discarded – undo
720 720
 	}
721 721
 ?>
722 722
             </div>
723
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
723
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
724 724
 
725 725
             <div class="col-md-6">
726 726
 <?php
727
-	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
727
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
728 728
 	if (count($airport_airport_array2) > 0) {
729 729
 		print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
730 730
 		print '<div id="chart4" class="chart" width="100%"></div><script>';
731 731
 		print "\n";
732 732
 		print 'var series = [';
733 733
 		$airport_data = '';
734
-		foreach($airport_airport_array2 as $airport_item)
734
+		foreach ($airport_airport_array2 as $airport_item)
735 735
 		{
736 736
 			$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
737 737
 		}
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 ?>
784 784
             </div>
785 785
         </div>
786
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
786
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
787 787
 <?php 
788 788
 }
789 789
 if ($type == 'aircraft') {
@@ -795,18 +795,18 @@  discard block
 block discarded – undo
795 795
             <div class="col-md-6">
796 796
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
797 797
 <?php
798
-		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
798
+		$year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
799 799
 		if (count($year_array) == 0) print _("No data available");
800 800
 		else {
801 801
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
802 802
 			$year_data = '';
803 803
 			$year_cnt = '';
804
-			foreach($year_array as $year_item) {
804
+			foreach ($year_array as $year_item) {
805 805
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
806 806
 				$year_cnt .= $year_item['date_count'].',';
807 807
 			}
808 808
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
809
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
809
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
810 810
 			print 'c3.generate({
811 811
 			    bindto: "#chart8",
812 812
 			    data: { x: "x",
@@ -819,22 +819,22 @@  discard block
 block discarded – undo
819 819
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
820 820
                 </div>
821 821
             </div>
822
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
822
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
823 823
             <div class="col-md-6">
824 824
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
825 825
 <?php
826
-		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
826
+		$month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
827 827
 		if (count($month_array) == 0) print _("No data available");
828 828
 		else {
829 829
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
830 830
 			$month_data = '';
831 831
 			$month_cnt = '';
832
-			foreach($month_array as $month_item) {
832
+			foreach ($month_array as $month_item) {
833 833
 				$month_data .= '"'.$month_item['date_name'].'",';
834 834
 				$month_cnt .= $month_item['date_count'].',';
835 835
 			}
836 836
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
837
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
837
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
838 838
 			print 'c3.generate({
839 839
 			    bindto: "#chart9",
840 840
 			    data: { x: "x",
@@ -847,23 +847,23 @@  discard block
 block discarded – undo
847 847
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
848 848
                 </div>
849 849
             </div>
850
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
850
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
851 851
 
852 852
             <div class="col-md-6">
853 853
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
854 854
 <?php
855
-		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
855
+		$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
856 856
 		if (empty($date_array)) print _("No data available");
857 857
 		else {
858 858
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
859 859
 			$date_data = '';
860 860
 			$date_cnt = '';
861
-			foreach($date_array as $date_item) {
861
+			foreach ($date_array as $date_item) {
862 862
 				$date_data .= '"'.$date_item['date_name'].'",';
863 863
 				$date_cnt .= $date_item['date_count'].',';
864 864
 			}
865 865
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
866
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
866
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
867 867
 			print 'c3.generate({
868 868
 			    bindto: "#chart5",
869 869
 			    data: { x: "x",
@@ -876,22 +876,22 @@  discard block
 block discarded – undo
876 876
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
877 877
                 </div>
878 878
             </div>
879
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
879
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
880 880
             <div class="col-md-6">
881 881
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
882 882
 <?php
883
-		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
883
+		$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
884 884
 		if (empty($hour_array)) print _("No data available");
885 885
 		else {
886 886
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
887 887
 			$hour_data = '';
888 888
 			$hour_cnt = '';
889
-			foreach($hour_array as $hour_item) {
889
+			foreach ($hour_array as $hour_item) {
890 890
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
891 891
 				$hour_cnt .= $hour_item['hour_count'].',';
892 892
 			}
893 893
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
894
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
894
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
895 895
 			print 'c3.generate({
896 896
 			    bindto: "#chart6",
897 897
 			    data: {
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
905 905
                 </div>
906 906
             </div>
907
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
907
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
908 908
         </div>
909 909
 <?php
910 910
 	}
@@ -920,18 +920,18 @@  discard block
 block discarded – undo
920 920
             <div class="col-md-6">
921 921
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
922 922
 <?php
923
-		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
923
+		$year_array = $Marine->countAllMonthsLastYear(true, $airline_icao, $filter_name);
924 924
 		if (count($year_array) == 0) print _("No data available");
925 925
 		else {
926 926
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
927 927
 			$year_data = '';
928 928
 			$year_cnt = '';
929
-			foreach($year_array as $year_item) {
929
+			foreach ($year_array as $year_item) {
930 930
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
931 931
 				$year_cnt .= $year_item['date_count'].',';
932 932
 			}
933 933
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
934
-			$year_cnt = "['vessels',".substr($year_cnt,0,-1)."]";
934
+			$year_cnt = "['vessels',".substr($year_cnt, 0, -1)."]";
935 935
 			print 'c3.generate({
936 936
 			    bindto: "#chart8",
937 937
 			    data: { x: "x",
@@ -945,22 +945,22 @@  discard block
 block discarded – undo
945 945
                 </div>
946 946
             </div>
947 947
             
948
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
948
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
949 949
             <div class="col-md-6">
950 950
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
951 951
 <?php
952
-		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
952
+		$month_array = $Marine->countAllDatesLastMonth($airline_icao, $filter_name);
953 953
 		if (count($month_array) == 0) print _("No data available");
954 954
 		else {
955 955
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
956 956
 			$month_data = '';
957 957
 			$month_cnt = '';
958
-			foreach($month_array as $month_item) {
958
+			foreach ($month_array as $month_item) {
959 959
 				$month_data .= '"'.$month_item['date_name'].'",';
960 960
 				$month_cnt .= $month_item['date_count'].',';
961 961
 			}
962 962
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
963
-			$month_cnt = "['vessels',".substr($month_cnt,0,-1)."]";
963
+			$month_cnt = "['vessels',".substr($month_cnt, 0, -1)."]";
964 964
 			print 'c3.generate({
965 965
 			    bindto: "#chart9",
966 966
 			    data: { x: "x",
@@ -973,23 +973,23 @@  discard block
 block discarded – undo
973 973
                     <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
974 974
                 </div>
975 975
             </div>
976
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
976
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
977 977
 
978 978
             <div class="col-md-6">
979 979
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
980 980
 <?php
981
-		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
981
+		$date_array = $Marine->countAllDatesLast7Days($airline_icao, $filter_name);
982 982
 		if (empty($date_array)) print _("No data available");
983 983
 		else {
984 984
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
985 985
 			$date_data = '';
986 986
 			$date_cnt = '';
987
-			foreach($date_array as $date_item) {
987
+			foreach ($date_array as $date_item) {
988 988
 				$date_data .= '"'.$date_item['date_name'].'",';
989 989
 				$date_cnt .= $date_item['date_count'].',';
990 990
 			}
991 991
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
992
-			$date_cnt = "['vessels',".substr($date_cnt,0,-1)."]";
992
+			$date_cnt = "['vessels',".substr($date_cnt, 0, -1)."]";
993 993
 			print 'c3.generate({
994 994
 			    bindto: "#chart5",
995 995
 			    data: { x: "x",
@@ -1002,22 +1002,22 @@  discard block
 block discarded – undo
1002 1002
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1003 1003
                 </div>
1004 1004
             </div>
1005
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1005
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1006 1006
             <div class="col-md-6">
1007 1007
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1008 1008
 <?php
1009
-		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1009
+		$hour_array = $Marine->countAllHours('hour', true, $airline_icao, $filter_name);
1010 1010
 		if (empty($hour_array)) print _("No data available");
1011 1011
 		else {
1012 1012
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1013 1013
 			$hour_data = '';
1014 1014
 			$hour_cnt = '';
1015
-			foreach($hour_array as $hour_item) {
1015
+			foreach ($hour_array as $hour_item) {
1016 1016
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1017 1017
 				$hour_cnt .= $hour_item['hour_count'].',';
1018 1018
 			}
1019 1019
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1020
-			$hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]";
1020
+			$hour_cnt = "['vessels',".substr($hour_cnt, 0, -1)."]";
1021 1021
 			print 'c3.generate({
1022 1022
 			    bindto: "#chart6",
1023 1023
 			    data: {
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
                     <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1031 1031
                 </div>
1032 1032
             </div>
1033
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1033
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1034 1034
         </div>
1035 1035
 <?php
1036 1036
 	}
@@ -1052,12 +1052,12 @@  discard block
 block discarded – undo
1052 1052
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1053 1053
 			$year_data = '';
1054 1054
 			$year_cnt = '';
1055
-			foreach($year_array as $year_item) {
1055
+			foreach ($year_array as $year_item) {
1056 1056
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1057 1057
 				$year_cnt .= $year_item['date_count'].',';
1058 1058
 			}
1059 1059
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1060
-			$year_cnt = "['trackers',".substr($year_cnt,0,-1)."]";
1060
+			$year_cnt = "['trackers',".substr($year_cnt, 0, -1)."]";
1061 1061
 			print 'c3.generate({
1062 1062
 			    bindto: "#chart8",
1063 1063
 			    data: { x: "x",
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
                 </div>
1072 1072
             </div>
1073 1073
             
1074
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1074
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1075 1075
             <div class="col-md-6">
1076 1076
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1077 1077
 <?php
@@ -1081,12 +1081,12 @@  discard block
 block discarded – undo
1081 1081
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1082 1082
 			$month_data = '';
1083 1083
 			$month_cnt = '';
1084
-			foreach($month_array as $month_item) {
1084
+			foreach ($month_array as $month_item) {
1085 1085
 				$month_data .= '"'.$month_item['date_name'].'",';
1086 1086
 				$month_cnt .= $month_item['date_count'].',';
1087 1087
 			}
1088 1088
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
1089
-			$month_cnt = "['trackers',".substr($month_cnt,0,-1)."]";
1089
+			$month_cnt = "['trackers',".substr($month_cnt, 0, -1)."]";
1090 1090
 			print 'c3.generate({
1091 1091
 			    bindto: "#chart9",
1092 1092
 			    data: { x: "x",
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
                     <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1100 1100
                 </div>
1101 1101
             </div>
1102
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1102
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1103 1103
 
1104 1104
             <div class="col-md-6">
1105 1105
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
@@ -1110,12 +1110,12 @@  discard block
 block discarded – undo
1110 1110
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1111 1111
 			$date_data = '';
1112 1112
 			$date_cnt = '';
1113
-			foreach($date_array as $date_item) {
1113
+			foreach ($date_array as $date_item) {
1114 1114
 				$date_data .= '"'.$date_item['date_name'].'",';
1115 1115
 				$date_cnt .= $date_item['date_count'].',';
1116 1116
 			}
1117 1117
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
1118
-			$date_cnt = "['trackers',".substr($date_cnt,0,-1)."]";
1118
+			$date_cnt = "['trackers',".substr($date_cnt, 0, -1)."]";
1119 1119
 			print 'c3.generate({
1120 1120
 			    bindto: "#chart5",
1121 1121
 			    data: { x: "x",
@@ -1128,22 +1128,22 @@  discard block
 block discarded – undo
1128 1128
                     <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1129 1129
                 </div>
1130 1130
             </div>
1131
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1131
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1132 1132
             <div class="col-md-6">
1133 1133
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1134 1134
 <?php
1135
-		$hour_array = $Tracker->countAllHours('hour',true);
1135
+		$hour_array = $Tracker->countAllHours('hour', true);
1136 1136
 		if (empty($hour_array)) print _("No data available");
1137 1137
 		else {
1138 1138
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1139 1139
 			$hour_data = '';
1140 1140
 			$hour_cnt = '';
1141
-			foreach($hour_array as $hour_item) {
1141
+			foreach ($hour_array as $hour_item) {
1142 1142
 				$hour_data .= '"'.$hour_item['hour_name'].':00",';
1143 1143
 				$hour_cnt .= $hour_item['hour_count'].',';
1144 1144
 			}
1145 1145
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
1146
-			$hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]";
1146
+			$hour_cnt = "['trackers',".substr($hour_cnt, 0, -1)."]";
1147 1147
 			print 'c3.generate({
1148 1148
 			    bindto: "#chart6",
1149 1149
 			    data: {
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
                     <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1157 1157
                 </div>
1158 1158
             </div>
1159
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1159
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1160 1160
         </div>
1161 1161
 <?php
1162 1162
 	}
@@ -1178,12 +1178,12 @@  discard block
 block discarded – undo
1178 1178
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1179 1179
 			$year_data = '';
1180 1180
 			$year_cnt = '';
1181
-			foreach($year_array as $year_item) {
1181
+			foreach ($year_array as $year_item) {
1182 1182
 				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
1183 1183
 				$year_cnt .= $year_item['date_count'].',';
1184 1184
 			}
1185 1185
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1186
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1186
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1187 1187
 			print 'c3.generate({
1188 1188
 			    bindto: "#chart21",
1189 1189
 			    data: { x: "x",
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
             -->
1200 1200
             </div>
1201 1201
             
1202
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1202
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1203 1203
             <div class="col-md-6">
1204 1204
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1205 1205
 <?php
@@ -1209,12 +1209,12 @@  discard block
 block discarded – undo
1209 1209
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1210 1210
 			$year_data = '';
1211 1211
 			$year_cnt = '';
1212
-			foreach($year_array as $year_item) {
1212
+			foreach ($year_array as $year_item) {
1213 1213
 				$year_data .= '"'.$year_item['year_name'].'-01-01'.'",';
1214 1214
 				$year_cnt .= $year_item['date_count'].',';
1215 1215
 			}
1216 1216
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1217
-			$year_cnt = "['satellite',".substr($year_cnt,0,-1)."]";
1217
+			$year_cnt = "['satellite',".substr($year_cnt, 0, -1)."]";
1218 1218
 			print 'c3.generate({
1219 1219
 			    bindto: "#chart22",
1220 1220
 			    data: { x: "x",
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
             -->
1231 1231
             </div>
1232 1232
             
1233
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1233
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1234 1234
         </div>
1235 1235
 <?php
1236 1236
 	}
@@ -1252,12 +1252,12 @@  discard block
 block discarded – undo
1252 1252
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1253 1253
 			$year_data = '';
1254 1254
 			$year_cnt = '';
1255
-			foreach($year_array as $year_item) {
1255
+			foreach ($year_array as $year_item) {
1256 1256
 				$year_data .= '"'.$year_item['year'].'-01-01",';
1257 1257
 				$year_cnt .= $year_item['count'].',';
1258 1258
 			}
1259 1259
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1260
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1260
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1261 1261
 			print 'c3.generate({
1262 1262
 			    bindto: "#chart32",
1263 1263
 			    data: { x: "x",
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1271 1271
                 </div>
1272 1272
             </div>
1273
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1273
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1274 1274
 
1275 1275
         <div class="row column">
1276 1276
             <div class="col-md-6">
@@ -1282,12 +1282,12 @@  discard block
 block discarded – undo
1282 1282
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1283 1283
 			$year_data = '';
1284 1284
 			$year_cnt = '';
1285
-			foreach($year_array as $year_item) {
1285
+			foreach ($year_array as $year_item) {
1286 1286
 				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
1287 1287
 				$year_cnt .= $year_item['count'].',';
1288 1288
 			}
1289 1289
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
1290
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
1290
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
1291 1291
 			print 'c3.generate({
1292 1292
 			    bindto: "#chart33",
1293 1293
 			    data: { x: "x",
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
1301 1301
                 </div>
1302 1302
             </div>
1303
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1303
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1304 1304
 <br/>
1305 1305
 <?php
1306 1306
 	}
@@ -1314,19 +1314,19 @@  discard block
 block discarded – undo
1314 1314
 	//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
1315 1315
 	if ($year == '' && $month == '') {
1316 1316
 		if ($type == 'aircraft') {
1317
-			$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
1317
+			$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
1318 1318
 		} elseif ($type == 'marine') {
1319
-			$polar = $Stats->getStatsSource('polar_marine',date('Y'),date('m'),date('d'));
1319
+			$polar = $Stats->getStatsSource('polar_marine', date('Y'), date('m'), date('d'));
1320 1320
 		} elseif ($type == 'tracker') {
1321
-			$polar = $Stats->getStatsSource('polar_tracker',date('Y'),date('m'),date('d'));
1321
+			$polar = $Stats->getStatsSource('polar_tracker', date('Y'), date('m'), date('d'));
1322 1322
 		}
1323 1323
 	} else {
1324 1324
 		if ($type == 'aircraft') {
1325
-			$polar = $Stats->getStatsSource('polar',$year,$month);
1325
+			$polar = $Stats->getStatsSource('polar', $year, $month);
1326 1326
 		} elseif ($type == 'marine') {
1327
-			$polar = $Stats->getStatsSource('polar_marine',$year,$month);
1327
+			$polar = $Stats->getStatsSource('polar_marine', $year, $month);
1328 1328
 		} elseif ($type == 'tracker') {
1329
-			$polar = $Stats->getStatsSource('polar_tracker',$year,$month);
1329
+			$polar = $Stats->getStatsSource('polar_tracker', $year, $month);
1330 1330
 		}
1331 1331
 	}
1332 1332
 	if (!empty($polar)) {
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 			unset($polar_data);
1336 1336
 			$Spotter = new Spotter();
1337 1337
 			$data = json_decode($eachpolar['source_data']);
1338
-			foreach($data as $value => $key) {
1338
+			foreach ($data as $value => $key) {
1339 1339
 				$direction = $Spotter->parseDirection(($value*22.5));
1340 1340
 				$distance = $key;
1341 1341
 				$unit = 'km';
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 ?>
1356 1356
             <div class="col-md-6">
1357 1357
                 <h4><?php print $eachpolar['source_name']; ?></h4>
1358
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1358
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
1359 1359
         	<script>
1360 1360
         	    (function() {
1361 1361
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 		      color: color,
1380 1380
 		      unit: '<?php echo $unit; ?>'
1381 1381
 		    };
1382
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1382
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
1383 1383
 		    })();
1384 1384
 		</script>
1385 1385
             </div>
@@ -1394,19 +1394,19 @@  discard block
 block discarded – undo
1394 1394
 	//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
1395 1395
 	if ($year == '' && $month == '') {
1396 1396
 		if ($type == 'aircraft') {
1397
-			$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
1397
+			$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
1398 1398
 		} elseif ($type == 'marine') {
1399
-			$msg = $Stats->getStatsSource('msg_marine',date('Y'),date('m'),date('d'));
1399
+			$msg = $Stats->getStatsSource('msg_marine', date('Y'), date('m'), date('d'));
1400 1400
 		} elseif ($type == 'tracker') {
1401
-			$msg = $Stats->getStatsSource('msg_tracker',date('Y'),date('m'),date('d'));
1401
+			$msg = $Stats->getStatsSource('msg_tracker', date('Y'), date('m'), date('d'));
1402 1402
 		}
1403 1403
 	} else {
1404 1404
 		if ($type == 'aircraft') {
1405
-			$msg = $Stats->getStatsSource('msg',$year,$month);
1405
+			$msg = $Stats->getStatsSource('msg', $year, $month);
1406 1406
 		} elseif ($type == 'marine') {
1407
-			$msg = $Stats->getStatsSource('msg_marine',$year,$month);
1407
+			$msg = $Stats->getStatsSource('msg_marine', $year, $month);
1408 1408
 		} elseif ($type == 'tracker') {
1409
-			$msg = $Stats->getStatsSource('msg_tracker',$year,$month);
1409
+			$msg = $Stats->getStatsSource('msg_tracker', $year, $month);
1410 1410
 		}
1411 1411
 	}
1412 1412
 	if (!empty($msg)) {
@@ -1414,13 +1414,13 @@  discard block
 block discarded – undo
1414 1414
 		foreach ($msg as $eachmsg) {
1415 1415
 			//$eachmsg = $msg[0];
1416 1416
 			$data = $eachmsg['source_data'];
1417
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1417
+			if ($data > 500) $max = (round(($data + 100)/100))*100;
1418 1418
 			else $max = 500;
1419 1419
 ?>
1420
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1420
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1421 1421
         	<script>
1422 1422
 		      var g = new JustGage({
1423
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
1423
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
1424 1424
 			    value: <?php echo $data; ?>,
1425 1425
 			    min: 0,
1426 1426
 			    max: <?php print $max; ?>,
@@ -1442,19 +1442,19 @@  discard block
 block discarded – undo
1442 1442
 	//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
1443 1443
 	if ($year == '' && $month == '') {
1444 1444
 		if ($type == 'aircraft') {
1445
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
1445
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
1446 1446
 		} elseif ($type == 'marine') {
1447
-			$hist = $Stats->getStatsSource('hist_marine',date('Y'),date('m'),date('d'));
1447
+			$hist = $Stats->getStatsSource('hist_marine', date('Y'), date('m'), date('d'));
1448 1448
 		} elseif ($type == 'tracker') {
1449
-			$hist = $Stats->getStatsSource('hist_tracker',date('Y'),date('m'),date('d'));
1449
+			$hist = $Stats->getStatsSource('hist_tracker', date('Y'), date('m'), date('d'));
1450 1450
 		}
1451 1451
 	} else {
1452 1452
 		if ($type == 'aircraft') {
1453
-			$hist = $Stats->getStatsSource('hist',$year,$month);
1453
+			$hist = $Stats->getStatsSource('hist', $year, $month);
1454 1454
 		} elseif ($type == 'marine') {
1455
-			$hist = $Stats->getStatsSource('hist_marine',$year,$month);
1455
+			$hist = $Stats->getStatsSource('hist_marine', $year, $month);
1456 1456
 		} elseif ($type == 'tracker') {
1457
-			$hist = $Stats->getStatsSource('hist_tracker',$year,$month);
1457
+			$hist = $Stats->getStatsSource('hist_tracker', $year, $month);
1458 1458
 		}
1459 1459
 	}
1460 1460
 	foreach ($hist as $hists) {
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
 		$source = $hists['source_name'];
1465 1465
 		$hist_array = json_decode($hists['source_data']);
1466 1466
 		$unit = 'km';
1467
-		foreach($hist_array as $distance => $nb) {
1467
+		foreach ($hist_array as $distance => $nb) {
1468 1468
 			if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1469 1469
 				$distance = round($distance*0.539957);
1470 1470
 				$unit = 'nm';
@@ -1484,18 +1484,18 @@  discard block
 block discarded – undo
1484 1484
 		$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
1485 1485
 ?>
1486 1486
             <div class="col-md-6">
1487
-                <h2><?php echo sprintf(_("Distance for %s"),$source); ?></h2>
1487
+                <h2><?php echo sprintf(_("Distance for %s"), $source); ?></h2>
1488 1488
 <?php
1489
-		print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
1489
+		print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
1490 1490
 		print 'c3.generate({
1491
-		    bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
1491
+		    bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
1492 1492
 		    data: { x: "x",
1493 1493
 		    columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
1494 1494
 		    axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
1495 1495
 		print '</script>';
1496 1496
 ?>
1497 1497
     	    </div>
1498
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
1498
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
1499 1499
 <?php
1500 1500
 	}
1501 1501
 ?>
Please login to merge, or discard this patch.
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -69,7 +78,9 @@  discard block
 block discarded – undo
69 78
 	if (isset($last_update[0]['value'])) {
70 79
 		date_default_timezone_set('UTC');
71 80
 		$lastupdate = strtotime($last_update[0]['value']);
72
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
81
+		if (isset($globalTimezone) && $globalTimezone != '') {
82
+			date_default_timezone_set($globalTimezone);
83
+		}
73 84
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
74 85
 	}
75 86
 }
@@ -154,8 +165,11 @@  discard block
 block discarded – undo
154 165
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
155 166
 		$aircraft_data = '';
156 167
 		foreach($aircraft_array as $aircraft_item) {
157
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
158
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
168
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
169
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
170
+			} else {
171
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			}
159 173
 		}
160 174
 		$aircraft_data = substr($aircraft_data, 0, -1);
161 175
 		print 'var series = ['.$aircraft_data.'];';
@@ -172,11 +186,17 @@  discard block
 block discarded – undo
172 186
 <?php
173 187
 	if ($year != '' && $month != '') {
174 188
 ?>
175
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
189
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
190
+	echo '/'.$airline_icao;
191
+}
192
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
176 193
 <?php
177 194
 	} else {
178 195
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
196
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
197
+	echo '/'.$airline_icao;
198
+}
199
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 200
 <?php
181 201
 	}
182 202
 ?>
@@ -205,11 +225,15 @@  discard block
 block discarded – undo
205 225
 			print '</script>';
206 226
 			if ($year != '' && $month != '') {
207 227
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
208
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
228
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
229
+					echo '/'.$airline_icao;
230
+				}
209 231
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
210 232
 			} else {
211 233
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
234
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
235
+					echo '/'.$airline_icao;
236
+				}
213 237
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 238
 			}
215 239
 			print '</div>';
@@ -229,8 +253,9 @@  discard block
 block discarded – undo
229 253
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
230 254
 <?php
231 255
 	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
232
-	if (count($marine_array) == 0) print _("No data available");
233
-	else {
256
+	if (count($marine_array) == 0) {
257
+		print _("No data available");
258
+	} else {
234 259
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
235 260
 		$marine_data = '';
236 261
 		foreach($marine_array as $marine_item) {
@@ -274,8 +299,9 @@  discard block
 block discarded – undo
274 299
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
275 300
 <?php
276 301
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
277
-	if (count($tracker_array) == 0) print _("No data available");
278
-	else {
302
+	if (count($tracker_array) == 0) {
303
+		print _("No data available");
304
+	} else {
279 305
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
280 306
 		$tracker_data = '';
281 307
 		foreach($tracker_array as $tracker_item) {
@@ -319,8 +345,9 @@  discard block
 block discarded – undo
319 345
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
320 346
 <?php
321 347
 		$owner_array = $Satellite->countAllOwners(true);
322
-		if (count($owner_array) == 0) print _("No data available");
323
-		else {
348
+		if (count($owner_array) == 0) {
349
+			print _("No data available");
350
+		} else {
324 351
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
325 352
 			$owner_data = '';
326 353
 			foreach($owner_array as $owner_item) {
@@ -339,7 +366,10 @@  discard block
 block discarded – undo
339 366
 ?>
340 367
                <!--
341 368
                 <div class="more">
342
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
369
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
370
+	echo '/'.$airline_icao;
371
+}
372
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
343 373
                 </div>
344 374
                 -->
345 375
             </div>
@@ -348,8 +378,9 @@  discard block
 block discarded – undo
348 378
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
349 379
 <?php
350 380
 		$countries_array = $Satellite->countAllCountriesOwners(true);
351
-		if (count($countries_array) == 0) print _("No data available");
352
-		else {
381
+		if (count($countries_array) == 0) {
382
+			print _("No data available");
383
+		} else {
353 384
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
354 385
 			$owner_data = '';
355 386
 			foreach($countries_array as $owner_item) {
@@ -368,7 +399,10 @@  discard block
 block discarded – undo
368 399
 ?>
369 400
 	    <!--
370 401
                 <div class="more">
371
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
402
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
403
+	echo '/'.$airline_icao;
404
+}
405
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
372 406
                 </div>
373 407
                 -->
374 408
             </div>
@@ -380,8 +414,9 @@  discard block
 block discarded – undo
380 414
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
381 415
 <?php
382 416
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
383
-		if (count($launch_site_array) == 0) print _("No data available");
384
-		else {
417
+		if (count($launch_site_array) == 0) {
418
+			print _("No data available");
419
+		} else {
385 420
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
386 421
 			$launch_site_data = '';
387 422
 			foreach($launch_site_array as $launch_site_item) {
@@ -400,7 +435,10 @@  discard block
 block discarded – undo
400 435
 ?>
401 436
                <!--
402 437
                 <div class="more">
403
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
438
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
439
+	echo '/'.$airline_icao;
440
+}
441
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
404 442
                 </div>
405 443
                 -->
406 444
             </div>
@@ -423,8 +461,9 @@  discard block
 block discarded – undo
423 461
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
424 462
 <?php
425 463
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
426
-		if (count($pilot_array) == 0) print _("No data available");
427
-		else {
464
+		if (count($pilot_array) == 0) {
465
+			print _("No data available");
466
+		} else {
428 467
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
429 468
 			$pilot_data = '';
430 469
 			foreach($pilot_array as $pilot_item) {
@@ -442,7 +481,9 @@  discard block
 block discarded – undo
442 481
 		}
443 482
 		print '<div class="more">';
444 483
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
445
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
484
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
485
+			echo '/'.$airline_icao;
486
+		}
446 487
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
447 488
 		print '</div>';
448 489
 ?>
@@ -458,8 +499,9 @@  discard block
 block discarded – undo
458 499
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
459 500
 <?php
460 501
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
461
-		if (count($owner_array) == 0) print _("No data available");
462
-		else {
502
+		if (count($owner_array) == 0) {
503
+			print _("No data available");
504
+		} else {
463 505
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
464 506
 			$owner_data = '';
465 507
 			foreach($owner_array as $owner_item) {
@@ -477,7 +519,10 @@  discard block
 block discarded – undo
477 519
 		}
478 520
 ?>
479 521
                 <div class="more">
480
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
522
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
523
+	echo '/'.$airline_icao;
524
+}
525
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
481 526
                 </div>
482 527
             </div>
483 528
         
@@ -490,8 +535,9 @@  discard block
 block discarded – undo
490 535
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
491 536
 <?php
492 537
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
493
-		if (count($flightover_array) == 0) print _("No data available");
494
-		else {
538
+		if (count($flightover_array) == 0) {
539
+			print _("No data available");
540
+		} else {
495 541
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
496 542
 			print 'var series = [';
497 543
 			$flightover_data = '';
@@ -533,7 +579,10 @@  discard block
 block discarded – undo
533 579
 		}
534 580
 ?>
535 581
                 <div class="more">
536
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
582
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
583
+	echo '/'.$airline_icao;
584
+}
585
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
537 586
                 </div>
538 587
             </div>
539 588
 <?php
@@ -551,8 +600,9 @@  discard block
 block discarded – undo
551 600
 	<div class="col-md-6">
552 601
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
553 602
 <?php
554
-	if (count($flightover_array) == 0) print _("No data available");
555
-	else {
603
+	if (count($flightover_array) == 0) {
604
+		print _("No data available");
605
+	} else {
556 606
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
557 607
 		print 'var series = [';
558 608
 		$flightover_data = '';
@@ -608,8 +658,9 @@  discard block
 block discarded – undo
608 658
 	<div class="col-md-6">
609 659
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
610 660
 <?php
611
-	if (count($flightover_array) == 0) print _("No data available");
612
-	else {
661
+	if (count($flightover_array) == 0) {
662
+		print _("No data available");
663
+	} else {
613 664
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
614 665
 		print 'var series = [';
615 666
 		$flightover_data = '';
@@ -715,7 +766,9 @@  discard block
 block discarded – undo
715 766
 		});";
716 767
 		print '</script>';
717 768
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
718
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
769
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
770
+			echo '/'.$airline_icao;
771
+		}
719 772
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
720 773
 	}
721 774
 ?>
@@ -777,7 +830,9 @@  discard block
 block discarded – undo
777 830
 		});";
778 831
 		print '</script>';
779 832
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
780
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
833
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
834
+			echo '/'.$airline_icao;
835
+		}
781 836
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
782 837
 	}
783 838
 ?>
@@ -796,8 +851,9 @@  discard block
 block discarded – undo
796 851
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
797 852
 <?php
798 853
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
799
-		if (count($year_array) == 0) print _("No data available");
800
-		else {
854
+		if (count($year_array) == 0) {
855
+			print _("No data available");
856
+		} else {
801 857
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
802 858
 			$year_data = '';
803 859
 			$year_cnt = '';
@@ -816,7 +872,10 @@  discard block
 block discarded – undo
816 872
 		}
817 873
 ?>
818 874
                 <div class="more">
819
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
875
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
876
+	echo '/'.$airline_icao;
877
+}
878
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
820 879
                 </div>
821 880
             </div>
822 881
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -824,8 +883,9 @@  discard block
 block discarded – undo
824 883
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
825 884
 <?php
826 885
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
827
-		if (count($month_array) == 0) print _("No data available");
828
-		else {
886
+		if (count($month_array) == 0) {
887
+			print _("No data available");
888
+		} else {
829 889
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
830 890
 			$month_data = '';
831 891
 			$month_cnt = '';
@@ -844,7 +904,10 @@  discard block
 block discarded – undo
844 904
 		}
845 905
 ?>
846 906
                 <div class="more">
847
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
907
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
908
+	echo '/'.$airline_icao;
909
+}
910
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
848 911
                 </div>
849 912
             </div>
850 913
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -853,8 +916,9 @@  discard block
 block discarded – undo
853 916
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
854 917
 <?php
855 918
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
856
-		if (empty($date_array)) print _("No data available");
857
-		else {
919
+		if (empty($date_array)) {
920
+			print _("No data available");
921
+		} else {
858 922
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
859 923
 			$date_data = '';
860 924
 			$date_cnt = '';
@@ -873,7 +937,10 @@  discard block
 block discarded – undo
873 937
 		}
874 938
 ?>
875 939
                 <div class="more">
876
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
940
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
941
+	echo '/'.$airline_icao;
942
+}
943
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
877 944
                 </div>
878 945
             </div>
879 946
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -881,8 +948,9 @@  discard block
 block discarded – undo
881 948
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
882 949
 <?php
883 950
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
884
-		if (empty($hour_array)) print _("No data available");
885
-		else {
951
+		if (empty($hour_array)) {
952
+			print _("No data available");
953
+		} else {
886 954
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
887 955
 			$hour_data = '';
888 956
 			$hour_cnt = '';
@@ -901,7 +969,10 @@  discard block
 block discarded – undo
901 969
 		}
902 970
 ?>
903 971
                 <div class="more">
904
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
972
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
973
+	echo '/'.$airline_icao;
974
+}
975
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
905 976
                 </div>
906 977
             </div>
907 978
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -921,8 +992,9 @@  discard block
 block discarded – undo
921 992
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
922 993
 <?php
923 994
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
924
-		if (count($year_array) == 0) print _("No data available");
925
-		else {
995
+		if (count($year_array) == 0) {
996
+			print _("No data available");
997
+		} else {
926 998
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
927 999
 			$year_data = '';
928 1000
 			$year_cnt = '';
@@ -950,8 +1022,9 @@  discard block
 block discarded – undo
950 1022
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
951 1023
 <?php
952 1024
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
953
-		if (count($month_array) == 0) print _("No data available");
954
-		else {
1025
+		if (count($month_array) == 0) {
1026
+			print _("No data available");
1027
+		} else {
955 1028
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
956 1029
 			$month_data = '';
957 1030
 			$month_cnt = '';
@@ -979,8 +1052,9 @@  discard block
 block discarded – undo
979 1052
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
980 1053
 <?php
981 1054
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
982
-		if (empty($date_array)) print _("No data available");
983
-		else {
1055
+		if (empty($date_array)) {
1056
+			print _("No data available");
1057
+		} else {
984 1058
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
985 1059
 			$date_data = '';
986 1060
 			$date_cnt = '';
@@ -1007,8 +1081,9 @@  discard block
 block discarded – undo
1007 1081
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1008 1082
 <?php
1009 1083
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1010
-		if (empty($hour_array)) print _("No data available");
1011
-		else {
1084
+		if (empty($hour_array)) {
1085
+			print _("No data available");
1086
+		} else {
1012 1087
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1013 1088
 			$hour_data = '';
1014 1089
 			$hour_cnt = '';
@@ -1047,8 +1122,9 @@  discard block
 block discarded – undo
1047 1122
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1048 1123
 <?php
1049 1124
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1050
-		if (count($year_array) == 0) print _("No data available");
1051
-		else {
1125
+		if (count($year_array) == 0) {
1126
+			print _("No data available");
1127
+		} else {
1052 1128
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1053 1129
 			$year_data = '';
1054 1130
 			$year_cnt = '';
@@ -1076,8 +1152,9 @@  discard block
 block discarded – undo
1076 1152
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1077 1153
 <?php
1078 1154
 		$month_array = $Tracker->countAllDatesLastMonth();
1079
-		if (count($month_array) == 0) print _("No data available");
1080
-		else {
1155
+		if (count($month_array) == 0) {
1156
+			print _("No data available");
1157
+		} else {
1081 1158
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1082 1159
 			$month_data = '';
1083 1160
 			$month_cnt = '';
@@ -1105,8 +1182,9 @@  discard block
 block discarded – undo
1105 1182
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1106 1183
 <?php
1107 1184
 		$date_array = $Tracker->countAllDatesLast7Days();
1108
-		if (empty($date_array)) print _("No data available");
1109
-		else {
1185
+		if (empty($date_array)) {
1186
+			print _("No data available");
1187
+		} else {
1110 1188
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1111 1189
 			$date_data = '';
1112 1190
 			$date_cnt = '';
@@ -1133,8 +1211,9 @@  discard block
 block discarded – undo
1133 1211
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1134 1212
 <?php
1135 1213
 		$hour_array = $Tracker->countAllHours('hour',true);
1136
-		if (empty($hour_array)) print _("No data available");
1137
-		else {
1214
+		if (empty($hour_array)) {
1215
+			print _("No data available");
1216
+		} else {
1138 1217
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1139 1218
 			$hour_data = '';
1140 1219
 			$hour_cnt = '';
@@ -1173,8 +1252,9 @@  discard block
 block discarded – undo
1173 1252
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1174 1253
 <?php
1175 1254
 		$year_array = $Satellite->countAllMonthsLastYear(true);
1176
-		if (count($year_array) == 0) print _("No data available");
1177
-		else {
1255
+		if (count($year_array) == 0) {
1256
+			print _("No data available");
1257
+		} else {
1178 1258
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1179 1259
 			$year_data = '';
1180 1260
 			$year_cnt = '';
@@ -1204,8 +1284,9 @@  discard block
 block discarded – undo
1204 1284
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1205 1285
 <?php
1206 1286
 		$year_array = $Satellite->countAllYears(true);
1207
-		if (count($year_array) == 0) print _("No data available");
1208
-		else {
1287
+		if (count($year_array) == 0) {
1288
+			print _("No data available");
1289
+		} else {
1209 1290
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1210 1291
 			$year_data = '';
1211 1292
 			$year_cnt = '';
@@ -1247,8 +1328,9 @@  discard block
 block discarded – undo
1247 1328
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1248 1329
 <?php
1249 1330
 		$year_array = $Stats->countFatalitiesByYear();
1250
-		if (count($year_array) == 0) print _("No data available");
1251
-		else {
1331
+		if (count($year_array) == 0) {
1332
+			print _("No data available");
1333
+		} else {
1252 1334
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1253 1335
 			$year_data = '';
1254 1336
 			$year_cnt = '';
@@ -1277,8 +1359,9 @@  discard block
 block discarded – undo
1277 1359
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1278 1360
 <?php
1279 1361
 		$year_array = $Stats->countFatalitiesLast12Months();
1280
-		if (count($year_array) == 0) print _("No data available");
1281
-		else {
1362
+		if (count($year_array) == 0) {
1363
+			print _("No data available");
1364
+		} else {
1282 1365
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1283 1366
 			$year_data = '';
1284 1367
 			$year_cnt = '';
@@ -1349,8 +1432,11 @@  discard block
 block discarded – undo
1349 1432
 					$distance = $distance;
1350 1433
 					$unit = 'km';
1351 1434
 				}
1352
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1353
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1435
+				if (!isset($polar_data)) {
1436
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1437
+				} else {
1438
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1439
+				}
1354 1440
 			}
1355 1441
 ?>
1356 1442
             <div class="col-md-6">
@@ -1414,9 +1500,12 @@  discard block
 block discarded – undo
1414 1500
 		foreach ($msg as $eachmsg) {
1415 1501
 			//$eachmsg = $msg[0];
1416 1502
 			$data = $eachmsg['source_data'];
1417
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1418
-			else $max = 500;
1419
-?>
1503
+			if ($data > 500) {
1504
+				$max = (round(($data+100)/100))*100;
1505
+			} else {
1506
+				$max = 500;
1507
+			}
1508
+			?>
1420 1509
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1421 1510
         	<script>
1422 1511
 		      var g = new JustGage({
Please login to merge, or discard this patch.